Skip to content
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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aaronhourie
Copy link

👋 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. The street/within/geojson endpoint allows the full set of streets to be queried for a given area.


Here's what actually got changed 👏

  • Added a new API class based on api/near.js for getting streets within a given area.
  • Added a new query class based on query/near.js to perform the query on the SQLite database.
  • Updated the README to include documentation for the new query.

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

@missinglink
Copy link
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.

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 )
Copy link
Member

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, the WHERE and AND condition can be independent.
  • The method is named WITHIN, but this seems to be an INTERSECTS? ie. the text says find 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?

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 };
Copy link
Member

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 ] );
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants