Skip to content

Instantly share code, notes, and snippets.

@chriswhong
Last active November 6, 2017 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriswhong/cec14acaf9b9c0827b11281a21284c28 to your computer and use it in GitHub Desktop.
Save chriswhong/cec14acaf9b9c0827b11281a21284c28 to your computer and use it in GitHub Desktop.
An autocomplete web API for geosupport

Problem

DCP maintains geosupport, the city's official geocoder, which can be accessed by using the libraries directly, or via various client-facing application/services including GOAT, GeoClient, GeoBat, etc.

The NYC Planning Labs team would like to incorporate geosupport results into web mapping applications, but geosupport's architecture does not work well with the "autocomplete" search style that is popular in modern web applications. Traditionally, to use geosupport, the user must provide at least a house number, street name, and borough, and will either git a hit, or a list of possible alternatives.

Below we propose some high-level specifications for a GeoSupport Autocomplete Web API that would be useful for search in modern web applications.

A Model to Emulate: Mapzen Search's Autocomplete API

Mapzen Search has an autocomplete API, which is well-documente, open source, and provides the type of experience developers want in a modern geocoder (NYC Planning Labs is using Mapzen Search in any apps that need address search)

A Simple Endpoint

While there is much more that geosupport can do, starting with a simple address search will be most impactful short-term use case.

/v1/autocomplete would be the primary endpoint, used specifically for locating addresses or alternate names of addresses, and can accept various URL parameters:

text - the freeform text string to match against. As a user types into a search input, the full text of the input will be passed to the endpoint as the text parameter.

focus.point.lat, focus.point.lon - allows the user to specify a focus point, returning closer results first

boundary.rect.min_lon, boundary.rect.min_lat, boundary.rect.max_lon, boundary.rect.max_lat - allows the user to specify a bounding box for search results, anything outside of the box will be excluded from search results

Response

/v1/autocomplete?text=120 Broadway should return a GeoJSON FeatureCollection, with an added geocoding property with metainformation about the search:

{
  "geocoding": {
    "time": 45, // query time in milliseconds
    "text": "120 Broadway", // the original search text
  },
  "type":"FeatureCollection",
  "features": [
    // array of geojson features with individual result data, the same as what geosupport normally returns.
      {
        "type":"Feature",
        "geometry":{
          "type":"Point",
          "coordinates": ...
        },
        "properties": {
          "addressnumber": 120,
          "streetname": "Broadway",
          "borough": "Manhattan,
          "fullname": "120 Broadway, Manhattan"
          "altnames": [
            "Equitable Life Building"
          ]
        }
      }
    ...
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment