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
- Redesign pin_detail.html to match detail page style: place name heading,
result card, button group, collapsible API response, element cards with
left-border highlight, collapsible SPARQL query
- Redesign map.html: compact header, styled prompt, shared CSS for element
cards and tag keys, loading state on XHR
- Add lat/lon URL params to /map: map centres on coords and auto-loads pin
- Add needs_commons checkbox to map page: toggles needs_commons=false in URL
and re-fetches the current pin when changed
- Return geojson in /pin/ JSON response so map can render the polygon layer
- Pass needs_commons through to /pin/ route and detail page link
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
When a point falls in the sea within a country boundary (e.g. Scotland
Q22 or England Q21) but not within any specific parish, find the nearest
civil parish or high-admin-level polygon within ~0.15 degrees (~10-17km).
- Add get_nearest_scotland_code() for Scottish civil parishes
- Add Polygon.nearest() for general OSM polygon lookup
- Use .limit(1).scalar() in scotland.py for cleaner returns
- Add parse_coordinate() function to handle both decimal degrees and DMS format
- Replace direct float() conversion with robust coordinate parsing
- Add proper validation for latitude/longitude ranges
- Create user-friendly error page instead of showing stack traces
- Support formats like "56°5'58.56"N" and "3°22'33.71"W"
- Update both /detail and / routes with improved error handling
Fixes#29: Don't return stack trace when lat/lon are not integers
- Import text from sqlalchemy
- Wrap "SELECT 1" statements in text() function in index() and
detail_page()
- Addresses SQLAlchemy 2.0+ requirement for explicit text() wrapper on
raw SQL strings