From e1f6b09ec10d6afcc4d99a26f17acfdaca66ac06 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 10 Jan 2024 16:25:22 +0000 Subject: [PATCH] Web interface with map where user can place pin for testing Closes: #21 --- lookup.py | 30 ++++++++++++++++++++++++++++++ templates/index.html | 2 ++ 2 files changed, 32 insertions(+) diff --git a/lookup.py b/lookup.py index df246a9..8541712 100755 --- a/lookup.py +++ b/lookup.py @@ -410,5 +410,35 @@ def reports() -> str: ) +@app.route("/pin//") +def pin_detail(lat: str, lon: str) -> Response: + """Details for map pin location.""" + reply = lat_lon_to_wikidata(float(lat), float(lon)) + element = reply["result"].pop("element", None) + geojson = reply["result"].pop("geojson", None) + + css = HtmlFormatter().get_style_defs(".highlight") + + html = render_template( + "pin_detail.html", + lat=lat, + lon=lon, + str=str, + element_id=element, + geojson=geojson, + css=css, + **reply, + ) + + return jsonify(html=html) + + +@app.route("/map") +def map_page() -> str: + """Map page.""" + css = HtmlFormatter().get_style_defs(".highlight") + return render_template("map.html", css=css) + + if __name__ == "__main__": app.run(host="0.0.0.0") diff --git a/templates/index.html b/templates/index.html index 3edddfe..544e7ef 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,6 +16,8 @@ Wikidata Query service (WDQS)
  • Return the most specific Wikidata QID and Commons Category.
  • +

    Interactive map with clickable pin for geocode testing: click on any location within the map to place a pin and see the geocoding results for that specific point.

    +
    Latitude/Longitude: (e.g. 54.375, -2.999)