@octostar/map-component 0.2.19 → 0.2.20
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 +372 -254
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +398 -279
- package/dist/index.mjs.map +1 -1
- 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/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.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { useState, useEffect, useSyncExternalStore, useCallback, useMemo, create
|
|
|
3
3
|
import maplibregl from "maplibre-gl";
|
|
4
4
|
import MapboxDraw from "@mapbox/mapbox-gl-draw";
|
|
5
5
|
import * as turf from "@turf/turf";
|
|
6
|
+
import { distance, point } from "@turf/turf";
|
|
6
7
|
import * as THREE from "three";
|
|
7
8
|
import proj4 from "proj4";
|
|
8
9
|
import { Button, Modal, Input, App, message, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Segmented, Collapse, ColorPicker, Tabs, Card, Table, DatePicker } from "antd";
|
|
@@ -143,7 +144,7 @@ async function featureCollectionBlobPartsAsync(collection, options) {
|
|
|
143
144
|
(_c = options == null ? void 0 : options.onProgress) == null ? void 0 : _c.call(options, total, total);
|
|
144
145
|
return coalescer.finish();
|
|
145
146
|
}
|
|
146
|
-
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=
|
|
147
|
+
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';
|
|
147
148
|
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");
|
|
148
149
|
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");
|
|
149
150
|
proj4.defs("EPSG:32630", "+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs");
|
|
@@ -208,6 +209,14 @@ function capFeatures(features, options) {
|
|
|
208
209
|
sourceCount
|
|
209
210
|
};
|
|
210
211
|
}
|
|
212
|
+
function truncationToCapInfo(truncation, rest) {
|
|
213
|
+
return {
|
|
214
|
+
...rest,
|
|
215
|
+
dropped: truncation.droppedCount,
|
|
216
|
+
sourceCount: truncation.sourceFeatureCount,
|
|
217
|
+
max: truncation.maxFeatures
|
|
218
|
+
};
|
|
219
|
+
}
|
|
211
220
|
function formatCount(value) {
|
|
212
221
|
return value.toLocaleString("en-US");
|
|
213
222
|
}
|
|
@@ -225,6 +234,16 @@ function formatFeatureCapToast(info) {
|
|
|
225
234
|
variant
|
|
226
235
|
};
|
|
227
236
|
}
|
|
237
|
+
const existing = info.existing ?? 0;
|
|
238
|
+
if (existing > 0) {
|
|
239
|
+
return {
|
|
240
|
+
title: "Feature limit reached",
|
|
241
|
+
description: withNote(
|
|
242
|
+
`"${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.`
|
|
243
|
+
),
|
|
244
|
+
variant
|
|
245
|
+
};
|
|
246
|
+
}
|
|
228
247
|
return {
|
|
229
248
|
title: "Feature limit reached",
|
|
230
249
|
description: withNote(
|
|
@@ -2933,7 +2952,9 @@ function LayersPanel({
|
|
|
2933
2952
|
key: "save-desktop",
|
|
2934
2953
|
icon: /* @__PURE__ */ jsx(Download, { className: "w-[18px] h-[18px]" }),
|
|
2935
2954
|
label: "Save GeoJSON to desktop",
|
|
2936
|
-
onClick: () =>
|
|
2955
|
+
onClick: () => {
|
|
2956
|
+
void onSaveLayerGeoJSON(layer.id);
|
|
2957
|
+
}
|
|
2937
2958
|
},
|
|
2938
2959
|
...onUpdateVisualConfig ? [
|
|
2939
2960
|
{ type: "divider" },
|
|
@@ -3614,7 +3635,9 @@ function LayersPanel({
|
|
|
3614
3635
|
key: "save-geojson",
|
|
3615
3636
|
icon: /* @__PURE__ */ jsx(Download, { className: "w-4 h-4" }),
|
|
3616
3637
|
label: "Download Map",
|
|
3617
|
-
onClick:
|
|
3638
|
+
onClick: () => {
|
|
3639
|
+
void onSaveAllGeoJSON();
|
|
3640
|
+
}
|
|
3618
3641
|
},
|
|
3619
3642
|
...onWorkspaceSave ? [{
|
|
3620
3643
|
key: "save-workspace",
|
|
@@ -6528,25 +6551,25 @@ function createSelectionPaintCache() {
|
|
|
6528
6551
|
updatable: true
|
|
6529
6552
|
};
|
|
6530
6553
|
}
|
|
6531
|
-
function recordPaintedFeature(
|
|
6532
|
-
if (
|
|
6533
|
-
|
|
6554
|
+
function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
6555
|
+
if (cache2.presentIds.has(featureId)) {
|
|
6556
|
+
cache2.updatable = false;
|
|
6534
6557
|
} else {
|
|
6535
|
-
|
|
6558
|
+
cache2.presentIds.add(featureId);
|
|
6536
6559
|
}
|
|
6537
|
-
|
|
6538
|
-
if (isSelected)
|
|
6560
|
+
cache2.basePriorityById.set(featureId, basePriority);
|
|
6561
|
+
if (isSelected) cache2.appliedSelectedIds.add(featureId);
|
|
6539
6562
|
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
6540
|
-
|
|
6563
|
+
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
6541
6564
|
}
|
|
6542
6565
|
if (visibleFillOpacity !== DEFAULT_VISIBLE_FILL_OPACITY) {
|
|
6543
|
-
|
|
6566
|
+
cache2.visibleFillOpacityById.set(featureId, visibleFillOpacity);
|
|
6544
6567
|
}
|
|
6545
|
-
if (isTimelineHidden)
|
|
6568
|
+
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
6546
6569
|
}
|
|
6547
|
-
function applySelectionFastPath(
|
|
6548
|
-
if (!
|
|
6549
|
-
const diff = buildSelectionDiff(
|
|
6570
|
+
function applySelectionFastPath(cache2, nextSelectedIds, source) {
|
|
6571
|
+
if (!cache2 || !cache2.updatable || !source) return false;
|
|
6572
|
+
const diff = buildSelectionDiff(cache2, nextSelectedIds);
|
|
6550
6573
|
if (diff) {
|
|
6551
6574
|
try {
|
|
6552
6575
|
source.updateData(diff);
|
|
@@ -6556,29 +6579,29 @@ function applySelectionFastPath(cache, nextSelectedIds, source) {
|
|
|
6556
6579
|
}
|
|
6557
6580
|
const applied = /* @__PURE__ */ new Set();
|
|
6558
6581
|
nextSelectedIds.forEach((id) => {
|
|
6559
|
-
if (
|
|
6582
|
+
if (cache2.presentIds.has(id)) applied.add(id);
|
|
6560
6583
|
});
|
|
6561
|
-
|
|
6584
|
+
cache2.appliedSelectedIds = applied;
|
|
6562
6585
|
return true;
|
|
6563
6586
|
}
|
|
6564
6587
|
function needsDrawSelectionUpdate(input) {
|
|
6565
6588
|
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
6566
6589
|
}
|
|
6567
|
-
function buildSelectionDiff(
|
|
6590
|
+
function buildSelectionDiff(cache2, nextSelectedIds) {
|
|
6568
6591
|
const update = [];
|
|
6569
|
-
|
|
6570
|
-
if (!nextSelectedIds.has(id) &&
|
|
6592
|
+
cache2.appliedSelectedIds.forEach((id) => {
|
|
6593
|
+
if (!nextSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
6571
6594
|
update.push({
|
|
6572
6595
|
id,
|
|
6573
6596
|
addOrUpdateProperties: [
|
|
6574
6597
|
{ key: "isSelected", value: 0 },
|
|
6575
|
-
{ key: "_labelPriority", value:
|
|
6598
|
+
{ key: "_labelPriority", value: cache2.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
|
|
6576
6599
|
]
|
|
6577
6600
|
});
|
|
6578
6601
|
}
|
|
6579
6602
|
});
|
|
6580
6603
|
nextSelectedIds.forEach((id) => {
|
|
6581
|
-
if (!
|
|
6604
|
+
if (!cache2.appliedSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
6582
6605
|
update.push({
|
|
6583
6606
|
id,
|
|
6584
6607
|
addOrUpdateProperties: [
|
|
@@ -6590,13 +6613,13 @@ function buildSelectionDiff(cache, nextSelectedIds) {
|
|
|
6590
6613
|
});
|
|
6591
6614
|
return update.length > 0 ? { update } : null;
|
|
6592
6615
|
}
|
|
6593
|
-
function buildTimelineVisibilityDiff(
|
|
6616
|
+
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
6594
6617
|
const update = [];
|
|
6595
6618
|
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
6596
|
-
|
|
6619
|
+
cache2.presentIds.forEach((id) => {
|
|
6597
6620
|
const nextHidden = nextVisibleSet !== null && !nextVisibleSet.has(id);
|
|
6598
6621
|
if (nextHidden) nextHiddenIds.add(id);
|
|
6599
|
-
if (nextHidden ===
|
|
6622
|
+
if (nextHidden === cache2.appliedHiddenIds.has(id)) return;
|
|
6600
6623
|
if (nextHidden) {
|
|
6601
6624
|
update.push({
|
|
6602
6625
|
id,
|
|
@@ -6610,8 +6633,8 @@ function buildTimelineVisibilityDiff(cache, nextVisibleSet) {
|
|
|
6610
6633
|
update.push({
|
|
6611
6634
|
id,
|
|
6612
6635
|
addOrUpdateProperties: [
|
|
6613
|
-
{ key: "stroke-opacity", value:
|
|
6614
|
-
{ key: "fill-opacity", value:
|
|
6636
|
+
{ key: "stroke-opacity", value: cache2.visibleStrokeOpacityById.get(id) ?? DEFAULT_VISIBLE_STROKE_OPACITY },
|
|
6637
|
+
{ key: "fill-opacity", value: cache2.visibleFillOpacityById.get(id) ?? DEFAULT_VISIBLE_FILL_OPACITY },
|
|
6615
6638
|
{ key: "isTimelineHidden", value: 0 }
|
|
6616
6639
|
]
|
|
6617
6640
|
});
|
|
@@ -6619,10 +6642,10 @@ function buildTimelineVisibilityDiff(cache, nextVisibleSet) {
|
|
|
6619
6642
|
});
|
|
6620
6643
|
return { diff: update.length > 0 ? { update } : null, nextHiddenIds };
|
|
6621
6644
|
}
|
|
6622
|
-
function applyTimelineFastPath(
|
|
6645
|
+
function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
6623
6646
|
var _a;
|
|
6624
|
-
if (!
|
|
6625
|
-
const { diff, nextHiddenIds } = buildTimelineVisibilityDiff(
|
|
6647
|
+
if (!cache2 || !cache2.updatable || !source) return { applied: false, toggled: 0 };
|
|
6648
|
+
const { diff, nextHiddenIds } = buildTimelineVisibilityDiff(cache2, nextVisibleSet);
|
|
6626
6649
|
if (diff) {
|
|
6627
6650
|
try {
|
|
6628
6651
|
source.updateData(diff);
|
|
@@ -6630,9 +6653,204 @@ function applyTimelineFastPath(cache, nextVisibleSet, source) {
|
|
|
6630
6653
|
return { applied: false, toggled: 0 };
|
|
6631
6654
|
}
|
|
6632
6655
|
}
|
|
6633
|
-
|
|
6656
|
+
cache2.appliedHiddenIds = nextHiddenIds;
|
|
6634
6657
|
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
6635
6658
|
}
|
|
6659
|
+
const TRACE_DEFAULT_COLOR = "#3b82f6";
|
|
6660
|
+
const TRACE_UNGROUPED_KEY = "__all__";
|
|
6661
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
6662
|
+
function getTraceGroups(features, groupByField) {
|
|
6663
|
+
const field = groupByField || null;
|
|
6664
|
+
let byField = cache.get(features);
|
|
6665
|
+
if (!byField) {
|
|
6666
|
+
byField = /* @__PURE__ */ new Map();
|
|
6667
|
+
cache.set(features, byField);
|
|
6668
|
+
}
|
|
6669
|
+
const fieldKey = field ?? "";
|
|
6670
|
+
let groups = byField.get(fieldKey);
|
|
6671
|
+
if (!groups) {
|
|
6672
|
+
groups = buildTraceGroups(features, field);
|
|
6673
|
+
byField.set(fieldKey, groups);
|
|
6674
|
+
}
|
|
6675
|
+
return groups;
|
|
6676
|
+
}
|
|
6677
|
+
function sortKey(time) {
|
|
6678
|
+
return Number.isNaN(time) ? -Infinity : time;
|
|
6679
|
+
}
|
|
6680
|
+
function compareStaged(a, b) {
|
|
6681
|
+
const ka = sortKey(a.time);
|
|
6682
|
+
const kb = sortKey(b.time);
|
|
6683
|
+
if (ka < kb) return -1;
|
|
6684
|
+
if (ka > kb) return 1;
|
|
6685
|
+
return 0;
|
|
6686
|
+
}
|
|
6687
|
+
function buildTraceGroups(features, field) {
|
|
6688
|
+
var _a;
|
|
6689
|
+
const staged = /* @__PURE__ */ new Map();
|
|
6690
|
+
for (const feature of features) {
|
|
6691
|
+
if (feature.id == null || feature.geometry.type !== "Point" || !((_a = feature.properties) == null ? void 0 : _a.startDate)) continue;
|
|
6692
|
+
const raw = field ? feature.properties[field] : void 0;
|
|
6693
|
+
const key = field && raw ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
6694
|
+
let bucket = staged.get(key);
|
|
6695
|
+
if (!bucket) {
|
|
6696
|
+
bucket = [];
|
|
6697
|
+
staged.set(key, bucket);
|
|
6698
|
+
}
|
|
6699
|
+
bucket.push({ feature, time: new Date(feature.properties.startDate).getTime() });
|
|
6700
|
+
}
|
|
6701
|
+
const count = staged.size;
|
|
6702
|
+
const groups = [];
|
|
6703
|
+
staged.forEach((bucket, key) => {
|
|
6704
|
+
bucket.sort(compareStaged);
|
|
6705
|
+
groups.push({
|
|
6706
|
+
key,
|
|
6707
|
+
points: bucket.map((p) => p.feature),
|
|
6708
|
+
ids: bucket.map((p) => String(p.feature.id)),
|
|
6709
|
+
times: bucket.map((p) => p.time),
|
|
6710
|
+
color: traceGroupColor(key, groups.length, count),
|
|
6711
|
+
label: field && key !== TRACE_UNGROUPED_KEY ? key : null,
|
|
6712
|
+
pairStats: /* @__PURE__ */ new Map()
|
|
6713
|
+
});
|
|
6714
|
+
});
|
|
6715
|
+
return groups;
|
|
6716
|
+
}
|
|
6717
|
+
function traceGroupColor(key, index, count) {
|
|
6718
|
+
if (key === TRACE_UNGROUPED_KEY) return TRACE_DEFAULT_COLOR;
|
|
6719
|
+
return `hsl(${index * 360 / count % 360}, 70%, 50%)`;
|
|
6720
|
+
}
|
|
6721
|
+
function visibleTraceIndices(group, isVisible) {
|
|
6722
|
+
const indices = [];
|
|
6723
|
+
for (let i = 0; i < group.ids.length; i++) {
|
|
6724
|
+
if (isVisible(group.ids[i])) indices.push(i);
|
|
6725
|
+
}
|
|
6726
|
+
return indices;
|
|
6727
|
+
}
|
|
6728
|
+
function timelineVisibility(visibleSet) {
|
|
6729
|
+
return visibleSet === null ? () => true : (id) => visibleSet.has(id);
|
|
6730
|
+
}
|
|
6731
|
+
function traceSegmentStats(group, fromIndex, toIndex) {
|
|
6732
|
+
const key = `${fromIndex}:${toIndex}`;
|
|
6733
|
+
const cached = group.pairStats.get(key);
|
|
6734
|
+
if (cached) return cached;
|
|
6735
|
+
const from = group.points[fromIndex].geometry;
|
|
6736
|
+
const to = group.points[toIndex].geometry;
|
|
6737
|
+
const distanceKm = distance(point(from.coordinates), point(to.coordinates), { units: "kilometers" });
|
|
6738
|
+
const durationMs = group.times[toIndex] - group.times[fromIndex];
|
|
6739
|
+
const durationHours = durationMs / (1e3 * 60 * 60);
|
|
6740
|
+
const avgSpeedKmh = durationHours > 0 ? distanceKm / durationHours : 0;
|
|
6741
|
+
const stats = {
|
|
6742
|
+
duration: formatDuration(durationMs),
|
|
6743
|
+
distance: distanceKm < 1 ? `${Math.round(distanceKm * 1e3)}m` : `${distanceKm.toFixed(2)}km`,
|
|
6744
|
+
avgSpeed: avgSpeedKmh < 1 ? `${(avgSpeedKmh * 1e3).toFixed(0)}m/h` : `${avgSpeedKmh.toFixed(1)}km/h`
|
|
6745
|
+
};
|
|
6746
|
+
group.pairStats.set(key, stats);
|
|
6747
|
+
return stats;
|
|
6748
|
+
}
|
|
6749
|
+
function formatDuration(durationMs) {
|
|
6750
|
+
if (durationMs < 6e4) return `${Math.round(durationMs / 1e3)}s`;
|
|
6751
|
+
if (durationMs < 36e5) return `${Math.round(durationMs / 6e4)}m`;
|
|
6752
|
+
if (durationMs < 864e5) {
|
|
6753
|
+
return `${Math.floor(durationMs / 36e5)}h ${Math.round(durationMs % 36e5 / 6e4)}m`;
|
|
6754
|
+
}
|
|
6755
|
+
return `${Math.floor(durationMs / 864e5)}d ${Math.round(durationMs % 864e5 / 36e5)}h`;
|
|
6756
|
+
}
|
|
6757
|
+
function traceSegmentId(groupIndex, fromIndex, toIndex) {
|
|
6758
|
+
return `${groupIndex}:${fromIndex}:${toIndex}`;
|
|
6759
|
+
}
|
|
6760
|
+
function traceSegmentFeature(group, groupIndex, fromIndex, toIndex) {
|
|
6761
|
+
var _a, _b;
|
|
6762
|
+
const from = group.points[fromIndex];
|
|
6763
|
+
const to = group.points[toIndex];
|
|
6764
|
+
return {
|
|
6765
|
+
type: "Feature",
|
|
6766
|
+
id: traceSegmentId(groupIndex, fromIndex, toIndex),
|
|
6767
|
+
properties: {
|
|
6768
|
+
group: group.key,
|
|
6769
|
+
color: group.color,
|
|
6770
|
+
...traceSegmentStats(group, fromIndex, toIndex),
|
|
6771
|
+
fromName: ((_a = from.properties) == null ? void 0 : _a.name) || "",
|
|
6772
|
+
toName: ((_b = to.properties) == null ? void 0 : _b.name) || ""
|
|
6773
|
+
},
|
|
6774
|
+
geometry: {
|
|
6775
|
+
type: "LineString",
|
|
6776
|
+
coordinates: [from.geometry.coordinates, to.geometry.coordinates]
|
|
6777
|
+
}
|
|
6778
|
+
};
|
|
6779
|
+
}
|
|
6780
|
+
const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
6781
|
+
const TRACE_POINT_RADIUS = 2;
|
|
6782
|
+
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
6783
|
+
function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
6784
|
+
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [], basePriorities: [] };
|
|
6785
|
+
const paintedVisible = (id) => !paint.appliedHiddenIds.has(id);
|
|
6786
|
+
const nextVisible = timelineVisibility(nextVisibleSet);
|
|
6787
|
+
trace.groups.forEach((group, groupIndex) => {
|
|
6788
|
+
const prev = visibleTraceIndices(group, paintedVisible);
|
|
6789
|
+
const next = visibleTraceIndices(group, nextVisible);
|
|
6790
|
+
const prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
6791
|
+
const nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
6792
|
+
if (prevEndpoint !== nextEndpoint) {
|
|
6793
|
+
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, paint, group, group.ids[prevEndpoint], false);
|
|
6794
|
+
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, paint, group, group.ids[nextEndpoint], true);
|
|
6795
|
+
}
|
|
6796
|
+
diffConsecutivePairs(
|
|
6797
|
+
prev,
|
|
6798
|
+
next,
|
|
6799
|
+
(from, to) => diff.segmentRemove.push(traceSegmentId(groupIndex, from, to)),
|
|
6800
|
+
(from, to) => diff.segmentAdd.push(traceSegmentFeature(group, groupIndex, from, to))
|
|
6801
|
+
);
|
|
6802
|
+
});
|
|
6803
|
+
return diff;
|
|
6804
|
+
}
|
|
6805
|
+
function pushEndpointUpdate(diff, trace, paint, group, id, isEndpoint) {
|
|
6806
|
+
const point2 = trace.pointPaint.get(id);
|
|
6807
|
+
if (!point2) return;
|
|
6808
|
+
const labelled = isEndpoint && group.label !== null;
|
|
6809
|
+
const basePriority = labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point2.basePriority;
|
|
6810
|
+
diff.pointUpdates.push({
|
|
6811
|
+
id,
|
|
6812
|
+
addOrUpdateProperties: [
|
|
6813
|
+
{ key: "pointRadius", value: isEndpoint ? point2.endpointRadius : TRACE_POINT_RADIUS },
|
|
6814
|
+
{ key: "name", value: labelled ? group.label : point2.name },
|
|
6815
|
+
{ key: "isTraceLabel", value: labelled },
|
|
6816
|
+
{ key: "_labelPriority", value: paint.appliedSelectedIds.has(id) ? 0 : basePriority }
|
|
6817
|
+
]
|
|
6818
|
+
});
|
|
6819
|
+
diff.basePriorities.push([id, basePriority]);
|
|
6820
|
+
}
|
|
6821
|
+
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
6822
|
+
let i = 0;
|
|
6823
|
+
let j = 0;
|
|
6824
|
+
while (i < prev.length - 1 || j < next.length - 1) {
|
|
6825
|
+
const prevFrom = i < prev.length - 1 ? prev[i] : Infinity;
|
|
6826
|
+
const nextFrom = j < next.length - 1 ? next[j] : Infinity;
|
|
6827
|
+
const prevTo = prev[i + 1];
|
|
6828
|
+
const nextTo = next[j + 1];
|
|
6829
|
+
if (prevFrom === nextFrom && prevTo === nextTo) {
|
|
6830
|
+
i++;
|
|
6831
|
+
j++;
|
|
6832
|
+
} else if (prevFrom < nextFrom || prevFrom === nextFrom && prevTo < nextTo) {
|
|
6833
|
+
onRemove(prevFrom, prevTo);
|
|
6834
|
+
i++;
|
|
6835
|
+
} else {
|
|
6836
|
+
onAdd(nextFrom, nextTo);
|
|
6837
|
+
j++;
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
|
|
6842
|
+
try {
|
|
6843
|
+
if (diff.pointUpdates.length > 0) pointSource.updateData({ update: diff.pointUpdates });
|
|
6844
|
+
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
6845
|
+
segmentSource.updateData({ add: diff.segmentAdd, remove: diff.segmentRemove });
|
|
6846
|
+
}
|
|
6847
|
+
} catch (error) {
|
|
6848
|
+
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
6849
|
+
return false;
|
|
6850
|
+
}
|
|
6851
|
+
diff.basePriorities.forEach(([id, priority]) => paint.basePriorityById.set(id, priority));
|
|
6852
|
+
return true;
|
|
6853
|
+
}
|
|
6636
6854
|
function deepClone(value) {
|
|
6637
6855
|
try {
|
|
6638
6856
|
return structuredClone(value);
|
|
@@ -6689,15 +6907,15 @@ function prepareFeaturesForLayer(input, caller, cap) {
|
|
|
6689
6907
|
const logging = mapPerfLogEnabled();
|
|
6690
6908
|
const started = logging ? performance.now() : 0;
|
|
6691
6909
|
const capped = cap ? capFeatures(input, cap) : null;
|
|
6692
|
-
|
|
6693
|
-
const count =
|
|
6910
|
+
const source = capped ? capped.features : input;
|
|
6911
|
+
const count = source.length;
|
|
6694
6912
|
const features = new Array(count);
|
|
6695
6913
|
const featureIds = new Array(count);
|
|
6696
6914
|
let hasTemporal = false;
|
|
6697
6915
|
let temporalCount = 0;
|
|
6698
6916
|
let reused = 0;
|
|
6699
6917
|
for (let i = 0; i < count; i++) {
|
|
6700
|
-
const f =
|
|
6918
|
+
const f = source[i];
|
|
6701
6919
|
const props = f.properties || {};
|
|
6702
6920
|
if (!hasAnyTemporalValue(props)) {
|
|
6703
6921
|
if (typeof f.id === "string" && f.id) {
|
|
@@ -8007,6 +8225,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8007
8225
|
});
|
|
8008
8226
|
return [...drawFeatures, ...readOnly];
|
|
8009
8227
|
}, []);
|
|
8228
|
+
const traceSourceFeatures = useCallback((layer, featureById) => {
|
|
8229
|
+
const readOnly = readOnlyFeatures.current.get(layer.id);
|
|
8230
|
+
if (readOnly) return readOnly;
|
|
8231
|
+
const features = [];
|
|
8232
|
+
layer.featureIds.forEach((id) => {
|
|
8233
|
+
const f = featureById.get(id);
|
|
8234
|
+
if (f) features.push(f);
|
|
8235
|
+
});
|
|
8236
|
+
return features;
|
|
8237
|
+
}, []);
|
|
8010
8238
|
const getSelectedFeatures = useCallback(() => {
|
|
8011
8239
|
const drawSelected = draw.current ? draw.current.getSelected().features : [];
|
|
8012
8240
|
const readOnlySelected = [];
|
|
@@ -8191,29 +8419,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8191
8419
|
layers.forEach((layer) => {
|
|
8192
8420
|
var _a;
|
|
8193
8421
|
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
8194
|
-
const
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
const f = featById.get(id);
|
|
8198
|
-
if (!f || f.geometry.type !== "Point" || !((_a2 = f.properties) == null ? void 0 : _a2.startDate)) return;
|
|
8199
|
-
layerFeatures.push(f);
|
|
8200
|
-
});
|
|
8201
|
-
if (layerFeatures.length < 1) return;
|
|
8202
|
-
const groupByField = layer.traceConfig.groupByField;
|
|
8203
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8204
|
-
layerFeatures.forEach((f) => {
|
|
8205
|
-
var _a2;
|
|
8206
|
-
const key = groupByField && ((_a2 = f.properties) == null ? void 0 : _a2[groupByField]) ? String(f.properties[groupByField]) : "__all__";
|
|
8207
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
8208
|
-
groups.get(key).push(f);
|
|
8209
|
-
});
|
|
8210
|
-
const groupKeys = Array.from(groups.keys());
|
|
8211
|
-
groupKeys.forEach((key, index) => {
|
|
8212
|
-
const color = key === "__all__" ? "#3b82f6" : `hsl(${index * 360 / groupKeys.length % 360}, 70%, 50%)`;
|
|
8213
|
-
groups.get(key).forEach((f) => {
|
|
8214
|
-
if (f.id) tracePointColors.set(String(f.id), color);
|
|
8215
|
-
});
|
|
8216
|
-
});
|
|
8422
|
+
for (const group of getTraceGroups(traceSourceFeatures(layer, featById), layer.traceConfig.groupByField)) {
|
|
8423
|
+
for (const id of group.ids) tracePointColors.set(id, group.color);
|
|
8424
|
+
}
|
|
8217
8425
|
});
|
|
8218
8426
|
const layerGradientRanges = /* @__PURE__ */ new Map();
|
|
8219
8427
|
selectedFeatureIds.forEach((fid) => {
|
|
@@ -8247,7 +8455,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8247
8455
|
colorMap.set(fid, color);
|
|
8248
8456
|
});
|
|
8249
8457
|
return colorMap;
|
|
8250
|
-
}, [selectedFeatureIds, layers, getAllFeatures]);
|
|
8458
|
+
}, [selectedFeatureIds, layers, getAllFeatures, traceSourceFeatures]);
|
|
8251
8459
|
const countVisibleFeatures = useCallback((threshold) => {
|
|
8252
8460
|
const m = map.current;
|
|
8253
8461
|
if (!m) return 0;
|
|
@@ -8266,6 +8474,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8266
8474
|
}, []);
|
|
8267
8475
|
const isSyncingRef = useRef(false);
|
|
8268
8476
|
const selectionPaintCacheRef = useRef(null);
|
|
8477
|
+
const tracePaintCacheRef = useRef(null);
|
|
8269
8478
|
const paintedArrowLinesRef = useRef([]);
|
|
8270
8479
|
const renderArrowOverlays = useCallback((arrowLines) => {
|
|
8271
8480
|
const mapInstance = map.current;
|
|
@@ -8435,60 +8644,29 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8435
8644
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
8436
8645
|
const lastTracePointLabels = /* @__PURE__ */ new Map();
|
|
8437
8646
|
const tracePointIds = /* @__PURE__ */ new Set();
|
|
8647
|
+
const paintedTraceGroups = [];
|
|
8648
|
+
const traceSegments = [];
|
|
8649
|
+
const tracePointPaint = /* @__PURE__ */ new Map();
|
|
8650
|
+
const isTimelineVisibleId = timelineVisibility(visibleSet);
|
|
8438
8651
|
currentLayers.forEach((layer) => {
|
|
8439
8652
|
var _a;
|
|
8440
8653
|
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
8441
|
-
const
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
const
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
layerFeatures.push(f);
|
|
8448
|
-
});
|
|
8449
|
-
if (layerFeatures.length < 1) return;
|
|
8450
|
-
const groupByField = layer.traceConfig.groupByField;
|
|
8451
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8452
|
-
layerFeatures.forEach((f) => {
|
|
8453
|
-
var _a2;
|
|
8454
|
-
const key = groupByField && ((_a2 = f.properties) == null ? void 0 : _a2[groupByField]) ? String(f.properties[groupByField]) : "__all__";
|
|
8455
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
8456
|
-
groups.get(key).push(f);
|
|
8457
|
-
});
|
|
8458
|
-
const groupKeys = Array.from(groups.keys());
|
|
8459
|
-
const groupColors = /* @__PURE__ */ new Map();
|
|
8460
|
-
groupKeys.forEach((key, index) => {
|
|
8461
|
-
if (key === "__all__") {
|
|
8462
|
-
groupColors.set(key, "#3b82f6");
|
|
8463
|
-
} else {
|
|
8464
|
-
const hue = index * 360 / groupKeys.length % 360;
|
|
8465
|
-
groupColors.set(key, `hsl(${hue}, 70%, 50%)`);
|
|
8654
|
+
const groups = getTraceGroups(traceSourceFeatures(layer, featureById), layer.traceConfig.groupByField);
|
|
8655
|
+
for (const group of groups) {
|
|
8656
|
+
const groupIndex = paintedTraceGroups.push(group) - 1;
|
|
8657
|
+
for (const id of group.ids) {
|
|
8658
|
+
tracePointIds.add(id);
|
|
8659
|
+
tracePointColors.set(id, group.color);
|
|
8466
8660
|
}
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
const
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
});
|
|
8475
|
-
if (sorted.length > 0) {
|
|
8476
|
-
const groupColor = groupColors.get(groupKey) || "#3b82f6";
|
|
8477
|
-
sorted.forEach((point) => {
|
|
8478
|
-
if (point.id) {
|
|
8479
|
-
tracePointIds.add(String(point.id));
|
|
8480
|
-
tracePointColors.set(String(point.id), groupColor);
|
|
8481
|
-
}
|
|
8482
|
-
});
|
|
8483
|
-
const lastPoint = sorted[sorted.length - 1];
|
|
8484
|
-
if (lastPoint.id) {
|
|
8485
|
-
lastTracePointIds.add(String(lastPoint.id));
|
|
8486
|
-
if (groupByField && groupKey !== "__all__") {
|
|
8487
|
-
lastTracePointLabels.set(String(lastPoint.id), groupKey);
|
|
8488
|
-
}
|
|
8489
|
-
}
|
|
8661
|
+
const visible = visibleTraceIndices(group, isTimelineVisibleId);
|
|
8662
|
+
if (visible.length === 0) continue;
|
|
8663
|
+
const endpointId = group.ids[visible[visible.length - 1]];
|
|
8664
|
+
lastTracePointIds.add(endpointId);
|
|
8665
|
+
if (group.label !== null) lastTracePointLabels.set(endpointId, group.label);
|
|
8666
|
+
for (let k = 1; k < visible.length; k++) {
|
|
8667
|
+
traceSegments.push(traceSegmentFeature(group, groupIndex, visible[k - 1], visible[k]));
|
|
8490
8668
|
}
|
|
8491
|
-
}
|
|
8669
|
+
}
|
|
8492
8670
|
});
|
|
8493
8671
|
const paintCache = createSelectionPaintCache();
|
|
8494
8672
|
const sourceData = {
|
|
@@ -8533,13 +8711,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8533
8711
|
const isTracePoint = tracePointIds.has(featureId);
|
|
8534
8712
|
const isLastTracePoint = lastTracePointIds.has(featureId);
|
|
8535
8713
|
const traceLabel = lastTracePointLabels.get(featureId);
|
|
8714
|
+
let traceEndpointRadius = null;
|
|
8536
8715
|
if (isTracePoint && f.geometry.type === "Point") {
|
|
8537
8716
|
strokeColor = tracePointColors.get(featureId) || strokeColor;
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
} else {
|
|
8541
|
-
pointRadius = 2;
|
|
8542
|
-
}
|
|
8717
|
+
traceEndpointRadius = Math.max(pointRadius, TRACE_ENDPOINT_MIN_RADIUS);
|
|
8718
|
+
pointRadius = isLastTracePoint ? traceEndpointRadius : TRACE_POINT_RADIUS;
|
|
8543
8719
|
}
|
|
8544
8720
|
let labelText = ((_d = f.properties) == null ? void 0 : _d.name) || "";
|
|
8545
8721
|
const labelConfig = visualConfig == null ? void 0 : visualConfig.label;
|
|
@@ -8553,6 +8729,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8553
8729
|
labelText = fieldValue !== void 0 && fieldValue !== null ? String(fieldValue) : "";
|
|
8554
8730
|
}
|
|
8555
8731
|
}
|
|
8732
|
+
const nonTraceLabelText = labelText;
|
|
8556
8733
|
if (traceLabel) {
|
|
8557
8734
|
labelText = traceLabel;
|
|
8558
8735
|
}
|
|
@@ -8584,11 +8761,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8584
8761
|
});
|
|
8585
8762
|
}
|
|
8586
8763
|
const isFeatureSelected = (enableSelectionRef.current || enableDrawingRef.current) && selectedIdSet.has(featureId) ? 1 : 0;
|
|
8587
|
-
let
|
|
8588
|
-
if (
|
|
8589
|
-
|
|
8590
|
-
} else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
8591
|
-
basePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
8764
|
+
let nonTracePriority = DEFAULT_LABEL_PRIORITY;
|
|
8765
|
+
if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
8766
|
+
nonTracePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
8592
8767
|
} else {
|
|
8593
8768
|
const idStr = String(featureId);
|
|
8594
8769
|
let h = 0;
|
|
@@ -8596,9 +8771,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8596
8771
|
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
8597
8772
|
h |= 0;
|
|
8598
8773
|
}
|
|
8599
|
-
|
|
8774
|
+
nonTracePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
8600
8775
|
}
|
|
8776
|
+
const basePriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
8601
8777
|
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
8778
|
+
if (traceEndpointRadius !== null) {
|
|
8779
|
+
tracePointPaint.set(featureId, { name: nonTraceLabelText, endpointRadius: traceEndpointRadius, basePriority: nonTracePriority });
|
|
8780
|
+
}
|
|
8602
8781
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
8603
8782
|
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
8604
8783
|
recordPaintedFeature(
|
|
@@ -8645,93 +8824,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8645
8824
|
source.setData(sourceData);
|
|
8646
8825
|
selectionPaintCacheRef.current = paintCache;
|
|
8647
8826
|
const traceSource = map.current.getSource("trace-features");
|
|
8648
|
-
if (traceSource) {
|
|
8649
|
-
|
|
8650
|
-
currentLayers.forEach((layer) => {
|
|
8651
|
-
var _a;
|
|
8652
|
-
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
8653
|
-
const layerFeatures = [];
|
|
8654
|
-
layer.featureIds.forEach((id) => {
|
|
8655
|
-
var _a2;
|
|
8656
|
-
const f = featureById.get(id);
|
|
8657
|
-
if (!f || f.geometry.type !== "Point" || !((_a2 = f.properties) == null ? void 0 : _a2.startDate)) return;
|
|
8658
|
-
if (visibleSet && f.id && !visibleSet.has(String(f.id))) return;
|
|
8659
|
-
layerFeatures.push(f);
|
|
8660
|
-
});
|
|
8661
|
-
if (layerFeatures.length < 2) return;
|
|
8662
|
-
const groupByField = layer.traceConfig.groupByField;
|
|
8663
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8664
|
-
layerFeatures.forEach((f) => {
|
|
8665
|
-
var _a2;
|
|
8666
|
-
const key = groupByField && ((_a2 = f.properties) == null ? void 0 : _a2[groupByField]) ? String(f.properties[groupByField]) : "__all__";
|
|
8667
|
-
if (!groups.has(key)) groups.set(key, []);
|
|
8668
|
-
groups.get(key).push(f);
|
|
8669
|
-
});
|
|
8670
|
-
const groupKeys = Array.from(groups.keys());
|
|
8671
|
-
const groupColors = /* @__PURE__ */ new Map();
|
|
8672
|
-
groupKeys.forEach((key, index) => {
|
|
8673
|
-
if (key === "__all__") {
|
|
8674
|
-
groupColors.set(key, "#3b82f6");
|
|
8675
|
-
} else {
|
|
8676
|
-
const hue = index * 360 / groupKeys.length % 360;
|
|
8677
|
-
groupColors.set(key, `hsl(${hue}, 70%, 50%)`);
|
|
8678
|
-
}
|
|
8679
|
-
});
|
|
8680
|
-
groups.forEach((groupFeatures, groupKey) => {
|
|
8681
|
-
var _a2, _b, _c, _d;
|
|
8682
|
-
const sorted = [...groupFeatures].sort((a, b) => {
|
|
8683
|
-
var _a3, _b2;
|
|
8684
|
-
const dateA = new Date(((_a3 = a.properties) == null ? void 0 : _a3.startDate) || 0).getTime();
|
|
8685
|
-
const dateB = new Date(((_b2 = b.properties) == null ? void 0 : _b2.startDate) || 0).getTime();
|
|
8686
|
-
return dateA - dateB;
|
|
8687
|
-
});
|
|
8688
|
-
if (sorted.length < 2) return;
|
|
8689
|
-
for (let i = 0; i < sorted.length - 1; i++) {
|
|
8690
|
-
const from = sorted[i];
|
|
8691
|
-
const to = sorted[i + 1];
|
|
8692
|
-
const fromCoords = from.geometry.coordinates;
|
|
8693
|
-
const toCoords = to.geometry.coordinates;
|
|
8694
|
-
const fromPoint = turf.point(fromCoords);
|
|
8695
|
-
const toPoint = turf.point(toCoords);
|
|
8696
|
-
const distanceKm = turf.distance(fromPoint, toPoint, { units: "kilometers" });
|
|
8697
|
-
const fromTime = new Date(((_a2 = from.properties) == null ? void 0 : _a2.startDate) || 0).getTime();
|
|
8698
|
-
const toTime = new Date(((_b = to.properties) == null ? void 0 : _b.startDate) || 0).getTime();
|
|
8699
|
-
const durationMs = toTime - fromTime;
|
|
8700
|
-
const durationHours = durationMs / (1e3 * 60 * 60);
|
|
8701
|
-
const avgSpeedKmh = durationHours > 0 ? distanceKm / durationHours : 0;
|
|
8702
|
-
let durationStr = "";
|
|
8703
|
-
if (durationMs < 6e4) {
|
|
8704
|
-
durationStr = `${Math.round(durationMs / 1e3)}s`;
|
|
8705
|
-
} else if (durationMs < 36e5) {
|
|
8706
|
-
durationStr = `${Math.round(durationMs / 6e4)}m`;
|
|
8707
|
-
} else if (durationMs < 864e5) {
|
|
8708
|
-
durationStr = `${Math.floor(durationMs / 36e5)}h ${Math.round(durationMs % 36e5 / 6e4)}m`;
|
|
8709
|
-
} else {
|
|
8710
|
-
durationStr = `${Math.floor(durationMs / 864e5)}d ${Math.round(durationMs % 864e5 / 36e5)}h`;
|
|
8711
|
-
}
|
|
8712
|
-
const distanceStr = distanceKm < 1 ? `${Math.round(distanceKm * 1e3)}m` : `${distanceKm.toFixed(2)}km`;
|
|
8713
|
-
const speedStr = avgSpeedKmh < 1 ? `${(avgSpeedKmh * 1e3).toFixed(0)}m/h` : `${avgSpeedKmh.toFixed(1)}km/h`;
|
|
8714
|
-
traceSegments.push({
|
|
8715
|
-
type: "Feature",
|
|
8716
|
-
properties: {
|
|
8717
|
-
group: groupKey,
|
|
8718
|
-
color: groupColors.get(groupKey) || "#3b82f6",
|
|
8719
|
-
duration: durationStr,
|
|
8720
|
-
distance: distanceStr,
|
|
8721
|
-
avgSpeed: speedStr,
|
|
8722
|
-
fromName: ((_c = from.properties) == null ? void 0 : _c.name) || "",
|
|
8723
|
-
toName: ((_d = to.properties) == null ? void 0 : _d.name) || ""
|
|
8724
|
-
},
|
|
8725
|
-
geometry: {
|
|
8726
|
-
type: "LineString",
|
|
8727
|
-
coordinates: [fromCoords, toCoords]
|
|
8728
|
-
}
|
|
8729
|
-
});
|
|
8730
|
-
}
|
|
8731
|
-
});
|
|
8732
|
-
});
|
|
8733
|
-
traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
8734
|
-
}
|
|
8827
|
+
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
8828
|
+
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
|
|
8735
8829
|
{
|
|
8736
8830
|
let sawArrowFeature = false;
|
|
8737
8831
|
const arrowLines = [];
|
|
@@ -9554,11 +9648,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9554
9648
|
let lastHoveredFeatureKey = null;
|
|
9555
9649
|
const positionTooltip = () => {
|
|
9556
9650
|
if (!tooltipLngLat || tooltipEl2.style.display === "none") return;
|
|
9557
|
-
const
|
|
9651
|
+
const point2 = mapInstance.project(tooltipLngLat);
|
|
9558
9652
|
const container = mapInstance.getContainer();
|
|
9559
9653
|
const rect = container.getBoundingClientRect();
|
|
9560
|
-
const ax = rect.left +
|
|
9561
|
-
const ay = rect.top +
|
|
9654
|
+
const ax = rect.left + point2.x;
|
|
9655
|
+
const ay = rect.top + point2.y;
|
|
9562
9656
|
const vw = window.innerWidth;
|
|
9563
9657
|
const vh = window.innerHeight;
|
|
9564
9658
|
tooltipEl2.style.maxWidth = Math.min(480, vw - 24) + "px";
|
|
@@ -9879,7 +9973,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9879
9973
|
if (e.features && e.features.length > 0) {
|
|
9880
9974
|
const props = e.features[0].properties || {};
|
|
9881
9975
|
const duration = props.duration || "";
|
|
9882
|
-
const
|
|
9976
|
+
const distance2 = props.distance || "";
|
|
9883
9977
|
const avgSpeed = props.avgSpeed || "";
|
|
9884
9978
|
const group = props.group !== "__all__" ? props.group : null;
|
|
9885
9979
|
const fromName = props.fromName || "";
|
|
@@ -9890,7 +9984,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9890
9984
|
}
|
|
9891
9985
|
html += '<div class="space-y-0.5">';
|
|
9892
9986
|
html += `<div><span class="text-muted-foreground">Duration:</span> <span class="font-medium">${duration}</span></div>`;
|
|
9893
|
-
html += `<div><span class="text-muted-foreground">Distance:</span> <span class="font-medium">${
|
|
9987
|
+
html += `<div><span class="text-muted-foreground">Distance:</span> <span class="font-medium">${distance2}</span></div>`;
|
|
9894
9988
|
html += `<div><span class="text-muted-foreground">Avg Speed:</span> <span class="font-medium">${avgSpeed}</span></div>`;
|
|
9895
9989
|
html += "</div>";
|
|
9896
9990
|
if (group) {
|
|
@@ -10618,7 +10712,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10618
10712
|
clusterConfig: options == null ? void 0 : options.clusterConfig,
|
|
10619
10713
|
altitudeDisplayMode: options == null ? void 0 : options.altitudeDisplayMode
|
|
10620
10714
|
};
|
|
10621
|
-
let addedFeatures =
|
|
10715
|
+
let addedFeatures = [];
|
|
10622
10716
|
let capDropped = 0;
|
|
10623
10717
|
if (geojson) {
|
|
10624
10718
|
const max = featureCapRef.current;
|
|
@@ -10675,9 +10769,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10675
10769
|
scheduleSync();
|
|
10676
10770
|
if (!(options == null ? void 0 : options.skipFit) && addedFeatures.length > 0 && map.current) {
|
|
10677
10771
|
try {
|
|
10678
|
-
const bbox = turf.bbox(
|
|
10679
|
-
|
|
10680
|
-
|
|
10772
|
+
const bbox = turf.bbox({
|
|
10773
|
+
type: "FeatureCollection",
|
|
10774
|
+
features: addedFeatures
|
|
10775
|
+
});
|
|
10681
10776
|
if (bbox.every((v) => isFinite(v))) {
|
|
10682
10777
|
map.current.fitBounds(
|
|
10683
10778
|
[[bbox[0], bbox[1]], [bbox[2], bbox[3]]],
|
|
@@ -10782,7 +10877,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10782
10877
|
dropped: prepared.dropped,
|
|
10783
10878
|
sourceCount: prepared.sourceCount,
|
|
10784
10879
|
max: featureCapRef.current,
|
|
10785
|
-
source: "api"
|
|
10880
|
+
source: "api",
|
|
10881
|
+
existing: existing.length
|
|
10786
10882
|
});
|
|
10787
10883
|
}
|
|
10788
10884
|
const layerHasTemporal = (((_a = layerTemporalCacheRef.current.get(layerId)) == null ? void 0 : _a.hasTemporal) ?? false) || prepared.hasTemporal;
|
|
@@ -10804,9 +10900,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10804
10900
|
}
|
|
10805
10901
|
if (!draw.current) return [];
|
|
10806
10902
|
const addedIds = [];
|
|
10903
|
+
const existingInLayer = countExisting(layer);
|
|
10807
10904
|
const cappedForDraw = capFeatures(features, {
|
|
10808
10905
|
max: featureCapRef.current,
|
|
10809
|
-
existing:
|
|
10906
|
+
existing: existingInLayer
|
|
10810
10907
|
});
|
|
10811
10908
|
if (cappedForDraw.dropped > 0) {
|
|
10812
10909
|
notifyFeatureCap({
|
|
@@ -10816,7 +10913,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10816
10913
|
dropped: cappedForDraw.dropped,
|
|
10817
10914
|
sourceCount: cappedForDraw.sourceCount,
|
|
10818
10915
|
max: featureCapRef.current,
|
|
10819
|
-
source: "api"
|
|
10916
|
+
source: "api",
|
|
10917
|
+
existing: existingInLayer
|
|
10820
10918
|
});
|
|
10821
10919
|
}
|
|
10822
10920
|
isApiAddingRef.current = true;
|
|
@@ -10933,9 +11031,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10933
11031
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
10934
11032
|
if (!layer || !draw.current || !isMapLoaded) return [];
|
|
10935
11033
|
const addedIds = [];
|
|
11034
|
+
const existingInLayer = countExisting(layer);
|
|
10936
11035
|
const capped = capFeatures(geojson.features, {
|
|
10937
11036
|
max: featureCapRef.current,
|
|
10938
|
-
existing:
|
|
11037
|
+
existing: existingInLayer
|
|
10939
11038
|
});
|
|
10940
11039
|
if (capped.dropped > 0) {
|
|
10941
11040
|
notifyFeatureCap({
|
|
@@ -10945,7 +11044,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10945
11044
|
dropped: capped.dropped,
|
|
10946
11045
|
sourceCount: capped.sourceCount,
|
|
10947
11046
|
max: featureCapRef.current,
|
|
10948
|
-
source: "api"
|
|
11047
|
+
source: "api",
|
|
11048
|
+
existing: existingInLayer
|
|
10949
11049
|
});
|
|
10950
11050
|
}
|
|
10951
11051
|
isApiAddingRef.current = true;
|
|
@@ -11532,8 +11632,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11532
11632
|
}, 0);
|
|
11533
11633
|
if (!map.current) return;
|
|
11534
11634
|
const mapInstance = map.current;
|
|
11535
|
-
const
|
|
11536
|
-
const clickedFeatures = mapInstance.queryRenderedFeatures(
|
|
11635
|
+
const point2 = [e.offsetX, e.offsetY];
|
|
11636
|
+
const clickedFeatures = mapInstance.queryRenderedFeatures(point2, {
|
|
11537
11637
|
layers: ["custom-point", "custom-line", "custom-polygon-fill"]
|
|
11538
11638
|
});
|
|
11539
11639
|
let features = [];
|
|
@@ -12725,23 +12825,26 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12725
12825
|
const m = map.current;
|
|
12726
12826
|
if (!m) return true;
|
|
12727
12827
|
if (hasArrowFeaturesRef.current) return false;
|
|
12728
|
-
if (layersRef.current.some((l) => {
|
|
12729
|
-
var _a;
|
|
12730
|
-
return l.visible && ((_a = l.traceConfig) == null ? void 0 : _a.enabled);
|
|
12731
|
-
})) return false;
|
|
12732
12828
|
const source = m.getSource("custom-features");
|
|
12733
|
-
const
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
);
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12829
|
+
const paintCache = selectionPaintCacheRef.current;
|
|
12830
|
+
const nextVisible = timelineVisibleIdsRef.current;
|
|
12831
|
+
const trace = tracePaintCacheRef.current;
|
|
12832
|
+
const traceSource = trace ? m.getSource("trace-features") : void 0;
|
|
12833
|
+
if (trace && !traceSource) return false;
|
|
12834
|
+
const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
|
|
12835
|
+
const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
|
|
12836
|
+
if (!applied || !paintCache || !source) return false;
|
|
12837
|
+
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, paintCache, source, traceSource))) return false;
|
|
12838
|
+
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
12839
|
+
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
12840
|
+
setLabelsSuppressed(false);
|
|
12841
|
+
mapPerfLog("timeline", "fast path applied", {
|
|
12842
|
+
toggled,
|
|
12843
|
+
endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
|
|
12844
|
+
segmentsAdded: (traceDiff == null ? void 0 : traceDiff.segmentAdd.length) ?? 0,
|
|
12845
|
+
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
12846
|
+
});
|
|
12847
|
+
return true;
|
|
12745
12848
|
}, [autoLabelConfig, countVisibleFeatures]);
|
|
12746
12849
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
12747
12850
|
const collectSelectionFeatureGroups = useCallback(() => {
|
|
@@ -13357,11 +13460,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13357
13460
|
const updated = [...prev, newPoint];
|
|
13358
13461
|
if (measureMode === "distance" && updated.length >= 2) {
|
|
13359
13462
|
const line = turf.lineString(updated);
|
|
13360
|
-
const
|
|
13361
|
-
if (
|
|
13362
|
-
setMeasureResult(`${(
|
|
13463
|
+
const distance2 = turf.length(line, { units: "kilometers" });
|
|
13464
|
+
if (distance2 < 1) {
|
|
13465
|
+
setMeasureResult(`${(distance2 * 1e3).toFixed(1)} m`);
|
|
13363
13466
|
} else {
|
|
13364
|
-
setMeasureResult(`${
|
|
13467
|
+
setMeasureResult(`${distance2.toFixed(2)} km`);
|
|
13365
13468
|
}
|
|
13366
13469
|
} else if (measureMode === "area" && updated.length >= 3) {
|
|
13367
13470
|
const closed = [...updated, updated[0]];
|
|
@@ -13503,11 +13606,18 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13503
13606
|
new Blob(parts, { type: "application/json" }),
|
|
13504
13607
|
`${layer.name.replace(/[^a-z0-9]/gi, "_")}.geojson`
|
|
13505
13608
|
);
|
|
13609
|
+
} catch (error) {
|
|
13610
|
+
console.error(`Failed to export layer "${layer.name}" as GeoJSON:`, error);
|
|
13611
|
+
toast({
|
|
13612
|
+
title: "Export failed",
|
|
13613
|
+
description: error instanceof Error ? error.message : "Could not prepare the download",
|
|
13614
|
+
variant: "destructive"
|
|
13615
|
+
});
|
|
13506
13616
|
} finally {
|
|
13507
13617
|
progress.end();
|
|
13508
13618
|
exportInFlightRef.current = false;
|
|
13509
13619
|
}
|
|
13510
|
-
}, [layers, ingestProgressStore]);
|
|
13620
|
+
}, [layers, ingestProgressStore, toast]);
|
|
13511
13621
|
const handleLoadLayerGeoJSON = useCallback((layerId) => {
|
|
13512
13622
|
const input = fileInputRef.current;
|
|
13513
13623
|
if (!input) return;
|
|
@@ -13587,11 +13697,18 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13587
13697
|
onProgress: (done) => progress.update(done)
|
|
13588
13698
|
});
|
|
13589
13699
|
downloadBlob(new Blob(parts, { type: "application/geo+json" }), "map_export.geojson");
|
|
13700
|
+
} catch (error) {
|
|
13701
|
+
console.error("Failed to export the map as GeoJSON:", error);
|
|
13702
|
+
toast({
|
|
13703
|
+
title: "Export failed",
|
|
13704
|
+
description: error instanceof Error ? error.message : "Could not prepare the download",
|
|
13705
|
+
variant: "destructive"
|
|
13706
|
+
});
|
|
13590
13707
|
} finally {
|
|
13591
13708
|
progress.end();
|
|
13592
13709
|
exportInFlightRef.current = false;
|
|
13593
13710
|
}
|
|
13594
|
-
}, [buildEnrichedExport, ingestProgressStore]);
|
|
13711
|
+
}, [buildEnrichedExport, ingestProgressStore, toast]);
|
|
13595
13712
|
const handleSearchAndAddToNewLayer = useCallback(async () => {
|
|
13596
13713
|
if (!onSearchEngineRequest || !map.current || !draw.current) return;
|
|
13597
13714
|
const mapInstance = map.current;
|
|
@@ -13626,9 +13743,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13626
13743
|
saveStateForUndo();
|
|
13627
13744
|
const activeId = activeEditingLayerIdRef.current;
|
|
13628
13745
|
const activeLayer = activeId ? layersRef.current.find((l) => l.id === activeId && !l.readOnly) : null;
|
|
13746
|
+
const existingInActive = activeLayer ? countExisting(activeLayer) : 0;
|
|
13629
13747
|
const capped = capFeatures(result.features, {
|
|
13630
13748
|
max: featureCapRef.current,
|
|
13631
|
-
existing:
|
|
13749
|
+
existing: existingInActive
|
|
13632
13750
|
});
|
|
13633
13751
|
const addedIds = [];
|
|
13634
13752
|
isApiAddingRef.current = true;
|
|
@@ -13687,7 +13805,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13687
13805
|
dropped: capped.dropped,
|
|
13688
13806
|
sourceCount: capped.sourceCount,
|
|
13689
13807
|
max: featureCapRef.current,
|
|
13690
|
-
source: "search"
|
|
13808
|
+
source: "search",
|
|
13809
|
+
existing: existingInActive
|
|
13691
13810
|
});
|
|
13692
13811
|
}
|
|
13693
13812
|
updateFeatureCount();
|
|
@@ -14028,15 +14147,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14028
14147
|
layerTemporalCacheRef.current.set(layerId, { featureCount: normalizedFeatures.length, hasTemporal: fileHasTemporal });
|
|
14029
14148
|
newLayer.featureIds = addedIds;
|
|
14030
14149
|
if (result.truncated) {
|
|
14031
|
-
notifyFeatureCap(
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
});
|
|
14150
|
+
notifyFeatureCap(
|
|
14151
|
+
truncationToCapInfo(result.truncated, {
|
|
14152
|
+
layerId,
|
|
14153
|
+
layerName: newLayer.name,
|
|
14154
|
+
kept: normalizedFeatures.length,
|
|
14155
|
+
source: "file"
|
|
14156
|
+
})
|
|
14157
|
+
);
|
|
14040
14158
|
}
|
|
14041
14159
|
setLayers((prev) => [...prev, newLayer]);
|
|
14042
14160
|
updateFeatureCount();
|
|
@@ -14081,9 +14199,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14081
14199
|
return;
|
|
14082
14200
|
}
|
|
14083
14201
|
const targetId = targetLayer.id;
|
|
14202
|
+
const existingInTarget = countExisting(targetLayer);
|
|
14084
14203
|
const appendCapped = capFeatures(normalizedFeatures, {
|
|
14085
14204
|
max: featureCapRef.current,
|
|
14086
|
-
existing:
|
|
14205
|
+
existing: existingInTarget
|
|
14087
14206
|
});
|
|
14088
14207
|
const appendFeatures = appendCapped.features;
|
|
14089
14208
|
const totalDropped = (((_b = result.truncated) == null ? void 0 : _b.droppedCount) ?? 0) + appendCapped.dropped;
|
|
@@ -14095,7 +14214,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14095
14214
|
dropped: totalDropped,
|
|
14096
14215
|
sourceCount: ((_c = result.truncated) == null ? void 0 : _c.sourceFeatureCount) ?? appendCapped.sourceCount,
|
|
14097
14216
|
max: featureCapRef.current,
|
|
14098
|
-
source: "file"
|
|
14217
|
+
source: "file",
|
|
14218
|
+
existing: existingInTarget
|
|
14099
14219
|
});
|
|
14100
14220
|
}
|
|
14101
14221
|
const withLayerMetadata = (l, addedIds) => ({
|
|
@@ -14205,15 +14325,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14205
14325
|
layerTemporalCacheRef.current.set(layerId, { featureCount: normalizedFeatures.length, hasTemporal: result.hasTemporal });
|
|
14206
14326
|
newLayer.featureIds = addedIds;
|
|
14207
14327
|
if (result.truncated) {
|
|
14208
|
-
notifyFeatureCap(
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
});
|
|
14328
|
+
notifyFeatureCap(
|
|
14329
|
+
truncationToCapInfo(result.truncated, {
|
|
14330
|
+
layerId,
|
|
14331
|
+
layerName: newLayer.name,
|
|
14332
|
+
kept: normalizedFeatures.length,
|
|
14333
|
+
source: "drop"
|
|
14334
|
+
})
|
|
14335
|
+
);
|
|
14217
14336
|
}
|
|
14218
14337
|
const nextLayers = [...layersRef.current, newLayer];
|
|
14219
14338
|
layersRef.current = nextLayers;
|
|
@@ -14759,8 +14878,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14759
14878
|
"polygon",
|
|
14760
14879
|
{
|
|
14761
14880
|
points: selectionPoints.map(([lng, lat]) => {
|
|
14762
|
-
const
|
|
14763
|
-
return `${
|
|
14881
|
+
const point2 = map.current.project([lng, lat]);
|
|
14882
|
+
return `${point2.x},${point2.y}`;
|
|
14764
14883
|
}).join(" "),
|
|
14765
14884
|
fill: "rgba(59, 130, 246, 0.15)",
|
|
14766
14885
|
stroke: "rgb(59, 130, 246)",
|
|
@@ -14819,12 +14938,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14819
14938
|
}
|
|
14820
14939
|
),
|
|
14821
14940
|
selectionPoints.map(([lng, lat], i) => {
|
|
14822
|
-
const
|
|
14941
|
+
const point2 = map.current.project([lng, lat]);
|
|
14823
14942
|
return /* @__PURE__ */ jsx(
|
|
14824
14943
|
"circle",
|
|
14825
14944
|
{
|
|
14826
|
-
cx:
|
|
14827
|
-
cy:
|
|
14945
|
+
cx: point2.x,
|
|
14946
|
+
cy: point2.y,
|
|
14828
14947
|
r: "5",
|
|
14829
14948
|
fill: "rgb(59, 130, 246)",
|
|
14830
14949
|
stroke: "white",
|
|
@@ -14856,8 +14975,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14856
14975
|
"polygon",
|
|
14857
14976
|
{
|
|
14858
14977
|
points: selectionPoints.map(([lng, lat]) => {
|
|
14859
|
-
const
|
|
14860
|
-
return `${
|
|
14978
|
+
const point2 = map.current.project([lng, lat]);
|
|
14979
|
+
return `${point2.x},${point2.y}`;
|
|
14861
14980
|
}).join(" "),
|
|
14862
14981
|
fill: "rgba(59, 130, 246, 0.15)",
|
|
14863
14982
|
stroke: "rgb(59, 130, 246)",
|
|
@@ -14877,8 +14996,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14877
14996
|
"polygon",
|
|
14878
14997
|
{
|
|
14879
14998
|
points: circleDrawPreview.map(([lng, lat]) => {
|
|
14880
|
-
const
|
|
14881
|
-
return `${
|
|
14999
|
+
const point2 = map.current.project([lng, lat]);
|
|
15000
|
+
return `${point2.x},${point2.y}`;
|
|
14882
15001
|
}).join(" "),
|
|
14883
15002
|
fill: "rgba(34, 197, 94, 0.15)",
|
|
14884
15003
|
stroke: "rgb(34, 197, 94)",
|
|
@@ -14910,8 +15029,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14910
15029
|
"polygon",
|
|
14911
15030
|
{
|
|
14912
15031
|
points: rectangleDrawPreview.map(([lng, lat]) => {
|
|
14913
|
-
const
|
|
14914
|
-
return `${
|
|
15032
|
+
const point2 = map.current.project([lng, lat]);
|
|
15033
|
+
return `${point2.x},${point2.y}`;
|
|
14915
15034
|
}).join(" "),
|
|
14916
15035
|
fill: "rgba(34, 197, 94, 0.15)",
|
|
14917
15036
|
stroke: "rgb(34, 197, 94)",
|
|
@@ -15644,9 +15763,9 @@ function generateNYCPoints(count) {
|
|
|
15644
15763
|
};
|
|
15645
15764
|
const features = Array.from({ length: count }, (_, i) => {
|
|
15646
15765
|
const angle = Math.random() * Math.PI * 2;
|
|
15647
|
-
const
|
|
15648
|
-
const lng = nycCenter.lng + Math.cos(angle) *
|
|
15649
|
-
const lat = nycCenter.lat + Math.sin(angle) *
|
|
15766
|
+
const distance2 = Math.random() * Math.random() * spread;
|
|
15767
|
+
const lng = nycCenter.lng + Math.cos(angle) * distance2;
|
|
15768
|
+
const lat = nycCenter.lat + Math.sin(angle) * distance2 * 0.7;
|
|
15650
15769
|
const type = getRandomType();
|
|
15651
15770
|
const maxOccupancy = getMaxOccupancy(type);
|
|
15652
15771
|
return {
|