@octostar/map-component 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +651 -472
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +677 -497
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +2 -0
- package/dist/types/components/layers-panel.d.ts +2 -2
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/lib/feature-cap.d.ts +14 -0
- package/dist/types/lib/feature-cap.d.ts.map +1 -1
- package/dist/types/lib/geojson-serialize.d.ts +8 -18
- package/dist/types/lib/geojson-serialize.d.ts.map +1 -1
- package/dist/types/lib/label-pinning.d.ts.map +1 -1
- package/dist/types/lib/paint-feature.d.ts +65 -0
- package/dist/types/lib/paint-feature.d.ts.map +1 -0
- package/dist/types/lib/tooltip-feature.d.ts +36 -0
- package/dist/types/lib/tooltip-feature.d.ts.map +1 -0
- package/dist/types/lib/trace-groups.d.ts +82 -0
- package/dist/types/lib/trace-groups.d.ts.map +1 -0
- package/dist/types/lib/trace-timeline.d.ts +75 -0
- package/dist/types/lib/trace-timeline.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -164,7 +164,7 @@ async function featureCollectionBlobPartsAsync(collection, options) {
|
|
|
164
164
|
(_c = options == null ? void 0 : options.onProgress) == null ? void 0 : _c.call(options, total, total);
|
|
165
165
|
return coalescer.finish();
|
|
166
166
|
}
|
|
167
|
-
const ingestWorkerSource = '"use strict";(()=>{function b(e,t){let n=e.length,r=Math.max(0,t.max-(t.existing??0));return n<=r?{features:e,dropped:0,sourceCount:n}:{features:e.slice(0,r),dropped:n-r,sourceCount:n}}function S(e){let t=e.crs?.properties?.name,n=null;if(t){let r=t.match(/EPSG::?(\\d+)/i);r&&(n=`EPSG:${r[1]}`)}if(!n&&e.features.length>0){let r=
|
|
167
|
+
const ingestWorkerSource = '"use strict";(()=>{function b(e,t){let n=e.length,r=Math.max(0,t.max-(t.existing??0));return n<=r?{features:e,dropped:0,sourceCount:n}:{features:e.slice(0,r),dropped:n-r,sourceCount:n}}function S(e){let t=e.crs?.properties?.name,n=null;if(t){let r=t.match(/EPSG::?(\\d+)/i);r&&(n=`EPSG:${r[1]}`)}if(!n&&e.features.length>0){let r=T(e.features[0].geometry);if(r){let[s,a]=r;if(Math.abs(s)<=180&&Math.abs(a)<=90)return{sourceCRS:"EPSG:4326",needsReprojection:!1}}return{sourceCRS:null,needsReprojection:!1}}return{sourceCRS:n,needsReprojection:n!==null&&n!=="EPSG:4326"}}function T(e){if(!e)return null;switch(e.type){case"Point":return e.coordinates;case"MultiPoint":case"LineString":return e.coordinates[0];case"MultiLineString":case"Polygon":return e.coordinates[0]?.[0];case"MultiPolygon":return e.coordinates[0]?.[0]?.[0];default:return null}}function I(e){return e.geometry?.type==="LineString"?e.geometry.coordinates.some(n=>n.length>=3&&n[2]!==0):e.geometry?.type==="MultiLineString"?e.geometry.coordinates.some(n=>n.some(r=>r.length>=3&&r[2]!==0)):!1}function d(e){if(!e)return null;if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function h(e){return!!(e.startDate||e.startdate||e.start_date||e.start_time||e.date||e.timestamp||e.flightDate||e.time||e.datetime||e.endDate||e.enddate||e.end_date||e.end_time)}function F(e){let t=d(e.startDate)||d(e.startdate)||d(e.start_date)||d(e.start_time)||d(e.date)||d(e.timestamp)||d(e.flightDate)||d(e.time)||d(e.datetime),n=d(e.endDate)||d(e.enddate)||d(e.end_date)||d(e.end_time);return t&&n&&n<t&&([t,n]=[n,t]),{startDate:t,endDate:n}}function x(e){return"kind"in e&&e.kind==="ack"}function G(){let e=globalThis.crypto?.randomUUID?.bind(globalThis.crypto);return e?e():`f-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _(e,t,n){switch(n.idStrategy){case"preserve":return e.id;case"layer-index":return e.id!==void 0&&e.id!==null?String(e.id):`${n.layerId}-f${t}`;case"uuid-fallback":return e.id?String(e.id):G()}}function C(e,t){if(Array.isArray(e)){if(typeof e[0]=="number"){let n=e[0],r=e[1];t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return}for(let n of e)C(n,t)}}function R(e,t){if(e){if(e.type==="GeometryCollection"){for(let n of e.geometries)R(n,t);return}C(e.coordinates,t)}}function D(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)R(n.geometry,t);return t.every(n=>isFinite(n))?t:null}function O(e,t){let n;if(e.type==="text")try{n=JSON.parse(e.text)}catch(c){return{kind:"error",code:"parse-error",message:c instanceof Error?c.message:"Invalid file"}}else n=e.data;if(n&&n.type==="Feature"&&(n={type:"FeatureCollection",features:[n]}),!n||n.type!=="FeatureCollection"||!Array.isArray(n.features))return{kind:"error",code:"invalid-format",message:"Invalid GeoJSON format"};if(t.emptyIsError&&n.features.length===0)return{kind:"error",code:"empty",message:"The file contains no features"};if(n["octostar:map"])return{kind:"enriched",data:n};let{sourceCRS:r,needsReprojection:s}=S(n),a=b(n.features,{max:t.maxFeatures??1/0}),o=!1,u=!1,i=[];a.features.forEach((c,E)=>{let p=_(c,E,t);!u&&I(c)&&(u=!0);let f=c.properties||{};if(!h(f)){i.push(t.idStrategy==="preserve"?c:{...c,id:p});return}let{startDate:y,endDate:k}=F(f);(y||k)&&(o=!0),i.push({...c,...p!==void 0&&{id:p},properties:{...f,startDate:y?.toISOString()||null,endDate:k?.toISOString()||null}})});let m=n.properties?.layerMetadata;return{kind:"features",features:i,featureCount:i.length,bbox:D(i),hasTemporal:o,hasAltitude:u,reprojected:!1,sourceCRS:r,...s&&{needsReprojection:s},...m&&{layerMetadata:m},...a.dropped>0&&{truncated:{droppedCount:a.dropped,sourceFeatureCount:a.sourceCount,maxFeatures:t.maxFeatures}}}}var N=5e3;function M(e,t){let n=Number.isNaN(t)?N:Math.max(1,Math.floor(t)),r=[];for(let s=0;s<e.length;s+=n)r.push(e.slice(s,s+n));return r}function g(e){if(e===void 0)return!1;if(typeof e=="number")return Number.isFinite(e)&&!Object.is(e,-0);if(e===null||typeof e!="object")return!0;if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!g(e[t]))return!1;return!0}for(let t in e)if(!g(e[t]))return!1;return!0}function P(e){for(let t=0;t<e.length;t++)if(!g(e[t]))return e;try{return JSON.stringify(e)}catch{return e}}function J(e){let{kind:t,features:n,...r}=e;return r}async function w(e,t,n,r){let s;try{s=O(t,n)}catch(a){r.post({kind:"result",id:e,ok:!1,error:a instanceof Error?a.message:String(a)});return}if(s.kind!=="features"){r.post({kind:"result",id:e,ok:!0,result:s});return}try{let a=r.encode??P,o=M(s.features,r.chunkSize??N);r.post({kind:"head",id:e,summary:J(s)});let u=o.length>0?a(o[0]):null;for(let i=0;i<o.length;i++){let m=r.waitAck(i);r.post({kind:"chunk",id:e,seq:i,payload:u}),u=i+1<o.length?a(o[i+1]):null,await m}r.post({kind:"done",id:e,chunkCount:o.length})}catch(a){r.post({kind:"error",id:e,message:a instanceof Error?a.message:String(a)})}}var A=e=>self.postMessage(e),l=new Map;self.onmessage=async e=>{let t=e.data;if(x(t)){let o=`${t.id}:${t.seq}`,u=l.get(o);l.delete(o),u?.();return}let{id:n,source:r,options:s,tuning:a}=t;try{let o=r.type==="blob"?{type:"text",text:await r.blob.text()}:r;await w(n,o,s,{post:A,waitAck:u=>new Promise(i=>{l.set(`${n}:${u}`,i)}),...a?.chunkSize!==void 0&&{chunkSize:a.chunkSize},...a?.featureArrayChunks&&{encode:u=>u}})}catch(o){A({kind:"result",id:n,ok:!1,error:o instanceof Error?o.message:String(o)})}finally{l.forEach((o,u)=>{u.startsWith(`${n}:`)&&l.delete(u)})}};})();\n';
|
|
168
168
|
proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
|
|
169
169
|
proj4.defs("EPSG:3857", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs");
|
|
170
170
|
proj4.defs("EPSG:32630", "+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs");
|
|
@@ -229,6 +229,14 @@ function capFeatures(features, options) {
|
|
|
229
229
|
sourceCount
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
|
+
function truncationToCapInfo(truncation, rest) {
|
|
233
|
+
return {
|
|
234
|
+
...rest,
|
|
235
|
+
dropped: truncation.droppedCount,
|
|
236
|
+
sourceCount: truncation.sourceFeatureCount,
|
|
237
|
+
max: truncation.maxFeatures
|
|
238
|
+
};
|
|
239
|
+
}
|
|
232
240
|
function formatCount(value) {
|
|
233
241
|
return value.toLocaleString("en-US");
|
|
234
242
|
}
|
|
@@ -246,6 +254,16 @@ function formatFeatureCapToast(info) {
|
|
|
246
254
|
variant
|
|
247
255
|
};
|
|
248
256
|
}
|
|
257
|
+
const existing = info.existing ?? 0;
|
|
258
|
+
if (existing > 0) {
|
|
259
|
+
return {
|
|
260
|
+
title: "Feature limit reached",
|
|
261
|
+
description: withNote(
|
|
262
|
+
`"${info.layerName}" already held ${formatCount(existing)} of its ${formatCount(info.max)}-feature limit, so only ${formatCount(info.kept)} more were added; ${formatCount(info.dropped)} were skipped.`
|
|
263
|
+
),
|
|
264
|
+
variant
|
|
265
|
+
};
|
|
266
|
+
}
|
|
249
267
|
return {
|
|
250
268
|
title: "Feature limit reached",
|
|
251
269
|
description: withNote(
|
|
@@ -2954,7 +2972,9 @@ function LayersPanel({
|
|
|
2954
2972
|
key: "save-desktop",
|
|
2955
2973
|
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "w-[18px] h-[18px]" }),
|
|
2956
2974
|
label: "Save GeoJSON to desktop",
|
|
2957
|
-
onClick: () =>
|
|
2975
|
+
onClick: () => {
|
|
2976
|
+
void onSaveLayerGeoJSON(layer.id);
|
|
2977
|
+
}
|
|
2958
2978
|
},
|
|
2959
2979
|
...onUpdateVisualConfig ? [
|
|
2960
2980
|
{ type: "divider" },
|
|
@@ -3635,7 +3655,9 @@ function LayersPanel({
|
|
|
3635
3655
|
key: "save-geojson",
|
|
3636
3656
|
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "w-4 h-4" }),
|
|
3637
3657
|
label: "Download Map",
|
|
3638
|
-
onClick:
|
|
3658
|
+
onClick: () => {
|
|
3659
|
+
void onSaveAllGeoJSON();
|
|
3660
|
+
}
|
|
3639
3661
|
},
|
|
3640
3662
|
...onWorkspaceSave ? [{
|
|
3641
3663
|
key: "save-workspace",
|
|
@@ -6549,25 +6571,25 @@ function createSelectionPaintCache() {
|
|
|
6549
6571
|
updatable: true
|
|
6550
6572
|
};
|
|
6551
6573
|
}
|
|
6552
|
-
function recordPaintedFeature(
|
|
6553
|
-
if (
|
|
6554
|
-
|
|
6574
|
+
function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
6575
|
+
if (cache2.presentIds.has(featureId)) {
|
|
6576
|
+
cache2.updatable = false;
|
|
6555
6577
|
} else {
|
|
6556
|
-
|
|
6578
|
+
cache2.presentIds.add(featureId);
|
|
6557
6579
|
}
|
|
6558
|
-
|
|
6559
|
-
if (isSelected)
|
|
6580
|
+
cache2.basePriorityById.set(featureId, basePriority);
|
|
6581
|
+
if (isSelected) cache2.appliedSelectedIds.add(featureId);
|
|
6560
6582
|
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
6561
|
-
|
|
6583
|
+
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
6562
6584
|
}
|
|
6563
6585
|
if (visibleFillOpacity !== DEFAULT_VISIBLE_FILL_OPACITY) {
|
|
6564
|
-
|
|
6586
|
+
cache2.visibleFillOpacityById.set(featureId, visibleFillOpacity);
|
|
6565
6587
|
}
|
|
6566
|
-
if (isTimelineHidden)
|
|
6588
|
+
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
6567
6589
|
}
|
|
6568
|
-
function applySelectionFastPath(
|
|
6569
|
-
if (!
|
|
6570
|
-
const diff = buildSelectionDiff(
|
|
6590
|
+
function applySelectionFastPath(cache2, nextSelectedIds, source) {
|
|
6591
|
+
if (!cache2 || !cache2.updatable || !source) return false;
|
|
6592
|
+
const diff = buildSelectionDiff(cache2, nextSelectedIds);
|
|
6571
6593
|
if (diff) {
|
|
6572
6594
|
try {
|
|
6573
6595
|
source.updateData(diff);
|
|
@@ -6577,29 +6599,29 @@ function applySelectionFastPath(cache, nextSelectedIds, source) {
|
|
|
6577
6599
|
}
|
|
6578
6600
|
const applied = /* @__PURE__ */ new Set();
|
|
6579
6601
|
nextSelectedIds.forEach((id) => {
|
|
6580
|
-
if (
|
|
6602
|
+
if (cache2.presentIds.has(id)) applied.add(id);
|
|
6581
6603
|
});
|
|
6582
|
-
|
|
6604
|
+
cache2.appliedSelectedIds = applied;
|
|
6583
6605
|
return true;
|
|
6584
6606
|
}
|
|
6585
6607
|
function needsDrawSelectionUpdate(input) {
|
|
6586
6608
|
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
6587
6609
|
}
|
|
6588
|
-
function buildSelectionDiff(
|
|
6610
|
+
function buildSelectionDiff(cache2, nextSelectedIds) {
|
|
6589
6611
|
const update = [];
|
|
6590
|
-
|
|
6591
|
-
if (!nextSelectedIds.has(id) &&
|
|
6612
|
+
cache2.appliedSelectedIds.forEach((id) => {
|
|
6613
|
+
if (!nextSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
6592
6614
|
update.push({
|
|
6593
6615
|
id,
|
|
6594
6616
|
addOrUpdateProperties: [
|
|
6595
6617
|
{ key: "isSelected", value: 0 },
|
|
6596
|
-
{ key: "_labelPriority", value:
|
|
6618
|
+
{ key: "_labelPriority", value: cache2.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
|
|
6597
6619
|
]
|
|
6598
6620
|
});
|
|
6599
6621
|
}
|
|
6600
6622
|
});
|
|
6601
6623
|
nextSelectedIds.forEach((id) => {
|
|
6602
|
-
if (!
|
|
6624
|
+
if (!cache2.appliedSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
6603
6625
|
update.push({
|
|
6604
6626
|
id,
|
|
6605
6627
|
addOrUpdateProperties: [
|
|
@@ -6611,13 +6633,13 @@ function buildSelectionDiff(cache, nextSelectedIds) {
|
|
|
6611
6633
|
});
|
|
6612
6634
|
return update.length > 0 ? { update } : null;
|
|
6613
6635
|
}
|
|
6614
|
-
function buildTimelineVisibilityDiff(
|
|
6636
|
+
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
6615
6637
|
const update = [];
|
|
6616
6638
|
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
6617
|
-
|
|
6639
|
+
cache2.presentIds.forEach((id) => {
|
|
6618
6640
|
const nextHidden = nextVisibleSet !== null && !nextVisibleSet.has(id);
|
|
6619
6641
|
if (nextHidden) nextHiddenIds.add(id);
|
|
6620
|
-
if (nextHidden ===
|
|
6642
|
+
if (nextHidden === cache2.appliedHiddenIds.has(id)) return;
|
|
6621
6643
|
if (nextHidden) {
|
|
6622
6644
|
update.push({
|
|
6623
6645
|
id,
|
|
@@ -6631,8 +6653,8 @@ function buildTimelineVisibilityDiff(cache, nextVisibleSet) {
|
|
|
6631
6653
|
update.push({
|
|
6632
6654
|
id,
|
|
6633
6655
|
addOrUpdateProperties: [
|
|
6634
|
-
{ key: "stroke-opacity", value:
|
|
6635
|
-
{ key: "fill-opacity", value:
|
|
6656
|
+
{ key: "stroke-opacity", value: cache2.visibleStrokeOpacityById.get(id) ?? DEFAULT_VISIBLE_STROKE_OPACITY },
|
|
6657
|
+
{ key: "fill-opacity", value: cache2.visibleFillOpacityById.get(id) ?? DEFAULT_VISIBLE_FILL_OPACITY },
|
|
6636
6658
|
{ key: "isTimelineHidden", value: 0 }
|
|
6637
6659
|
]
|
|
6638
6660
|
});
|
|
@@ -6640,10 +6662,10 @@ function buildTimelineVisibilityDiff(cache, nextVisibleSet) {
|
|
|
6640
6662
|
});
|
|
6641
6663
|
return { diff: update.length > 0 ? { update } : null, nextHiddenIds };
|
|
6642
6664
|
}
|
|
6643
|
-
function applyTimelineFastPath(
|
|
6665
|
+
function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
6644
6666
|
var _a;
|
|
6645
|
-
if (!
|
|
6646
|
-
const { diff, nextHiddenIds } = buildTimelineVisibilityDiff(
|
|
6667
|
+
if (!cache2 || !cache2.updatable || !source) return { applied: false, toggled: 0 };
|
|
6668
|
+
const { diff, nextHiddenIds } = buildTimelineVisibilityDiff(cache2, nextVisibleSet);
|
|
6647
6669
|
if (diff) {
|
|
6648
6670
|
try {
|
|
6649
6671
|
source.updateData(diff);
|
|
@@ -6651,9 +6673,204 @@ function applyTimelineFastPath(cache, nextVisibleSet, source) {
|
|
|
6651
6673
|
return { applied: false, toggled: 0 };
|
|
6652
6674
|
}
|
|
6653
6675
|
}
|
|
6654
|
-
|
|
6676
|
+
cache2.appliedHiddenIds = nextHiddenIds;
|
|
6655
6677
|
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
6656
6678
|
}
|
|
6679
|
+
const TRACE_DEFAULT_COLOR = "#3b82f6";
|
|
6680
|
+
const TRACE_UNGROUPED_KEY = "__all__";
|
|
6681
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
6682
|
+
function getTraceGroups(features, groupByField) {
|
|
6683
|
+
const field = groupByField || null;
|
|
6684
|
+
let byField = cache.get(features);
|
|
6685
|
+
if (!byField) {
|
|
6686
|
+
byField = /* @__PURE__ */ new Map();
|
|
6687
|
+
cache.set(features, byField);
|
|
6688
|
+
}
|
|
6689
|
+
const fieldKey = field ?? "";
|
|
6690
|
+
let groups = byField.get(fieldKey);
|
|
6691
|
+
if (!groups) {
|
|
6692
|
+
groups = buildTraceGroups(features, field);
|
|
6693
|
+
byField.set(fieldKey, groups);
|
|
6694
|
+
}
|
|
6695
|
+
return groups;
|
|
6696
|
+
}
|
|
6697
|
+
function sortKey(time) {
|
|
6698
|
+
return Number.isNaN(time) ? -Infinity : time;
|
|
6699
|
+
}
|
|
6700
|
+
function compareStaged(a, b) {
|
|
6701
|
+
const ka = sortKey(a.time);
|
|
6702
|
+
const kb = sortKey(b.time);
|
|
6703
|
+
if (ka < kb) return -1;
|
|
6704
|
+
if (ka > kb) return 1;
|
|
6705
|
+
return 0;
|
|
6706
|
+
}
|
|
6707
|
+
function buildTraceGroups(features, field) {
|
|
6708
|
+
var _a;
|
|
6709
|
+
const staged = /* @__PURE__ */ new Map();
|
|
6710
|
+
for (const feature of features) {
|
|
6711
|
+
if (feature.id == null || feature.geometry.type !== "Point" || !((_a = feature.properties) == null ? void 0 : _a.startDate)) continue;
|
|
6712
|
+
const raw = field ? feature.properties[field] : void 0;
|
|
6713
|
+
const key = field && raw ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
6714
|
+
let bucket = staged.get(key);
|
|
6715
|
+
if (!bucket) {
|
|
6716
|
+
bucket = [];
|
|
6717
|
+
staged.set(key, bucket);
|
|
6718
|
+
}
|
|
6719
|
+
bucket.push({ feature, time: new Date(feature.properties.startDate).getTime() });
|
|
6720
|
+
}
|
|
6721
|
+
const count = staged.size;
|
|
6722
|
+
const groups = [];
|
|
6723
|
+
staged.forEach((bucket, key) => {
|
|
6724
|
+
bucket.sort(compareStaged);
|
|
6725
|
+
groups.push({
|
|
6726
|
+
key,
|
|
6727
|
+
points: bucket.map((p) => p.feature),
|
|
6728
|
+
ids: bucket.map((p) => String(p.feature.id)),
|
|
6729
|
+
times: bucket.map((p) => p.time),
|
|
6730
|
+
color: traceGroupColor(key, groups.length, count),
|
|
6731
|
+
label: field && key !== TRACE_UNGROUPED_KEY ? key : null,
|
|
6732
|
+
pairStats: /* @__PURE__ */ new Map()
|
|
6733
|
+
});
|
|
6734
|
+
});
|
|
6735
|
+
return groups;
|
|
6736
|
+
}
|
|
6737
|
+
function traceGroupColor(key, index, count) {
|
|
6738
|
+
if (key === TRACE_UNGROUPED_KEY) return TRACE_DEFAULT_COLOR;
|
|
6739
|
+
return `hsl(${index * 360 / count % 360}, 70%, 50%)`;
|
|
6740
|
+
}
|
|
6741
|
+
function visibleTraceIndices(group, isVisible) {
|
|
6742
|
+
const indices = [];
|
|
6743
|
+
for (let i = 0; i < group.ids.length; i++) {
|
|
6744
|
+
if (isVisible(group.ids[i])) indices.push(i);
|
|
6745
|
+
}
|
|
6746
|
+
return indices;
|
|
6747
|
+
}
|
|
6748
|
+
function timelineVisibility(visibleSet) {
|
|
6749
|
+
return visibleSet === null ? () => true : (id) => visibleSet.has(id);
|
|
6750
|
+
}
|
|
6751
|
+
function traceSegmentStats(group, fromIndex, toIndex) {
|
|
6752
|
+
const key = `${fromIndex}:${toIndex}`;
|
|
6753
|
+
const cached = group.pairStats.get(key);
|
|
6754
|
+
if (cached) return cached;
|
|
6755
|
+
const from = group.points[fromIndex].geometry;
|
|
6756
|
+
const to = group.points[toIndex].geometry;
|
|
6757
|
+
const distanceKm = turf.distance(turf.point(from.coordinates), turf.point(to.coordinates), { units: "kilometers" });
|
|
6758
|
+
const durationMs = group.times[toIndex] - group.times[fromIndex];
|
|
6759
|
+
const durationHours = durationMs / (1e3 * 60 * 60);
|
|
6760
|
+
const avgSpeedKmh = durationHours > 0 ? distanceKm / durationHours : 0;
|
|
6761
|
+
const stats = {
|
|
6762
|
+
duration: formatDuration(durationMs),
|
|
6763
|
+
distance: distanceKm < 1 ? `${Math.round(distanceKm * 1e3)}m` : `${distanceKm.toFixed(2)}km`,
|
|
6764
|
+
avgSpeed: avgSpeedKmh < 1 ? `${(avgSpeedKmh * 1e3).toFixed(0)}m/h` : `${avgSpeedKmh.toFixed(1)}km/h`
|
|
6765
|
+
};
|
|
6766
|
+
group.pairStats.set(key, stats);
|
|
6767
|
+
return stats;
|
|
6768
|
+
}
|
|
6769
|
+
function formatDuration(durationMs) {
|
|
6770
|
+
if (durationMs < 6e4) return `${Math.round(durationMs / 1e3)}s`;
|
|
6771
|
+
if (durationMs < 36e5) return `${Math.round(durationMs / 6e4)}m`;
|
|
6772
|
+
if (durationMs < 864e5) {
|
|
6773
|
+
return `${Math.floor(durationMs / 36e5)}h ${Math.round(durationMs % 36e5 / 6e4)}m`;
|
|
6774
|
+
}
|
|
6775
|
+
return `${Math.floor(durationMs / 864e5)}d ${Math.round(durationMs % 864e5 / 36e5)}h`;
|
|
6776
|
+
}
|
|
6777
|
+
function traceSegmentId(groupIndex, fromIndex, toIndex) {
|
|
6778
|
+
return `${groupIndex}:${fromIndex}:${toIndex}`;
|
|
6779
|
+
}
|
|
6780
|
+
function traceSegmentFeature(group, groupIndex, fromIndex, toIndex) {
|
|
6781
|
+
var _a, _b;
|
|
6782
|
+
const from = group.points[fromIndex];
|
|
6783
|
+
const to = group.points[toIndex];
|
|
6784
|
+
return {
|
|
6785
|
+
type: "Feature",
|
|
6786
|
+
id: traceSegmentId(groupIndex, fromIndex, toIndex),
|
|
6787
|
+
properties: {
|
|
6788
|
+
group: group.key,
|
|
6789
|
+
color: group.color,
|
|
6790
|
+
...traceSegmentStats(group, fromIndex, toIndex),
|
|
6791
|
+
fromName: ((_a = from.properties) == null ? void 0 : _a.name) || "",
|
|
6792
|
+
toName: ((_b = to.properties) == null ? void 0 : _b.name) || ""
|
|
6793
|
+
},
|
|
6794
|
+
geometry: {
|
|
6795
|
+
type: "LineString",
|
|
6796
|
+
coordinates: [from.geometry.coordinates, to.geometry.coordinates]
|
|
6797
|
+
}
|
|
6798
|
+
};
|
|
6799
|
+
}
|
|
6800
|
+
const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
6801
|
+
const TRACE_POINT_RADIUS = 2;
|
|
6802
|
+
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
6803
|
+
function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
6804
|
+
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [], basePriorities: [] };
|
|
6805
|
+
const paintedVisible = (id) => !paint.appliedHiddenIds.has(id);
|
|
6806
|
+
const nextVisible = timelineVisibility(nextVisibleSet);
|
|
6807
|
+
trace.groups.forEach((group, groupIndex) => {
|
|
6808
|
+
const prev = visibleTraceIndices(group, paintedVisible);
|
|
6809
|
+
const next = visibleTraceIndices(group, nextVisible);
|
|
6810
|
+
const prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
6811
|
+
const nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
6812
|
+
if (prevEndpoint !== nextEndpoint) {
|
|
6813
|
+
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, paint, group, group.ids[prevEndpoint], false);
|
|
6814
|
+
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, paint, group, group.ids[nextEndpoint], true);
|
|
6815
|
+
}
|
|
6816
|
+
diffConsecutivePairs(
|
|
6817
|
+
prev,
|
|
6818
|
+
next,
|
|
6819
|
+
(from, to) => diff.segmentRemove.push(traceSegmentId(groupIndex, from, to)),
|
|
6820
|
+
(from, to) => diff.segmentAdd.push(traceSegmentFeature(group, groupIndex, from, to))
|
|
6821
|
+
);
|
|
6822
|
+
});
|
|
6823
|
+
return diff;
|
|
6824
|
+
}
|
|
6825
|
+
function pushEndpointUpdate(diff, trace, paint, group, id, isEndpoint) {
|
|
6826
|
+
const point = trace.pointPaint.get(id);
|
|
6827
|
+
if (!point) return;
|
|
6828
|
+
const labelled = isEndpoint && group.label !== null;
|
|
6829
|
+
const basePriority = labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point.basePriority;
|
|
6830
|
+
diff.pointUpdates.push({
|
|
6831
|
+
id,
|
|
6832
|
+
addOrUpdateProperties: [
|
|
6833
|
+
{ key: "pointRadius", value: isEndpoint ? point.endpointRadius : TRACE_POINT_RADIUS },
|
|
6834
|
+
{ key: "name", value: labelled ? group.label : point.name },
|
|
6835
|
+
{ key: "isTraceLabel", value: labelled },
|
|
6836
|
+
{ key: "_labelPriority", value: paint.appliedSelectedIds.has(id) ? 0 : basePriority }
|
|
6837
|
+
]
|
|
6838
|
+
});
|
|
6839
|
+
diff.basePriorities.push([id, basePriority]);
|
|
6840
|
+
}
|
|
6841
|
+
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
6842
|
+
let i = 0;
|
|
6843
|
+
let j = 0;
|
|
6844
|
+
while (i < prev.length - 1 || j < next.length - 1) {
|
|
6845
|
+
const prevFrom = i < prev.length - 1 ? prev[i] : Infinity;
|
|
6846
|
+
const nextFrom = j < next.length - 1 ? next[j] : Infinity;
|
|
6847
|
+
const prevTo = prev[i + 1];
|
|
6848
|
+
const nextTo = next[j + 1];
|
|
6849
|
+
if (prevFrom === nextFrom && prevTo === nextTo) {
|
|
6850
|
+
i++;
|
|
6851
|
+
j++;
|
|
6852
|
+
} else if (prevFrom < nextFrom || prevFrom === nextFrom && prevTo < nextTo) {
|
|
6853
|
+
onRemove(prevFrom, prevTo);
|
|
6854
|
+
i++;
|
|
6855
|
+
} else {
|
|
6856
|
+
onAdd(nextFrom, nextTo);
|
|
6857
|
+
j++;
|
|
6858
|
+
}
|
|
6859
|
+
}
|
|
6860
|
+
}
|
|
6861
|
+
function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
|
|
6862
|
+
try {
|
|
6863
|
+
if (diff.pointUpdates.length > 0) pointSource.updateData({ update: diff.pointUpdates });
|
|
6864
|
+
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
6865
|
+
segmentSource.updateData({ add: diff.segmentAdd, remove: diff.segmentRemove });
|
|
6866
|
+
}
|
|
6867
|
+
} catch (error) {
|
|
6868
|
+
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
6869
|
+
return false;
|
|
6870
|
+
}
|
|
6871
|
+
diff.basePriorities.forEach(([id, priority]) => paint.basePriorityById.set(id, priority));
|
|
6872
|
+
return true;
|
|
6873
|
+
}
|
|
6657
6874
|
function deepClone(value) {
|
|
6658
6875
|
try {
|
|
6659
6876
|
return structuredClone(value);
|
|
@@ -6710,15 +6927,15 @@ function prepareFeaturesForLayer(input, caller, cap) {
|
|
|
6710
6927
|
const logging = mapPerfLogEnabled();
|
|
6711
6928
|
const started = logging ? performance.now() : 0;
|
|
6712
6929
|
const capped = cap ? capFeatures(input, cap) : null;
|
|
6713
|
-
|
|
6714
|
-
const count =
|
|
6930
|
+
const source = capped ? capped.features : input;
|
|
6931
|
+
const count = source.length;
|
|
6715
6932
|
const features = new Array(count);
|
|
6716
6933
|
const featureIds = new Array(count);
|
|
6717
6934
|
let hasTemporal = false;
|
|
6718
6935
|
let temporalCount = 0;
|
|
6719
6936
|
let reused = 0;
|
|
6720
6937
|
for (let i = 0; i < count; i++) {
|
|
6721
|
-
const f =
|
|
6938
|
+
const f = source[i];
|
|
6722
6939
|
const props = f.properties || {};
|
|
6723
6940
|
if (!hasAnyTemporalValue(props)) {
|
|
6724
6941
|
if (typeof f.id === "string" && f.id) {
|
|
@@ -6916,6 +7133,269 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
6916
7133
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
6917
7134
|
return selectedIds;
|
|
6918
7135
|
}
|
|
7136
|
+
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
7137
|
+
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
7138
|
+
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
7139
|
+
function computeLabelNeverHide(label) {
|
|
7140
|
+
return (label == null ? void 0 : label.neverHide) && !label.hidden ? 1 : 0;
|
|
7141
|
+
}
|
|
7142
|
+
function buildCustomLabelLayout() {
|
|
7143
|
+
return {
|
|
7144
|
+
// Hide labels for trace points (except last point which has isTraceLabel),
|
|
7145
|
+
// arrows handled by the custom-arrow-labels layer. Features blanked by
|
|
7146
|
+
// heatmap/cluster modes stay blank in BOTH layers: "never hide"
|
|
7147
|
+
// exempts labels from collision and density culling, it does not resurrect
|
|
7148
|
+
// labels other mode choices explicitly blank.
|
|
7149
|
+
"text-field": [
|
|
7150
|
+
"case",
|
|
7151
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
7152
|
+
"",
|
|
7153
|
+
["==", ["get", "isHiddenByCluster"], 1],
|
|
7154
|
+
"",
|
|
7155
|
+
["==", ["get", "kind"], "arrow"],
|
|
7156
|
+
"",
|
|
7157
|
+
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
7158
|
+
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
7159
|
+
"",
|
|
7160
|
+
["==", ["get", "kind"], "text"],
|
|
7161
|
+
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
7162
|
+
["coalesce", ["get", "name"], ""]
|
|
7163
|
+
],
|
|
7164
|
+
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
7165
|
+
"text-size": [
|
|
7166
|
+
"case",
|
|
7167
|
+
["==", ["get", "kind"], "text"],
|
|
7168
|
+
["coalesce", ["get", "fontSize"], 14],
|
|
7169
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7170
|
+
14,
|
|
7171
|
+
12
|
|
7172
|
+
],
|
|
7173
|
+
// Text features: center anchor; others: top anchor
|
|
7174
|
+
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
7175
|
+
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
7176
|
+
"text-padding": 2,
|
|
7177
|
+
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
7178
|
+
"text-font": [
|
|
7179
|
+
"case",
|
|
7180
|
+
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
7181
|
+
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
7182
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7183
|
+
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
7184
|
+
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
7185
|
+
]
|
|
7186
|
+
};
|
|
7187
|
+
}
|
|
7188
|
+
function buildCustomLabelPaint() {
|
|
7189
|
+
return {
|
|
7190
|
+
// Text features use fontColor; others use default
|
|
7191
|
+
"text-color": [
|
|
7192
|
+
"case",
|
|
7193
|
+
["==", ["get", "kind"], "text"],
|
|
7194
|
+
["coalesce", ["get", "fontColor"], "#000000"],
|
|
7195
|
+
"#1f2937"
|
|
7196
|
+
],
|
|
7197
|
+
"text-halo-color": "#ffffff",
|
|
7198
|
+
// Thicker halo for trace labels and text features
|
|
7199
|
+
"text-halo-width": [
|
|
7200
|
+
"case",
|
|
7201
|
+
["==", ["get", "kind"], "text"],
|
|
7202
|
+
2,
|
|
7203
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7204
|
+
2,
|
|
7205
|
+
1.5
|
|
7206
|
+
],
|
|
7207
|
+
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
7208
|
+
};
|
|
7209
|
+
}
|
|
7210
|
+
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
7211
|
+
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
7212
|
+
"kind",
|
|
7213
|
+
"text",
|
|
7214
|
+
"label",
|
|
7215
|
+
"fontSize",
|
|
7216
|
+
"fontColor",
|
|
7217
|
+
"fontWeight",
|
|
7218
|
+
"arrowSize"
|
|
7219
|
+
];
|
|
7220
|
+
function sanitizeValue(value) {
|
|
7221
|
+
if (value === null || value === void 0) return null;
|
|
7222
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
7223
|
+
if (value instanceof Date) return value.toISOString();
|
|
7224
|
+
return String(value);
|
|
7225
|
+
}
|
|
7226
|
+
function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
7227
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
7228
|
+
const featureId = String(f.id);
|
|
7229
|
+
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
7230
|
+
const isTimelineVisible = ctx.timelineVisibleIds === null || ctx.timelineVisibleIds.has(featureId);
|
|
7231
|
+
const baseOpacity = ((_a = f.properties) == null ? void 0 : _a["stroke-opacity"]) ?? DEFAULT_VISIBLE_STROKE_OPACITY;
|
|
7232
|
+
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
7233
|
+
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7234
|
+
if (colorConfig) {
|
|
7235
|
+
strokeColor = resolveFeatureColor(
|
|
7236
|
+
colorConfig,
|
|
7237
|
+
f.properties,
|
|
7238
|
+
strokeColor,
|
|
7239
|
+
layer ? ctx.colorFieldRanges.get(layer.id) : void 0
|
|
7240
|
+
);
|
|
7241
|
+
}
|
|
7242
|
+
let strokeWidth = ((_c = f.properties) == null ? void 0 : _c["stroke-width"]) || 2;
|
|
7243
|
+
let pointRadius = Math.round(3 + strokeWidth);
|
|
7244
|
+
const sizeConfig = visualConfig == null ? void 0 : visualConfig.size;
|
|
7245
|
+
if (sizeConfig) {
|
|
7246
|
+
if (sizeConfig.mode === "override" && sizeConfig.overrideValue !== void 0) {
|
|
7247
|
+
strokeWidth = Math.max(1, Math.min(10, sizeConfig.overrideValue));
|
|
7248
|
+
pointRadius = Math.round(3 + strokeWidth);
|
|
7249
|
+
} else if (sizeConfig.mode === "field" && sizeConfig.fieldName && layer) {
|
|
7250
|
+
const range = ctx.sizeFieldRanges.get(layer.id);
|
|
7251
|
+
if (range && f.properties) {
|
|
7252
|
+
const rawVal = f.properties[sizeConfig.fieldName];
|
|
7253
|
+
const val = typeof rawVal === "number" ? rawVal : typeof rawVal === "string" && rawVal.trim() !== "" ? Number(rawVal) : NaN;
|
|
7254
|
+
if (isFinite(val)) {
|
|
7255
|
+
const normalized = range.max > range.min ? (val - range.min) / (range.max - range.min) : 0.5;
|
|
7256
|
+
strokeWidth = 2 + normalized * 8;
|
|
7257
|
+
pointRadius = Math.round(2 + normalized * 16);
|
|
7258
|
+
}
|
|
7259
|
+
}
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
const isTracePoint = ctx.tracePointIds.has(featureId);
|
|
7263
|
+
const isLastTracePoint = ctx.lastTracePointIds.has(featureId);
|
|
7264
|
+
const traceLabel = ctx.lastTracePointLabels.get(featureId);
|
|
7265
|
+
let traceEndpointRadius = null;
|
|
7266
|
+
if (isTracePoint && f.geometry.type === "Point") {
|
|
7267
|
+
strokeColor = ctx.tracePointColors.get(featureId) || strokeColor;
|
|
7268
|
+
traceEndpointRadius = Math.max(pointRadius, TRACE_ENDPOINT_MIN_RADIUS);
|
|
7269
|
+
pointRadius = isLastTracePoint ? traceEndpointRadius : TRACE_POINT_RADIUS;
|
|
7270
|
+
}
|
|
7271
|
+
let labelText = ((_d = f.properties) == null ? void 0 : _d.name) || "";
|
|
7272
|
+
const labelConfig = visualConfig == null ? void 0 : visualConfig.label;
|
|
7273
|
+
if (labelConfig == null ? void 0 : labelConfig.hidden) {
|
|
7274
|
+
labelText = "";
|
|
7275
|
+
} else if (labelConfig) {
|
|
7276
|
+
if (labelConfig.mode === "fixed" && labelConfig.fixedText) {
|
|
7277
|
+
labelText = labelConfig.fixedText;
|
|
7278
|
+
} else if (labelConfig.mode === "field" && labelConfig.fieldName && f.properties) {
|
|
7279
|
+
const fieldValue = f.properties[labelConfig.fieldName];
|
|
7280
|
+
labelText = fieldValue !== void 0 && fieldValue !== null ? String(fieldValue) : "";
|
|
7281
|
+
}
|
|
7282
|
+
}
|
|
7283
|
+
const nonTraceLabelText = labelText;
|
|
7284
|
+
if (traceLabel) {
|
|
7285
|
+
labelText = traceLabel;
|
|
7286
|
+
}
|
|
7287
|
+
let featureIcon = ((_e = f.properties) == null ? void 0 : _e.pointIcon) || ((_f = f.properties) == null ? void 0 : _f.icon);
|
|
7288
|
+
let featureIconSize = ((_g = f.properties) == null ? void 0 : _g.pointIconSize) || ((_h = f.properties) == null ? void 0 : _h.iconSize) || 24;
|
|
7289
|
+
const iconConfig = visualConfig == null ? void 0 : visualConfig.icon;
|
|
7290
|
+
if ((iconConfig == null ? void 0 : iconConfig.enabled) && iconConfig.icon && !featureIcon) {
|
|
7291
|
+
featureIcon = iconConfig.icon;
|
|
7292
|
+
featureIconSize = iconConfig.size ?? 24;
|
|
7293
|
+
}
|
|
7294
|
+
const isPoint = f.geometry.type === "Point";
|
|
7295
|
+
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled) === true;
|
|
7296
|
+
const hideByCluster = isPoint && ((_j = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _j.enabled) === true && !((_k = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _k.showPointDots);
|
|
7297
|
+
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
7298
|
+
const hideFlatFor3DOnly = isLine && (layer == null ? void 0 : layer.hasAltitudeData) && (layer == null ? void 0 : layer.altitudeDisplayMode) === "3d";
|
|
7299
|
+
const sanitizedProps = {};
|
|
7300
|
+
const props = f.properties;
|
|
7301
|
+
if (props) {
|
|
7302
|
+
if (slim) {
|
|
7303
|
+
RENDER_PASSTHROUGH_KEYS.forEach((key) => {
|
|
7304
|
+
if (key in props) sanitizedProps[key] = sanitizeValue(props[key]);
|
|
7305
|
+
});
|
|
7306
|
+
if (typeof props.kind === "string") {
|
|
7307
|
+
ANNOTATION_PASSTHROUGH_KEYS.forEach((key) => {
|
|
7308
|
+
if (key in props) sanitizedProps[key] = sanitizeValue(props[key]);
|
|
7309
|
+
});
|
|
7310
|
+
}
|
|
7311
|
+
} else {
|
|
7312
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
7313
|
+
sanitizedProps[key] = sanitizeValue(value);
|
|
7314
|
+
});
|
|
7315
|
+
}
|
|
7316
|
+
}
|
|
7317
|
+
const isFeatureSelected = ctx.selectionEnabled && ctx.selectedIds.has(featureId) ? 1 : 0;
|
|
7318
|
+
let nonTracePriority = DEFAULT_LABEL_PRIORITY;
|
|
7319
|
+
if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
7320
|
+
nonTracePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
7321
|
+
} else {
|
|
7322
|
+
const idStr = String(featureId);
|
|
7323
|
+
let h = 0;
|
|
7324
|
+
for (let i = 0; i < idStr.length; i++) {
|
|
7325
|
+
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
7326
|
+
h |= 0;
|
|
7327
|
+
}
|
|
7328
|
+
nonTracePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
7329
|
+
}
|
|
7330
|
+
const basePriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
7331
|
+
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
7332
|
+
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
7333
|
+
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
7334
|
+
return {
|
|
7335
|
+
feature: {
|
|
7336
|
+
type: "Feature",
|
|
7337
|
+
id: featureId,
|
|
7338
|
+
geometry: f.geometry,
|
|
7339
|
+
properties: {
|
|
7340
|
+
// Record fields (draw features) or just the passthroughs (read-only)
|
|
7341
|
+
...sanitizedProps,
|
|
7342
|
+
// Override with computed visual properties
|
|
7343
|
+
id: featureId,
|
|
7344
|
+
name: labelText,
|
|
7345
|
+
isSelected: isFeatureSelected,
|
|
7346
|
+
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
7347
|
+
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
7348
|
+
isTracePoint: isTracePoint ? true : false,
|
|
7349
|
+
isTraceLabel: traceLabel ? true : false,
|
|
7350
|
+
icon: featureIcon || "",
|
|
7351
|
+
iconSize: featureIconSize,
|
|
7352
|
+
stroke: strokeColor,
|
|
7353
|
+
"stroke-width": strokeWidth,
|
|
7354
|
+
"stroke-opacity": isTimelineVisible ? visibleStrokeOpacity : 0,
|
|
7355
|
+
fill: strokeColor,
|
|
7356
|
+
"fill-opacity": isTimelineVisible ? visibleFillOpacity : 0,
|
|
7357
|
+
pointRadius,
|
|
7358
|
+
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
7359
|
+
_labelPriority: labelPriority,
|
|
7360
|
+
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_o = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _o.label)
|
|
7361
|
+
}
|
|
7362
|
+
},
|
|
7363
|
+
paint: {
|
|
7364
|
+
featureId,
|
|
7365
|
+
basePriority,
|
|
7366
|
+
selected: isFeatureSelected === 1,
|
|
7367
|
+
visibleStrokeOpacity,
|
|
7368
|
+
visibleFillOpacity,
|
|
7369
|
+
timelineHidden: !isTimelineVisible
|
|
7370
|
+
},
|
|
7371
|
+
tracePaint: traceEndpointRadius !== null ? { name: nonTraceLabelText, endpointRadius: traceEndpointRadius, basePriority: nonTracePriority } : null
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7374
|
+
function renderedFeatureId(f) {
|
|
7375
|
+
var _a;
|
|
7376
|
+
const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
|
|
7377
|
+
if (fromProps !== void 0 && fromProps !== null && fromProps !== "") return String(fromProps);
|
|
7378
|
+
if (f.id !== void 0 && f.id !== null && f.id !== "") return String(f.id);
|
|
7379
|
+
return null;
|
|
7380
|
+
}
|
|
7381
|
+
function resolveTooltipFeature(rendered, lookup) {
|
|
7382
|
+
const id = renderedFeatureId(rendered);
|
|
7383
|
+
const stored = id === null ? null : lookup(id);
|
|
7384
|
+
if (stored) {
|
|
7385
|
+
return deepClone({
|
|
7386
|
+
type: "Feature",
|
|
7387
|
+
geometry: stored.geometry,
|
|
7388
|
+
properties: stored.properties ?? {},
|
|
7389
|
+
id: stored.id
|
|
7390
|
+
});
|
|
7391
|
+
}
|
|
7392
|
+
return {
|
|
7393
|
+
type: "Feature",
|
|
7394
|
+
geometry: rendered.geometry,
|
|
7395
|
+
properties: { ...rendered.properties ?? {} },
|
|
7396
|
+
id: rendered.id
|
|
7397
|
+
};
|
|
7398
|
+
}
|
|
6919
7399
|
const CLUSTER_COUNT_VALUE_PROP = "__cluster_count_value";
|
|
6920
7400
|
const CLUSTER_SUM_PROP = "value_sum";
|
|
6921
7401
|
const CLUSTER_MEMBER_ID_PROP = "__cluster_fid";
|
|
@@ -7109,82 +7589,6 @@ function createClusterGradientManager(map, sourceId, options) {
|
|
|
7109
7589
|
}
|
|
7110
7590
|
};
|
|
7111
7591
|
}
|
|
7112
|
-
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
7113
|
-
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
7114
|
-
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
7115
|
-
function computeLabelNeverHide(label) {
|
|
7116
|
-
return (label == null ? void 0 : label.neverHide) && !label.hidden ? 1 : 0;
|
|
7117
|
-
}
|
|
7118
|
-
function buildCustomLabelLayout() {
|
|
7119
|
-
return {
|
|
7120
|
-
// Hide labels for trace points (except last point which has isTraceLabel),
|
|
7121
|
-
// arrows handled by the custom-arrow-labels layer. Features blanked by
|
|
7122
|
-
// heatmap/cluster/trace modes stay blank in BOTH layers: "never hide"
|
|
7123
|
-
// exempts labels from collision and density culling, it does not resurrect
|
|
7124
|
-
// labels other mode choices explicitly blank.
|
|
7125
|
-
"text-field": [
|
|
7126
|
-
"case",
|
|
7127
|
-
["==", ["get", "isHiddenByTrace"], true],
|
|
7128
|
-
"",
|
|
7129
|
-
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
7130
|
-
"",
|
|
7131
|
-
["==", ["get", "isHiddenByCluster"], 1],
|
|
7132
|
-
"",
|
|
7133
|
-
["==", ["get", "kind"], "arrow"],
|
|
7134
|
-
"",
|
|
7135
|
-
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
7136
|
-
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
7137
|
-
"",
|
|
7138
|
-
["==", ["get", "kind"], "text"],
|
|
7139
|
-
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
7140
|
-
["coalesce", ["get", "name"], ""]
|
|
7141
|
-
],
|
|
7142
|
-
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
7143
|
-
"text-size": [
|
|
7144
|
-
"case",
|
|
7145
|
-
["==", ["get", "kind"], "text"],
|
|
7146
|
-
["coalesce", ["get", "fontSize"], 14],
|
|
7147
|
-
["==", ["get", "isTraceLabel"], true],
|
|
7148
|
-
14,
|
|
7149
|
-
12
|
|
7150
|
-
],
|
|
7151
|
-
// Text features: center anchor; others: top anchor
|
|
7152
|
-
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
7153
|
-
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
7154
|
-
"text-padding": 2,
|
|
7155
|
-
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
7156
|
-
"text-font": [
|
|
7157
|
-
"case",
|
|
7158
|
-
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
7159
|
-
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
7160
|
-
["==", ["get", "isTraceLabel"], true],
|
|
7161
|
-
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
7162
|
-
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
7163
|
-
]
|
|
7164
|
-
};
|
|
7165
|
-
}
|
|
7166
|
-
function buildCustomLabelPaint() {
|
|
7167
|
-
return {
|
|
7168
|
-
// Text features use fontColor; others use default
|
|
7169
|
-
"text-color": [
|
|
7170
|
-
"case",
|
|
7171
|
-
["==", ["get", "kind"], "text"],
|
|
7172
|
-
["coalesce", ["get", "fontColor"], "#000000"],
|
|
7173
|
-
"#1f2937"
|
|
7174
|
-
],
|
|
7175
|
-
"text-halo-color": "#ffffff",
|
|
7176
|
-
// Thicker halo for trace labels and text features
|
|
7177
|
-
"text-halo-width": [
|
|
7178
|
-
"case",
|
|
7179
|
-
["==", ["get", "kind"], "text"],
|
|
7180
|
-
2,
|
|
7181
|
-
["==", ["get", "isTraceLabel"], true],
|
|
7182
|
-
2,
|
|
7183
|
-
1.5
|
|
7184
|
-
],
|
|
7185
|
-
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
7186
|
-
};
|
|
7187
|
-
}
|
|
7188
7592
|
const OTHER_BUCKET_KEY = "__other__";
|
|
7189
7593
|
const OTHER_BUCKET_LABEL = "Other";
|
|
7190
7594
|
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
@@ -8028,6 +8432,16 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8028
8432
|
});
|
|
8029
8433
|
return [...drawFeatures, ...readOnly];
|
|
8030
8434
|
}, []);
|
|
8435
|
+
const traceSourceFeatures = react.useCallback((layer, featureById) => {
|
|
8436
|
+
const readOnly = readOnlyFeatures.current.get(layer.id);
|
|
8437
|
+
if (readOnly) return readOnly;
|
|
8438
|
+
const features = [];
|
|
8439
|
+
layer.featureIds.forEach((id) => {
|
|
8440
|
+
const f = featureById.get(id);
|
|
8441
|
+
if (f) features.push(f);
|
|
8442
|
+
});
|
|
8443
|
+
return features;
|
|
8444
|
+
}, []);
|
|
8031
8445
|
const getSelectedFeatures = react.useCallback(() => {
|
|
8032
8446
|
const drawSelected = draw.current ? draw.current.getSelected().features : [];
|
|
8033
8447
|
const readOnlySelected = [];
|
|
@@ -8212,29 +8626,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8212
8626
|
layers.forEach((layer) => {
|
|
8213
8627
|
var _a;
|
|
8214
8628
|
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
8215
|
-
const
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
const f = featById.get(id);
|
|
8219
|
-
if (!f || f.geometry.type !== "Point" || !((_a2 = f.properties) == null ? void 0 : _a2.startDate)) return;
|
|
8220
|
-
layerFeatures.push(f);
|
|
8221
|
-
});
|
|
8222
|
-
if (layerFeatures.length < 1) return;
|
|
8223
|
-
const groupByField = layer.traceConfig.groupByField;
|
|
8224
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8225
|
-
layerFeatures.forEach((f) => {
|
|
8226
|
-
var _a2;
|
|
8227
|
-
const key = groupByField && ((_a2 = f.properties) == null ? void 0 : _a2[groupByField]) ? String(f.properties[groupByField]) : "__all__";
|
|
8228
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
8229
|
-
groups.get(key).push(f);
|
|
8230
|
-
});
|
|
8231
|
-
const groupKeys = Array.from(groups.keys());
|
|
8232
|
-
groupKeys.forEach((key, index) => {
|
|
8233
|
-
const color = key === "__all__" ? "#3b82f6" : `hsl(${index * 360 / groupKeys.length % 360}, 70%, 50%)`;
|
|
8234
|
-
groups.get(key).forEach((f) => {
|
|
8235
|
-
if (f.id) tracePointColors.set(String(f.id), color);
|
|
8236
|
-
});
|
|
8237
|
-
});
|
|
8629
|
+
for (const group of getTraceGroups(traceSourceFeatures(layer, featById), layer.traceConfig.groupByField)) {
|
|
8630
|
+
for (const id of group.ids) tracePointColors.set(id, group.color);
|
|
8631
|
+
}
|
|
8238
8632
|
});
|
|
8239
8633
|
const layerGradientRanges = /* @__PURE__ */ new Map();
|
|
8240
8634
|
selectedFeatureIds.forEach((fid) => {
|
|
@@ -8268,7 +8662,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8268
8662
|
colorMap.set(fid, color);
|
|
8269
8663
|
});
|
|
8270
8664
|
return colorMap;
|
|
8271
|
-
}, [selectedFeatureIds, layers, getAllFeatures]);
|
|
8665
|
+
}, [selectedFeatureIds, layers, getAllFeatures, traceSourceFeatures]);
|
|
8272
8666
|
const countVisibleFeatures = react.useCallback((threshold) => {
|
|
8273
8667
|
const m = map.current;
|
|
8274
8668
|
if (!m) return 0;
|
|
@@ -8287,6 +8681,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8287
8681
|
}, []);
|
|
8288
8682
|
const isSyncingRef = react.useRef(false);
|
|
8289
8683
|
const selectionPaintCacheRef = react.useRef(null);
|
|
8684
|
+
const tracePaintCacheRef = react.useRef(null);
|
|
8290
8685
|
const paintedArrowLinesRef = react.useRef([]);
|
|
8291
8686
|
const renderArrowOverlays = react.useCallback((arrowLines) => {
|
|
8292
8687
|
const mapInstance = map.current;
|
|
@@ -8456,303 +8851,66 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8456
8851
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
8457
8852
|
const lastTracePointLabels = /* @__PURE__ */ new Map();
|
|
8458
8853
|
const tracePointIds = /* @__PURE__ */ new Set();
|
|
8854
|
+
const paintedTraceGroups = [];
|
|
8855
|
+
const traceSegments = [];
|
|
8856
|
+
const tracePointPaint = /* @__PURE__ */ new Map();
|
|
8857
|
+
const isTimelineVisibleId = timelineVisibility(visibleSet);
|
|
8459
8858
|
currentLayers.forEach((layer) => {
|
|
8460
8859
|
var _a;
|
|
8461
8860
|
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
8462
|
-
const
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
const
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
layerFeatures.push(f);
|
|
8469
|
-
});
|
|
8470
|
-
if (layerFeatures.length < 1) return;
|
|
8471
|
-
const groupByField = layer.traceConfig.groupByField;
|
|
8472
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8473
|
-
layerFeatures.forEach((f) => {
|
|
8474
|
-
var _a2;
|
|
8475
|
-
const key = groupByField && ((_a2 = f.properties) == null ? void 0 : _a2[groupByField]) ? String(f.properties[groupByField]) : "__all__";
|
|
8476
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
8477
|
-
groups.get(key).push(f);
|
|
8478
|
-
});
|
|
8479
|
-
const groupKeys = Array.from(groups.keys());
|
|
8480
|
-
const groupColors = /* @__PURE__ */ new Map();
|
|
8481
|
-
groupKeys.forEach((key, index) => {
|
|
8482
|
-
if (key === "__all__") {
|
|
8483
|
-
groupColors.set(key, "#3b82f6");
|
|
8484
|
-
} else {
|
|
8485
|
-
const hue = index * 360 / groupKeys.length % 360;
|
|
8486
|
-
groupColors.set(key, `hsl(${hue}, 70%, 50%)`);
|
|
8861
|
+
const groups = getTraceGroups(traceSourceFeatures(layer, featureById), layer.traceConfig.groupByField);
|
|
8862
|
+
for (const group of groups) {
|
|
8863
|
+
const groupIndex = paintedTraceGroups.push(group) - 1;
|
|
8864
|
+
for (const id of group.ids) {
|
|
8865
|
+
tracePointIds.add(id);
|
|
8866
|
+
tracePointColors.set(id, group.color);
|
|
8487
8867
|
}
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
const
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
});
|
|
8496
|
-
if (sorted.length > 0) {
|
|
8497
|
-
const groupColor = groupColors.get(groupKey) || "#3b82f6";
|
|
8498
|
-
sorted.forEach((point) => {
|
|
8499
|
-
if (point.id) {
|
|
8500
|
-
tracePointIds.add(String(point.id));
|
|
8501
|
-
tracePointColors.set(String(point.id), groupColor);
|
|
8502
|
-
}
|
|
8503
|
-
});
|
|
8504
|
-
const lastPoint = sorted[sorted.length - 1];
|
|
8505
|
-
if (lastPoint.id) {
|
|
8506
|
-
lastTracePointIds.add(String(lastPoint.id));
|
|
8507
|
-
if (groupByField && groupKey !== "__all__") {
|
|
8508
|
-
lastTracePointLabels.set(String(lastPoint.id), groupKey);
|
|
8509
|
-
}
|
|
8510
|
-
}
|
|
8868
|
+
const visible = visibleTraceIndices(group, isTimelineVisibleId);
|
|
8869
|
+
if (visible.length === 0) continue;
|
|
8870
|
+
const endpointId = group.ids[visible[visible.length - 1]];
|
|
8871
|
+
lastTracePointIds.add(endpointId);
|
|
8872
|
+
if (group.label !== null) lastTracePointLabels.set(endpointId, group.label);
|
|
8873
|
+
for (let k = 1; k < visible.length; k++) {
|
|
8874
|
+
traceSegments.push(traceSegmentFeature(group, groupIndex, visible[k - 1], visible[k]));
|
|
8511
8875
|
}
|
|
8512
|
-
}
|
|
8876
|
+
}
|
|
8513
8877
|
});
|
|
8514
8878
|
const paintCache = createSelectionPaintCache();
|
|
8879
|
+
const paintContext = {
|
|
8880
|
+
timelineVisibleIds: visibleSet,
|
|
8881
|
+
selectedIds: selectedIdSet,
|
|
8882
|
+
selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
|
|
8883
|
+
sizeFieldRanges,
|
|
8884
|
+
colorFieldRanges,
|
|
8885
|
+
tracePointIds,
|
|
8886
|
+
lastTracePointIds,
|
|
8887
|
+
lastTracePointLabels,
|
|
8888
|
+
tracePointColors
|
|
8889
|
+
};
|
|
8890
|
+
const drawFeatureCount = drawFeatures.features.length;
|
|
8515
8891
|
const sourceData = {
|
|
8516
8892
|
type: "FeatureCollection",
|
|
8517
|
-
features: allFeatures.map((f) => {
|
|
8518
|
-
|
|
8519
|
-
const
|
|
8520
|
-
const layer = featureToLayer.get(featureId);
|
|
8521
|
-
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
8522
|
-
const isTimelineVisible = visibleSet === null || visibleSet.has(featureId);
|
|
8523
|
-
const baseOpacity = ((_a = f.properties) == null ? void 0 : _a["stroke-opacity"]) ?? DEFAULT_VISIBLE_STROKE_OPACITY;
|
|
8524
|
-
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
8525
|
-
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
8526
|
-
if (colorConfig) {
|
|
8527
|
-
strokeColor = resolveFeatureColor(
|
|
8528
|
-
colorConfig,
|
|
8529
|
-
f.properties,
|
|
8530
|
-
strokeColor,
|
|
8531
|
-
layer ? colorFieldRanges.get(layer.id) : void 0
|
|
8532
|
-
);
|
|
8533
|
-
}
|
|
8534
|
-
let strokeWidth = ((_c = f.properties) == null ? void 0 : _c["stroke-width"]) || 2;
|
|
8535
|
-
let pointRadius = Math.round(3 + strokeWidth);
|
|
8536
|
-
const sizeConfig = visualConfig == null ? void 0 : visualConfig.size;
|
|
8537
|
-
if (sizeConfig) {
|
|
8538
|
-
if (sizeConfig.mode === "override" && sizeConfig.overrideValue !== void 0) {
|
|
8539
|
-
strokeWidth = Math.max(1, Math.min(10, sizeConfig.overrideValue));
|
|
8540
|
-
pointRadius = Math.round(3 + strokeWidth);
|
|
8541
|
-
} else if (sizeConfig.mode === "field" && sizeConfig.fieldName && layer) {
|
|
8542
|
-
const range = sizeFieldRanges.get(layer.id);
|
|
8543
|
-
if (range && f.properties) {
|
|
8544
|
-
const rawVal = f.properties[sizeConfig.fieldName];
|
|
8545
|
-
const val = typeof rawVal === "number" ? rawVal : typeof rawVal === "string" && rawVal.trim() !== "" ? Number(rawVal) : NaN;
|
|
8546
|
-
if (isFinite(val)) {
|
|
8547
|
-
const normalized = range.max > range.min ? (val - range.min) / (range.max - range.min) : 0.5;
|
|
8548
|
-
strokeWidth = 2 + normalized * 8;
|
|
8549
|
-
pointRadius = Math.round(2 + normalized * 16);
|
|
8550
|
-
}
|
|
8551
|
-
}
|
|
8552
|
-
}
|
|
8553
|
-
}
|
|
8554
|
-
const isTracePoint = tracePointIds.has(featureId);
|
|
8555
|
-
const isLastTracePoint = lastTracePointIds.has(featureId);
|
|
8556
|
-
const traceLabel = lastTracePointLabels.get(featureId);
|
|
8557
|
-
if (isTracePoint && f.geometry.type === "Point") {
|
|
8558
|
-
strokeColor = tracePointColors.get(featureId) || strokeColor;
|
|
8559
|
-
if (isLastTracePoint) {
|
|
8560
|
-
pointRadius = Math.max(pointRadius, 8);
|
|
8561
|
-
} else {
|
|
8562
|
-
pointRadius = 2;
|
|
8563
|
-
}
|
|
8564
|
-
}
|
|
8565
|
-
let labelText = ((_d = f.properties) == null ? void 0 : _d.name) || "";
|
|
8566
|
-
const labelConfig = visualConfig == null ? void 0 : visualConfig.label;
|
|
8567
|
-
if (labelConfig == null ? void 0 : labelConfig.hidden) {
|
|
8568
|
-
labelText = "";
|
|
8569
|
-
} else if (labelConfig) {
|
|
8570
|
-
if (labelConfig.mode === "fixed" && labelConfig.fixedText) {
|
|
8571
|
-
labelText = labelConfig.fixedText;
|
|
8572
|
-
} else if (labelConfig.mode === "field" && labelConfig.fieldName && f.properties) {
|
|
8573
|
-
const fieldValue = f.properties[labelConfig.fieldName];
|
|
8574
|
-
labelText = fieldValue !== void 0 && fieldValue !== null ? String(fieldValue) : "";
|
|
8575
|
-
}
|
|
8576
|
-
}
|
|
8577
|
-
if (traceLabel) {
|
|
8578
|
-
labelText = traceLabel;
|
|
8579
|
-
}
|
|
8580
|
-
let featureIcon = ((_e = f.properties) == null ? void 0 : _e.pointIcon) || ((_f = f.properties) == null ? void 0 : _f.icon);
|
|
8581
|
-
let featureIconSize = ((_g = f.properties) == null ? void 0 : _g.pointIconSize) || ((_h = f.properties) == null ? void 0 : _h.iconSize) || 24;
|
|
8582
|
-
const iconConfig = visualConfig == null ? void 0 : visualConfig.icon;
|
|
8583
|
-
if ((iconConfig == null ? void 0 : iconConfig.enabled) && iconConfig.icon && !featureIcon) {
|
|
8584
|
-
featureIcon = iconConfig.icon;
|
|
8585
|
-
featureIconSize = iconConfig.size ?? 24;
|
|
8586
|
-
}
|
|
8587
|
-
const isPoint = f.geometry.type === "Point";
|
|
8588
|
-
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled) === true;
|
|
8589
|
-
const hideByCluster = isPoint && ((_j = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _j.enabled) === true && !((_k = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _k.showPointDots);
|
|
8590
|
-
const hideByTrace = false;
|
|
8591
|
-
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
8592
|
-
const hideFlatFor3DOnly = isLine && (layer == null ? void 0 : layer.hasAltitudeData) && (layer == null ? void 0 : layer.altitudeDisplayMode) === "3d";
|
|
8593
|
-
const sanitizedProps = {};
|
|
8594
|
-
if (f.properties) {
|
|
8595
|
-
Object.entries(f.properties).forEach(([key, value]) => {
|
|
8596
|
-
if (value === null || value === void 0) {
|
|
8597
|
-
sanitizedProps[key] = null;
|
|
8598
|
-
} else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
8599
|
-
sanitizedProps[key] = value;
|
|
8600
|
-
} else if (value instanceof Date) {
|
|
8601
|
-
sanitizedProps[key] = value.toISOString();
|
|
8602
|
-
} else {
|
|
8603
|
-
sanitizedProps[key] = String(value);
|
|
8604
|
-
}
|
|
8605
|
-
});
|
|
8606
|
-
}
|
|
8607
|
-
const isFeatureSelected = (enableSelectionRef.current || enableDrawingRef.current) && selectedIdSet.has(featureId) ? 1 : 0;
|
|
8608
|
-
let basePriority = DEFAULT_LABEL_PRIORITY;
|
|
8609
|
-
if (traceLabel) {
|
|
8610
|
-
basePriority = 5;
|
|
8611
|
-
} else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
8612
|
-
basePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
8613
|
-
} else {
|
|
8614
|
-
const idStr = String(featureId);
|
|
8615
|
-
let h = 0;
|
|
8616
|
-
for (let i = 0; i < idStr.length; i++) {
|
|
8617
|
-
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
8618
|
-
h |= 0;
|
|
8619
|
-
}
|
|
8620
|
-
basePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
8621
|
-
}
|
|
8622
|
-
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
8623
|
-
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
8624
|
-
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
8893
|
+
features: allFeatures.map((f, i) => {
|
|
8894
|
+
const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
|
|
8895
|
+
const p = styled.paint;
|
|
8625
8896
|
recordPaintedFeature(
|
|
8626
8897
|
paintCache,
|
|
8627
|
-
featureId,
|
|
8628
|
-
basePriority,
|
|
8629
|
-
|
|
8630
|
-
visibleStrokeOpacity,
|
|
8631
|
-
visibleFillOpacity,
|
|
8632
|
-
|
|
8898
|
+
p.featureId,
|
|
8899
|
+
p.basePriority,
|
|
8900
|
+
p.selected,
|
|
8901
|
+
p.visibleStrokeOpacity,
|
|
8902
|
+
p.visibleFillOpacity,
|
|
8903
|
+
p.timelineHidden
|
|
8633
8904
|
);
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
id: featureId,
|
|
8637
|
-
geometry: f.geometry,
|
|
8638
|
-
properties: {
|
|
8639
|
-
// Preserve original properties for tooltip display (sanitized)
|
|
8640
|
-
...sanitizedProps,
|
|
8641
|
-
// Override with computed visual properties
|
|
8642
|
-
id: featureId,
|
|
8643
|
-
name: labelText,
|
|
8644
|
-
isSelected: isFeatureSelected,
|
|
8645
|
-
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
8646
|
-
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
8647
|
-
isHiddenByTrace: hideByTrace ? true : false,
|
|
8648
|
-
isTracePoint: isTracePoint ? true : false,
|
|
8649
|
-
isTraceLabel: traceLabel ? true : false,
|
|
8650
|
-
icon: featureIcon || "",
|
|
8651
|
-
iconSize: featureIconSize,
|
|
8652
|
-
stroke: strokeColor,
|
|
8653
|
-
"stroke-width": strokeWidth,
|
|
8654
|
-
"stroke-opacity": isTimelineVisible ? visibleStrokeOpacity : 0,
|
|
8655
|
-
fill: strokeColor,
|
|
8656
|
-
"fill-opacity": isTimelineVisible ? visibleFillOpacity : 0,
|
|
8657
|
-
pointRadius,
|
|
8658
|
-
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
8659
|
-
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
8660
|
-
_labelPriority: labelPriority,
|
|
8661
|
-
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_o = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _o.label)
|
|
8662
|
-
}
|
|
8663
|
-
};
|
|
8905
|
+
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
8906
|
+
return styled.feature;
|
|
8664
8907
|
})
|
|
8665
8908
|
};
|
|
8666
8909
|
source.setData(sourceData);
|
|
8667
8910
|
selectionPaintCacheRef.current = paintCache;
|
|
8668
8911
|
const traceSource = map.current.getSource("trace-features");
|
|
8669
|
-
if (traceSource) {
|
|
8670
|
-
|
|
8671
|
-
currentLayers.forEach((layer) => {
|
|
8672
|
-
var _a;
|
|
8673
|
-
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
8674
|
-
const layerFeatures = [];
|
|
8675
|
-
layer.featureIds.forEach((id) => {
|
|
8676
|
-
var _a2;
|
|
8677
|
-
const f = featureById.get(id);
|
|
8678
|
-
if (!f || f.geometry.type !== "Point" || !((_a2 = f.properties) == null ? void 0 : _a2.startDate)) return;
|
|
8679
|
-
if (visibleSet && f.id && !visibleSet.has(String(f.id))) return;
|
|
8680
|
-
layerFeatures.push(f);
|
|
8681
|
-
});
|
|
8682
|
-
if (layerFeatures.length < 2) return;
|
|
8683
|
-
const groupByField = layer.traceConfig.groupByField;
|
|
8684
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8685
|
-
layerFeatures.forEach((f) => {
|
|
8686
|
-
var _a2;
|
|
8687
|
-
const key = groupByField && ((_a2 = f.properties) == null ? void 0 : _a2[groupByField]) ? String(f.properties[groupByField]) : "__all__";
|
|
8688
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
8689
|
-
groups.get(key).push(f);
|
|
8690
|
-
});
|
|
8691
|
-
const groupKeys = Array.from(groups.keys());
|
|
8692
|
-
const groupColors = /* @__PURE__ */ new Map();
|
|
8693
|
-
groupKeys.forEach((key, index) => {
|
|
8694
|
-
if (key === "__all__") {
|
|
8695
|
-
groupColors.set(key, "#3b82f6");
|
|
8696
|
-
} else {
|
|
8697
|
-
const hue = index * 360 / groupKeys.length % 360;
|
|
8698
|
-
groupColors.set(key, `hsl(${hue}, 70%, 50%)`);
|
|
8699
|
-
}
|
|
8700
|
-
});
|
|
8701
|
-
groups.forEach((groupFeatures, groupKey) => {
|
|
8702
|
-
var _a2, _b, _c, _d;
|
|
8703
|
-
const sorted = [...groupFeatures].sort((a, b) => {
|
|
8704
|
-
var _a3, _b2;
|
|
8705
|
-
const dateA = new Date(((_a3 = a.properties) == null ? void 0 : _a3.startDate) || 0).getTime();
|
|
8706
|
-
const dateB = new Date(((_b2 = b.properties) == null ? void 0 : _b2.startDate) || 0).getTime();
|
|
8707
|
-
return dateA - dateB;
|
|
8708
|
-
});
|
|
8709
|
-
if (sorted.length < 2) return;
|
|
8710
|
-
for (let i = 0; i < sorted.length - 1; i++) {
|
|
8711
|
-
const from = sorted[i];
|
|
8712
|
-
const to = sorted[i + 1];
|
|
8713
|
-
const fromCoords = from.geometry.coordinates;
|
|
8714
|
-
const toCoords = to.geometry.coordinates;
|
|
8715
|
-
const fromPoint = turf__namespace.point(fromCoords);
|
|
8716
|
-
const toPoint = turf__namespace.point(toCoords);
|
|
8717
|
-
const distanceKm = turf__namespace.distance(fromPoint, toPoint, { units: "kilometers" });
|
|
8718
|
-
const fromTime = new Date(((_a2 = from.properties) == null ? void 0 : _a2.startDate) || 0).getTime();
|
|
8719
|
-
const toTime = new Date(((_b = to.properties) == null ? void 0 : _b.startDate) || 0).getTime();
|
|
8720
|
-
const durationMs = toTime - fromTime;
|
|
8721
|
-
const durationHours = durationMs / (1e3 * 60 * 60);
|
|
8722
|
-
const avgSpeedKmh = durationHours > 0 ? distanceKm / durationHours : 0;
|
|
8723
|
-
let durationStr = "";
|
|
8724
|
-
if (durationMs < 6e4) {
|
|
8725
|
-
durationStr = `${Math.round(durationMs / 1e3)}s`;
|
|
8726
|
-
} else if (durationMs < 36e5) {
|
|
8727
|
-
durationStr = `${Math.round(durationMs / 6e4)}m`;
|
|
8728
|
-
} else if (durationMs < 864e5) {
|
|
8729
|
-
durationStr = `${Math.floor(durationMs / 36e5)}h ${Math.round(durationMs % 36e5 / 6e4)}m`;
|
|
8730
|
-
} else {
|
|
8731
|
-
durationStr = `${Math.floor(durationMs / 864e5)}d ${Math.round(durationMs % 864e5 / 36e5)}h`;
|
|
8732
|
-
}
|
|
8733
|
-
const distanceStr = distanceKm < 1 ? `${Math.round(distanceKm * 1e3)}m` : `${distanceKm.toFixed(2)}km`;
|
|
8734
|
-
const speedStr = avgSpeedKmh < 1 ? `${(avgSpeedKmh * 1e3).toFixed(0)}m/h` : `${avgSpeedKmh.toFixed(1)}km/h`;
|
|
8735
|
-
traceSegments.push({
|
|
8736
|
-
type: "Feature",
|
|
8737
|
-
properties: {
|
|
8738
|
-
group: groupKey,
|
|
8739
|
-
color: groupColors.get(groupKey) || "#3b82f6",
|
|
8740
|
-
duration: durationStr,
|
|
8741
|
-
distance: distanceStr,
|
|
8742
|
-
avgSpeed: speedStr,
|
|
8743
|
-
fromName: ((_c = from.properties) == null ? void 0 : _c.name) || "",
|
|
8744
|
-
toName: ((_d = to.properties) == null ? void 0 : _d.name) || ""
|
|
8745
|
-
},
|
|
8746
|
-
geometry: {
|
|
8747
|
-
type: "LineString",
|
|
8748
|
-
coordinates: [fromCoords, toCoords]
|
|
8749
|
-
}
|
|
8750
|
-
});
|
|
8751
|
-
}
|
|
8752
|
-
});
|
|
8753
|
-
});
|
|
8754
|
-
traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
8755
|
-
}
|
|
8912
|
+
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
8913
|
+
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
|
|
8756
8914
|
{
|
|
8757
8915
|
let sawArrowFeature = false;
|
|
8758
8916
|
const arrowLines = [];
|
|
@@ -9662,7 +9820,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9662
9820
|
const buildBuiltinTooltipHtml = (feature) => {
|
|
9663
9821
|
var _a2, _b;
|
|
9664
9822
|
const props = feature.properties || {};
|
|
9665
|
-
const featureId = String(
|
|
9823
|
+
const featureId = String(feature.id ?? props.id ?? "");
|
|
9666
9824
|
const currentLayers = layersRef.current;
|
|
9667
9825
|
const featureLayer = currentLayers.find((l) => l.featureIds.includes(featureId));
|
|
9668
9826
|
const visualConfig = featureLayer == null ? void 0 : featureLayer.visualConfig;
|
|
@@ -9721,6 +9879,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9721
9879
|
const props = f.properties || {};
|
|
9722
9880
|
return String(props._dvl_h3 || props.id || f.id || "");
|
|
9723
9881
|
};
|
|
9882
|
+
const resolveRendered = (f) => resolveTooltipFeature(f, getFeatureById);
|
|
9724
9883
|
const getFeatureAnchor = (f, fallback) => {
|
|
9725
9884
|
const geom = f.geometry;
|
|
9726
9885
|
if (geom.type === "Point") {
|
|
@@ -9793,7 +9952,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9793
9952
|
id: f.id
|
|
9794
9953
|
});
|
|
9795
9954
|
};
|
|
9796
|
-
addUnique(hoveredFeature);
|
|
9955
|
+
addUnique(resolveRendered(hoveredFeature));
|
|
9797
9956
|
if (hoveredCoords) {
|
|
9798
9957
|
const allFeatures = [];
|
|
9799
9958
|
if (draw.current) {
|
|
@@ -9813,7 +9972,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9813
9972
|
}
|
|
9814
9973
|
}
|
|
9815
9974
|
if (uniqueFeatures.length === 0) {
|
|
9816
|
-
addUnique(hoveredFeature);
|
|
9975
|
+
addUnique(resolveRendered(hoveredFeature));
|
|
9817
9976
|
}
|
|
9818
9977
|
tooltipFeatures = uniqueFeatures;
|
|
9819
9978
|
tooltipPageIndex = 0;
|
|
@@ -9854,12 +10013,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9854
10013
|
lastHoveredFeatureKey = currentKey;
|
|
9855
10014
|
lastHoveredGeomType = geomType || null;
|
|
9856
10015
|
const feature = e.features[0];
|
|
9857
|
-
const featureObj =
|
|
9858
|
-
type: "Feature",
|
|
9859
|
-
geometry: feature.geometry,
|
|
9860
|
-
properties: { ...feature.properties || {} },
|
|
9861
|
-
id: feature.id
|
|
9862
|
-
};
|
|
10016
|
+
const featureObj = resolveRendered(feature);
|
|
9863
10017
|
const anchorLngLat = isPolygon ? e.lngLat : getFeatureAnchor(feature, e.lngLat);
|
|
9864
10018
|
tooltipFeatures = [featureObj];
|
|
9865
10019
|
tooltipPageIndex = 0;
|
|
@@ -10639,7 +10793,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10639
10793
|
clusterConfig: options == null ? void 0 : options.clusterConfig,
|
|
10640
10794
|
altitudeDisplayMode: options == null ? void 0 : options.altitudeDisplayMode
|
|
10641
10795
|
};
|
|
10642
|
-
let addedFeatures =
|
|
10796
|
+
let addedFeatures = [];
|
|
10643
10797
|
let capDropped = 0;
|
|
10644
10798
|
if (geojson) {
|
|
10645
10799
|
const max = featureCapRef.current;
|
|
@@ -10696,9 +10850,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10696
10850
|
scheduleSync();
|
|
10697
10851
|
if (!(options == null ? void 0 : options.skipFit) && addedFeatures.length > 0 && map.current) {
|
|
10698
10852
|
try {
|
|
10699
|
-
const bbox = turf__namespace.bbox(
|
|
10700
|
-
|
|
10701
|
-
|
|
10853
|
+
const bbox = turf__namespace.bbox({
|
|
10854
|
+
type: "FeatureCollection",
|
|
10855
|
+
features: addedFeatures
|
|
10856
|
+
});
|
|
10702
10857
|
if (bbox.every((v) => isFinite(v))) {
|
|
10703
10858
|
map.current.fitBounds(
|
|
10704
10859
|
[[bbox[0], bbox[1]], [bbox[2], bbox[3]]],
|
|
@@ -10803,7 +10958,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10803
10958
|
dropped: prepared.dropped,
|
|
10804
10959
|
sourceCount: prepared.sourceCount,
|
|
10805
10960
|
max: featureCapRef.current,
|
|
10806
|
-
source: "api"
|
|
10961
|
+
source: "api",
|
|
10962
|
+
existing: existing.length
|
|
10807
10963
|
});
|
|
10808
10964
|
}
|
|
10809
10965
|
const layerHasTemporal = (((_a = layerTemporalCacheRef.current.get(layerId)) == null ? void 0 : _a.hasTemporal) ?? false) || prepared.hasTemporal;
|
|
@@ -10825,9 +10981,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10825
10981
|
}
|
|
10826
10982
|
if (!draw.current) return [];
|
|
10827
10983
|
const addedIds = [];
|
|
10984
|
+
const existingInLayer = countExisting(layer);
|
|
10828
10985
|
const cappedForDraw = capFeatures(features, {
|
|
10829
10986
|
max: featureCapRef.current,
|
|
10830
|
-
existing:
|
|
10987
|
+
existing: existingInLayer
|
|
10831
10988
|
});
|
|
10832
10989
|
if (cappedForDraw.dropped > 0) {
|
|
10833
10990
|
notifyFeatureCap({
|
|
@@ -10837,7 +10994,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10837
10994
|
dropped: cappedForDraw.dropped,
|
|
10838
10995
|
sourceCount: cappedForDraw.sourceCount,
|
|
10839
10996
|
max: featureCapRef.current,
|
|
10840
|
-
source: "api"
|
|
10997
|
+
source: "api",
|
|
10998
|
+
existing: existingInLayer
|
|
10841
10999
|
});
|
|
10842
11000
|
}
|
|
10843
11001
|
isApiAddingRef.current = true;
|
|
@@ -10954,9 +11112,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10954
11112
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
10955
11113
|
if (!layer || !draw.current || !isMapLoaded) return [];
|
|
10956
11114
|
const addedIds = [];
|
|
11115
|
+
const existingInLayer = countExisting(layer);
|
|
10957
11116
|
const capped = capFeatures(geojson.features, {
|
|
10958
11117
|
max: featureCapRef.current,
|
|
10959
|
-
existing:
|
|
11118
|
+
existing: existingInLayer
|
|
10960
11119
|
});
|
|
10961
11120
|
if (capped.dropped > 0) {
|
|
10962
11121
|
notifyFeatureCap({
|
|
@@ -10966,7 +11125,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10966
11125
|
dropped: capped.dropped,
|
|
10967
11126
|
sourceCount: capped.sourceCount,
|
|
10968
11127
|
max: featureCapRef.current,
|
|
10969
|
-
source: "api"
|
|
11128
|
+
source: "api",
|
|
11129
|
+
existing: existingInLayer
|
|
10970
11130
|
});
|
|
10971
11131
|
}
|
|
10972
11132
|
isApiAddingRef.current = true;
|
|
@@ -12746,23 +12906,26 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12746
12906
|
const m = map.current;
|
|
12747
12907
|
if (!m) return true;
|
|
12748
12908
|
if (hasArrowFeaturesRef.current) return false;
|
|
12749
|
-
if (layersRef.current.some((l) => {
|
|
12750
|
-
var _a;
|
|
12751
|
-
return l.visible && ((_a = l.traceConfig) == null ? void 0 : _a.enabled);
|
|
12752
|
-
})) return false;
|
|
12753
12909
|
const source = m.getSource("custom-features");
|
|
12754
|
-
const
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
);
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12910
|
+
const paintCache = selectionPaintCacheRef.current;
|
|
12911
|
+
const nextVisible = timelineVisibleIdsRef.current;
|
|
12912
|
+
const trace = tracePaintCacheRef.current;
|
|
12913
|
+
const traceSource = trace ? m.getSource("trace-features") : void 0;
|
|
12914
|
+
if (trace && !traceSource) return false;
|
|
12915
|
+
const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
|
|
12916
|
+
const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
|
|
12917
|
+
if (!applied || !paintCache || !source) return false;
|
|
12918
|
+
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, paintCache, source, traceSource))) return false;
|
|
12919
|
+
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
12920
|
+
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
12921
|
+
setLabelsSuppressed(false);
|
|
12922
|
+
mapPerfLog("timeline", "fast path applied", {
|
|
12923
|
+
toggled,
|
|
12924
|
+
endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
|
|
12925
|
+
segmentsAdded: (traceDiff == null ? void 0 : traceDiff.segmentAdd.length) ?? 0,
|
|
12926
|
+
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
12927
|
+
});
|
|
12928
|
+
return true;
|
|
12766
12929
|
}, [autoLabelConfig, countVisibleFeatures]);
|
|
12767
12930
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
12768
12931
|
const collectSelectionFeatureGroups = react.useCallback(() => {
|
|
@@ -13524,11 +13687,18 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13524
13687
|
new Blob(parts, { type: "application/json" }),
|
|
13525
13688
|
`${layer.name.replace(/[^a-z0-9]/gi, "_")}.geojson`
|
|
13526
13689
|
);
|
|
13690
|
+
} catch (error) {
|
|
13691
|
+
console.error(`Failed to export layer "${layer.name}" as GeoJSON:`, error);
|
|
13692
|
+
toast({
|
|
13693
|
+
title: "Export failed",
|
|
13694
|
+
description: error instanceof Error ? error.message : "Could not prepare the download",
|
|
13695
|
+
variant: "destructive"
|
|
13696
|
+
});
|
|
13527
13697
|
} finally {
|
|
13528
13698
|
progress.end();
|
|
13529
13699
|
exportInFlightRef.current = false;
|
|
13530
13700
|
}
|
|
13531
|
-
}, [layers, ingestProgressStore]);
|
|
13701
|
+
}, [layers, ingestProgressStore, toast]);
|
|
13532
13702
|
const handleLoadLayerGeoJSON = react.useCallback((layerId) => {
|
|
13533
13703
|
const input = fileInputRef.current;
|
|
13534
13704
|
if (!input) return;
|
|
@@ -13608,11 +13778,18 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13608
13778
|
onProgress: (done) => progress.update(done)
|
|
13609
13779
|
});
|
|
13610
13780
|
downloadBlob(new Blob(parts, { type: "application/geo+json" }), "map_export.geojson");
|
|
13781
|
+
} catch (error) {
|
|
13782
|
+
console.error("Failed to export the map as GeoJSON:", error);
|
|
13783
|
+
toast({
|
|
13784
|
+
title: "Export failed",
|
|
13785
|
+
description: error instanceof Error ? error.message : "Could not prepare the download",
|
|
13786
|
+
variant: "destructive"
|
|
13787
|
+
});
|
|
13611
13788
|
} finally {
|
|
13612
13789
|
progress.end();
|
|
13613
13790
|
exportInFlightRef.current = false;
|
|
13614
13791
|
}
|
|
13615
|
-
}, [buildEnrichedExport, ingestProgressStore]);
|
|
13792
|
+
}, [buildEnrichedExport, ingestProgressStore, toast]);
|
|
13616
13793
|
const handleSearchAndAddToNewLayer = react.useCallback(async () => {
|
|
13617
13794
|
if (!onSearchEngineRequest || !map.current || !draw.current) return;
|
|
13618
13795
|
const mapInstance = map.current;
|
|
@@ -13647,9 +13824,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13647
13824
|
saveStateForUndo();
|
|
13648
13825
|
const activeId = activeEditingLayerIdRef.current;
|
|
13649
13826
|
const activeLayer = activeId ? layersRef.current.find((l) => l.id === activeId && !l.readOnly) : null;
|
|
13827
|
+
const existingInActive = activeLayer ? countExisting(activeLayer) : 0;
|
|
13650
13828
|
const capped = capFeatures(result.features, {
|
|
13651
13829
|
max: featureCapRef.current,
|
|
13652
|
-
existing:
|
|
13830
|
+
existing: existingInActive
|
|
13653
13831
|
});
|
|
13654
13832
|
const addedIds = [];
|
|
13655
13833
|
isApiAddingRef.current = true;
|
|
@@ -13708,7 +13886,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13708
13886
|
dropped: capped.dropped,
|
|
13709
13887
|
sourceCount: capped.sourceCount,
|
|
13710
13888
|
max: featureCapRef.current,
|
|
13711
|
-
source: "search"
|
|
13889
|
+
source: "search",
|
|
13890
|
+
existing: existingInActive
|
|
13712
13891
|
});
|
|
13713
13892
|
}
|
|
13714
13893
|
updateFeatureCount();
|
|
@@ -14049,15 +14228,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
14049
14228
|
layerTemporalCacheRef.current.set(layerId, { featureCount: normalizedFeatures.length, hasTemporal: fileHasTemporal });
|
|
14050
14229
|
newLayer.featureIds = addedIds;
|
|
14051
14230
|
if (result.truncated) {
|
|
14052
|
-
notifyFeatureCap(
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
});
|
|
14231
|
+
notifyFeatureCap(
|
|
14232
|
+
truncationToCapInfo(result.truncated, {
|
|
14233
|
+
layerId,
|
|
14234
|
+
layerName: newLayer.name,
|
|
14235
|
+
kept: normalizedFeatures.length,
|
|
14236
|
+
source: "file"
|
|
14237
|
+
})
|
|
14238
|
+
);
|
|
14061
14239
|
}
|
|
14062
14240
|
setLayers((prev) => [...prev, newLayer]);
|
|
14063
14241
|
updateFeatureCount();
|
|
@@ -14102,9 +14280,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
14102
14280
|
return;
|
|
14103
14281
|
}
|
|
14104
14282
|
const targetId = targetLayer.id;
|
|
14283
|
+
const existingInTarget = countExisting(targetLayer);
|
|
14105
14284
|
const appendCapped = capFeatures(normalizedFeatures, {
|
|
14106
14285
|
max: featureCapRef.current,
|
|
14107
|
-
existing:
|
|
14286
|
+
existing: existingInTarget
|
|
14108
14287
|
});
|
|
14109
14288
|
const appendFeatures = appendCapped.features;
|
|
14110
14289
|
const totalDropped = (((_b = result.truncated) == null ? void 0 : _b.droppedCount) ?? 0) + appendCapped.dropped;
|
|
@@ -14116,7 +14295,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
14116
14295
|
dropped: totalDropped,
|
|
14117
14296
|
sourceCount: ((_c = result.truncated) == null ? void 0 : _c.sourceFeatureCount) ?? appendCapped.sourceCount,
|
|
14118
14297
|
max: featureCapRef.current,
|
|
14119
|
-
source: "file"
|
|
14298
|
+
source: "file",
|
|
14299
|
+
existing: existingInTarget
|
|
14120
14300
|
});
|
|
14121
14301
|
}
|
|
14122
14302
|
const withLayerMetadata = (l, addedIds) => ({
|
|
@@ -14226,15 +14406,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
14226
14406
|
layerTemporalCacheRef.current.set(layerId, { featureCount: normalizedFeatures.length, hasTemporal: result.hasTemporal });
|
|
14227
14407
|
newLayer.featureIds = addedIds;
|
|
14228
14408
|
if (result.truncated) {
|
|
14229
|
-
notifyFeatureCap(
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
});
|
|
14409
|
+
notifyFeatureCap(
|
|
14410
|
+
truncationToCapInfo(result.truncated, {
|
|
14411
|
+
layerId,
|
|
14412
|
+
layerName: newLayer.name,
|
|
14413
|
+
kept: normalizedFeatures.length,
|
|
14414
|
+
source: "drop"
|
|
14415
|
+
})
|
|
14416
|
+
);
|
|
14238
14417
|
}
|
|
14239
14418
|
const nextLayers = [...layersRef.current, newLayer];
|
|
14240
14419
|
layersRef.current = nextLayers;
|