1

We use pelias geocoder environment in our project. There is a case "selection a polygon, which links with pelias result." For example we choose "Muenich" in search field -> on client we see this:

polygon

How to realise it? Geocoder answers have only bbox and node coordinate (if i use &source=osm too), how to links them with osm admin boundary?

3

Pelias does not currently support directly returning polygon or polyline data. However, you can use a workaround until it does.

A search or autocomplete request to pelias that returns Munich will have a feature in the response that looks something like this (with some data removed for conciseness):

"properties": {
        "id": "101748479",
        "gid": "whosonfirst:locality:101748479",
        "layer": "locality",
        "source": "whosonfirst",
        "name": "Munich",
        "locality": "Munich",
        "locality_gid": "whosonfirst:locality:101748479",
        "country_a": "DEU"
        "label": "Munich, Germany"
      },

The id here is a stable identifier within the Who's on First (WOF) gazetteer. Knowing this identifier, you can fetch the original data from the WOF source on GitHub.

WOF stores data in separate repositories based on the two digit ISO-3166-1 alpha-2 country code. Pelias returns the 3 digit alpha-3 code, which can be converted to the two digit. In this case the data is stored in the whosonfirst-data/whosonfirst-data-admin-de repository.

Using the WOF ID, you can determine the file which contains the GeoJSON geometry for Munich. WOF documents are stored in a nested subdirectory structure with each set of 3 numbers corresponding to a directory level.

You can construct the URL to the Munich GeoJSON file on github.com:

https://github.com/whosonfirst-data/whosonfirst-data-admin-de/blob/master/data/101/748/479/101748479.geojson

or the raw file which is useful for download:

https://raw.githubusercontent.com/whosonfirst-data/whosonfirst-data-admin-de/master/data/101/748/479/101748479.geojson

WOF record for Munich on GitHub

Note: if you're doing this for many records, you might want to mirror this data yourself and possibly simplify the geometry to reduce the data size.

In the future, Pelias will support returning polygons from WOF directly, and may even support returning OSM geometries via the Pelias spatial service, which is currently in early alpha.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.