-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added "streets within" query to API #288
base: master
Are you sure you want to change the base?
Conversation
Added 'within' query for getting streets within a bounding box
Hi @aaronhourie, an interesting extension of the original interpolation APIs. I'm guessing you have a business need for such a query, if you'd like to chat more about your requirements please send me an email, we have a tool you might find more suitable for the task. |
WHERE ((street.rtree.minX + street.rtree.maxX) / 2 BETWEEN $topLeftLon AND $bottomRightLon | ||
AND (street.rtree.minY + street.rtree.maxY) / 2 BETWEEN $bottomRightLat AND $topLeftLat ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions about the math here:
- Given the values
minX=-1, maxX=+1
, what happens when dividing 0.0 by 2? - Can the brackets be simplified? maybe
(math) BETWEEN x AND y
, theWHERE
andAND
condition can be independent. - The method is named
WITHIN
, but this seems to be anINTERSECTS
? ie. the text saysfind all streets which have a bbox which envelops the specified point
but the input is a box, not a point, the result will contain geometries which 'leak' out of the bounding box? maybe rename the API for clarity?
var topLeft = { lat: req.query.topLeftLat, lon: req.query.topLeftLon }; | ||
var bottomRight = { lat: req.query.bottomRightLat, lon: req.query.bottomRightLon }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of copying these variables around giving them slightly different names, can we simplify this?
}; | ||
|
||
// order streets by proximity from point (by projecting it on to each line string) | ||
var ordered = proximity.nearest.street( res, [ center.lon, center.lat ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to sort the results by distance from the center? I could see users not wanting this or wanting it to be tunable.
👋 I did some awesome work for the Pelias project and would love for everyone to have a look at it and provide feedback.
Here's the reason for this change 🚀
It was difficult to generate a "complete set" of street geometry data based on the
street/near/geojson
API endpoint. Thestreet/within/geojson
endpoint allows the full set of streets to be queried for a given area.Here's what actually got changed 👏
api/near.js
for getting streets within a given area.query/near.js
to perform the query on the SQLite database.Here's how others can test the changes 👀
The API change can be tested by making a GET request to a path like so, adjusting the lat/lon boundaries to work with your loaded data:
/street/within/geojson?topLeftLat=0.0&topLeftLon=0.0&bottomRightLat=0.0&bottomRightLon=0.0