Categorygithub.com/kmulvey/trashmap
module
0.0.0-20220513171635-3c7f7e5af3e7
Repository: https://github.com/kmulvey/trashmap.git
Documentation: pkg.go.dev

# README

Trash Map

TrashMap Go Report Card Go Reference Stand With Ukraine

Run Locally

cd deployments/local/
docker-compose up -d
cd ../../
go run cmd/trashmap/main.go

pgAdmin will come up on http://localhost:8080/browser/

HTTP routes

PathMethodArgsDescription
/loginPOSTemail, passwordlogs the user in
/userPUTemail, password, contact_allowedcreates the use acct
/user/:idDELETEuser iddeletes the user
/areaPUTgps corrdinate json (see below)creates a new pickup area
/areasPOSTgps corrdinate json (see below), must be four pointsreturns all the pickup areas within the given area

Data format

gps.Coordinate

{
  "lat": 40.259822802779816,
  "long": -105.65290936674407
}

gps.Area

[
  {
    "lat": 40.259822802779816,
    "long": -105.65290936674407
  },
  {
    "lat": 40.26201885227386,
    "long": -105.05519389236237
  },
  {
    "lat": 39.95833557541779,
    "long": -105.05494458234654
  },
    {
    "lat": 39.93788639054093,
    "long": -105.68899269947714
  }
]

gps.Map

[
  {
    "Coords": [
      {
        "lat": 40.259822802779816,
        "long": -105.65290936674407
      },
      {
        "lat": 40.26201885227386,
        "long": -105.05519389236237
      },
      {
        "lat": 39.95833557541779,
        "long": -105.05494458234654
      },
        {
        "lat": 39.93788639054093,
        "long": -105.68899269947714
      }
    ]
  },
  {
    "Coords": [
      {
        "lat": 36.24244932613963,
        "long": -112.40547934312802
      },
      {
        "lat": 36.223086062103704,
        "long": -111.81857028617547
      },
      {
        "lat": 36.00588425331162,
        "long": -111.83171900919251
      },
        {
        "lat": 36.02265323852763,
        "long": -112.34279966186926
      }
    ]
  }
]

curl examples

Create User

curl --http2-prior-knowledge  --insecure --cookie-jar jar.txt -v -XPUT https://localhost:8000/user -F 'contact_allowed=true' -F '[email protected]' -F 'password=password'

Login

curl --http2-prior-knowledge  --insecure --cookie-jar jar.txt -v -XPOST https://localhost:8000/login -F '[email protected]' -F 'password=password'

Create Area

curl --http2-prior-knowledge  --insecure -b jar.txt -v -XPUT https://localhost:8000/area -F 'user_id=1' -F 'area=[{"lat":40.259822802779816,"long":-105.65290936674407},{"lat":40.26201885227386,"long":-105.05519389236237},{"lat":39.95833557541779,"long":-105.05494458234654},{"lat":39.93788639054093,"long":-105.68899269947714}]'
curl --http2-prior-knowledge  --insecure -b jar.txt -v -XPUT https://localhost:8000/area -F 'user_id=1' -F 'area=[{"lat":36.24244932613963,"long":-112.40547934312802},{"lat":36.223086062103704,"long":-111.81857028617547},{"lat":36.00588425331162,"long":-111.83171900919251},{"lat":36.02265323852763,"long":-112.34279966186926}]'

Get all areas within a wider area

curl --http2-prior-knowledge  --insecure -b jar.txt -v -XPOST https://localhost:8000/areas -F 'area=[{"lat":40.99837454922104,"long":-109.05421673800787},{"lat":41.0004139327614,"long":-102.05758033526878},{"lat":37.015379641011805,"long":-109.05244682441632},{"lat":37.004114233165524,"long":-102.04615148062369}]'

# Packages

No description provided by the author