Add mapped Pro fiducial point layer
This commit is contained in:
1 parent
7b642afe2d
commit
85e1c93d8a
4 files changed
+360
-19
No files matched your search
+143
-2
@@ -9,6 +9,7 @@ const lmeState = {
|
||||
"gpsTrail",
|
||||
"gpsParcels",
|
||||
"selectedParcels",
|
||||
"fiducials",
|
||||
"importedSheets",
|
||||
"imported",
|
||||
"cadastre"
|
||||
@@ -50,6 +51,9 @@ const lmeState = {
|
||||
gpsTrail: null,
|
||||
selectedParcelsLayer: null,
|
||||
selectedParcelsVisible: true,
|
||||
fiducials: null,
|
||||
fiducialsVisible: true,
|
||||
fiducialColor: "#dc2626",
|
||||
gpsParcelLayer: null,
|
||||
gpsTrailEnabled: false,
|
||||
gpsTrailPoints: [],
|
||||
@@ -131,6 +135,10 @@ window.lmeMap = {
|
||||
closeCadastrePreview,
|
||||
clearSelectedParcels,
|
||||
setSelectedParcelsVisible,
|
||||
setFiducialPoints,
|
||||
setFiducialPointsVisible,
|
||||
setFiducialColor,
|
||||
fitFiducialPoints,
|
||||
clearMapElements,
|
||||
fitImported,
|
||||
clearImported,
|
||||
@@ -310,6 +318,7 @@ function init(dotNetReference) {
|
||||
lmeState.importedMeasurements = L.layerGroup().addTo(lmeState.map);
|
||||
lmeState.drawingMeasurements = L.layerGroup().addTo(lmeState.map);
|
||||
lmeState.selectedParcelsLayer = L.featureGroup().addTo(lmeState.map);
|
||||
lmeState.fiducials = L.featureGroup().addTo(lmeState.map);
|
||||
lmeState.gpsParcelLayer = L.featureGroup().addTo(lmeState.map);
|
||||
const navigationSheetPane = lmeState.map.createPane("navigationSheetPane");
|
||||
navigationSheetPane.style.zIndex = "465";
|
||||
@@ -1339,6 +1348,7 @@ function managedLayerPanes() {
|
||||
gpsTrail: "gpsTrailPane",
|
||||
gpsParcels: "gpsParcelsPane",
|
||||
selectedParcels: "selectedParcelsPane",
|
||||
fiducials: "fiducialsPane",
|
||||
importedSheets: "importedSheetPane",
|
||||
imported: "importedPane",
|
||||
cadastre: "cadastrePane"
|
||||
@@ -1427,6 +1437,7 @@ function layerManagerCategories() {
|
||||
{ key: "gpsTrail", label: "Traccia GPS", roots: [lmeState.gpsTrail].filter(Boolean) },
|
||||
{ key: "gpsParcels", label: "Particella rilevata dal GPS", roots: [lmeState.gpsParcelLayer].filter(Boolean) },
|
||||
{ key: "selectedParcels", label: "Particelle catastali evidenziate", roots: [lmeState.selectedParcelsLayer].filter(Boolean) },
|
||||
{ key: "fiducials", label: "Punti fiduciali", roots: [lmeState.fiducials].filter(Boolean) },
|
||||
{ key: "importedSheets", label: "Cornici e fogli importati", roots: [lmeState.importedSheets].filter(Boolean), blocks: true },
|
||||
{ key: "imported", label: "Progetti e dati importati", roots: [lmeState.imported].filter(Boolean), blocks: true },
|
||||
{ key: "cadastre", label: "Layer catastali AdE", roots: [lmeState.cadastre].filter(Boolean) }
|
||||
@@ -3271,6 +3282,8 @@ function setManagedCategoryVisible(category, visible) {
|
||||
lmeState.importedSheetsVisible = visible;
|
||||
} else if (category.key === "selectedParcels") {
|
||||
lmeState.selectedParcelsVisible = visible;
|
||||
} else if (category.key === "fiducials") {
|
||||
lmeState.fiducialsVisible = visible;
|
||||
} else if (category.key === "gpsPosition") {
|
||||
lmeState.gpsPositionVisible = visible;
|
||||
}
|
||||
@@ -3344,6 +3357,9 @@ function managedCategoryEnabled(categoryKey) {
|
||||
if (categoryKey === "selectedParcels") {
|
||||
return lmeState.selectedParcelsVisible;
|
||||
}
|
||||
if (categoryKey === "fiducials") {
|
||||
return lmeState.fiducialsVisible;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4721,7 +4737,7 @@ function circleToPolygon(center, radiusMeters) {
|
||||
function createProjectSnapshot(includeCadastralParcels) {
|
||||
const center = lmeState.map.getCenter();
|
||||
return JSON.stringify({
|
||||
schemaVersion: 5,
|
||||
schemaVersion: 6,
|
||||
view: {
|
||||
latitude: center.lat,
|
||||
longitude: center.lng,
|
||||
@@ -4731,6 +4747,7 @@ function createProjectSnapshot(includeCadastralParcels) {
|
||||
imported: managedGroupGeoJson(lmeState.imported, "imported"),
|
||||
importedSheets: managedGroupGeoJson(lmeState.importedSheets, "importedSheets"),
|
||||
importedSheetsVisible: lmeState.importedSheetsVisible,
|
||||
fiducials: managedGroupGeoJson(lmeState.fiducials, "fiducials"),
|
||||
displayOptions: captureDisplayOptions(),
|
||||
selectedParcels: includeCadastralParcels
|
||||
? managedGroupGeoJson(lmeState.selectedParcelsLayer, "selectedParcels")
|
||||
@@ -4766,6 +4783,7 @@ function loadProjectSnapshot(raw, projectName) {
|
||||
lmeState.drawingMeasurements.clearLayers();
|
||||
lmeState.importedMeasurements.clearLayers();
|
||||
lmeState.selectedParcelsLayer.clearLayers();
|
||||
lmeState.fiducials.clearLayers();
|
||||
lmeState.gpsParcelLayer.clearLayers();
|
||||
|
||||
const restoredDrawings = L.geoJSON(data.drawings || emptyFeatureCollection(), {
|
||||
@@ -4826,6 +4844,10 @@ function loadProjectSnapshot(raw, projectName) {
|
||||
applyStyleFromProperties(layer);
|
||||
}
|
||||
}).addTo(lmeState.selectedParcelsLayer);
|
||||
L.geoJSON(data.fiducials || emptyFeatureCollection(), {
|
||||
pointToLayer: (feature, latlng) => createFiducialMarker(feature, latlng),
|
||||
onEachFeature: (feature, layer) => bindFiducialPopup(feature, layer)
|
||||
}).addTo(lmeState.fiducials);
|
||||
if (lmeState.importedSheetsVisible) {
|
||||
void ensureImportedSheetOutlines().then(() => {
|
||||
applyImportedSheetVisibility();
|
||||
@@ -4848,6 +4870,7 @@ function loadProjectSnapshot(raw, projectName) {
|
||||
lmeState.drawings,
|
||||
lmeState.imported,
|
||||
lmeState.selectedParcelsLayer,
|
||||
lmeState.fiducials,
|
||||
lmeState.gpsTrail
|
||||
];
|
||||
if (lmeState.importedSheetsVisible) {
|
||||
@@ -4898,6 +4921,8 @@ function captureDisplayOptions() {
|
||||
drawToolsVisible: Boolean(lmeState.drawControl),
|
||||
gpsPositionVisible: lmeState.gpsPositionVisible,
|
||||
selectedParcelsVisible: lmeState.selectedParcelsVisible,
|
||||
fiducialsVisible: lmeState.fiducialsVisible,
|
||||
fiducialColor: lmeState.fiducialColor,
|
||||
layerOrder: [...lmeState.layerOrder],
|
||||
layerObjectOrder: { ...lmeState.managerObjectOrder },
|
||||
layerCategoryNames: { ...lmeState.managerCategoryNames },
|
||||
@@ -4965,6 +4990,10 @@ function applyProjectDisplayOptions(options) {
|
||||
}
|
||||
setGpsPositionVisible(options.gpsPositionVisible !== false);
|
||||
setSelectedParcelsVisible(options.selectedParcelsVisible !== false);
|
||||
if (typeof options.fiducialColor === "string") {
|
||||
setFiducialColor(options.fiducialColor);
|
||||
}
|
||||
setFiducialPointsVisible(options.fiducialsVisible !== false);
|
||||
toggleTrail(Boolean(options.trailEnabled));
|
||||
setDrawToolsVisible(Boolean(options.drawToolsVisible));
|
||||
applyStoredLayerManagerVisibility();
|
||||
@@ -5634,6 +5663,116 @@ function activeCadastreLayers() {
|
||||
return drawOrder.filter(layer => lmeState.cadastreLayers.includes(layer));
|
||||
}
|
||||
|
||||
function setFiducialPoints(points, color, visible = true) {
|
||||
if (!lmeState.fiducials) return;
|
||||
const source = Array.isArray(points) ? points : [];
|
||||
if (source.length || lmeState.fiducials.getLayers().length) rememberMapChange();
|
||||
lmeState.fiducials.clearLayers();
|
||||
clearManagedCategoryState("fiducials");
|
||||
if (typeof color === "string" && /^#[0-9a-f]{6}$/i.test(color)) {
|
||||
lmeState.fiducialColor = color;
|
||||
}
|
||||
source.forEach((point, index) => {
|
||||
const latitude = Number(point.latitude ?? point.Latitude);
|
||||
const longitude = Number(point.longitude ?? point.Longitude);
|
||||
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return;
|
||||
const feature = {
|
||||
type: "Feature",
|
||||
geometry: { type: "Point", coordinates: [longitude, latitude] },
|
||||
properties: {
|
||||
name: String(point.identifier ?? point.Identifier ?? `PF ${index + 1}`),
|
||||
_lmeDisplayName: String(point.identifier ?? point.Identifier ?? `PF ${index + 1}`),
|
||||
_lmeSource: "Punti fiduciali georiferiti",
|
||||
_lmeColor: lmeState.fiducialColor,
|
||||
_lmeFillColor: lmeState.fiducialColor,
|
||||
_lmeWeight: 3,
|
||||
_lmeOpacity: 1,
|
||||
_lmeFillOpacity: 0.72,
|
||||
cadastralNorth: point.cadastralNorth ?? point.CadastralNorth ?? null,
|
||||
cadastralEast: point.cadastralEast ?? point.CadastralEast ?? null,
|
||||
reliability: String(point.reliability ?? point.Reliability ?? ""),
|
||||
elevation: point.elevation ?? point.Elevation ?? null,
|
||||
parcel: String(point.parcel ?? point.Parcel ?? ""),
|
||||
updatedAt: String(point.updatedAt ?? point.UpdatedAt ?? ""),
|
||||
originId: String(point.originId ?? point.OriginId ?? ""),
|
||||
monographUrl: String(point.monographUrl ?? point.MonographUrl ?? "")
|
||||
}
|
||||
};
|
||||
const marker = createFiducialMarker(feature, L.latLng(latitude, longitude));
|
||||
marker.feature = feature;
|
||||
bindFiducialPopup(feature, marker);
|
||||
lmeState.fiducials.addLayer(marker);
|
||||
});
|
||||
setFiducialPointsVisible(visible);
|
||||
refreshLayerManager();
|
||||
if (source.length) finishMapChange();
|
||||
}
|
||||
|
||||
function createFiducialMarker(feature, latlng) {
|
||||
const properties = feature?.properties || {};
|
||||
const color = properties._lmeColor || lmeState.fiducialColor;
|
||||
return L.circleMarker(latlng, {
|
||||
pane: "fiducialsPane",
|
||||
radius: 8,
|
||||
color,
|
||||
fillColor: properties._lmeFillColor || color,
|
||||
weight: Number(properties._lmeWeight) || 3,
|
||||
opacity: Number.isFinite(Number(properties._lmeOpacity)) ? Number(properties._lmeOpacity) : 1,
|
||||
fillOpacity: Number.isFinite(Number(properties._lmeFillOpacity)) ? Number(properties._lmeFillOpacity) : 0.72
|
||||
});
|
||||
}
|
||||
|
||||
function bindFiducialPopup(feature, layer) {
|
||||
const properties = feature?.properties || {};
|
||||
const rows = [];
|
||||
if (properties.cadastralNorth != null) rows.push(`Nord/X catastale: ${escapeHtml(properties.cadastralNorth)}`);
|
||||
if (properties.cadastralEast != null) rows.push(`Est/Y catastale: ${escapeHtml(properties.cadastralEast)}`);
|
||||
if (properties.reliability) rows.push(`Attendibilita: ${escapeHtml(properties.reliability)}`);
|
||||
if (properties.elevation != null) rows.push(`Quota: ${escapeHtml(properties.elevation)}`);
|
||||
if (properties.parcel) rows.push(`Particella: ${escapeHtml(properties.parcel)}`);
|
||||
const url = String(properties.monographUrl || "");
|
||||
const monograph = /^https:\/\//i.test(url)
|
||||
? `<p><a href="${escapeHtml(url)}" target="_blank" rel="noopener">Apri monografia ufficiale</a></p>`
|
||||
: "";
|
||||
layer.bindPopup(`<strong>${escapeHtml(properties._lmeDisplayName || properties.name || "Punto fiduciale")}</strong><p>${rows.join("<br>")}</p>${monograph}<small>Posizione cartografica sperimentale GloboGIS: verificare prima dell'uso topografico.</small>`);
|
||||
applyStyleFromProperties(layer);
|
||||
}
|
||||
|
||||
function setFiducialPointsVisible(enabled) {
|
||||
lmeState.fiducialsVisible = Boolean(enabled);
|
||||
if (!lmeState.map || !lmeState.fiducials) return;
|
||||
if (lmeState.fiducialsVisible) {
|
||||
lmeState.managerHiddenCategories.delete("fiducials");
|
||||
if (!lmeState.map.hasLayer(lmeState.fiducials)) lmeState.fiducials.addTo(lmeState.map);
|
||||
lmeState.fiducials.bringToFront?.();
|
||||
} else {
|
||||
lmeState.managerHiddenCategories.add("fiducials");
|
||||
if (lmeState.map.hasLayer(lmeState.fiducials)) lmeState.map.removeLayer(lmeState.fiducials);
|
||||
}
|
||||
refreshLayerManager();
|
||||
}
|
||||
|
||||
function setFiducialColor(color) {
|
||||
if (!/^#[0-9a-f]{6}$/i.test(String(color))) return;
|
||||
lmeState.fiducialColor = color;
|
||||
lmeState.fiducials?.eachLayer(layer => {
|
||||
if (layer.feature?.properties) {
|
||||
layer.feature.properties._lmeColor = color;
|
||||
layer.feature.properties._lmeFillColor = color;
|
||||
}
|
||||
applyStyleFromProperties(layer);
|
||||
});
|
||||
refreshLayerManager();
|
||||
}
|
||||
|
||||
function fitFiducialPoints() {
|
||||
if (!lmeState.fiducials?.getLayers().length) {
|
||||
setInfo("Nessun Punto Fiduciale da inquadrare.");
|
||||
return;
|
||||
}
|
||||
fitLayer(lmeState.fiducials);
|
||||
}
|
||||
|
||||
function clearSelectedParcels() {
|
||||
const count = managedGroupGeoJson(lmeState.selectedParcelsLayer, "selectedParcels").features.length;
|
||||
if (count) rememberMapChange();
|
||||
@@ -5672,6 +5811,7 @@ function setSelectedParcelsVisible(enabled) {
|
||||
function clearMapElements() {
|
||||
const count = managedGroupGeoJson(lmeState.selectedParcelsLayer, "selectedParcels").features.length
|
||||
+ managedGroupGeoJson(lmeState.gpsParcelLayer, "gpsParcels").features.length
|
||||
+ managedGroupGeoJson(lmeState.fiducials, "fiducials").features.length
|
||||
+ managedGroupGeoJson(lmeState.imported, "imported").features.length
|
||||
+ managedGroupGeoJson(lmeState.importedSheets, "importedSheets").features.length
|
||||
+ managedGroupGeoJson(lmeState.drawings, "drawings").features.length
|
||||
@@ -5680,7 +5820,7 @@ function clearMapElements() {
|
||||
setInfo("La mappa non contiene elementi da pulire.");
|
||||
return;
|
||||
}
|
||||
if (!window.confirm("Rimuovere particelle evidenziate, file importati, disegni, POI e traccia GPS dalla mappa?")) {
|
||||
if (!window.confirm("Rimuovere particelle evidenziate, Punti Fiduciali, file importati, disegni, POI e traccia GPS dalla mappa?")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5688,6 +5828,7 @@ function clearMapElements() {
|
||||
resetLayerManagerProjectState();
|
||||
lmeState.selectedParcelsLayer.clearLayers();
|
||||
lmeState.gpsParcelLayer.clearLayers();
|
||||
lmeState.fiducials.clearLayers();
|
||||
lmeState.imported.clearLayers();
|
||||
lmeState.importedSheets.clearLayers();
|
||||
lmeState.drawings.clearLayers();
|
||||
|
||||
Reference in new issue
Block a user