osm-search / Nominatim

Open Source search based on OpenStreetMap data
https://nominatim.org
GNU General Public License v3.0
3.2k stars 715 forks source link

How to get the city (town,village,hamlet) correctly, point by point? #885

Closed nonuzer closed 6 years ago

nonuzer commented 6 years ago

Hi.

How to get the city (town,village,hamlet) correctly, point by point?

What I do:

http://nominatim.openstreetmap.org/reverse.php?format=json&lat=51.896801191943&lon=-0.49737201287174&zoom=10&accept-language=en

"town":"Dunstable"

{"place_id":"138127","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"26744103","lat":"51.8885447","lon":"-0.5161863","display_name":"Dunstable, Central Bedfordshire, East of England, England, LU5 4HD, United Kingdom","address":{"town":"Dunstable","county":"Central Bedfordshire","state_district":"East of England","state":"England","postcode":"LU5 4HD","country":"United Kingdom","country_code":"gb"},"boundingbox":["51.8085447","51.9685447","-0.5961863","-0.4361863"]}

All perfectly. I get the town.

I make the following query with zoom 10

http://nominatim.openstreetmap.org/reverse.php?format=json&lat=52.35925362&lon=-2.94525499&accept-language=en&zoom=10

No town

{"place_id":"180063014","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"6811031","lat":"52.3606416","lon":"-2.9512644","display_name":"Bucknell, Shropshire, West Midlands, England, United Kingdom","address":{"suburb":"Bucknell","county":"Shropshire","state_district":"West Midlands","state":"England","country":"United Kingdom","country_code":"gb"},"boundingbox":["52.3487675","52.380122","-2.9936035","-2.9209356"]}

I make the following request with zoom 16

http://nominatim.openstreetmap.org/reverse.php?format=json&lat=52.35925362&lon=-2.94525499&accept-language=en&zoom=16

"village":"Bucknell"

{"place_id":"130899668","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"262780033","lat":"52.3597582","lon":"-2.9440895","display_name":"Old Bedstone Road, Bucknell, Shropshire, West Midlands, England, SY7 0AU, United Kingdom","address":{"road":"Old Bedstone Road","village":"Bucknell","county":"Shropshire","state_district":"West Midlands","state":"England","postcode":"SY7 0AU","country":"United Kingdom","country_code":"gb"},"boundingbox":["52.3592431","52.3597582","-2.9450653","-2.9440895"]}

If I make a request to the first link with zoom 16, I do not get the city

http://nominatim.openstreetmap.org/reverse.php?format=json&lat=51.896801191943&lon=-0.49737201287174&zoom=16&accept-language=en

{"place_id":"91521144","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"101809025","lat":"51.8958973","lon":"-0.4952488","display_name":"Poynters Road, Dunstable, Luton, East of England, England, LU5 4SQ, United Kingdom","address":{"road":"Poynters Road","suburb":"Dunstable","county":"Luton","state_district":"East of England","state":"England","postcode":"LU5 4SQ","country":"United Kingdom","country_code":"gb"},"boundingbox":["51.891562","51.8998255","-0.5042884","-0.4855205"]}

Sory, no town.

Help please advice.

P.S. Sorry for my english

lonvia commented 6 years ago

Look for the first of 'city', 'town', 'village', 'hamlet', 'suburb' in your result. With paramter zoom=10, use the first entry in the address field (or the first part of display_name up to the first comma.

Before you complain, this is an underlying data issue with OSM with a possible solution discussed already in #213. A discussion about the specific issues with suburbs not being suburbs in England is already in #231.