A simple geocoder for NYC. Similar to the NYC's official geoclient api, but with far fewer bells and whistles.
All the heavy lifting is done by:
-
@jordanderson's ruby binding to City Planning's geosupport
-
Mapzen's libpostal
There's only one endpoint with 3 ways to submit an address:
- House, Street, and Borough
curl https://geocode.nycdb.info/?house=1000&street=surf avenue&borough=brooklyn
- House, Street, and Zipcode
curl https://geocode.nycdb.info/?house=1000&street=surf avenue&zipcode=11224
- Address
curl https://geocode.nycdb.info/?address=1000 Surf Avenue Brooklyn, NY 11224
All of those requests return the same json object:
{
"bbl": "3086960212",
"latitude": 40.57436,
"longitude": -73.978499,
"status": "OK"
}
Successful responses contains a simple JSON object with 4 fields: bbl, latitude, longitude, status.
Responses with errors have one or two fields: status and message. If present, the message field will contain information that might help you figure out what went wrong.
Example error:
This request:
curl https://geocode.nycdb.info/?house=1000&street=Surf%20Avenue
Returns this error:
{
"status":"ERROR",
"message":"Missing parameter: zipcode or borough"
}
That's it! There's no authorization and no other information provided besides bbl, latitude and longitude.
NOTE: This has not tested on anything other Debian-based systems. As currently setup it almost certainly won't work on other OSs.
setup geosupport and libpostal
make setup libpostal
Install ruby gems:
bundle install
Setup geosupport paths
source libgeo-paths
Run:
ruby app.rb
Run the tests:
rspec test.rb