From 0d854dd5d950729ee1af4e5cfa9fcd81a8f72856 Mon Sep 17 00:00:00 2001 From: Carlo Baratto Date: Tue, 25 Aug 2026 08:56:50 +0200 Subject: [PATCH] fix ricerca libera: geocoding via Photon (Nominatim 403 con UA QML) + osm_tag place:city --- qml/pages/MainPage.qml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index f63c34e..7654a0a 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -149,17 +149,24 @@ Page { } function geoXhr(query, cb) { + // Photon (komoot) invece di Nominatim: accetta qualsiasi User-Agent + // (Nominatim risponde 403 all'UA generico inviato dalle XHR QML di Qt) + // e supporta il filtro osm_tag=place:city per le città vere. var xhr = new XMLHttpRequest() - xhr.open("GET", "https://nominatim.openstreetmap.org/search?format=jsonv2&limit=1&q=" + xhr.open("GET", "https://photon.komoot.io/api/?limit=1&osm_tag=place:city&q=" + encodeURIComponent(query), true) xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { try { var j = JSON.parse(xhr.responseText) - if (j && j.length > 0) { - cb(j[0].name || j[0].display_name.split(",")[0], - parseFloat(j[0].lat), parseFloat(j[0].lon), "OpenStreetMap") + if (j && j.features && j.features.length > 0) { + var f = j.features[0] + var name = f.properties.name || query + cb(name, + f.geometry.coordinates[1], + f.geometry.coordinates[0], + "OpenStreetMap") } else { cb(null) }