Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0adc27cf5 | ||
|
|
3dfeef54ea | ||
|
|
b600412285 | ||
|
|
f65451c414 |
No files matched your search
@@ -57,7 +57,7 @@
|
|||||||
"data" =>
|
"data" =>
|
||||||
[
|
[
|
||||||
"Importazione: premi Carica KML, KMZ o GeoJSON e scegli il file dal dispositivo. I nomi e gli attributi riconosciuti vengono mantenuti.",
|
"Importazione: premi Carica KML, KMZ o GeoJSON e scegli il file dal dispositivo. I nomi e gli attributi riconosciuti vengono mantenuti.",
|
||||||
"Per KML e KMZ, Includi anche il layer del foglio importa pure cornici e riquadri generali; disattivalo quando vuoi conservare soltanto le particelle riconosciute.",
|
"Per KML e KMZ, Includi anche il layer del foglio conserva le cornici presenti nel file. Mostra cornice/layer del foglio recupera inoltre dal servizio ufficiale una cornice distinta per ciascun foglio delle particelle, senza creare un unico riquadro tra fogli lontani.",
|
||||||
"Usa Mostra dati importati e Mostra cornice per controllare separatamente la visibilita. Inquadra dati porta la mappa sull'estensione completa del file.",
|
"Usa Mostra dati importati e Mostra cornice per controllare separatamente la visibilita. Inquadra dati porta la mappa sull'estensione completa del file.",
|
||||||
"Disegno: premi Mostra strumenti sulla mappa, torna alla mappa e scegli linea, poligono, rettangolo, cerchio o POI nella barra Leaflet.",
|
"Disegno: premi Mostra strumenti sulla mappa, torna alla mappa e scegli linea, poligono, rettangolo, cerchio o POI nella barra Leaflet.",
|
||||||
"Modifica ed eliminazione possono agire sull'oggetto selezionato o su tutti i disegni. Prima seleziona sulla mappa la linea o il poligono interessato, poi scegli l'ambito dal piccolo comando accanto alla matita o al cestino.",
|
"Modifica ed eliminazione possono agire sull'oggetto selezionato o su tutti i disegni. Prima seleziona sulla mappa la linea o il poligono interessato, poi scegli l'ambito dal piccolo comando accanto alla matita o al cestino.",
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
"Rinomina cambia il nome del progetto selezionato senza alterarne contenuti e revisioni. Duplica crea invece una copia modificabile, utile prima di una variante importante o quando ricevi un progetto in sola lettura.",
|
"Rinomina cambia il nome del progetto selezionato senza alterarne contenuti e revisioni. Duplica crea invece una copia modificabile, utile prima di una variante importante o quando ricevi un progetto in sola lettura.",
|
||||||
"Archivia nasconde logicamente i lavori conclusi senza eliminarli; Ripristina li riporta tra quelli attivi. Elimina rimuove invece il progetto dall'archivio.",
|
"Archivia nasconde logicamente i lavori conclusi senza eliminarli; Ripristina li riporta tra quelli attivi. Elimina rimuove invece il progetto dall'archivio.",
|
||||||
"Condividi modificabile consente al destinatario di continuare il lavoro; Condividi in sola lettura protegge l'originale e richiede una duplicazione per modificarlo.",
|
"Condividi modificabile consente al destinatario di continuare il lavoro; Condividi in sola lettura protegge l'originale e richiede una duplicazione per modificarlo.",
|
||||||
"Revisioni: seleziona una data e usa Apri revisione per consultarne lo stato oppure Confronta per vedere le differenze con la versione corrente.",
|
"Revisioni: la prima viene creata quando salvi per la seconda volta un progetto gia esistente. L'elenco si aggiorna anche dopo i salvataggi automatici; seleziona una data e usa Apri revisione oppure Confronta.",
|
||||||
"Backup: Crea backup raccoglie tutti i progetti in un file trasferibile. Ripristina backup ricarica un archivio completo; Importa progetto aggiunge invece un singolo progetto condiviso."
|
"Backup: Crea backup raccoglie tutti i progetti in un file trasferibile. Ripristina backup ricarica un archivio completo; Importa progetto aggiunge invece un singolo progetto condiviso."
|
||||||
],
|
],
|
||||||
"tools" =>
|
"tools" =>
|
||||||
|
|||||||
+129
-4
@@ -10,6 +10,7 @@
|
|||||||
@inject MapExportService MapExportService
|
@inject MapExportService MapExportService
|
||||||
@inject CloudSyncService CloudSyncService
|
@inject CloudSyncService CloudSyncService
|
||||||
@inject AppUpdateService AppUpdateService
|
@inject AppUpdateService AppUpdateService
|
||||||
|
@inject IncomingFileService IncomingFiles
|
||||||
@implements IAsyncDisposable
|
@implements IAsyncDisposable
|
||||||
|
|
||||||
<PageTitle>LME Mappe Catastali</PageTitle>
|
<PageTitle>LME Mappe Catastali</PageTitle>
|
||||||
@@ -219,7 +220,7 @@
|
|||||||
<input type="checkbox" @bind="ShowImportedSheetLayer" @bind:after="ApplyImportedSheetLayerVisibility" />
|
<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">Carica dal servizio ufficiale una cornice distinta per ogni foglio delle particelle; le cornici restano separate, trasferibili e salvabili nel progetto.</small>
|
||||||
<label class="toggle-line project-save-option">
|
<label class="toggle-line project-save-option">
|
||||||
<input type="checkbox" @bind="ShowImportedMeasurements" @bind:after="ApplyImportedMeasurementsVisibility" />
|
<input type="checkbox" @bind="ShowImportedMeasurements" @bind:after="ApplyImportedMeasurementsVisibility" />
|
||||||
<span>Mostra misure dei file caricati</span>
|
<span>Mostra misure dei file caricati</span>
|
||||||
@@ -374,6 +375,14 @@
|
|||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
@if (!string.IsNullOrWhiteSpace(SelectedProjectId) && ProjectVersions.Count == 0)
|
||||||
|
{
|
||||||
|
<small class="field-help">Non ci sono ancora revisioni: la prima viene creata quando salvi nuovamente un progetto già esistente.</small>
|
||||||
|
}
|
||||||
|
else if (ProjectVersions.Count > 0)
|
||||||
|
{
|
||||||
|
<small class="field-help">@ProjectVersions.Count revisioni disponibili, ordinate dalla più recente.</small>
|
||||||
|
}
|
||||||
<div class="button-row">
|
<div class="button-row">
|
||||||
<button class="secondary-command" @onclick="LoadProjectVersion" disabled="@(string.IsNullOrWhiteSpace(SelectedVersionId))">Apri revisione</button>
|
<button class="secondary-command" @onclick="LoadProjectVersion" disabled="@(string.IsNullOrWhiteSpace(SelectedVersionId))">Apri revisione</button>
|
||||||
<button class="secondary-command" @onclick="CompareProjectVersion" disabled="@(string.IsNullOrWhiteSpace(SelectedVersionId))">Confronta</button>
|
<button class="secondary-command" @onclick="CompareProjectVersion" disabled="@(string.IsNullOrWhiteSpace(SelectedVersionId))">Confronta</button>
|
||||||
@@ -689,6 +698,7 @@
|
|||||||
private bool SyncBusy { get; set; }
|
private bool SyncBusy { get; set; }
|
||||||
private string SyncStatus { get; set; } = "Sincronizzazione non configurata.";
|
private string SyncStatus { get; set; } = "Sincronizzazione non configurata.";
|
||||||
private bool UpdateBusy { get; set; }
|
private bool UpdateBusy { get; set; }
|
||||||
|
private bool MapReady { get; set; }
|
||||||
private string UpdateStatus { get; set; } = $"Versione installata: {AppUpdateService.CurrentVersion}";
|
private string UpdateStatus { get; set; } = $"Versione installata: {AppUpdateService.CurrentVersion}";
|
||||||
private string UpdateDownloadUrl { get; set; } = string.Empty;
|
private string UpdateDownloadUrl { get; set; } = string.Empty;
|
||||||
private string UpdateReleaseNotes { get; set; } = string.Empty;
|
private string UpdateReleaseNotes { get; set; } = string.Empty;
|
||||||
@@ -746,6 +756,7 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
IncomingFiles.FileAvailable += OnIncomingFileAvailable;
|
||||||
LoadFlagPreferences();
|
LoadFlagPreferences();
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -789,12 +800,14 @@
|
|||||||
{
|
{
|
||||||
MapCallbackReference = DotNetObjectReference.Create(this);
|
MapCallbackReference = DotNetObjectReference.Create(this);
|
||||||
await JS.InvokeVoidAsync("lmeMap.init", MapCallbackReference);
|
await JS.InvokeVoidAsync("lmeMap.init", MapCallbackReference);
|
||||||
|
MapReady = true;
|
||||||
await ApplyFlagPreferencesToMapAsync();
|
await ApplyFlagPreferencesToMapAsync();
|
||||||
await ApplyAdvancedOptions();
|
await ApplyAdvancedOptions();
|
||||||
await CenterOnInitialLocationAsync();
|
await CenterOnInitialLocationAsync();
|
||||||
await MigrateLegacyProjectAsync();
|
await MigrateLegacyProjectAsync();
|
||||||
var offlineCount = await JS.InvokeAsync<int>("lmeMap.getOfflineTileStats");
|
var offlineCount = await JS.InvokeAsync<int>("lmeMap.getOfflineTileStats");
|
||||||
OfflineStatus = offlineCount == 0 ? "Nessuna tessera salvata." : $"{offlineCount} tessere disponibili offline.";
|
OfflineStatus = offlineCount == 0 ? "Nessuna tessera salvata." : $"{offlineCount} tessere disponibili offline.";
|
||||||
|
await ProcessIncomingFilesAsync();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -905,6 +918,7 @@
|
|||||||
await JS.InvokeVoidAsync("lmeMap.clearLegacyProjectSnapshot");
|
await JS.InvokeVoidAsync("lmeMap.clearLegacyProjectSnapshot");
|
||||||
await RefreshProjectsAsync();
|
await RefreshProjectsAsync();
|
||||||
SelectedProjectId = migrated.Id;
|
SelectedProjectId = migrated.Id;
|
||||||
|
await RefreshProjectVersionsAsync(true);
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -1299,6 +1313,10 @@
|
|||||||
return InvokeAsync(StateHasChanged);
|
return InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JSInvokable]
|
||||||
|
public Task<string> GetOfficialCadastralSheetsNear(double latitude, double longitude) =>
|
||||||
|
OfficialCadastreService.GetSheetsNearAsync(latitude, longitude);
|
||||||
|
|
||||||
[JSInvokable]
|
[JSInvokable]
|
||||||
public Task OnMapChanged(string action)
|
public Task OnMapChanged(string action)
|
||||||
{
|
{
|
||||||
@@ -1362,6 +1380,7 @@
|
|||||||
{
|
{
|
||||||
SelectedProjectId = string.Empty;
|
SelectedProjectId = string.Empty;
|
||||||
}
|
}
|
||||||
|
await RefreshProjectVersionsAsync();
|
||||||
ProjectArchiveMessage = Projects.Count == 0
|
ProjectArchiveMessage = Projects.Count == 0
|
||||||
? "Nessun progetto salvato."
|
? "Nessun progetto salvato."
|
||||||
: $"{Projects.Count} {(Projects.Count == 1 ? "progetto salvato" : "progetti salvati")} nell'archivio interno.";
|
: $"{Projects.Count} {(Projects.Count == 1 ? "progetto salvato" : "progetti salvati")} nell'archivio interno.";
|
||||||
@@ -1376,10 +1395,18 @@
|
|||||||
{
|
{
|
||||||
SelectedProjectId = args.Value?.ToString() ?? string.Empty;
|
SelectedProjectId = args.Value?.ToString() ?? string.Empty;
|
||||||
ProjectFolder = SelectedProject?.Folder ?? string.Empty;
|
ProjectFolder = SelectedProject?.Folder ?? string.Empty;
|
||||||
SelectedVersionId = string.Empty;
|
await RefreshProjectVersionsAsync(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RefreshProjectVersionsAsync(bool resetSelection = false)
|
||||||
|
{
|
||||||
ProjectVersions = string.IsNullOrWhiteSpace(SelectedProjectId)
|
ProjectVersions = string.IsNullOrWhiteSpace(SelectedProjectId)
|
||||||
? []
|
? []
|
||||||
: await ProjectStorageService.GetVersionsAsync(SelectedProjectId);
|
: await ProjectStorageService.GetVersionsAsync(SelectedProjectId);
|
||||||
|
if (resetSelection || ProjectVersions.All(version => version.Id != SelectedVersionId))
|
||||||
|
{
|
||||||
|
SelectedVersionId = string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task UndoMapChange() => JS.InvokeVoidAsync("lmeMap.undoMapChange").AsTask();
|
private Task UndoMapChange() => JS.InvokeVoidAsync("lmeMap.undoMapChange").AsTask();
|
||||||
@@ -1401,6 +1428,7 @@
|
|||||||
await RefreshProjectsAsync();
|
await RefreshProjectsAsync();
|
||||||
SelectedProjectId = copy.Id;
|
SelectedProjectId = copy.Id;
|
||||||
ProjectFolder = copy.Folder;
|
ProjectFolder = copy.Folder;
|
||||||
|
await RefreshProjectVersionsAsync(true);
|
||||||
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Progetto duplicato: {copy.Name}.");
|
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Progetto duplicato: {copy.Name}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1420,6 +1448,7 @@
|
|||||||
var renamed = await ProjectStorageService.RenameAsync(project.Id, requestedName);
|
var renamed = await ProjectStorageService.RenameAsync(project.Id, requestedName);
|
||||||
await RefreshProjectsAsync();
|
await RefreshProjectsAsync();
|
||||||
SelectedProjectId = renamed.Id;
|
SelectedProjectId = renamed.Id;
|
||||||
|
await RefreshProjectVersionsAsync();
|
||||||
NewProjectName = renamed.Name;
|
NewProjectName = renamed.Name;
|
||||||
if (!HasUnsavedChanges)
|
if (!HasUnsavedChanges)
|
||||||
{
|
{
|
||||||
@@ -1468,7 +1497,11 @@
|
|||||||
|
|
||||||
private async Task RestoreBackup()
|
private async Task RestoreBackup()
|
||||||
{
|
{
|
||||||
var file = await FilePicker.Default.PickAsync(new PickOptions { PickerTitle = "Scegli backup LME" });
|
var file = await FilePicker.Default.PickAsync(new PickOptions
|
||||||
|
{
|
||||||
|
PickerTitle = "Scegli backup LME (.lmebackup.zip)",
|
||||||
|
FileTypes = BackupPickerFileTypes
|
||||||
|
});
|
||||||
if (file is null) return;
|
if (file is null) return;
|
||||||
var path = await CopyPickedFileToCacheAsync(file);
|
var path = await CopyPickedFileToCacheAsync(file);
|
||||||
var count = await ProjectStorageService.RestoreBackupAsync(path);
|
var count = await ProjectStorageService.RestoreBackupAsync(path);
|
||||||
@@ -1478,12 +1511,17 @@
|
|||||||
|
|
||||||
private async Task ImportProject()
|
private async Task ImportProject()
|
||||||
{
|
{
|
||||||
var file = await FilePicker.Default.PickAsync(new PickOptions { PickerTitle = "Scegli progetto LME" });
|
var file = await FilePicker.Default.PickAsync(new PickOptions
|
||||||
|
{
|
||||||
|
PickerTitle = "Scegli progetto LME (.lmeproject.json)",
|
||||||
|
FileTypes = ProjectPickerFileTypes
|
||||||
|
});
|
||||||
if (file is null) return;
|
if (file is null) return;
|
||||||
var path = await CopyPickedFileToCacheAsync(file);
|
var path = await CopyPickedFileToCacheAsync(file);
|
||||||
var imported = await ProjectStorageService.ImportProjectAsync(path);
|
var imported = await ProjectStorageService.ImportProjectAsync(path);
|
||||||
await RefreshProjectsAsync();
|
await RefreshProjectsAsync();
|
||||||
SelectedProjectId = imported.Id;
|
SelectedProjectId = imported.Id;
|
||||||
|
await RefreshProjectVersionsAsync(true);
|
||||||
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Progetto importato: {imported.Name}.");
|
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Progetto importato: {imported.Name}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1496,6 +1534,91 @@
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnIncomingFileAvailable()
|
||||||
|
{
|
||||||
|
if (MapReady) _ = InvokeAsync(ProcessIncomingFilesAsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ProcessIncomingFilesAsync()
|
||||||
|
{
|
||||||
|
while (IncomingFiles.TryDequeue(out var incoming) && incoming is not null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var lowerName = incoming.FileName.ToLowerInvariant();
|
||||||
|
if (lowerName.EndsWith(".kml", StringComparison.Ordinal)
|
||||||
|
|| lowerName.EndsWith(".kmz", StringComparison.Ordinal)
|
||||||
|
|| lowerName.EndsWith(".geojson", StringComparison.Ordinal)
|
||||||
|
|| await IsGeoJsonAsync(incoming.Path))
|
||||||
|
{
|
||||||
|
var content = Convert.ToBase64String(await File.ReadAllBytesAsync(incoming.Path));
|
||||||
|
await JS.InvokeAsync<string>("lmeMap.importExternalGisFile", incoming.FileName, content, incoming.ContentType);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerName.EndsWith(".zip", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var count = await ProjectStorageService.RestoreBackupAsync(incoming.Path);
|
||||||
|
await RefreshProjectsAsync();
|
||||||
|
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Backup aperto: {count} progetti ripristinati.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerName.EndsWith(".json", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var imported = await ProjectStorageService.ImportProjectAsync(incoming.Path);
|
||||||
|
await RefreshProjectsAsync();
|
||||||
|
SelectedProjectId = imported.Id;
|
||||||
|
await RefreshProjectVersionsAsync(true);
|
||||||
|
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Progetto aperto: {imported.Name}.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Formato non riconosciuto: {incoming.FileName}.");
|
||||||
|
}
|
||||||
|
catch (Exception error)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("lmeMap.showInfo", $"Impossibile aprire {incoming.FileName}: {error.GetBaseException().Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try { File.Delete(incoming.Path); } catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<bool> IsGeoJsonAsync(string path)
|
||||||
|
{
|
||||||
|
if (!Path.GetExtension(path).Equals(".json", StringComparison.OrdinalIgnoreCase)) return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var stream = File.OpenRead(path);
|
||||||
|
using var document = await System.Text.Json.JsonDocument.ParseAsync(stream);
|
||||||
|
if (!document.RootElement.TryGetProperty("type", out var typeProperty)) return false;
|
||||||
|
var type = typeProperty.GetString();
|
||||||
|
return type is "Feature" or "FeatureCollection" or "Point" or "MultiPoint"
|
||||||
|
or "LineString" or "MultiLineString" or "Polygon" or "MultiPolygon"
|
||||||
|
or "GeometryCollection";
|
||||||
|
}
|
||||||
|
catch { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly FilePickerFileType ProjectPickerFileTypes = new(new Dictionary<DevicePlatform, IEnumerable<string>>
|
||||||
|
{
|
||||||
|
[DevicePlatform.Android] = ["application/json", "text/json", "text/plain", "application/octet-stream"],
|
||||||
|
[DevicePlatform.WinUI] = [".json"],
|
||||||
|
[DevicePlatform.iOS] = ["public.json", "public.data"],
|
||||||
|
[DevicePlatform.macOS] = ["public.json", "public.data"]
|
||||||
|
});
|
||||||
|
|
||||||
|
private static readonly FilePickerFileType BackupPickerFileTypes = new(new Dictionary<DevicePlatform, IEnumerable<string>>
|
||||||
|
{
|
||||||
|
[DevicePlatform.Android] = ["application/zip", "application/x-zip-compressed", "application/octet-stream"],
|
||||||
|
[DevicePlatform.WinUI] = [".zip"],
|
||||||
|
[DevicePlatform.iOS] = ["public.zip-archive", "public.data"],
|
||||||
|
[DevicePlatform.macOS] = ["public.zip-archive", "public.data"]
|
||||||
|
});
|
||||||
|
|
||||||
private async Task LoadProjectVersion()
|
private async Task LoadProjectVersion()
|
||||||
{
|
{
|
||||||
if (SelectedProject is null || string.IsNullOrWhiteSpace(SelectedVersionId)) return;
|
if (SelectedProject is null || string.IsNullOrWhiteSpace(SelectedVersionId)) return;
|
||||||
@@ -1584,6 +1707,7 @@
|
|||||||
existing?.Id);
|
existing?.Id);
|
||||||
await RefreshProjectsAsync();
|
await RefreshProjectsAsync();
|
||||||
SelectedProjectId = saved.Id;
|
SelectedProjectId = saved.Id;
|
||||||
|
await RefreshProjectVersionsAsync();
|
||||||
NewProjectName = saved.Name;
|
NewProjectName = saved.Name;
|
||||||
await JS.InvokeVoidAsync("lmeMap.setProjectReadOnly", false);
|
await JS.InvokeVoidAsync("lmeMap.setProjectReadOnly", false);
|
||||||
await JS.InvokeVoidAsync("lmeMap.markProjectSaved");
|
await JS.InvokeVoidAsync("lmeMap.markProjectSaved");
|
||||||
@@ -2095,6 +2219,7 @@
|
|||||||
|
|
||||||
public ValueTask DisposeAsync()
|
public ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
|
IncomingFiles.FileAvailable -= OnIncomingFileAvailable;
|
||||||
CancelCatalogWork();
|
CancelCatalogWork();
|
||||||
LocationService.StopTracking();
|
LocationService.StopTracking();
|
||||||
GpsLookupCancellation?.Cancel();
|
GpsLookupCancellation?.Cancel();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
|
<TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
|
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks>
|
||||||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
|
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
|
||||||
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->
|
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@
|
|||||||
<ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId>
|
<ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId>
|
||||||
|
|
||||||
<!-- Versions -->
|
<!-- Versions -->
|
||||||
<ApplicationDisplayVersion>0.4.5</ApplicationDisplayVersion>
|
<ApplicationDisplayVersion>0.4.8</ApplicationDisplayVersion>
|
||||||
<ApplicationVersion>40</ApplicationVersion>
|
<ApplicationVersion>43</ApplicationVersion>
|
||||||
<Version>$(ApplicationDisplayVersion)</Version>
|
<Version>$(ApplicationDisplayVersion)</Version>
|
||||||
|
|
||||||
<!-- 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 -->
|
||||||
@@ -43,6 +43,14 @@
|
|||||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
||||||
|
<AndroidTargetSdkVersion>36</AndroidTargetSdkVersion>
|
||||||
|
<AndroidPackageFormat>aab</AndroidPackageFormat>
|
||||||
|
<AndroidUseAapt2>true</AndroidUseAapt2>
|
||||||
|
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
|
||||||
|
<RunAOTCompilation>true</RunAOTCompilation>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- App Icon -->
|
<!-- App Icon -->
|
||||||
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#075E54" />
|
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#075E54" />
|
||||||
@@ -64,7 +72,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
|
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.12" />
|
||||||
<PackageReference Include="Parquet.Net" Version="6.1.0" />
|
<PackageReference Include="Parquet.Net" Version="6.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public static class MauiProgram
|
|||||||
builder.Services.AddSingleton<MapExportService>();
|
builder.Services.AddSingleton<MapExportService>();
|
||||||
builder.Services.AddSingleton<CloudSyncService>();
|
builder.Services.AddSingleton<CloudSyncService>();
|
||||||
builder.Services.AddSingleton<AppUpdateService>();
|
builder.Services.AddSingleton<AppUpdateService>();
|
||||||
|
builder.Services.AddSingleton(IncomingFileService.Shared);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
builder.Services.AddBlazorWebViewDeveloperTools();
|
builder.Services.AddBlazorWebViewDeveloperTools();
|
||||||
|
|||||||
@@ -1,10 +1,75 @@
|
|||||||
using Android.App;
|
using Android.App;
|
||||||
|
using Android.Content;
|
||||||
using Android.Content.PM;
|
using Android.Content.PM;
|
||||||
|
using Android.Database;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
|
using Android.Provider;
|
||||||
|
using LMEMappeCatastaliApp.Services;
|
||||||
|
|
||||||
namespace LMEMappeCatastaliApp;
|
namespace LMEMappeCatastaliApp;
|
||||||
|
|
||||||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
|
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/json")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/geo+json")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/geojson")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/vnd.google-earth.kml+xml")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/vnd.google-earth.kmz")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/xml")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "text/xml")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/zip")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/x-zip-compressed")]
|
||||||
|
[IntentFilter([Intent.ActionView], Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable], DataMimeType = "application/octet-stream")]
|
||||||
public class MainActivity : MauiAppCompatActivity
|
public class MainActivity : MauiAppCompatActivity
|
||||||
{
|
{
|
||||||
|
protected override void OnCreate(Bundle? savedInstanceState)
|
||||||
|
{
|
||||||
|
base.OnCreate(savedInstanceState);
|
||||||
|
QueueViewedFile(Intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnNewIntent(Intent? intent)
|
||||||
|
{
|
||||||
|
base.OnNewIntent(intent);
|
||||||
|
Intent = intent;
|
||||||
|
QueueViewedFile(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QueueViewedFile(Intent? intent)
|
||||||
|
{
|
||||||
|
if (intent?.Action == Android.Content.Intent.ActionView && intent.Data is not null)
|
||||||
|
{
|
||||||
|
_ = CopyViewedFileAsync(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CopyViewedFileAsync(Intent intent)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var uri = intent.Data!;
|
||||||
|
var fileName = ReadDisplayName(uri) ?? $"file-{Guid.NewGuid():N}";
|
||||||
|
fileName = string.Concat(fileName.Select(character => Path.GetInvalidFileNameChars().Contains(character) ? '_' : character));
|
||||||
|
var directory = Path.Combine(FileSystem.CacheDirectory, "Incoming");
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
var path = Path.Combine(directory, $"{Guid.NewGuid():N}-{fileName}");
|
||||||
|
await using var input = ContentResolver!.OpenInputStream(uri)
|
||||||
|
?? throw new IOException("Impossibile leggere il file selezionato.");
|
||||||
|
await using var output = File.Create(path);
|
||||||
|
await input.CopyToAsync(output);
|
||||||
|
IncomingFileService.Shared.Enqueue(new IncomingFile(path, fileName, intent.Type));
|
||||||
|
}
|
||||||
|
catch (Exception error)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"Apertura file LME non riuscita: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ReadDisplayName(Android.Net.Uri uri)
|
||||||
|
{
|
||||||
|
if (uri.Scheme == ContentResolver.SchemeFile) return Path.GetFileName(uri.Path);
|
||||||
|
using ICursor? cursor = ContentResolver?.Query(uri, [IOpenableColumns.DisplayName], null, null, null);
|
||||||
|
if (cursor is null || !cursor.MoveToFirst()) return null;
|
||||||
|
var index = cursor.GetColumnIndex(IOpenableColumns.DisplayName);
|
||||||
|
return index >= 0 ? cursor.GetString(index) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,27 @@
|
|||||||
|
|
||||||
App .NET MAUI Blazor Hybrid per Android, iOS, Mac Catalyst e Windows, pensata per consultare mappe catastali e lavorare sul campo con GPS.
|
App .NET MAUI Blazor Hybrid per Android, iOS, Mac Catalyst e Windows, pensata per consultare mappe catastali e lavorare sul campo con GPS.
|
||||||
|
|
||||||
|
## Versione 0.4.8
|
||||||
|
|
||||||
|
- Aggiornamento a .NET 10 e target Android API 36.
|
||||||
|
- KML e KMZ generici conservano punti, linee e poligoni; il filtro particelle viene applicato soltanto ai file riconosciuti come catastali.
|
||||||
|
- Android propone LME tra le app disponibili per aprire KML, KMZ, GeoJSON, progetti JSON e backup ZIP.
|
||||||
|
- I selettori file Android mostrano correttamente progetti condivisi e backup con estensione composta.
|
||||||
|
|
||||||
|
## Versione 0.4.7
|
||||||
|
|
||||||
|
- La ricerca nel pannello Layer conserva correttamente posizione e selezione del cursore durante il filtraggio; digitando `pio` il testo non viene piu invertito in `oip`.
|
||||||
|
- L'elenco revisioni viene aggiornato dopo salvataggi manuali e automatici, rinomina, importazione e selezione del progetto.
|
||||||
|
- Il pannello Progetti mostra quante revisioni sono disponibili e spiega quando un progetto appena creato non possiede ancora versioni precedenti.
|
||||||
|
|
||||||
|
## Versione 0.4.6
|
||||||
|
|
||||||
|
- `Mostra cornice/layer del foglio` carica dal WFS ufficiale AdE il vero confine `CP:CadastralZoning` di ciascun foglio delle particelle.
|
||||||
|
- Le particelle appartenenti a fogli diversi producono cornici distinte, senza piu creare un unico rettangolo cumulativo tra aree lontane.
|
||||||
|
- Le cornici gia presenti nel progetto o trasferite in un altro gruppo vengono riconosciute e non vengono scaricate o duplicate.
|
||||||
|
- Ogni foglio e salvato come oggetto autonomo e puo essere rinominato, bloccato, rimosso o spostato in un altro gruppo dal pannello Layer.
|
||||||
|
- I vecchi riquadri cumulativi generati automaticamente vengono rimossi durante il caricamento e sostituiti dai fogli ufficiali.
|
||||||
|
|
||||||
## Versione 0.4.5
|
## Versione 0.4.5
|
||||||
|
|
||||||
- Corretto il layout del pannello Layer sui telefoni e sui foldable: checkbox, lucchetto, ordinamento e freccia di espansione non si sovrappongono e restano allineati.
|
- Corretto il layout del pannello Layer sui telefoni e sui foldable: checkbox, lucchetto, ordinamento e freccia di espansione non si sovrappongono e restano allineati.
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
|
namespace LMEMappeCatastaliApp.Services;
|
||||||
|
|
||||||
|
public sealed class IncomingFileService
|
||||||
|
{
|
||||||
|
private readonly ConcurrentQueue<IncomingFile> _files = new();
|
||||||
|
public static IncomingFileService Shared { get; } = new();
|
||||||
|
public event Action? FileAvailable;
|
||||||
|
|
||||||
|
public void Enqueue(IncomingFile file)
|
||||||
|
{
|
||||||
|
_files.Enqueue(file);
|
||||||
|
MainThread.BeginInvokeOnMainThread(() => FileAvailable?.Invoke());
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryDequeue(out IncomingFile? file) => _files.TryDequeue(out file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed record IncomingFile(string Path, string FileName, string? ContentType);
|
||||||
@@ -85,7 +85,7 @@ public sealed class MapExportService
|
|||||||
{
|
{
|
||||||
var root = new XElement("gpx",
|
var root = new XElement("gpx",
|
||||||
new XAttribute("version", "1.1"),
|
new XAttribute("version", "1.1"),
|
||||||
new XAttribute("creator", "LME Mappe Catastali 0.4.5"),
|
new XAttribute("creator", "LME Mappe Catastali 0.4.7"),
|
||||||
new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
|
new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
|
||||||
new XElement("metadata", new XElement("name", name)));
|
new XElement("metadata", new XElement("name", name)));
|
||||||
foreach (var feature in features.EnumerateArray())
|
foreach (var feature in features.EnumerateArray())
|
||||||
|
|||||||
@@ -22,6 +22,34 @@ public sealed class OfficialCadastreService
|
|||||||
double longitude,
|
double longitude,
|
||||||
double radiusMeters,
|
double radiusMeters,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
|
=> await GetFeaturesNearAsync(
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
radiusMeters,
|
||||||
|
"CP:CadastralParcel",
|
||||||
|
100,
|
||||||
|
cancellationToken);
|
||||||
|
|
||||||
|
public async Task<string> GetSheetsNearAsync(
|
||||||
|
double latitude,
|
||||||
|
double longitude,
|
||||||
|
double radiusMeters = 10,
|
||||||
|
CancellationToken cancellationToken = default)
|
||||||
|
=> await GetFeaturesNearAsync(
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
radiusMeters,
|
||||||
|
"CP:CadastralZoning",
|
||||||
|
20,
|
||||||
|
cancellationToken);
|
||||||
|
|
||||||
|
private async Task<string> GetFeaturesNearAsync(
|
||||||
|
double latitude,
|
||||||
|
double longitude,
|
||||||
|
double radiusMeters,
|
||||||
|
string typeName,
|
||||||
|
int count,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var meters = Math.Clamp(radiusMeters, 2, 30);
|
var meters = Math.Clamp(radiusMeters, 2, 30);
|
||||||
var deltaLatitude = meters / 111_320d;
|
var deltaLatitude = meters / 111_320d;
|
||||||
@@ -40,11 +68,11 @@ public sealed class OfficialCadastreService
|
|||||||
["language"] = "ita",
|
["language"] = "ita",
|
||||||
["SERVICE"] = "WFS",
|
["SERVICE"] = "WFS",
|
||||||
["VERSION"] = "2.0.0",
|
["VERSION"] = "2.0.0",
|
||||||
["TYPENAMES"] = "CP:CadastralParcel",
|
["TYPENAMES"] = typeName,
|
||||||
["SRSNAME"] = "urn:ogc:def:crs:EPSG::6706",
|
["SRSNAME"] = "urn:ogc:def:crs:EPSG::6706",
|
||||||
["BBOX"] = bbox,
|
["BBOX"] = bbox,
|
||||||
["REQUEST"] = "GetFeature",
|
["REQUEST"] = "GetFeature",
|
||||||
["COUNT"] = "100"
|
["COUNT"] = count.ToString(CultureInfo.InvariantCulture)
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = WfsEndpoint + "?" + string.Join("&", query.Select(item =>
|
var url = WfsEndpoint + "?" + string.Join("&", query.Select(item =>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "10.0.401",
|
||||||
|
"rollForward": "latestPatch"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
param([string]$Configuration = "Release")
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$projectRoot = Split-Path -Parent $PSScriptRoot
|
||||||
|
$dotnet = Join-Path $env:USERPROFILE ".dotnet10\dotnet.exe"
|
||||||
|
$androidSdk = Join-Path $env:LOCALAPPDATA "Android\Sdk"
|
||||||
|
$keyStore = Join-Path $env:LOCALAPPDATA "Xamarin\Mono for Android\debug.keystore"
|
||||||
|
$outputDirectory = Join-Path $projectRoot "artifacts\android-test"
|
||||||
|
$projectPath = Join-Path $projectRoot "LMEMappeCatastaliApp.csproj"
|
||||||
|
[xml]$projectXml = Get-Content -Raw -LiteralPath $projectPath
|
||||||
|
$appVersion = ($projectXml.Project.PropertyGroup | Where-Object ApplicationDisplayVersion | Select-Object -First 1).ApplicationDisplayVersion
|
||||||
|
|
||||||
|
foreach ($requiredPath in @($dotnet, $androidSdk, $keyStore)) {
|
||||||
|
if (-not (Test-Path -LiteralPath $requiredPath)) { throw "Componente richiesto non trovato: $requiredPath" }
|
||||||
|
}
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
|
||||||
|
$packages = [System.Collections.Generic.List[System.IO.FileInfo]]::new()
|
||||||
|
foreach ($format in @("apk", "aab")) {
|
||||||
|
$publishArguments = @(
|
||||||
|
"publish", $projectPath,
|
||||||
|
"-f", "net10.0-android",
|
||||||
|
"-c", $Configuration,
|
||||||
|
"-p:AndroidSdkDirectory=$androidSdk",
|
||||||
|
"-p:AndroidPackageFormat=$format",
|
||||||
|
"-p:AndroidKeyStore=true",
|
||||||
|
"-p:AndroidSigningKeyStore=$keyStore",
|
||||||
|
"-p:AndroidSigningKeyAlias=androiddebugkey",
|
||||||
|
"-p:AndroidSigningStorePass=android",
|
||||||
|
"-p:AndroidSigningKeyPass=android"
|
||||||
|
)
|
||||||
|
& $dotnet @publishArguments
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw "Pubblicazione Android $format non riuscita." }
|
||||||
|
|
||||||
|
$publishDirectory = Join-Path $projectRoot "bin\$Configuration\net10.0-android\publish"
|
||||||
|
$package = Get-ChildItem -LiteralPath $publishDirectory -Filter "*-Signed.$format" -File |
|
||||||
|
Sort-Object LastWriteTime -Descending |
|
||||||
|
Select-Object -First 1
|
||||||
|
if ($null -eq $package) { throw "Nessun pacchetto $format firmato prodotto." }
|
||||||
|
|
||||||
|
$destination = Join-Path $outputDirectory "LME-Mappe-Catastali-$appVersion.$format"
|
||||||
|
Copy-Item -LiteralPath $package.FullName -Destination $destination -Force
|
||||||
|
$packages.Add((Get-Item -LiteralPath $destination))
|
||||||
|
}
|
||||||
|
|
||||||
|
$packages | ForEach-Object {
|
||||||
|
$hash = Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName
|
||||||
|
"$($hash.Hash.ToLowerInvariant()) $($_.Name)"
|
||||||
|
} | Set-Content -LiteralPath (Join-Path $outputDirectory "SHA256SUMS.txt") -Encoding ascii
|
||||||
|
|
||||||
|
$packages | Select-Object Name, Length, LastWriteTime
|
||||||
+215
-80
@@ -167,6 +167,7 @@ window.lmeMap = {
|
|||||||
clearOfflineTiles,
|
clearOfflineTiles,
|
||||||
getOfflineTileStats,
|
getOfflineTileStats,
|
||||||
resize,
|
resize,
|
||||||
|
importExternalGisFile,
|
||||||
showInfo: setInfo
|
showInfo: setInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -737,6 +738,28 @@ function bindFileImport() {
|
|||||||
if (file.size > 100 * 1024 * 1024) throw new Error("file superiore a 100 MB; suddividilo prima dell'importazione");
|
if (file.size > 100 * 1024 * 1024) throw new Error("file superiore a 100 MB; suddividilo prima dell'importazione");
|
||||||
setInfo(`Analisi di ${file.name} (${(file.size / 1024 / 1024).toFixed(1)} MB)...`);
|
setInfo(`Analisi di ${file.name} (${(file.size / 1024 / 1024).toFixed(1)} MB)...`);
|
||||||
await new Promise(resolve => window.setTimeout(resolve, 20));
|
await new Promise(resolve => window.setTimeout(resolve, 20));
|
||||||
|
await importGisFile(file);
|
||||||
|
} catch (error) {
|
||||||
|
setInfo(`File non leggibile: ${error.message}`);
|
||||||
|
} finally {
|
||||||
|
event.target.value = "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
lmeState.fileImportBound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function importExternalGisFile(fileName, base64Content, mimeType) {
|
||||||
|
const binary = atob(base64Content);
|
||||||
|
const bytes = new Uint8Array(binary.length);
|
||||||
|
for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
|
||||||
|
const file = new File([bytes], fileName, { type: mimeType || "application/octet-stream" });
|
||||||
|
if (file.size > 100 * 1024 * 1024) throw new Error("file superiore a 100 MB; suddividilo prima dell'importazione");
|
||||||
|
setInfo(`Analisi di ${file.name} (${(file.size / 1024 / 1024).toFixed(1)} MB)...`);
|
||||||
|
await new Promise(resolve => window.setTimeout(resolve, 20));
|
||||||
|
return importGisFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function importGisFile(file) {
|
||||||
const result = await readGisFile(file);
|
const result = await readGisFile(file);
|
||||||
rememberMapChange();
|
rememberMapChange();
|
||||||
const geojson = result.geojson;
|
const geojson = result.geojson;
|
||||||
@@ -748,25 +771,16 @@ function bindFileImport() {
|
|||||||
refreshImportedMeasurements();
|
refreshImportedMeasurements();
|
||||||
const featureCount = geojson.features.length;
|
const featureCount = geojson.features.length;
|
||||||
const sheetCount = sheetGeojson.features.length;
|
const sheetCount = sheetGeojson.features.length;
|
||||||
const ignored = result.ignoredCount
|
const ignored = result.ignoredCount ? `; esclusi ${result.ignoredCount} elementi del foglio o non particella` : "";
|
||||||
? `; esclusi ${result.ignoredCount} elementi del foglio o non particella`
|
const includedSheets = sheetCount ? `; ${sheetCount} elementi foglio ${lmeState.importedSheetsVisible ? "visibili" : "nascosti"}` : "";
|
||||||
: "";
|
|
||||||
const includedSheets = sheetCount
|
|
||||||
? `; ${sheetCount} elementi foglio ${lmeState.importedSheetsVisible ? "visibili" : "nascosti"}`
|
|
||||||
: "";
|
|
||||||
const reprojected = result.reprojected ? "; coordinate Web Mercator convertite" : "";
|
const reprojected = result.reprojected ? "; coordinate Web Mercator convertite" : "";
|
||||||
const warnings = result.validationWarnings ? `; ${result.validationWarnings} geometrie da verificare` : "";
|
const warnings = result.validationWarnings ? `; ${result.validationWarnings} geometrie da verificare` : "";
|
||||||
setInfo(`Caricato ${file.name}: ${featureCount} particelle/elementi${includedSheets}${ignored}${reprojected}${warnings}.`);
|
const message = `Caricato ${file.name}: ${featureCount} particelle/elementi${includedSheets}${ignored}${reprojected}${warnings}.`;
|
||||||
|
setInfo(message);
|
||||||
updateGpsInsideState();
|
updateGpsInsideState();
|
||||||
refreshLayerManager();
|
refreshLayerManager();
|
||||||
finishMapChange();
|
finishMapChange();
|
||||||
} catch (error) {
|
return message;
|
||||||
setInfo(`File non leggibile: ${error.message}`);
|
|
||||||
} finally {
|
|
||||||
event.target.value = "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
lmeState.fileImportBound = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readGisFile(file) {
|
async function readGisFile(file) {
|
||||||
@@ -985,6 +999,15 @@ function normalizeKmlFiles(files) {
|
|||||||
throw new Error("KML senza geometrie utilizzabili");
|
throw new Error("KML senza geometrie utilizzabili");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!looksLikeCadastralKml(features)) {
|
||||||
|
return {
|
||||||
|
geojson: { type: "FeatureCollection", features },
|
||||||
|
sheetGeojson: emptyFeatureCollection(),
|
||||||
|
ignoredCount: 0,
|
||||||
|
reprojected: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const polygonParts = splitKmlPolygonFeatures(features);
|
const polygonParts = splitKmlPolygonFeatures(features);
|
||||||
const parcels = filterKmlParcelFeatures(polygonParts);
|
const parcels = filterKmlParcelFeatures(polygonParts);
|
||||||
const parcelSet = new Set(parcels);
|
const parcelSet = new Set(parcels);
|
||||||
@@ -1005,6 +1028,22 @@ function normalizeKmlFiles(files) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function looksLikeCadastralKml(features) {
|
||||||
|
return features.some(feature => {
|
||||||
|
const properties = feature?.properties || {};
|
||||||
|
const name = String(properties.name || properties.Name || properties.LABEL || "").trim();
|
||||||
|
const context = [
|
||||||
|
name,
|
||||||
|
properties.layer,
|
||||||
|
properties.Layer,
|
||||||
|
properties.type,
|
||||||
|
properties.Tipo,
|
||||||
|
properties._lmeFolder
|
||||||
|
].filter(Boolean).join(" ").toLowerCase();
|
||||||
|
return /\b(particell|mappal|catast|foglio|parcel|cadastral)\w*/i.test(context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function kmlTextToGeoJson(text, sourceName) {
|
function kmlTextToGeoJson(text, sourceName) {
|
||||||
const xml = new DOMParser().parseFromString(text, "text/xml");
|
const xml = new DOMParser().parseFromString(text, "text/xml");
|
||||||
if (xml.getElementsByTagName("parsererror").length) {
|
if (xml.getElementsByTagName("parsererror").length) {
|
||||||
@@ -2019,9 +2058,15 @@ function renderLayerSelectionToolbar() {
|
|||||||
</div>`;
|
</div>`;
|
||||||
const search = toolbar.querySelector("input");
|
const search = toolbar.querySelector("input");
|
||||||
search.addEventListener("input", () => {
|
search.addEventListener("input", () => {
|
||||||
|
const selectionStart = search.selectionStart ?? search.value.length;
|
||||||
|
const selectionEnd = search.selectionEnd ?? selectionStart;
|
||||||
lmeState.managerSearchText = search.value;
|
lmeState.managerSearchText = search.value;
|
||||||
refreshLayerManager();
|
refreshLayerManager();
|
||||||
requestAnimationFrame(() => document.querySelector(".layer-selection-toolbar input")?.focus());
|
const replacement = document.querySelector(".layer-selection-toolbar input");
|
||||||
|
if (replacement) {
|
||||||
|
replacement.focus({ preventScroll: true });
|
||||||
|
replacement.setSelectionRange(selectionStart, selectionEnd);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
toolbar.querySelectorAll("button").forEach(button => button.addEventListener("click", () => {
|
toolbar.querySelectorAll("button").forEach(button => button.addEventListener("click", () => {
|
||||||
const records = [...lmeState.managerSelectedObjectIds]
|
const records = [...lmeState.managerSelectedObjectIds]
|
||||||
@@ -3461,77 +3506,155 @@ function applyManagedVisualOrder(container) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImportedSheetLayerVisible(enabled) {
|
async function setImportedSheetLayerVisible(enabled) {
|
||||||
migrateMisclassifiedImportedSheets();
|
migrateMisclassifiedImportedSheets();
|
||||||
lmeState.importedSheetsVisible = Boolean(enabled);
|
lmeState.importedSheetsVisible = Boolean(enabled);
|
||||||
const generated = lmeState.importedSheetsVisible && ensureImportedSheetOutline();
|
let sheetResult = null;
|
||||||
|
if (lmeState.importedSheetsVisible) {
|
||||||
|
setInfo("Carico i fogli catastali delle particelle...");
|
||||||
|
sheetResult = await ensureImportedSheetOutlines();
|
||||||
|
}
|
||||||
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
|
? (count
|
||||||
? `${generated ? "Cornice generata dai dati importati" : "Layer del foglio importato visibile"} (${count} elementi).`
|
? `${sheetResult?.added ? "Fogli catastali ufficiali caricati" : "Layer dei fogli catastali visibile"} (${count} cornici).`
|
||||||
: "Nessun dato importato da cui ricavare la cornice del foglio.")
|
: (sheetResult?.failed
|
||||||
|
? "Il servizio ufficiale dei fogli catastali non e' al momento disponibile. Riprova mostrando nuovamente il layer."
|
||||||
|
: "Nessuna particella con cui individuare il foglio catastale."))
|
||||||
: "Layer del foglio importato nascosto; le particelle restano visibili.");
|
: "Layer del foglio importato nascosto; le particelle restano visibili.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureImportedSheetOutline() {
|
function removeLegacyGeneratedSheetOutlines() {
|
||||||
if (!lmeState.imported || !lmeState.importedSheets) {
|
const category = layerManagerCategories().find(item => item.key === "importedSheets");
|
||||||
return false;
|
if (!category) return 0;
|
||||||
}
|
const generated = managedRecordsForCategory(category).filter(record =>
|
||||||
|
Boolean(record.layer?.feature?.properties?._lmeGeneratedSheetOutline));
|
||||||
const currentSheets = lmeState.importedSheets.toGeoJSON();
|
generated.forEach(record => {
|
||||||
const hasAreaOutline = (currentSheets.features || []).some(feature =>
|
record.parent?.removeLayer?.(record.layer);
|
||||||
["Polygon", "MultiPolygon"].includes(feature?.geometry?.type));
|
clearManagedObjectState(record.id);
|
||||||
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;
|
return generated.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cadastralSheetIdentity(feature, index) {
|
||||||
|
const properties = feature?.properties || {};
|
||||||
|
const explicit = properties.foglio ?? properties.FOGLIO ?? properties.sheet ?? properties.SHEET;
|
||||||
|
const administrativeUnit = String(properties.ADMINISTRATIVEUNIT || "").trim().toUpperCase();
|
||||||
|
if (String(explicit ?? "").trim()) {
|
||||||
|
return `${administrativeUnit}|${String(explicit).trim().replace(/^0+/, "") || "0"}`;
|
||||||
|
}
|
||||||
|
const context = [
|
||||||
|
properties.NATIONALCADASTRALREFERENCE,
|
||||||
|
properties.INSPIREID_LOCALID,
|
||||||
|
properties._lmeParcelReference,
|
||||||
|
properties._lmeSource,
|
||||||
|
properties._lmeFolder,
|
||||||
|
properties.name,
|
||||||
|
properties.Name
|
||||||
|
].filter(Boolean).join(" ").toUpperCase();
|
||||||
|
const namedSheet = context.match(/\bFOGLIO\s*[_ .-]*0*(\d+[A-Z]?)\b/i);
|
||||||
|
const codedSheet = context.match(/\b([A-Z]\d{3})[._-]([0-9]{4}[A-Z0-9]{2})(?=[._/-]|\b)/i);
|
||||||
|
if (namedSheet) return `${administrativeUnit}|${namedSheet[1]}`;
|
||||||
|
if (codedSheet) return `${codedSheet[1]}|${codedSheet[2]}`;
|
||||||
|
return `geometria-${index}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sheetRepresentativePoint(feature) {
|
||||||
|
try {
|
||||||
|
return turf.pointOnFeature(feature).geometry.coordinates;
|
||||||
|
} catch {
|
||||||
|
const bounds = geoJsonBounds(feature?.geometry);
|
||||||
|
return bounds ? boundsCenter(bounds) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cadastralSheetFeatureKey(feature) {
|
||||||
|
const properties = feature?.properties || {};
|
||||||
|
return String(properties.NATIONALCADASTRALZONINGREFERENCE
|
||||||
|
|| properties.INSPIREID_LOCALID
|
||||||
|
|| properties.LABEL
|
||||||
|
|| JSON.stringify(feature?.geometry || {})).trim().toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureImportedSheetOutlines() {
|
||||||
|
if (!lmeState.imported || !lmeState.importedSheets) {
|
||||||
|
return { added: 0, failed: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
removeLegacyGeneratedSheetOutlines();
|
||||||
|
const existingAreaSheets = layerManagerCategories()
|
||||||
|
.flatMap(category => managedRecordsForCategory(category))
|
||||||
|
.map(record => ({ categoryKey: record.categoryKey, feature: record.layer?.toGeoJSON?.() }))
|
||||||
|
.filter(item => ["Polygon", "MultiPolygon"].includes(item.feature?.geometry?.type)
|
||||||
|
&& !item.feature?.properties?._lmeGeneratedSheetOutline
|
||||||
|
&& (item.categoryKey === "importedSheets"
|
||||||
|
|| item.feature?.properties?._lmeOfficialSheet
|
||||||
|
|| item.feature?.properties?.NATIONALCADASTRALZONINGREFERENCE
|
||||||
|
|| isSheetOrOverlayFeature(item.feature)))
|
||||||
|
.map(item => item.feature);
|
||||||
|
|
||||||
|
const parcelFeatures = [
|
||||||
|
...(lmeState.imported.toGeoJSON()?.features || []),
|
||||||
|
...(lmeState.selectedParcelsLayer?.toGeoJSON?.()?.features || [])
|
||||||
|
].filter(feature => ["Polygon", "MultiPolygon"].includes(feature?.geometry?.type));
|
||||||
|
const representatives = new Map();
|
||||||
|
parcelFeatures.forEach((feature, index) => {
|
||||||
|
const identity = cadastralSheetIdentity(feature, index);
|
||||||
|
if (!representatives.has(identity)) representatives.set(identity, feature);
|
||||||
|
});
|
||||||
|
if (!representatives.size || !lmeState.dotNetReference) {
|
||||||
|
return { added: 0, failed: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingKeys = new Set(existingAreaSheets.map(cadastralSheetFeatureKey));
|
||||||
|
const officialSheets = new Map();
|
||||||
|
let failures = 0;
|
||||||
|
for (const [identity, parcelFeature] of representatives) {
|
||||||
|
const point = sheetRepresentativePoint(parcelFeature);
|
||||||
|
if (!point) continue;
|
||||||
|
const existingSheet = findContainingPolygon(point, {
|
||||||
|
type: "FeatureCollection",
|
||||||
|
features: [...existingAreaSheets, ...officialSheets.values()]
|
||||||
|
});
|
||||||
|
if (existingSheet) continue;
|
||||||
|
try {
|
||||||
|
const xml = await lmeState.dotNetReference.invokeMethodAsync(
|
||||||
|
"GetOfficialCadastralSheetsNear",
|
||||||
|
point[1],
|
||||||
|
point[0]);
|
||||||
|
const candidates = gmlParcelsToGeoJson(xml).features || [];
|
||||||
|
const containing = findContainingPolygon(point, { type: "FeatureCollection", features: candidates });
|
||||||
|
const sheet = containing || candidates[0];
|
||||||
|
if (!sheet) continue;
|
||||||
|
const key = cadastralSheetFeatureKey(sheet);
|
||||||
|
if (existingKeys.has(key) || officialSheets.has(key)) continue;
|
||||||
|
const reference = String(sheet.properties?.NATIONALCADASTRALZONINGREFERENCE
|
||||||
|
|| sheet.properties?.LABEL
|
||||||
|
|| identity.split("|").pop()
|
||||||
|
|| "").trim();
|
||||||
|
sheet.properties = {
|
||||||
|
...(sheet.properties || {}),
|
||||||
|
name: reference ? `Foglio catastale ${reference}` : "Foglio catastale",
|
||||||
|
foglio: reference,
|
||||||
|
_lmeSheetIdentity: identity,
|
||||||
|
_lmeOfficialSheet: true,
|
||||||
|
_lmeSource: reference ? `Foglio catastale ${reference}` : "Fogli catastali AdE",
|
||||||
|
_lmeGroupName: reference ? `Foglio ${reference}` : "Fogli catastali AdE"
|
||||||
|
};
|
||||||
|
officialSheets.set(key, sheet);
|
||||||
|
} catch {
|
||||||
|
failures++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (officialSheets.size) {
|
||||||
|
addImportedSheetFeatures({ type: "FeatureCollection", features: [...officialSheets.values()] });
|
||||||
|
applyImportedSheetVisibility();
|
||||||
|
refreshLayerManager();
|
||||||
|
finishMapChange(`${officialSheets.size} fogli catastali ufficiali caricati.`);
|
||||||
|
}
|
||||||
|
return { added: officialSheets.size, failed: failures > 0 && !officialSheets.size };
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateMisclassifiedImportedSheets() {
|
function migrateMisclassifiedImportedSheets() {
|
||||||
@@ -4551,9 +4674,6 @@ 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(), {
|
||||||
pane: "selectedParcelsPane",
|
pane: "selectedParcelsPane",
|
||||||
@@ -4576,6 +4696,12 @@ function loadProjectSnapshot(raw, projectName) {
|
|||||||
applyStyleFromProperties(layer);
|
applyStyleFromProperties(layer);
|
||||||
}
|
}
|
||||||
}).addTo(lmeState.selectedParcelsLayer);
|
}).addTo(lmeState.selectedParcelsLayer);
|
||||||
|
if (lmeState.importedSheetsVisible) {
|
||||||
|
void ensureImportedSheetOutlines().then(() => {
|
||||||
|
applyImportedSheetVisibility();
|
||||||
|
refreshLayerManager();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
lmeState.gpsTrailPoints = Array.isArray(data.trail) ? data.trail : [];
|
lmeState.gpsTrailPoints = Array.isArray(data.trail) ? data.trail : [];
|
||||||
lmeState.gpsTrailStartedAt = data.trailStartedAt || null;
|
lmeState.gpsTrailStartedAt = data.trailStartedAt || null;
|
||||||
@@ -5559,7 +5685,16 @@ function parcelMemberToFeature(member) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const properties = {};
|
const properties = {};
|
||||||
["INSPIREID_LOCALID", "INSPIREID_NAMESPACE", "LABEL", "NATIONALCADASTRALREFERENCE", "ADMINISTRATIVEUNIT"].forEach(name => {
|
[
|
||||||
|
"INSPIREID_LOCALID",
|
||||||
|
"INSPIREID_NAMESPACE",
|
||||||
|
"LABEL",
|
||||||
|
"NATIONALCADASTRALREFERENCE",
|
||||||
|
"NATIONALCADASTRALZONINGREFERENCE",
|
||||||
|
"LEVEL",
|
||||||
|
"LEVELNAME",
|
||||||
|
"ADMINISTRATIVEUNIT"
|
||||||
|
].forEach(name => {
|
||||||
const value = member.getElementsByTagNameNS("*", name)[0]?.textContent;
|
const value = member.getElementsByTagNameNS("*", name)[0]?.textContent;
|
||||||
if (value) {
|
if (value) {
|
||||||
properties[name] = value;
|
properties[name] = value;
|
||||||
|
|||||||
Reference in new issue
Block a user