Compare commits

...
3 Commits
Author SHA1 Message Date
livio 708f539c64 Persist map flags and toggle selected parcels 2026-09-22 14:43:27 +02:00
livio e93dd9b867 Generate missing imported sheet outline 2026-09-22 10:47:35 +02:00
livio a9b1d74983 Fix imported sheet layer visibility 2026-09-22 10:25:51 +02:00
5 changed files with 236 additions and 57 deletions

No files matched your search

+125 -30
View File
@@ -58,8 +58,15 @@
</span> </span>
</label> </label>
} }
<label class="map-layer-option">
<input type="checkbox" @bind="ShowSelectedParcels" @bind:after="ApplySelectedParcelsVisibility" />
<span>
<strong>Particelle selezionate</strong>
<small>Nascondi o mostra senza eliminare i dati</small>
</span>
</label>
<div class="layer-panel-actions"> <div class="layer-panel-actions">
<button class="secondary-command" @onclick="ClearSelectedParcels">Rimuovi particelle selezionate</button> <button class="danger-command" @onclick="ClearSelectedParcels">Elimina definitivamente le particelle selezionate</button>
<button class="danger-command" @onclick="ClearMapElements">Pulisci elementi mappa</button> <button class="danger-command" @onclick="ClearMapElements">Pulisci elementi mappa</button>
</div> </div>
</section> </section>
@@ -161,7 +168,7 @@
<input id="gisFileInput" type="file" accept=".kml,.kmz,.geojson,.json,application/vnd.google-earth.kml+xml,application/vnd.google-earth.kmz,application/geo+json" /> <input id="gisFileInput" type="file" accept=".kml,.kmz,.geojson,.json,application/vnd.google-earth.kml+xml,application/vnd.google-earth.kmz,application/geo+json" />
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@IncludeKmlSheetLayer" @onchange="ToggleKmlSheetLayer" /> <input type="checkbox" @bind="IncludeKmlSheetLayer" @bind:after="ApplyKmlSheetLayerOption" />
<span>KML/KMZ: includi anche il layer del foglio</span> <span>KML/KMZ: includi anche il layer del foglio</span>
</label> </label>
<small class="field-help"> <small class="field-help">
@@ -170,12 +177,12 @@
: "Disattivato: importa solo i poligoni delle particelle riconosciute.") : "Disattivato: importa solo i poligoni delle particelle riconosciute.")
</small> </small>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowImportedSheetLayer" @onchange="ToggleImportedSheetLayer" /> <input type="checkbox" @bind="ShowImportedSheetLayer" @bind:after="ApplyImportedSheetLayerVisibility" />
<span>Mostra cornice/layer del foglio importato</span> <span>Mostra cornice/layer del foglio importato</span>
</label> </label>
<small class="field-help">La cornice grande resta separata dalle particelle e puo essere nascosta anche nei progetti salvati.</small> <small class="field-help">La cornice grande resta separata dalle particelle e puo essere nascosta anche nei progetti salvati.</small>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowImportedMeasurements" @onchange="ToggleImportedMeasurements" /> <input type="checkbox" @bind="ShowImportedMeasurements" @bind:after="ApplyImportedMeasurementsVisibility" />
<span>Mostra misure dei file caricati</span> <span>Mostra misure dei file caricati</span>
</label> </label>
<div class="button-row"> <div class="button-row">
@@ -187,7 +194,7 @@
<section class="panel-section"> <section class="panel-section">
<h2>Disegni e misure</h2> <h2>Disegni e misure</h2>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowDrawingMeasurements" @onchange="ToggleDrawingMeasurements" /> <input type="checkbox" @bind="ShowDrawingMeasurements" @bind:after="ApplyDrawingMeasurementsVisibility" />
<span>Mostra superficie, perimetro e lati</span> <span>Mostra superficie, perimetro e lati</span>
</label> </label>
<button class="secondary-command" aria-pressed="@DrawToolsVisible" @onclick="ToggleDrawTools"> <button class="secondary-command" aria-pressed="@DrawToolsVisible" @onclick="ToggleDrawTools">
@@ -225,27 +232,27 @@
</label> </label>
<div class="export-options" role="group" aria-label="Oggetti da esportare"> <div class="export-options" role="group" aria-label="Oggetti da esportare">
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportImported" /> <input type="checkbox" @bind="ExportImported" @bind:after="SaveFlagPreferences" />
<span>Particelle e dati GIS importati</span> <span>Particelle e dati GIS importati</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportImportedSheets" /> <input type="checkbox" @bind="ExportImportedSheets" @bind:after="SaveFlagPreferences" />
<span>Cornici, fogli e riquadri KMZ</span> <span>Cornici, fogli e riquadri KMZ</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportCadastral" /> <input type="checkbox" @bind="ExportCadastral" @bind:after="SaveFlagPreferences" />
<span>Particelle catastali rosse e GPS</span> <span>Particelle catastali rosse e GPS</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportDrawings" /> <input type="checkbox" @bind="ExportDrawings" @bind:after="SaveFlagPreferences" />
<span>Disegni, aree, linee e cerchi</span> <span>Disegni, aree, linee e cerchi</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportPoi" /> <input type="checkbox" @bind="ExportPoi" @bind:after="SaveFlagPreferences" />
<span>Punti di interesse</span> <span>Punti di interesse</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="ExportTrail" /> <input type="checkbox" @bind="ExportTrail" @bind:after="SaveFlagPreferences" />
<span>Traccia GPS registrata</span> <span>Traccia GPS registrata</span>
</label> </label>
</div> </div>
@@ -267,7 +274,7 @@
<input @bind="NewProjectName" @bind:event="oninput" placeholder="Es. Rilievo San Nicola" maxlength="80" /> <input @bind="NewProjectName" @bind:event="oninput" placeholder="Es. Rilievo San Nicola" maxlength="80" />
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" @bind="IncludeCadastralParcels" /> <input type="checkbox" @bind="IncludeCadastralParcels" @bind:after="SaveFlagPreferences" />
<span>Includi le particelle catastali rosse</span> <span>Includi le particelle catastali rosse</span>
</label> </label>
<button class="primary-command" @onclick="SaveProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(NewProjectName))">Salva progetto</button> <button class="primary-command" @onclick="SaveProject" disabled="@(ProjectBusy || string.IsNullOrWhiteSpace(NewProjectName))">Salva progetto</button>
@@ -295,16 +302,16 @@
<section class="panel-section"> <section class="panel-section">
<h2>Visualizzazione progetto</h2> <h2>Visualizzazione progetto</h2>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowImportedSheetLayer" @onchange="ToggleImportedSheetLayer" /> <input type="checkbox" @bind="ShowImportedSheetLayer" @bind:after="ApplyImportedSheetLayerVisibility" />
<span>Mostra cornice/layer del foglio importato</span> <span>Mostra cornice/layer del foglio importato</span>
</label> </label>
<small class="field-help">Il comando agisce subito sulla mappa e sui dati del progetto caricato.</small> <small class="field-help">Il comando agisce subito sulla mappa e sui dati del progetto caricato.</small>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowImportedMeasurements" @onchange="ToggleImportedMeasurements" /> <input type="checkbox" @bind="ShowImportedMeasurements" @bind:after="ApplyImportedMeasurementsVisibility" />
<span>Mostra misure dei file caricati</span> <span>Mostra misure dei file caricati</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowDrawingMeasurements" @onchange="ToggleDrawingMeasurements" /> <input type="checkbox" @bind="ShowDrawingMeasurements" @bind:after="ApplyDrawingMeasurementsVisibility" />
<span>Mostra misure dei disegni</span> <span>Mostra misure dei disegni</span>
</label> </label>
</section> </section>
@@ -357,11 +364,11 @@
<section class="panel-section"> <section class="panel-section">
<h2>GPS e percorso</h2> <h2>GPS e percorso</h2>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@ShowGpsPosition" @onchange="ToggleGpsPosition" /> <input type="checkbox" @bind="ShowGpsPosition" @bind:after="ApplyGpsPositionVisibility" />
<span>Mostra punto e cerchio GPS</span> <span>Mostra punto e cerchio GPS</span>
</label> </label>
<label class="toggle-line project-save-option"> <label class="toggle-line project-save-option">
<input type="checkbox" checked="@TrailEnabled" @onchange="ToggleTrail" /> <input type="checkbox" @bind="TrailEnabled" @bind:after="ApplyTrailOption" />
<span>Registra la traccia mentre cammini</span> <span>Registra la traccia mentre cammini</span>
</label> </label>
</section> </section>
@@ -415,6 +422,7 @@
</div> </div>
@code { @code {
private const string FlagPreferencePrefix = "lme_flag_";
private string ActiveTab { get; set; } = "map"; private string ActiveTab { get; set; } = "map";
private string SearchText { get; set; } = string.Empty; private string SearchText { get; set; } = string.Empty;
private string NewProjectName { get; set; } = string.Empty; private string NewProjectName { get; set; } = string.Empty;
@@ -437,6 +445,7 @@
private bool CatalogBusy { get; set; } private bool CatalogBusy { get; set; }
private bool GpsActive { get; set; } private bool GpsActive { get; set; }
private bool ShowGpsPosition { get; set; } = true; private bool ShowGpsPosition { get; set; } = true;
private bool ShowSelectedParcels { get; set; } = true;
private bool DrawToolsVisible { get; set; } private bool DrawToolsVisible { get; set; }
private bool TrailEnabled { get; set; } private bool TrailEnabled { get; set; }
private bool LayerPanelOpen { get; set; } private bool LayerPanelOpen { get; set; }
@@ -502,6 +511,8 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
LoadFlagPreferences();
try try
{ {
GoogleMapsApiKey = await SecureStorage.Default.GetAsync("google_maps_api_key") ?? string.Empty; GoogleMapsApiKey = await SecureStorage.Default.GetAsync("google_maps_api_key") ?? string.Empty;
@@ -537,6 +548,7 @@
if (firstRender) if (firstRender)
{ {
await JS.InvokeVoidAsync("lmeMap.init"); await JS.InvokeVoidAsync("lmeMap.init");
await ApplyFlagPreferencesToMapAsync();
await CenterOnInitialLocationAsync(); await CenterOnInitialLocationAsync();
await MigrateLegacyProjectAsync(); await MigrateLegacyProjectAsync();
} }
@@ -854,9 +866,9 @@
} }
} }
private async Task ToggleGpsPosition(ChangeEventArgs args) private async Task ApplyGpsPositionVisibility()
{ {
ShowGpsPosition = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setGpsPositionVisible", ShowGpsPosition); await JS.InvokeVoidAsync("lmeMap.setGpsPositionVisible", ShowGpsPosition);
} }
@@ -969,39 +981,41 @@
private async Task ClearImportedLayers() private async Task ClearImportedLayers()
{ {
ShowImportedSheetLayer = false; ShowImportedSheetLayer = false;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.clearImported"); await JS.InvokeVoidAsync("lmeMap.clearImported");
} }
private Task AddProjectMarker() => JS.InvokeVoidAsync("lmeMap.addProjectMarker", PoiName).AsTask(); private Task AddProjectMarker() => JS.InvokeVoidAsync("lmeMap.addProjectMarker", PoiName).AsTask();
private async Task ToggleKmlSheetLayer(ChangeEventArgs args) private async Task ApplyKmlSheetLayerOption()
{ {
IncludeKmlSheetLayer = (bool?)args.Value == true;
ShowImportedSheetLayer = IncludeKmlSheetLayer; ShowImportedSheetLayer = IncludeKmlSheetLayer;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer); await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer);
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer); await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer);
} }
private async Task ToggleImportedSheetLayer(ChangeEventArgs args) private Task ApplyImportedSheetLayerVisibility()
{ {
ShowImportedSheetLayer = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer); return JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer).AsTask();
} }
private async Task ToggleImportedMeasurements(ChangeEventArgs args) private async Task ApplyImportedMeasurementsVisibility()
{ {
ShowImportedMeasurements = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setImportedMeasurementsVisible", ShowImportedMeasurements); await JS.InvokeVoidAsync("lmeMap.setImportedMeasurementsVisible", ShowImportedMeasurements);
} }
private async Task ToggleDrawingMeasurements(ChangeEventArgs args) private async Task ApplyDrawingMeasurementsVisibility()
{ {
ShowDrawingMeasurements = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements); await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements);
} }
private async Task ToggleDrawTools() private async Task ToggleDrawTools()
{ {
DrawToolsVisible = !DrawToolsVisible; DrawToolsVisible = !DrawToolsVisible;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", DrawToolsVisible); await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", DrawToolsVisible);
if (DrawToolsVisible) if (DrawToolsVisible)
@@ -1166,6 +1180,7 @@
ShowDrawingMeasurements = options.ShowDrawingMeasurements; ShowDrawingMeasurements = options.ShowDrawingMeasurements;
DrawToolsVisible = options.DrawToolsVisible; DrawToolsVisible = options.DrawToolsVisible;
ShowGpsPosition = options.GpsPositionVisible; ShowGpsPosition = options.GpsPositionVisible;
ShowSelectedParcels = options.SelectedParcelsVisible;
TrailEnabled = options.TrailEnabled; TrailEnabled = options.TrailEnabled;
var activeLayers = (options.CadastreLayers ?? []).ToHashSet(StringComparer.Ordinal); var activeLayers = (options.CadastreLayers ?? []).ToHashSet(StringComparer.Ordinal);
@@ -1173,6 +1188,7 @@
{ {
layer.Enabled = activeLayers.Contains(layer.Key); layer.Enabled = activeLayers.Contains(layer.Key);
} }
SaveFlagPreferences();
} }
private async Task DeleteProject() private async Task DeleteProject()
@@ -1205,9 +1221,9 @@
} }
} }
private Task CenterOnGps() => JS.InvokeVoidAsync("lmeMap.centerOnGps").AsTask(); private Task CenterOnGps() => JS.InvokeVoidAsync("lmeMap.centerOnGps").AsTask();
private async Task ToggleTrail(ChangeEventArgs args) private async Task ApplyTrailOption()
{ {
TrailEnabled = (bool?)args.Value == true; SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.toggleTrail", TrailEnabled); await JS.InvokeVoidAsync("lmeMap.toggleTrail", TrailEnabled);
} }
private async Task ChangeBaseLayer(ChangeEventArgs args) private async Task ChangeBaseLayer(ChangeEventArgs args)
@@ -1312,9 +1328,87 @@
private async Task ToggleCadastreLayer(CadastralLayer layer, ChangeEventArgs args) private async Task ToggleCadastreLayer(CadastralLayer layer, ChangeEventArgs args)
{ {
layer.Enabled = args.Value is true; layer.Enabled = args.Value is true;
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.toggleCadastreLayer", layer.Key, layer.Enabled); await JS.InvokeVoidAsync("lmeMap.toggleCadastreLayer", layer.Key, layer.Enabled);
} }
private void LoadFlagPreferences()
{
IncludeCadastralParcels = GetFlagPreference("include_cadastral_parcels", true);
IncludeKmlSheetLayer = GetFlagPreference("include_kml_sheet_layer", false);
ShowImportedSheetLayer = GetFlagPreference("show_imported_sheet_layer", false);
ShowImportedMeasurements = GetFlagPreference("show_imported_measurements", false);
ShowDrawingMeasurements = GetFlagPreference("show_drawing_measurements", true);
DrawToolsVisible = GetFlagPreference("draw_tools_visible", false);
ShowGpsPosition = GetFlagPreference("show_gps_position", true);
ShowSelectedParcels = GetFlagPreference("show_selected_parcels", true);
TrailEnabled = GetFlagPreference("trail_enabled", false);
ExportImported = GetFlagPreference("export_imported", true);
ExportImportedSheets = GetFlagPreference("export_imported_sheets", true);
ExportCadastral = GetFlagPreference("export_cadastral", true);
ExportDrawings = GetFlagPreference("export_drawings", true);
ExportPoi = GetFlagPreference("export_poi", true);
ExportTrail = GetFlagPreference("export_trail", true);
foreach (var layer in CadastralLayers)
{
layer.Enabled = GetFlagPreference($"cadastre_layer_{layer.Key}", layer.Enabled);
}
}
private void SaveFlagPreferences()
{
SetFlagPreference("include_cadastral_parcels", IncludeCadastralParcels);
SetFlagPreference("include_kml_sheet_layer", IncludeKmlSheetLayer);
SetFlagPreference("show_imported_sheet_layer", ShowImportedSheetLayer);
SetFlagPreference("show_imported_measurements", ShowImportedMeasurements);
SetFlagPreference("show_drawing_measurements", ShowDrawingMeasurements);
SetFlagPreference("draw_tools_visible", DrawToolsVisible);
SetFlagPreference("show_gps_position", ShowGpsPosition);
SetFlagPreference("show_selected_parcels", ShowSelectedParcels);
SetFlagPreference("trail_enabled", TrailEnabled);
SetFlagPreference("export_imported", ExportImported);
SetFlagPreference("export_imported_sheets", ExportImportedSheets);
SetFlagPreference("export_cadastral", ExportCadastral);
SetFlagPreference("export_drawings", ExportDrawings);
SetFlagPreference("export_poi", ExportPoi);
SetFlagPreference("export_trail", ExportTrail);
foreach (var layer in CadastralLayers)
{
SetFlagPreference($"cadastre_layer_{layer.Key}", layer.Enabled);
}
}
private async Task ApplyFlagPreferencesToMapAsync()
{
await JS.InvokeVoidAsync("lmeMap.setIncludeKmlSheetLayer", IncludeKmlSheetLayer);
await JS.InvokeVoidAsync("lmeMap.setImportedSheetLayerVisible", ShowImportedSheetLayer);
await JS.InvokeVoidAsync("lmeMap.setImportedMeasurementsVisible", ShowImportedMeasurements);
await JS.InvokeVoidAsync("lmeMap.setDrawingMeasurementsVisible", ShowDrawingMeasurements);
await JS.InvokeVoidAsync("lmeMap.setDrawToolsVisible", DrawToolsVisible);
await JS.InvokeVoidAsync("lmeMap.setGpsPositionVisible", ShowGpsPosition);
await JS.InvokeVoidAsync("lmeMap.setSelectedParcelsVisible", ShowSelectedParcels);
await JS.InvokeVoidAsync("lmeMap.toggleTrail", TrailEnabled);
foreach (var layer in CadastralLayers)
{
await JS.InvokeVoidAsync("lmeMap.toggleCadastreLayer", layer.Key, layer.Enabled);
}
}
private static bool GetFlagPreference(string name, bool defaultValue) =>
Preferences.Default.Get($"{FlagPreferencePrefix}{name}", defaultValue);
private static void SetFlagPreference(string name, bool value) =>
Preferences.Default.Set($"{FlagPreferencePrefix}{name}", value);
private async Task ApplySelectedParcelsVisibility()
{
SaveFlagPreferences();
await JS.InvokeVoidAsync("lmeMap.setSelectedParcelsVisible", ShowSelectedParcels);
}
private async Task ExportCadastralImage() private async Task ExportCadastralImage()
{ {
ActiveTab = "map"; ActiveTab = "map";
@@ -1353,6 +1447,7 @@
public bool ShowDrawingMeasurements { get; init; } = true; public bool ShowDrawingMeasurements { get; init; } = true;
public bool DrawToolsVisible { get; init; } public bool DrawToolsVisible { get; init; }
public bool GpsPositionVisible { get; init; } = true; public bool GpsPositionVisible { get; init; } = true;
public bool SelectedParcelsVisible { get; init; } = true;
public bool TrailEnabled { get; init; } public bool TrailEnabled { get; init; }
} }
+2 -2
View File
@@ -28,8 +28,8 @@
<ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId> <ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId>
<!-- Versions --> <!-- Versions -->
<ApplicationDisplayVersion>0.2.14</ApplicationDisplayVersion> <ApplicationDisplayVersion>0.2.17</ApplicationDisplayVersion>
<ApplicationVersion>18</ApplicationVersion> <ApplicationVersion>21</ApplicationVersion>
<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged --> <!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
<WindowsPackageType>None</WindowsPackageType> <WindowsPackageType>None</WindowsPackageType>
+1 -1
View File
@@ -13,7 +13,7 @@ public sealed class AzureMapsService
public AzureMapsService() public AzureMapsService()
{ {
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.14"); _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.17");
_httpClient.DefaultRequestHeaders.Accept.ParseAdd("application/json"); _httpClient.DefaultRequestHeaders.Accept.ParseAdd("application/json");
} }
+1 -1
View File
@@ -13,7 +13,7 @@ public sealed class NetworkLocationService
public NetworkLocationService() public NetworkLocationService()
{ {
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.14"); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("LMEMappeCatastali/0.2.17");
} }
public async Task<NetworkLocationSnapshot?> GetApproximateLocationAsync( public async Task<NetworkLocationSnapshot?> GetApproximateLocationAsync(
+107 -23
View File
@@ -26,6 +26,7 @@ const lmeState = {
lastAccuracy: 0, lastAccuracy: 0,
gpsTrail: null, gpsTrail: null,
selectedParcelsLayer: null, selectedParcelsLayer: null,
selectedParcelsVisible: true,
gpsParcelLayer: null, gpsParcelLayer: null,
gpsTrailEnabled: false, gpsTrailEnabled: false,
gpsTrailPoints: [], gpsTrailPoints: [],
@@ -50,6 +51,7 @@ window.lmeMap = {
exportCadastreView, exportCadastreView,
closeCadastrePreview, closeCadastrePreview,
clearSelectedParcels, clearSelectedParcels,
setSelectedParcelsVisible,
clearMapElements, clearMapElements,
fitImported, fitImported,
clearImported, clearImported,
@@ -132,6 +134,8 @@ function init() {
}); });
lmeState.currentBase = lmeState.baseLayers.satellite.addTo(lmeState.map); lmeState.currentBase = lmeState.baseLayers.satellite.addTo(lmeState.map);
const importedSheetPane = lmeState.map.createPane("importedSheetPane");
importedSheetPane.style.zIndex = "520";
lmeState.imported = L.featureGroup().addTo(lmeState.map); lmeState.imported = L.featureGroup().addTo(lmeState.map);
lmeState.importedSheets = L.featureGroup(); lmeState.importedSheets = L.featureGroup();
lmeState.drawings = L.featureGroup().addTo(lmeState.map); lmeState.drawings = L.featureGroup().addTo(lmeState.map);
@@ -469,23 +473,9 @@ function bindFileImport() {
try { try {
const result = await readGisFile(file); const result = await readGisFile(file);
const geojson = result.geojson; const geojson = result.geojson;
const parcelLayer = L.geoJSON(geojson, { const parcelLayer = addImportedFeatures(geojson);
style: { color: "#22c55e", weight: 3, opacity: 0.95, fillOpacity: 0.18 },
pointToLayer: (feature, latlng) => L.circleMarker(latlng, { radius: 7, color: "#22c55e", fillColor: "#ffffff", fillOpacity: 0.9 }),
onEachFeature: (feature, layer) => {
const name = feature?.properties?.name || file.name;
layer.bindPopup(`<strong>${escapeHtml(name)}</strong>`);
}
}).addTo(lmeState.imported);
const sheetGeojson = result.sheetGeojson || emptyFeatureCollection(); const sheetGeojson = result.sheetGeojson || emptyFeatureCollection();
const sheetLayer = L.geoJSON(sheetGeojson, { const sheetLayer = addImportedSheetFeatures(sheetGeojson);
style: { color: "#15803d", weight: 3, opacity: 0.85, fillOpacity: 0.04, dashArray: "9 7" },
pointToLayer: (feature, latlng) => L.circleMarker(latlng, { radius: 6, color: "#15803d", fillOpacity: 0.25 }),
onEachFeature: (feature, layer) => {
const name = feature?.properties?.name || "Foglio catastale importato";
layer.bindPopup(`<strong>${escapeHtml(name)}</strong>`);
}
}).addTo(lmeState.importedSheets);
applyImportedSheetVisibility(); applyImportedSheetVisibility();
fitLayer(geojson.features.length ? parcelLayer : sheetLayer); fitLayer(geojson.features.length ? parcelLayer : sheetLayer);
refreshImportedMeasurements(); refreshImportedMeasurements();
@@ -901,13 +891,76 @@ function setIncludeKmlSheetLayer(enabled) {
function setImportedSheetLayerVisible(enabled) { function setImportedSheetLayerVisible(enabled) {
migrateMisclassifiedImportedSheets(); migrateMisclassifiedImportedSheets();
lmeState.importedSheetsVisible = Boolean(enabled); lmeState.importedSheetsVisible = Boolean(enabled);
const generated = lmeState.importedSheetsVisible && ensureImportedSheetOutline();
applyImportedSheetVisibility(); applyImportedSheetVisibility();
const count = lmeState.importedSheets?.toGeoJSON()?.features?.length || 0; const count = lmeState.importedSheets?.toGeoJSON()?.features?.length || 0;
setInfo(lmeState.importedSheetsVisible setInfo(lmeState.importedSheetsVisible
? (count ? `Layer del foglio importato visibile (${count} elementi).` : "Il layer del foglio sara visibile quando verra importato.") ? (count
? `${generated ? "Cornice generata dai dati importati" : "Layer del foglio importato visibile"} (${count} elementi).`
: "Nessun dato importato da cui ricavare la cornice del foglio.")
: "Layer del foglio importato nascosto; le particelle restano visibili."); : "Layer del foglio importato nascosto; le particelle restano visibili.");
} }
function ensureImportedSheetOutline() {
if (!lmeState.imported || !lmeState.importedSheets) {
return false;
}
const currentSheets = lmeState.importedSheets.toGeoJSON();
const hasAreaOutline = (currentSheets.features || []).some(feature =>
["Polygon", "MultiPolygon"].includes(feature?.geometry?.type));
if (hasAreaOutline) {
return false;
}
const imported = lmeState.imported.toGeoJSON();
const points = collectGeoJsonCoordinates(imported);
if (!points.length) {
return false;
}
const bounds = points.reduce((result, point) => ({
west: Math.min(result.west, point[0]),
south: Math.min(result.south, point[1]),
east: Math.max(result.east, point[0]),
north: Math.max(result.north, point[1])
}), { west: Infinity, south: Infinity, east: -Infinity, north: -Infinity });
if (!Number.isFinite(bounds.west)
|| !Number.isFinite(bounds.south)
|| bounds.east <= bounds.west
|| bounds.north <= bounds.south) {
return false;
}
const longitudePadding = Math.max((bounds.east - bounds.west) * 0.01, 0.000001);
const latitudePadding = Math.max((bounds.north - bounds.south) * 0.01, 0.000001);
const west = bounds.west - longitudePadding;
const south = bounds.south - latitudePadding;
const east = bounds.east + longitudePadding;
const north = bounds.north + latitudePadding;
addImportedSheetFeatures({
type: "FeatureCollection",
features: [{
type: "Feature",
properties: {
name: "Cornice del foglio importato",
_lmeGeneratedSheetOutline: true
},
geometry: {
type: "Polygon",
coordinates: [[
[west, south],
[east, south],
[east, north],
[west, north],
[west, south]
]]
}
}]
});
return true;
}
function migrateMisclassifiedImportedSheets() { function migrateMisclassifiedImportedSheets() {
if (!lmeState.imported || !lmeState.importedSheets) { if (!lmeState.imported || !lmeState.importedSheets) {
return 0; return 0;
@@ -942,11 +995,14 @@ function addImportedFeatures(geojson) {
function addImportedSheetFeatures(geojson) { function addImportedSheetFeatures(geojson) {
return L.geoJSON(geojson || emptyFeatureCollection(), { return L.geoJSON(geojson || emptyFeatureCollection(), {
style: { color: "#15803d", weight: 3, opacity: 0.85, fillOpacity: 0.04, dashArray: "9 7" }, pane: "importedSheetPane",
style: { color: "#f59e0b", weight: 4, opacity: 1, fillOpacity: 0.03, dashArray: "10 6" },
pointToLayer: (feature, latlng) => L.circleMarker(latlng, { pointToLayer: (feature, latlng) => L.circleMarker(latlng, {
radius: 6, pane: "importedSheetPane",
color: "#15803d", radius: 7,
fillOpacity: 0.25 color: "#f59e0b",
fillColor: "#ffffff",
fillOpacity: 0.85
}), }),
onEachFeature: bindStoredFeaturePopup onEachFeature: bindStoredFeaturePopup
}).addTo(lmeState.importedSheets); }).addTo(lmeState.importedSheets);
@@ -960,8 +1016,7 @@ function applyImportedSheetVisibility() {
if (!lmeState.map.hasLayer(lmeState.importedSheets)) { if (!lmeState.map.hasLayer(lmeState.importedSheets)) {
lmeState.importedSheets.addTo(lmeState.map); lmeState.importedSheets.addTo(lmeState.map);
} }
lmeState.importedSheets.bringToBack(); lmeState.importedSheets.bringToFront();
lmeState.imported.bringToFront();
return; return;
} }
if (lmeState.map.hasLayer(lmeState.importedSheets)) { if (lmeState.map.hasLayer(lmeState.importedSheets)) {
@@ -1578,6 +1633,9 @@ function loadProjectSnapshot(raw, projectName) {
lmeState.importedSheetsVisible = projectDisplayOptions lmeState.importedSheetsVisible = projectDisplayOptions
? Boolean(projectDisplayOptions.importedSheetsVisible) ? Boolean(projectDisplayOptions.importedSheetsVisible)
: data.schemaVersion >= 2 && Boolean(data.importedSheetsVisible); : data.schemaVersion >= 2 && Boolean(data.importedSheetsVisible);
if (lmeState.importedSheetsVisible) {
ensureImportedSheetOutline();
}
applyImportedSheetVisibility(); applyImportedSheetVisibility();
L.geoJSON(data.selectedParcels || emptyFeatureCollection(), { L.geoJSON(data.selectedParcels || emptyFeatureCollection(), {
style: { color: "#ef4444", weight: 4, opacity: 1, fillColor: "#fbbf24", fillOpacity: 0.26 }, style: { color: "#ef4444", weight: 4, opacity: 1, fillColor: "#fbbf24", fillOpacity: 0.26 },
@@ -1645,6 +1703,7 @@ function captureDisplayOptions() {
showDrawingMeasurements: lmeState.showDrawingMeasurements, showDrawingMeasurements: lmeState.showDrawingMeasurements,
drawToolsVisible: Boolean(lmeState.drawControl), drawToolsVisible: Boolean(lmeState.drawControl),
gpsPositionVisible: lmeState.gpsPositionVisible, gpsPositionVisible: lmeState.gpsPositionVisible,
selectedParcelsVisible: lmeState.selectedParcelsVisible,
trailEnabled: lmeState.gpsTrailEnabled trailEnabled: lmeState.gpsTrailEnabled
}; };
} }
@@ -1677,6 +1736,7 @@ function applyProjectDisplayOptions(options) {
setBaseLayer(options.baseLayer); setBaseLayer(options.baseLayer);
} }
setGpsPositionVisible(options.gpsPositionVisible !== false); setGpsPositionVisible(options.gpsPositionVisible !== false);
setSelectedParcelsVisible(options.selectedParcelsVisible !== false);
toggleTrail(Boolean(options.trailEnabled)); toggleTrail(Boolean(options.trailEnabled));
setDrawToolsVisible(Boolean(options.drawToolsVisible)); setDrawToolsVisible(Boolean(options.drawToolsVisible));
} }
@@ -2010,6 +2070,30 @@ function clearSelectedParcels() {
setInfo(count ? `${count} particelle selezionate rimosse.` : "Non ci sono particelle selezionate da rimuovere."); setInfo(count ? `${count} particelle selezionate rimosse.` : "Non ci sono particelle selezionate da rimuovere.");
} }
function setSelectedParcelsVisible(enabled) {
lmeState.selectedParcelsVisible = Boolean(enabled);
if (!lmeState.map || !lmeState.selectedParcelsLayer) {
return;
}
if (lmeState.selectedParcelsVisible) {
if (!lmeState.map.hasLayer(lmeState.selectedParcelsLayer)) {
lmeState.selectedParcelsLayer.addTo(lmeState.map);
}
lmeState.selectedParcelsLayer.bringToFront();
const count = lmeState.selectedParcelsLayer.toGeoJSON().features?.length || 0;
setInfo(count
? `${count} particelle selezionate visibili.`
: "Nessuna particella selezionata da mostrare.");
return;
}
if (lmeState.map.hasLayer(lmeState.selectedParcelsLayer)) {
lmeState.map.removeLayer(lmeState.selectedParcelsLayer);
}
setInfo("Particelle selezionate nascoste; i dati restano nel progetto.");
}
function clearMapElements() { function clearMapElements() {
const count = lmeState.selectedParcelsLayer.getLayers().length const count = lmeState.selectedParcelsLayer.getLayers().length
+ lmeState.gpsParcelLayer.getLayers().length + lmeState.gpsParcelLayer.getLayers().length