From ab43c5ca30747516433cec0ef565cce447878379 Mon Sep 17 00:00:00 2001 From: livio Date: Fri, 11 Sep 2026 20:57:15 +0200 Subject: [PATCH] Fix Agency cadastral WMS coordinate system --- LMEMappeCatastaliApp.csproj | 4 ++-- README.md | 1 + Services/AzureMapsService.cs | 2 +- wwwroot/js/lme-map.js | 32 +++++++++++++++++++++++++++----- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/LMEMappeCatastaliApp.csproj b/LMEMappeCatastaliApp.csproj index 422416f..13d8d72 100644 --- a/LMEMappeCatastaliApp.csproj +++ b/LMEMappeCatastaliApp.csproj @@ -28,8 +28,8 @@ com.companyname.lmemappecatastaliapp - 0.2.5 - 9 + 0.2.6 + 10 None diff --git a/README.md b/README.md index 0c06560..deb30bf 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ App .NET MAUI Blazor Hybrid per Android, iOS, Mac Catalyst e Windows, pensata pe - Comandi separati per rimuovere le particelle selezionate o pulire importazioni, disegni, POI e traccia GPS. - Anteprima WMS ufficiale mostrata dentro l'app senza aprire una nuova finestra Android. - Confini delle particelle selezionate e della particella GPS sovrapposti anche all'anteprima WMS corrente. +- Richieste WMS catastali in EPSG:4258 compatibili con il servizio AdE; i numeri particella sono visibili alle scale di dettaglio consentite dal servizio (circa zoom 17 o superiore). - Collegamenti separati al Geoportale pubblico e all'Area riservata AdE per CAPTCHA, SPID/CIE e download ufficiali. ## Limite ufficiale AdE da considerare diff --git a/Services/AzureMapsService.cs b/Services/AzureMapsService.cs index f53bfaa..173f74d 100644 --- a/Services/AzureMapsService.cs +++ b/Services/AzureMapsService.cs @@ -13,7 +13,7 @@ public sealed class AzureMapsService public AzureMapsService() { - _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.5"); + _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.6"); _httpClient.DefaultRequestHeaders.Accept.ParseAdd("application/json"); } diff --git a/wwwroot/js/lme-map.js b/wwwroot/js/lme-map.js index 0902239..0ceac13 100644 --- a/wwwroot/js/lme-map.js +++ b/wwwroot/js/lme-map.js @@ -26,6 +26,10 @@ const lmeState = { azureAttribution: null }; +// AdE publishes the cadastral WMS in ETRS89. WMS 1.1.1 keeps the longitude, +// latitude BBOX order expected by Leaflet while sending the required CRS code. +const cadastreCrs = L.extend({}, L.CRS.EPSG4326, { code: "EPSG:4258" }); + window.lmeMap = { init, showSearchResult, @@ -291,7 +295,10 @@ function exportCadastreView() { previewMap.hidden = false; const highlightedCount = lmeState.selectedParcelsLayer.getLayers().length + lmeState.gpsParcelLayer.getLayers().length; - setInfo(`Vista WMS caricata con ${layers.length} layer e ${highlightedCount} particelle evidenziate.`); + const zoomHint = layers.includes("codice_plla") && lmeState.map.getZoom() < 17 + ? " Ingrandisci almeno fino a zoom 17 per leggere i numeri delle particelle." + : ""; + setInfo(`Vista WMS caricata con ${layers.length} layer e ${highlightedCount} particelle evidenziate.${zoomHint}`); }; image.onerror = () => { previewMap.hidden = true; @@ -782,16 +789,31 @@ function refreshCadastreLayer() { return; } - lmeState.cadastre = L.tileLayer.wms(cadastreUrl(), { + const cadastreLayer = L.tileLayer.wms(cadastreUrl(), { layers: layers.join(","), format: "image/png", transparent: true, - version: "1.3.0", - crs: L.CRS.EPSG4326, + version: "1.1.1", + crs: cadastreCrs, maxZoom: 22, opacity: lmeState.cadastreOpacity, attribution: "Agenzia delle Entrate - CC BY 4.0" - }).addTo(lmeState.map); + }); + + let errorShown = false; + cadastreLayer.on("tileerror", () => { + if (errorShown) { + return; + } + + errorShown = true; + setInfo("Layer catastali non caricati dal servizio AdE. Controlla la connessione e riprova."); + }); + cadastreLayer.on("load", () => { + errorShown = false; + }); + + lmeState.cadastre = cadastreLayer.addTo(lmeState.map); } function activeCadastreLayers() {