Example request (on local server):
curl --header "Content-Type: application/json" \
--request POST \
--data '{"n_neighbors":2, "radius":10000, "points":[{"lat":10, "lon":10}, {"lat":15, "lon":20}]}' \
http://127.0.0.1:5000/mosaiks-features/
Limits:
n_neighbors <= 50(the number of neighbors to return for each mosaiks/point requested)radius <= 50000(the maximum distance for a nearest neighbor)points.length <= 100
Command to psql on AWS: here
.env used by python scripts should have the following:
#!/bin/bash
export MOSAIKS_DATABASE_PASSWORD=<password_here>
export MOSAIKS_DATABASE_HOST=<db_host_here>
pg_ctl -D /usr/local/var/postgres start
To query for all features (and their exact lon/lat) within 10000 meters (ie 10 km) of an input longitude/latitude:
SELECT features, ST_X(lonlat) x, ST_Y(lonlat) y FROM mosaiks WHERE ST_DWITHIN(lonlat, ST_SetSRID(ST_MakePoint(<INPUT_LONGITUDE>, <INPUT_LATITUDE>), 4326), 10000, false)
Documentation for everything used: https://postgis.net/docs/ST_DWithin.html https://postgis.net/docs/ST_SetSRID.html https://postgis.net/docs/ST_MakePoint.html https://postgis.net/docs/ST_Distance.html
Alternatively, if you're down with string injections, you can also do it with less postgis functions:
SELECT features, ST_X(lonlat) x, ST_Y(lonlat) y FROM mosaiks WHERE ST_DWITHIN(lonlat, 'SRID=4326;POINT(<INPUT_LONGITUDE> <INPUT_LATITUDE>)', 10000, false)
SELECT lonlat FROM mosaiks ORDER BY lonlat <-> point (<INPUT_LONGITUDE>, <INPUT_LATITUDE>) LIMIT 1;