Extend nearest-polygon fallback to all countries, not just Scotland
Points in the sea near England (or any other country) now fall back to Polygon.nearest() to find the closest admin_level>=7 polygon on land, giving a specific civil parish or district instead of just returning England (Q21). Closes #30
This commit is contained in:
parent
76437d5240
commit
6a5d5d0c2f
1 changed files with 7 additions and 0 deletions
|
|
@ -151,6 +151,13 @@ def lat_lon_to_wikidata(
|
||||||
if not nearby_result.get("missing"):
|
if not nearby_result.get("missing"):
|
||||||
return {"elements": elements, "result": nearby_result}
|
return {"elements": elements, "result": nearby_result}
|
||||||
|
|
||||||
|
# For points in the sea near any coast (e.g. England), try nearest polygon
|
||||||
|
nearest = model.Polygon.nearest(lat, lon)
|
||||||
|
if nearest:
|
||||||
|
nearby_result = do_lookup([nearest], lat, lon)
|
||||||
|
if not nearby_result.get("missing"):
|
||||||
|
return {"elements": elements, "result": nearby_result}
|
||||||
|
|
||||||
if not needs_commons:
|
if not needs_commons:
|
||||||
# Direct lookup: find Wikidata items whose P402 (OSM relation ID) matches
|
# Direct lookup: find Wikidata items whose P402 (OSM relation ID) matches
|
||||||
# one of the OSM polygons that contain this point.
|
# one of the OSM polygons that contain this point.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue