Added "streets within" query to API#288
Draft
aaronhourie wants to merge 3 commits intopelias:masterfrom
Draft
Conversation
Added 'within' query for getting streets within a bounding box
Member
|
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. |
missinglink
reviewed
Jun 14, 2022
Comment on lines
+14
to
+15
| WHERE ((street.rtree.minX + street.rtree.maxX) / 2 BETWEEN $topLeftLon AND $bottomRightLon | ||
| AND (street.rtree.minY + street.rtree.maxY) / 2 BETWEEN $bottomRightLat AND $topLeftLat ) |
Member
There was a problem hiding this comment.
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, theWHEREandANDcondition 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 pointbut 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?
missinglink
reviewed
Jun 14, 2022
Comment on lines
+181
to
+182
| var topLeft = { lat: req.query.topLeftLat, lon: req.query.topLeftLon }; | ||
| var bottomRight = { lat: req.query.bottomRightLat, lon: req.query.bottomRightLon }; |
Member
There was a problem hiding this comment.
There is a lot of copying these variables around giving them slightly different names, can we simplify this?
missinglink
reviewed
Jun 14, 2022
| }; | ||
|
|
||
| // order streets by proximity from point (by projecting it on to each line string) | ||
| var ordered = proximity.nearest.street( res, [ center.lon, center.lat ] ); |
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
👋 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/geojsonAPI endpoint. Thestreet/within/geojsonendpoint allows the full set of streets to be queried for a given area.Here's what actually got changed 👏
api/near.jsfor getting streets within a given area.query/near.jsto 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