Browse Source

Merge pull request #114 from pelias/source_id

Update /place endpoint ids info
pull/116/head
Diana Shkolnikov 9 years ago
parent
commit
dc1c2a146d
  1. 29
      place.md
  2. 1
      response.md

29
place.md

@ -2,36 +2,27 @@
When you know an identification number and the source it came from, you can use Mapzen Search to get details on the location.
To get started with a `/place` search, you need a [developer API key](https://mapzen.com/developers) and these three pieces of information:
To get started with a `/place` search, you need a [developer API key](https://mapzen.com/developers).
* source - the data source, such as OpenStreetMap
* layer - the type of place, such as a venue, address, or country.
* id - the identification number of the item
If you have all those, join them together with semicolons and pass them in with the `ids` parameter.
The `/place` endpoint accepts Mapzen Search `gid` strings that get returned for every record in all query responses.
These `gid` strings should not be built manually, but rather used directly as-is to lookup additional details on the location that `gid` refers to.
For example, this `/place` query looks up the Eiffel Tower in OpenStreetMap (OSM):
https://search.mapzen.com/v1/place?api_key=search-XXXXXXX&ids=osm:venue:5013364
https://search.mapzen.com/v1/place?api_key=search-XXXXXXX&ids=openstreetmap:venue:way:5013364
## Search for multiple places in a query
To search for more than one `/place` in a request, join multiple values together and separate them with a comma. For example, this /place query looks up the Eiffel Tower in OpenStreetMap and `30 West 26th St, New York, NY` in OpenAddresses:
To search for more than one `/place` in a request, join multiple values together and separate them with a comma. For example, this `/place` query looks up the Eiffel Tower in OpenStreetMap and the borough of Manhattan in Who's on First:
https://search.mapzen.com/v1/place?api_key=search-XXXXXXX&ids=osm:venue:5013364,oa:address:65cf57e4eb5548eca9bb548fb1461633
https://search.mapzen.com/v1/place?api_key=search-XXXXXXX&ids=openstreetmap:venue:way:5013364,whosonfirst:borough:421205771
The results are returned in the order requested.
One reason you'd want to do this is to exclude a particular dataset from being searched; you would include all the other data sources you do want to search.
Keep in mind that if you enter a `source:layer:id` combination that cannot be found, then the `features` array in the response contains a different number of elements than the number of requests. This will be most noticeable in requests with multiple IDs, as your request may have three IDs requested but only two results returned. The reason for this is that the `features` section of the response is GeoJSON-compliant, and JSON does not allow a way to convey an exception condition (not even an empty JSON element, `{}`). For this reason, if your application is dependent upon the results mapping directly to the individual input requests in order, then you'll have to do your own bookkeeping to handle exception conditions.
If you enter a valid `gid` that cannot be found or has "expired" due to a newer build, you may get empty results. The request will NOT return an error.
## Valid combinations of place searches
If the structure of your `gid` is invalid, an error will be returned as part of the geojson structure.
Some combinations of `sources` and `layers` can be used together while others cannot. This table shows valid combinations.
Keep in mind that if you enter a `gid` that cannot be found in a list of multiple ids, then the `features` array in the response contains a different number of elements than the number of requests. For example, your request may have three IDs requested but only two results returned. The reason for this is that the `features` section of the response is GeoJSON-compliant, and JSON does not allow a way to convey an exception condition (not even an empty JSON element, `{}`). For this reason, if your application is dependent upon the results mapping directly to the individual input requests in order, then you'll have to do your own bookkeeping to handle exception conditions.
source | layers
--- | ---
`osm` or `openstreetmap` | `venue`, `address`
`oa` or `openaddresses` | `address`
`gn` or `geonames` | `venue`, `address`, `neighbourhood`, `locality`, `county`, `region`, `country`, `coarse`
:warning: It is important to not use any `gid` values to attempt `/place` queries after longer than an hour. These ids are not intended to be stable across build, as we employ datasets that do not have consistent ids.

1
response.md

@ -36,6 +36,7 @@ Each item in this list will contain all the information needed to find it in hum
"gid": "whosonfirst:locality:101750367",
"layer": "locality",
"source": "whosonfirst",
"souce_id": "101750367",
"name": "London",
"confidence": 0.949,
"country": "United Kingdom",

Loading…
Cancel
Save