diff --git a/lookup.py b/lookup.py index 9c6ad53..76c1745 100755 --- a/lookup.py +++ b/lookup.py @@ -151,6 +151,13 @@ def lat_lon_to_wikidata( if not nearby_result.get("missing"): 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: # Direct lookup: find Wikidata items whose P402 (OSM relation ID) matches # one of the OSM polygons that contain this point.