Add needs_commons=false option and redesign detail and index pages
Add a needs_commons parameter (default true) to both the API endpoint and the detail page. When needs_commons=false, look up Wikidata items by OSM relation ID (P402) via WDQS to return the most specific matching item even if it has no Wikimedia Commons category. Only activate this path when the matched item has no Commons category, so that locations with a Commons cat always get the same result regardless of the parameter. Remove the nearest-polygon fallback that was returning incorrect results for inland points in broad admin areas (e.g. returning Falmer for a point in Brighton). That fallback found the nearest polygon by boundary distance without requiring containment, so the pin would appear outside the polygon. The geosearch handles these cases correctly. Redesign the detail page: place name as heading, result card, collapsible API response and SPARQL query, improved OSM element cards with left-border highlight on the matched element, and a toggle button between modes. Redesign the index page: two-column layout with numbered steps and API documentation including the needs_commons parameter, Bootstrap form, and examples as a table. Closes #28 (Add support for returning Wikidata item instead of commons category) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
90b009fc90
commit
cd9d8779d3
6 changed files with 385 additions and 138 deletions
10
templates/sparql/lookup_by_osm_relation.sparql
Normal file
10
templates/sparql/lookup_by_osm_relation.sparql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
SELECT ?item ?itemLabel ?commonsCat ?commonsSiteLink ?osmRelation WHERE {
|
||||
VALUES ?osmRelation {
|
||||
{% for id in relation_ids %}"{{ id }}" {% endfor %}
|
||||
}
|
||||
?item wdt:P402 ?osmRelation .
|
||||
OPTIONAL { ?item wdt:P373 ?commonsCat. }
|
||||
OPTIONAL { ?commonsSiteLink schema:about ?item ;
|
||||
schema:isPartOf <https://commons.wikimedia.org/>. }
|
||||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue