Routing in NYC with pgRouting and authoritative NYC data. This project is currently a proof of concept and not intended for real world routing scenarios.
- Driving, Walking and Biking routes using DCP's LION data
- Address searching using Geosupport and geosupport-suggest
- Routing capabilities using pgRouting
- Web API using Flask RESTful
- Frontend using React JS and Mapbox GL JS
- Containerized with Docker
This projected is orchestrated with docker-compose.
-
Clone this repo and
cd
into it:git clone https://github.com/ishiland/nyc-open-routing.git
-
Build the project.
docker-compose build
-
Start the project.
docker-compose up -d
If this is the first time starting, the
api
container will download and install geosupport. You can upgrade geosupport by specifying a different version in the .env file and restarting the service. -
Import the Lion data using the following command:
docker-compose exec api sh /data-imports/scripts/import-lion.sh
You can also specify a version of Lion:
docker-compose exec api sh /data-imports/scripts/import-lion.sh 23a
-
When its complete navigate to http://localhost:3001
Use the flask api to query routes directly. All successful requests return GeoJSON w/MultiLineString geometries. You can comment out the client
container in the docker-compose.yml if all you require is the api.
Parameters:
orig
: Origin coordinates. Expects a comma separated lat,long.dest
: Destination coordinates. Expects a comma separated lat,long.mode
: Travel mode. Can bedrive
,walk
orbike
Example request: http://localhost:5001/api/route?orig=-74.0117,40.649221&dest=-73.951458,40.797061&mode=drive
response:
{
"features": [
{
"properties": {
"seq": 1, // sequence of segment in route
"street": "3 AVENUE",
"distance": 260.679437746423, // distance of segment in feet
"travel_time": 0.0987422112675845, // travel time of segment in minutes
},
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "MultiLineString",
"coordinates": [
[
[
-74.01149956053376,
40.65037686591395
],
[
-74.01207536260924,
40.649811516367066
]
]
]
}
]
}
},
...
- Incorporate traffic data to more accurately calculate driving costs. Live or static traffic data would be a significant improvement.
- Add public transit modes using MTA data.
- Ferry schedules for more accurate biking/walking cost.
- Travel time isochrones for selected addresses.
- Line Merge segments where possible to optimize and reduce complexity of graph.
- Optimize functions by adding BBOX parameter.
- Add turn by turn directions with angle (left, right, sharp right, etc. ) similar to google maps.
- Send GeoJSON directly from the database using
ST_AsGeoJSON
to remove gdal dependency inapi
container.