@octostar/map-component 0.6.4 → 0.6.5
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.mjs +303 -124
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -0
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/timebar.d.ts +9 -1
- package/dist/types/components/timebar.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/history-diff.d.ts +2 -0
- package/dist/types/lib/history-diff.d.ts.map +1 -1
- package/dist/types/lib/map-editor-api.d.ts +30 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/dist/types/lib/temporal-ingest.d.ts +4 -1
- package/dist/types/lib/temporal-ingest.d.ts.map +1 -1
- package/dist/types/lib/temporal-normalize.d.ts +16 -0
- package/dist/types/lib/temporal-normalize.d.ts.map +1 -1
- package/dist/types/lib/timeline-index.d.ts +6 -5
- package/dist/types/lib/timeline-index.d.ts.map +1 -1
- package/dist/types/lib/timeline-state.d.ts +21 -5
- package/dist/types/lib/timeline-state.d.ts.map +1 -1
- package/dist/types/lib/trace-group-suggestion.d.ts +2 -1
- package/dist/types/lib/trace-group-suggestion.d.ts.map +1 -1
- package/dist/types/lib/trace-groups.d.ts +8 -4
- package/dist/types/lib/trace-groups.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -144,7 +144,7 @@ async function featureCollectionBlobPartsAsync(collection, options) {
|
|
|
144
144
|
(_c = options == null ? void 0 : options.onProgress) == null ? void 0 : _c.call(options, total, total);
|
|
145
145
|
return coalescer.finish();
|
|
146
146
|
}
|
|
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=
|
|
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=A(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 A(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 E(){let e=globalThis.crypto?.randomUUID?.bind(globalThis.crypto);return e?e():`f-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function G(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):E()}}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 _(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,w)=>{let p=G(c,w,t);!u&&I(c)&&(u=!0);let g=c.properties||{};if(!h(g)){i.push(t.idStrategy==="preserve"?c:{...c,id:p});return}let{startDate:y,endDate:k}=F(g);(y||k)&&(o=!0),i.push({...c,...p!==void 0&&{id:p},properties:{...g,startDate:y?.toISOString()||null,endDate:k?.toISOString()||null}})});let m=n.properties?.layerMetadata;return{kind:"features",features:i,featureCount:i.length,bbox:_(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 T=5e3;function J(e,t){let n=Number.isNaN(t)?T: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 f(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(!f(e[t]))return!1;return!0}for(let t in e)if(!f(e[t]))return!1;return!0}function M(e){for(let t=0;t<e.length;t++)if(!f(e[t]))return e;try{return JSON.stringify(e)}catch{return e}}function P(e){let{kind:t,features:n,...r}=e;return r}async function D(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??M,o=J(s.features,r.chunkSize??T);r.post({kind:"head",id:e,summary:P(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 N=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 D(n,o,s,{post:N,waitAck:u=>new Promise(i=>{l.set(`${n}:${u}`,i)}),...a?.chunkSize!==void 0&&{chunkSize:a.chunkSize},...a?.featureArrayChunks&&{encode:u=>u}})}catch(o){N({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';
|
|
148
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");
|
|
149
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");
|
|
150
150
|
proj4.defs("EPSG:32630", "+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs");
|
|
@@ -272,6 +272,23 @@ function normalizeTemporalProperties(properties) {
|
|
|
272
272
|
}
|
|
273
273
|
return { startDate, endDate };
|
|
274
274
|
}
|
|
275
|
+
const timelineFieldsKey = (fields) => fields ? JSON.stringify([fields.start, fields.end ?? null]) : "";
|
|
276
|
+
function hasTimelineValue(properties, fields) {
|
|
277
|
+
return fields ? !!properties[fields.start] : hasAnyTemporalValue(properties);
|
|
278
|
+
}
|
|
279
|
+
const anyTimelineDate = (features, fields) => features.some((f) => {
|
|
280
|
+
const properties = f.properties ?? {};
|
|
281
|
+
if (!hasTimelineValue(properties, fields)) return false;
|
|
282
|
+
const { startDate, endDate } = readTimelineDates(properties, fields);
|
|
283
|
+
return startDate !== null || endDate !== null;
|
|
284
|
+
});
|
|
285
|
+
function readTimelineDates(properties, fields) {
|
|
286
|
+
if (!fields) return normalizeTemporalProperties(properties);
|
|
287
|
+
const startDate = parseDate(properties[fields.start]);
|
|
288
|
+
if (!startDate) return { startDate: null, endDate: null };
|
|
289
|
+
const endDate = fields.end ? parseDate(properties[fields.end]) : null;
|
|
290
|
+
return endDate && endDate < startDate ? { startDate: endDate, endDate: startDate } : { startDate, endDate };
|
|
291
|
+
}
|
|
275
292
|
function generateUuid() {
|
|
276
293
|
var _a, _b;
|
|
277
294
|
const uuid = (_b = (_a = globalThis.crypto) == null ? void 0 : _a.randomUUID) == null ? void 0 : _b.bind(globalThis.crypto);
|
|
@@ -1693,24 +1710,24 @@ function isIntervalVisible(s, e, w) {
|
|
|
1693
1710
|
return (noStart ? e : s) <= w.t1 && (noEnd ? s : e) >= w.t0;
|
|
1694
1711
|
}
|
|
1695
1712
|
const interval = { s: NaN, e: NaN };
|
|
1696
|
-
function readInterval(f) {
|
|
1713
|
+
function readInterval(f, fields) {
|
|
1697
1714
|
interval.s = NaN;
|
|
1698
1715
|
interval.e = NaN;
|
|
1699
1716
|
const props = f.properties;
|
|
1700
|
-
if (!props || !
|
|
1701
|
-
const { startDate, endDate } =
|
|
1717
|
+
if (!props || !hasTimelineValue(props, fields)) return;
|
|
1718
|
+
const { startDate, endDate } = readTimelineDates(props, fields);
|
|
1702
1719
|
const s = startDate ? startDate.getTime() : NaN;
|
|
1703
1720
|
const e = endDate ? endDate.getTime() : NaN;
|
|
1704
1721
|
interval.s = Number.isNaN(s) ? e : s;
|
|
1705
1722
|
interval.e = Number.isNaN(e) ? s : e;
|
|
1706
1723
|
}
|
|
1707
|
-
function featureInterval(f) {
|
|
1708
|
-
readInterval(f);
|
|
1724
|
+
function featureInterval(f, fields) {
|
|
1725
|
+
readInterval(f, fields);
|
|
1709
1726
|
return { s: interval.s, e: interval.e };
|
|
1710
1727
|
}
|
|
1711
|
-
function isFeatureVisible(f, w) {
|
|
1728
|
+
function isFeatureVisible(f, w, fields) {
|
|
1712
1729
|
if (w === null) return true;
|
|
1713
|
-
readInterval(f);
|
|
1730
|
+
readInterval(f, fields);
|
|
1714
1731
|
return isIntervalVisible(interval.s, interval.e, w);
|
|
1715
1732
|
}
|
|
1716
1733
|
function collectRepeats(features) {
|
|
@@ -1730,13 +1747,13 @@ function collectRepeats(features) {
|
|
|
1730
1747
|
}
|
|
1731
1748
|
return repeats;
|
|
1732
1749
|
}
|
|
1733
|
-
function buildIndex(features) {
|
|
1750
|
+
function buildIndex(features, fields) {
|
|
1734
1751
|
const size = features.length;
|
|
1735
1752
|
const starts = new Float64Array(size);
|
|
1736
1753
|
const ends = new Float64Array(size);
|
|
1737
1754
|
let timed = 0;
|
|
1738
1755
|
for (let i = 0; i < size; i++) {
|
|
1739
|
-
readInterval(features[i]);
|
|
1756
|
+
readInterval(features[i], fields);
|
|
1740
1757
|
starts[i] = interval.s;
|
|
1741
1758
|
ends[i] = interval.e;
|
|
1742
1759
|
if (!Number.isNaN(interval.s)) timed++;
|
|
@@ -1762,14 +1779,14 @@ function buildIndex(features) {
|
|
|
1762
1779
|
};
|
|
1763
1780
|
}
|
|
1764
1781
|
const cache$1 = /* @__PURE__ */ new WeakMap();
|
|
1765
|
-
function getTimelineIndex(features) {
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1782
|
+
function getTimelineIndex(features, fields) {
|
|
1783
|
+
const key = timelineFieldsKey(fields);
|
|
1784
|
+
const cached = cache$1.get(features);
|
|
1785
|
+
if ((cached == null ? void 0 : cached.key) === key) return cached.index;
|
|
1786
|
+
const started = performance.now();
|
|
1787
|
+
const index = buildIndex(features, fields);
|
|
1788
|
+
cache$1.set(features, { key, index });
|
|
1789
|
+
mapPerfLog("timeline", "index built", { n: features.length, ms: Math.round(performance.now() - started) });
|
|
1773
1790
|
return index;
|
|
1774
1791
|
}
|
|
1775
1792
|
function isVisibleAt(index, position, w) {
|
|
@@ -1830,21 +1847,29 @@ function countVisible(index, w) {
|
|
|
1830
1847
|
const TRACE_DEFAULT_COLOR = "#3b82f6";
|
|
1831
1848
|
const TRACE_UNGROUPED_KEY = "__all__";
|
|
1832
1849
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
1833
|
-
function getTraceGroups(features, groupByField) {
|
|
1850
|
+
function getTraceGroups(features, groupByField, fields) {
|
|
1834
1851
|
const field = groupByField || null;
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1852
|
+
const fieldsKey = timelineFieldsKey(fields);
|
|
1853
|
+
let entry = cache.get(features);
|
|
1854
|
+
if ((entry == null ? void 0 : entry.fieldsKey) !== fieldsKey) {
|
|
1855
|
+
entry = { fieldsKey, byField: /* @__PURE__ */ new Map() };
|
|
1856
|
+
cache.set(features, entry);
|
|
1839
1857
|
}
|
|
1858
|
+
const { byField } = entry;
|
|
1840
1859
|
const fieldKey = field ?? "";
|
|
1841
1860
|
let groups = byField.get(fieldKey);
|
|
1842
1861
|
if (!groups) {
|
|
1843
|
-
groups = buildTraceGroups(features, field);
|
|
1862
|
+
groups = buildTraceGroups(features, field, fields);
|
|
1844
1863
|
byField.set(fieldKey, groups);
|
|
1845
1864
|
}
|
|
1846
1865
|
return groups;
|
|
1847
1866
|
}
|
|
1867
|
+
function traceTime(feature, fields) {
|
|
1868
|
+
const props = feature.properties;
|
|
1869
|
+
if (!fields) return (props == null ? void 0 : props.startDate) ? new Date(props.startDate).getTime() : null;
|
|
1870
|
+
const { startDate } = readTimelineDates(props ?? {}, fields);
|
|
1871
|
+
return startDate ? startDate.getTime() : null;
|
|
1872
|
+
}
|
|
1848
1873
|
function sortKey(time) {
|
|
1849
1874
|
return Number.isNaN(time) ? -Infinity : time;
|
|
1850
1875
|
}
|
|
@@ -1855,20 +1880,22 @@ function compareStaged(a, b) {
|
|
|
1855
1880
|
if (ka > kb) return 1;
|
|
1856
1881
|
return 0;
|
|
1857
1882
|
}
|
|
1858
|
-
function buildTraceGroups(features, field) {
|
|
1883
|
+
function buildTraceGroups(features, field, fields) {
|
|
1859
1884
|
var _a;
|
|
1860
1885
|
const staged = /* @__PURE__ */ new Map();
|
|
1861
1886
|
for (let position = 0; position < features.length; position++) {
|
|
1862
1887
|
const feature = features[position];
|
|
1863
|
-
if (feature.id == null || feature.geometry.type !== "Point"
|
|
1864
|
-
const
|
|
1888
|
+
if (feature.id == null || feature.geometry.type !== "Point") continue;
|
|
1889
|
+
const time = traceTime(feature, fields);
|
|
1890
|
+
if (time === null) continue;
|
|
1891
|
+
const raw = field ? (_a = feature.properties) == null ? void 0 : _a[field] : void 0;
|
|
1865
1892
|
const key = field && raw != null && raw !== "" ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
1866
1893
|
let bucket = staged.get(key);
|
|
1867
1894
|
if (!bucket) {
|
|
1868
1895
|
bucket = [];
|
|
1869
1896
|
staged.set(key, bucket);
|
|
1870
1897
|
}
|
|
1871
|
-
bucket.push({ feature, time
|
|
1898
|
+
bucket.push({ feature, time, position });
|
|
1872
1899
|
}
|
|
1873
1900
|
const count = staged.size;
|
|
1874
1901
|
const groups = [];
|
|
@@ -7619,6 +7646,7 @@ function useTimelineStore(selector) {
|
|
|
7619
7646
|
return useStore(store, select);
|
|
7620
7647
|
}
|
|
7621
7648
|
const TIMEBAR_HEIGHT = 158;
|
|
7649
|
+
const EMPTY_TIMEBAR_HEIGHT = 46;
|
|
7622
7650
|
const TIMEBAR_BOTTOM_OFFSET = 12;
|
|
7623
7651
|
const DEFAULT_LABELS = {
|
|
7624
7652
|
play: "Play",
|
|
@@ -7857,6 +7885,7 @@ function Timebar({
|
|
|
7857
7885
|
selectionDisplay = "bars",
|
|
7858
7886
|
className,
|
|
7859
7887
|
timebarExtra,
|
|
7888
|
+
keepExtraWhenEmpty = false,
|
|
7860
7889
|
formatCount: formatCount2,
|
|
7861
7890
|
labels: labelOverrides
|
|
7862
7891
|
}) {
|
|
@@ -8005,7 +8034,19 @@ function Timebar({
|
|
|
8005
8034
|
};
|
|
8006
8035
|
}, [isPlaying, globalMinDate, globalMaxDate, setRange, setPlaying]);
|
|
8007
8036
|
if (!isEnabled || !hasTemporalData || !globalMinDate || !globalMaxDate) {
|
|
8008
|
-
return null;
|
|
8037
|
+
if (!isEnabled || !keepExtraWhenEmpty) return null;
|
|
8038
|
+
return /* @__PURE__ */ jsx(
|
|
8039
|
+
"div",
|
|
8040
|
+
{
|
|
8041
|
+
className: cn(
|
|
8042
|
+
"absolute bottom-3 left-4 right-4 z-20 bg-background/95 floating-panel rounded-lg shadow-lg border border-border px-4 flex items-center justify-end",
|
|
8043
|
+
className
|
|
8044
|
+
),
|
|
8045
|
+
style: { height: EMPTY_TIMEBAR_HEIGHT },
|
|
8046
|
+
"data-testid": "timebar-panel-empty",
|
|
8047
|
+
children: timebarExtra
|
|
8048
|
+
}
|
|
8049
|
+
);
|
|
8009
8050
|
}
|
|
8010
8051
|
const totalRange = globalMaxDate.getTime() - globalMinDate.getTime();
|
|
8011
8052
|
const startPercent = rangeStart ? (rangeStart.getTime() - globalMinDate.getTime()) / totalRange * 100 : 0;
|
|
@@ -8313,6 +8354,9 @@ function historyLayersEqual(a, b) {
|
|
|
8313
8354
|
const { featureIds: _bIds, ...bRest } = b;
|
|
8314
8355
|
return JSON.stringify(aRest) === JSON.stringify(bRest);
|
|
8315
8356
|
}
|
|
8357
|
+
function historyFeatureContentEqual(a, b) {
|
|
8358
|
+
return JSON.stringify(a.geometry) === JSON.stringify(b.geometry) && JSON.stringify(a.properties ?? {}) === JSON.stringify(b.properties ?? {});
|
|
8359
|
+
}
|
|
8316
8360
|
function diffHistorySnapshots(before, after, beforeLayers, afterLayers) {
|
|
8317
8361
|
const allFeatureIds = /* @__PURE__ */ new Set();
|
|
8318
8362
|
before.forEach((_v, k) => allFeatureIds.add(k));
|
|
@@ -8326,9 +8370,7 @@ function diffHistorySnapshots(before, after, beforeLayers, afterLayers) {
|
|
|
8326
8370
|
return;
|
|
8327
8371
|
}
|
|
8328
8372
|
if (b.feature === a.feature) return;
|
|
8329
|
-
if (
|
|
8330
|
-
featureIds.add(id);
|
|
8331
|
-
}
|
|
8373
|
+
if (!historyFeatureContentEqual(b.feature, a.feature)) featureIds.add(id);
|
|
8332
8374
|
});
|
|
8333
8375
|
const allLayerIds = /* @__PURE__ */ new Set();
|
|
8334
8376
|
beforeLayers.forEach((_v, k) => allLayerIds.add(k));
|
|
@@ -8670,25 +8712,25 @@ function pushCopy(copies, id, copy, first) {
|
|
|
8670
8712
|
if (list) list.push(copy);
|
|
8671
8713
|
else copies.set(id, [first, copy]);
|
|
8672
8714
|
}
|
|
8673
|
-
function collectCopies(slices) {
|
|
8715
|
+
function collectCopies(slices, fields) {
|
|
8674
8716
|
const copies = /* @__PURE__ */ new Map();
|
|
8675
8717
|
if (slices.length === 1) {
|
|
8676
8718
|
const { features, start, end } = slices[0];
|
|
8677
|
-
const index = getTimelineIndex(features);
|
|
8719
|
+
const index = getTimelineIndex(features, fields);
|
|
8678
8720
|
index.repeats.forEach((positions, id) => {
|
|
8679
8721
|
const inside = positions.filter((p) => p >= start && p < end);
|
|
8680
|
-
if (inside.length > 1) copies.set(id, inside.map((position) => ({ index, position })));
|
|
8722
|
+
if (inside.length > 1) copies.set(id, inside.map((position) => ({ features, index, position })));
|
|
8681
8723
|
});
|
|
8682
8724
|
return copies;
|
|
8683
8725
|
}
|
|
8684
8726
|
const first = /* @__PURE__ */ new Map();
|
|
8685
8727
|
slices.forEach(({ features, start, end }) => {
|
|
8686
|
-
const index = getTimelineIndex(features);
|
|
8728
|
+
const index = getTimelineIndex(features, fields);
|
|
8687
8729
|
for (let position = start; position < end; position++) {
|
|
8688
8730
|
const raw = features[position].id;
|
|
8689
8731
|
if (raw === void 0 || raw === null) continue;
|
|
8690
8732
|
const id = String(raw);
|
|
8691
|
-
const copy = { index, position };
|
|
8733
|
+
const copy = { features, index, position };
|
|
8692
8734
|
const seen = first.get(id);
|
|
8693
8735
|
if (seen) pushCopy(copies, id, copy, seen);
|
|
8694
8736
|
else first.set(id, copy);
|
|
@@ -8696,13 +8738,13 @@ function collectCopies(slices) {
|
|
|
8696
8738
|
});
|
|
8697
8739
|
return copies;
|
|
8698
8740
|
}
|
|
8699
|
-
function copiesOf(record) {
|
|
8700
|
-
record.copies ?? (record.copies = collectCopies(record.slices));
|
|
8741
|
+
function copiesOf(record, fields) {
|
|
8742
|
+
record.copies ?? (record.copies = collectCopies(record.slices, fields));
|
|
8701
8743
|
return record.copies;
|
|
8702
8744
|
}
|
|
8703
|
-
function shouldHide(record, id, index, position, w) {
|
|
8745
|
+
function shouldHide(record, id, index, position, w, fields) {
|
|
8704
8746
|
if (isVisibleAt(index, position, w)) return false;
|
|
8705
|
-
const copies = copiesOf(record).get(id);
|
|
8747
|
+
const copies = copiesOf(record, fields).get(id);
|
|
8706
8748
|
return !copies || copies.every((c) => !isVisibleAt(c.index, c.position, w));
|
|
8707
8749
|
}
|
|
8708
8750
|
function setHidden(host, record, id, hide) {
|
|
@@ -8720,7 +8762,27 @@ function idAt(features, position) {
|
|
|
8720
8762
|
const raw = features[position].id;
|
|
8721
8763
|
return raw === void 0 || raw === null ? null : String(raw);
|
|
8722
8764
|
}
|
|
8723
|
-
function
|
|
8765
|
+
function hiddenAt(record, w, fields) {
|
|
8766
|
+
const hide = /* @__PURE__ */ new Set();
|
|
8767
|
+
if (w === null) return hide;
|
|
8768
|
+
record.slices.forEach(({ features, start, end }) => {
|
|
8769
|
+
const index = getTimelineIndex(features, fields);
|
|
8770
|
+
for (let position = start; position < end; position++) {
|
|
8771
|
+
const id = idAt(features, position);
|
|
8772
|
+
if (id !== null && shouldHide(record, id, index, position, w, fields)) hide.add(id);
|
|
8773
|
+
}
|
|
8774
|
+
});
|
|
8775
|
+
return hide;
|
|
8776
|
+
}
|
|
8777
|
+
function setHiddenSet(host, record, hide, changed) {
|
|
8778
|
+
Array.from(record.hidden).forEach((id) => {
|
|
8779
|
+
if (!hide.has(id) && setHidden(host, record, id, false)) changed.push(id);
|
|
8780
|
+
});
|
|
8781
|
+
hide.forEach((id) => {
|
|
8782
|
+
if (setHidden(host, record, id, true)) changed.push(id);
|
|
8783
|
+
});
|
|
8784
|
+
}
|
|
8785
|
+
function seedTimelineSource(host, applied, sourceId, slices, w, fields) {
|
|
8724
8786
|
const handle = host.source(sourceId);
|
|
8725
8787
|
const old = applied.get(sourceId);
|
|
8726
8788
|
if (!handle) {
|
|
@@ -8734,27 +8796,38 @@ function seedTimelineSource(host, applied, sourceId, slices, w) {
|
|
|
8734
8796
|
slices,
|
|
8735
8797
|
hidden: (old == null ? void 0 : old.handle) === handle ? old.hidden : /* @__PURE__ */ new Set(),
|
|
8736
8798
|
copies: null,
|
|
8737
|
-
window: w
|
|
8799
|
+
window: w,
|
|
8800
|
+
stale: false
|
|
8738
8801
|
};
|
|
8739
8802
|
applied.set(sourceId, record);
|
|
8740
|
-
const
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
}
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8803
|
+
const changed = [];
|
|
8804
|
+
setHiddenSet(host, record, hiddenAt(record, w, fields), changed);
|
|
8805
|
+
return changed.length;
|
|
8806
|
+
}
|
|
8807
|
+
function reindexCopies(record, fields) {
|
|
8808
|
+
if (!record.copies) return;
|
|
8809
|
+
const indexes = new Map(record.slices.map((s) => [s.features, getTimelineIndex(s.features, fields)]));
|
|
8810
|
+
record.copies.forEach((list) => list.forEach((copy) => {
|
|
8811
|
+
copy.index = indexes.get(copy.features) ?? copy.index;
|
|
8812
|
+
}));
|
|
8813
|
+
}
|
|
8814
|
+
function rederive(host, record, w, fields, changed) {
|
|
8815
|
+
reindexCopies(record, fields);
|
|
8816
|
+
setHiddenSet(host, record, hiddenAt(record, w, fields), changed);
|
|
8817
|
+
record.window = w;
|
|
8818
|
+
record.stale = false;
|
|
8819
|
+
}
|
|
8820
|
+
function reindexTimelineSources(host, applied, w, isActive = () => true, fields) {
|
|
8821
|
+
const changed = [];
|
|
8822
|
+
applied.forEach((record, sourceId) => {
|
|
8823
|
+
if (host.source(sourceId) !== record.handle) {
|
|
8824
|
+
applied.delete(sourceId);
|
|
8825
|
+
return;
|
|
8826
|
+
}
|
|
8827
|
+
if (isActive(sourceId)) rederive(host, record, w, fields, changed);
|
|
8828
|
+
else record.stale = true;
|
|
8756
8829
|
});
|
|
8757
|
-
return
|
|
8830
|
+
return changed;
|
|
8758
8831
|
}
|
|
8759
8832
|
function isTimelineHiddenOn(applied, sourceId, id) {
|
|
8760
8833
|
var _a;
|
|
@@ -8775,14 +8848,19 @@ function ownerOf(owners, position) {
|
|
|
8775
8848
|
}
|
|
8776
8849
|
return found && position < found.end ? found : null;
|
|
8777
8850
|
}
|
|
8778
|
-
function groupBySliceArray(host, applied, next, isActive) {
|
|
8851
|
+
function groupBySliceArray(host, applied, next, isActive, fields, changed) {
|
|
8779
8852
|
const groups = [];
|
|
8780
8853
|
applied.forEach((record, sourceId) => {
|
|
8781
8854
|
if (host.source(sourceId) !== record.handle) {
|
|
8782
8855
|
applied.delete(sourceId);
|
|
8783
8856
|
return;
|
|
8784
8857
|
}
|
|
8785
|
-
if (!isActive(sourceId)
|
|
8858
|
+
if (!isActive(sourceId)) return;
|
|
8859
|
+
if (record.stale) {
|
|
8860
|
+
rederive(host, record, next, fields, changed);
|
|
8861
|
+
return;
|
|
8862
|
+
}
|
|
8863
|
+
if (sameWindow(record.window, next)) return;
|
|
8786
8864
|
record.slices.forEach(({ features, start, end }) => {
|
|
8787
8865
|
let group = groups.find((g) => g.features === features && sameWindow(g.from, record.window));
|
|
8788
8866
|
if (!group) {
|
|
@@ -8795,19 +8873,19 @@ function groupBySliceArray(host, applied, next, isActive) {
|
|
|
8795
8873
|
});
|
|
8796
8874
|
return groups;
|
|
8797
8875
|
}
|
|
8798
|
-
function applyTimelineWindow(host, applied, next, isActive = () => true) {
|
|
8876
|
+
function applyTimelineWindow(host, applied, next, isActive = () => true, fields) {
|
|
8799
8877
|
const flipped = [];
|
|
8800
8878
|
const positions = [];
|
|
8801
|
-
groupBySliceArray(host, applied, next, isActive).forEach(({ features, from, owners }) => {
|
|
8879
|
+
groupBySliceArray(host, applied, next, isActive, fields, flipped).forEach(({ features, from, owners }) => {
|
|
8802
8880
|
owners.sort((a, b) => a.start - b.start);
|
|
8803
|
-
const index = getTimelineIndex(features);
|
|
8881
|
+
const index = getTimelineIndex(features, fields);
|
|
8804
8882
|
positions.length = 0;
|
|
8805
8883
|
flippedPositions(index, from, next, positions);
|
|
8806
8884
|
positions.forEach((position) => {
|
|
8807
8885
|
const owner = ownerOf(owners, position);
|
|
8808
8886
|
const id = owner ? idAt(features, position) : null;
|
|
8809
8887
|
if (!owner || id === null) return;
|
|
8810
|
-
if (setHidden(host, owner.record, id, shouldHide(owner.record, id, index, position, next))) flipped.push(id);
|
|
8888
|
+
if (setHidden(host, owner.record, id, shouldHide(owner.record, id, index, position, next, fields))) flipped.push(id);
|
|
8811
8889
|
});
|
|
8812
8890
|
});
|
|
8813
8891
|
return flipped;
|
|
@@ -8830,16 +8908,16 @@ const MIN_COVERAGE = 0.9;
|
|
|
8830
8908
|
const MAX_GROUPS = 500;
|
|
8831
8909
|
const MIN_POINTS_PER_GROUP = 2;
|
|
8832
8910
|
const MAX_SAMPLES = 1e4;
|
|
8833
|
-
function isTracePoint(f) {
|
|
8834
|
-
var _a
|
|
8835
|
-
return !!f && f.id != null && ((_a = f.geometry) == null ? void 0 : _a.type) === "Point" &&
|
|
8911
|
+
function isTracePoint(f, timelineFields) {
|
|
8912
|
+
var _a;
|
|
8913
|
+
return !!f && f.id != null && ((_a = f.geometry) == null ? void 0 : _a.type) === "Point" && traceTime(f, timelineFields) !== null;
|
|
8836
8914
|
}
|
|
8837
8915
|
function identityRank(field) {
|
|
8838
8916
|
const name = field.toLowerCase();
|
|
8839
8917
|
if (NOT_IDENTITY.has(name) || CATEGORY_SUFFIX.test(name)) return -1;
|
|
8840
8918
|
return IDENTITY_PATTERNS.findIndex((pattern) => pattern.test(name));
|
|
8841
8919
|
}
|
|
8842
|
-
function suggestTraceGroupField(features, fields) {
|
|
8920
|
+
function suggestTraceGroupField(features, fields, timelineFields) {
|
|
8843
8921
|
var _a;
|
|
8844
8922
|
const candidates = fields.map((field) => ({ field, rank: identityRank(field) })).filter((c) => c.rank >= 0).sort((a, b) => a.rank - b.rank || a.field.localeCompare(b.field));
|
|
8845
8923
|
if (candidates.length === 0) return null;
|
|
@@ -8847,7 +8925,7 @@ function suggestTraceGroupField(features, fields) {
|
|
|
8847
8925
|
const points = [];
|
|
8848
8926
|
for (let i = 0; i < features.length && points.length < MAX_SAMPLES; i += step) {
|
|
8849
8927
|
const f = features[i];
|
|
8850
|
-
if (isTracePoint(f)) points.push(f);
|
|
8928
|
+
if (isTracePoint(f, timelineFields)) points.push(f);
|
|
8851
8929
|
}
|
|
8852
8930
|
if (points.length < 2) return null;
|
|
8853
8931
|
const splitsIntoTracks = (field) => {
|
|
@@ -8981,17 +9059,17 @@ function prepareFeaturesForLayer(input, caller, cap) {
|
|
|
8981
9059
|
sourceCount: (capped == null ? void 0 : capped.sourceCount) ?? count
|
|
8982
9060
|
};
|
|
8983
9061
|
}
|
|
8984
|
-
function scanTemporalFeatures(features, resolveLayerId, out) {
|
|
9062
|
+
function scanTemporalFeatures(features, resolveLayerId, out, fields) {
|
|
8985
9063
|
let foundTemporal = false;
|
|
8986
9064
|
for (let i = 0; i < features.length; i++) {
|
|
8987
9065
|
const feature = features[i];
|
|
8988
9066
|
const id = feature.id;
|
|
8989
9067
|
const props = feature.properties || {};
|
|
8990
|
-
if (!
|
|
9068
|
+
if (!hasTimelineValue(props, fields)) {
|
|
8991
9069
|
out.untimedIds.push(id);
|
|
8992
9070
|
continue;
|
|
8993
9071
|
}
|
|
8994
|
-
const { startDate, endDate } =
|
|
9072
|
+
const { startDate, endDate } = readTimelineDates(props, fields);
|
|
8995
9073
|
if (startDate || endDate) {
|
|
8996
9074
|
out.temporal.push({ id, startDate, endDate, layerId: resolveLayerId(id) });
|
|
8997
9075
|
foundTemporal = true;
|
|
@@ -9781,7 +9859,7 @@ function createFlightPath3DLayer(layerId, mapInstance, flightPaths) {
|
|
|
9781
9859
|
}
|
|
9782
9860
|
};
|
|
9783
9861
|
}
|
|
9784
|
-
function extract3DFlightPaths(features) {
|
|
9862
|
+
function extract3DFlightPaths(features, fields) {
|
|
9785
9863
|
const paths = [];
|
|
9786
9864
|
features.forEach((feature) => {
|
|
9787
9865
|
var _a, _b;
|
|
@@ -9809,13 +9887,12 @@ function extract3DFlightPaths(features) {
|
|
|
9809
9887
|
});
|
|
9810
9888
|
const pointsByTarget = /* @__PURE__ */ new Map();
|
|
9811
9889
|
features.forEach((feature) => {
|
|
9812
|
-
var _a
|
|
9890
|
+
var _a;
|
|
9813
9891
|
if (feature.geometry.type === "Point") {
|
|
9814
9892
|
const coords = feature.geometry.coordinates;
|
|
9815
9893
|
if (coords.length >= 3 && coords[2] !== 0) {
|
|
9816
9894
|
const targetId = ((_a = feature.properties) == null ? void 0 : _a.TargetID) || "default-points";
|
|
9817
|
-
const
|
|
9818
|
-
const timestamp = startDateStr ? new Date(startDateStr).getTime() : 0;
|
|
9895
|
+
const timestamp = traceTime(feature, fields) ?? 0;
|
|
9819
9896
|
if (!pointsByTarget.has(targetId)) {
|
|
9820
9897
|
pointsByTarget.set(targetId, []);
|
|
9821
9898
|
}
|
|
@@ -9927,6 +10004,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9927
10004
|
featureCountProvider,
|
|
9928
10005
|
fitBoundsProvider,
|
|
9929
10006
|
timebarExtra,
|
|
10007
|
+
timelineFields,
|
|
10008
|
+
keepTimebarExtra = false,
|
|
9930
10009
|
onOpenInNewTab,
|
|
9931
10010
|
onEntityContextMenu
|
|
9932
10011
|
}, ref) {
|
|
@@ -9983,6 +10062,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9983
10062
|
const moveLabelsBeforeBasemapSymbolsRef = useRef(null);
|
|
9984
10063
|
const tooltipProviderRef = useRef(tooltipProvider);
|
|
9985
10064
|
tooltipProviderRef.current = tooltipProvider;
|
|
10065
|
+
const onFeatureUpdateRef = useRef(onFeatureUpdate);
|
|
10066
|
+
onFeatureUpdateRef.current = onFeatureUpdate;
|
|
9986
10067
|
const restoreEnrichedGeoJSONRef = useRef(null);
|
|
9987
10068
|
const [isMapLoaded, setIsMapLoaded] = useState(false);
|
|
9988
10069
|
const isMapLoadedRef = useRef(false);
|
|
@@ -10048,6 +10129,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10048
10129
|
const [timelineStoreApi] = useState(createTimelineStore);
|
|
10049
10130
|
const timelineEnabled = useStore(timelineStoreApi, (s) => s.isEnabled);
|
|
10050
10131
|
const timelineHasData = useStore(timelineStoreApi, (s) => s.hasTemporalData);
|
|
10132
|
+
const timebarHeight = timelineHasData ? TIMEBAR_HEIGHT : EMPTY_TIMEBAR_HEIGHT;
|
|
10051
10133
|
const { toast: internalToast } = useToast();
|
|
10052
10134
|
const toast = toastProvider ?? internalToast;
|
|
10053
10135
|
const featureCap = useMemo(() => resolveFeatureCap(maxFeaturesPerLayer), [maxFeaturesPerLayer]);
|
|
@@ -10343,6 +10425,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10343
10425
|
}, []);
|
|
10344
10426
|
const timelineWindowRef = useRef(null);
|
|
10345
10427
|
const appliedTimelineRef = useRef(/* @__PURE__ */ new Map());
|
|
10428
|
+
const timelineFieldsRef = useRef(timelineFields);
|
|
10429
|
+
const fieldsChangingRef = useRef(false);
|
|
10430
|
+
const timelineFieldsId = timelineFieldsKey(timelineFields);
|
|
10431
|
+
const pickedTimelineFields = useMemo(() => timelineFields, [timelineFieldsId]);
|
|
10346
10432
|
const isTimelineSourceActive = useCallback((sourceId) => {
|
|
10347
10433
|
var _a;
|
|
10348
10434
|
const shard = parseShardSourceId(sourceId);
|
|
@@ -10387,7 +10473,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10387
10473
|
if (sameWindow(next, timelineWindowRef.current)) return;
|
|
10388
10474
|
timelineWindowRef.current = next;
|
|
10389
10475
|
scheduleSync("timeline");
|
|
10390
|
-
(_a = update3DFlightPathsRef.current) == null ? void 0 : _a.call(update3DFlightPathsRef);
|
|
10476
|
+
if (!fieldsChangingRef.current) (_a = update3DFlightPathsRef.current) == null ? void 0 : _a.call(update3DFlightPathsRef);
|
|
10391
10477
|
};
|
|
10392
10478
|
follow(timelineStoreApi.getState());
|
|
10393
10479
|
return timelineStoreApi.subscribe(follow);
|
|
@@ -10414,7 +10500,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10414
10500
|
layers.forEach((layer) => {
|
|
10415
10501
|
var _a;
|
|
10416
10502
|
if (!((_a = layer.traceConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
10417
|
-
for (const group of getTraceGroups(traceSourceFeatures(layer, featById), layer.traceConfig.groupByField)) {
|
|
10503
|
+
for (const group of getTraceGroups(traceSourceFeatures(layer, featById), layer.traceConfig.groupByField, pickedTimelineFields)) {
|
|
10418
10504
|
for (const id of group.ids) tracePointColors.set(id, group.color);
|
|
10419
10505
|
}
|
|
10420
10506
|
});
|
|
@@ -10450,7 +10536,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10450
10536
|
colorMap.set(fid, color);
|
|
10451
10537
|
});
|
|
10452
10538
|
return colorMap;
|
|
10453
|
-
}, [selectedFeatureIds, layers, getAllFeatures, traceSourceFeatures]);
|
|
10539
|
+
}, [selectedFeatureIds, layers, getAllFeatures, traceSourceFeatures, pickedTimelineFields]);
|
|
10454
10540
|
const countVisibleFeatures = useCallback((threshold) => {
|
|
10455
10541
|
const m = map.current;
|
|
10456
10542
|
if (!m) return 0;
|
|
@@ -10458,7 +10544,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10458
10544
|
const w = timelineWindowRef.current;
|
|
10459
10545
|
const groupOf = (features) => {
|
|
10460
10546
|
if (w === null) return { features };
|
|
10461
|
-
const index = getTimelineIndex(features);
|
|
10547
|
+
const index = getTimelineIndex(features, timelineFieldsRef.current);
|
|
10462
10548
|
const group = { features, isVisible: (p) => isVisibleAt(index, p, w) };
|
|
10463
10549
|
const spatial = features.length >= SPATIAL_COUNT_MIN_FEATURES ? getGroupSpatialIndex(features) : void 0;
|
|
10464
10550
|
if (spatial) group.indexed = { spatial, visibleTotal: countVisible(index, w) };
|
|
@@ -10467,7 +10553,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10467
10553
|
const groups = [];
|
|
10468
10554
|
if (draw.current) {
|
|
10469
10555
|
const features = draw.current.getAll().features;
|
|
10470
|
-
groups.push(w === null ? { features } : { features, isVisible: (p) => isFeatureVisible(features[p], w) });
|
|
10556
|
+
groups.push(w === null ? { features } : { features, isVisible: (p) => isFeatureVisible(features[p], w, timelineFieldsRef.current) });
|
|
10471
10557
|
}
|
|
10472
10558
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10473
10559
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
@@ -10588,6 +10674,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10588
10674
|
if (!source) return;
|
|
10589
10675
|
const drawFeatures = (draw.current ? draw.current.getAll().features : []).filter((f) => isPaintableGeometry(f.geometry));
|
|
10590
10676
|
const timelineWindow = timelineWindowRef.current;
|
|
10677
|
+
const timelineFieldsNow = timelineFieldsRef.current;
|
|
10591
10678
|
const currentLayers = layersRef.current;
|
|
10592
10679
|
const isLayerVisible = (layer) => {
|
|
10593
10680
|
return layer.visible;
|
|
@@ -10666,8 +10753,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10666
10753
|
var _a2;
|
|
10667
10754
|
if (!((_a2 = layer.traceConfig) == null ? void 0 : _a2.enabled) || !layer.visible) return;
|
|
10668
10755
|
const traceFeatures = traceSourceFeatures(layer, featureById);
|
|
10669
|
-
const traceIndex = getTimelineIndex(traceFeatures);
|
|
10670
|
-
const groups = getTraceGroups(traceFeatures, layer.traceConfig.groupByField);
|
|
10756
|
+
const traceIndex = getTimelineIndex(traceFeatures, timelineFieldsNow);
|
|
10757
|
+
const groups = getTraceGroups(traceFeatures, layer.traceConfig.groupByField, timelineFieldsNow);
|
|
10671
10758
|
const pointsHidden = layerHidesPoints(layer);
|
|
10672
10759
|
for (const group of groups) {
|
|
10673
10760
|
paintedTraceGroups.push(pointsHidden && group.label !== null ? { ...group, label: null } : group);
|
|
@@ -10694,8 +10781,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10694
10781
|
source.setData(sourceData);
|
|
10695
10782
|
overlayPaintContextRef.current = paintContext;
|
|
10696
10783
|
const stateHost = featureStateHostFor(map.current);
|
|
10697
|
-
seedTimelineSource(stateHost, appliedTimelineRef.current, SHARED_SOURCE_ID, sharedSlices, timelineWindow);
|
|
10698
|
-
applyTimelineWindow(stateHost, appliedTimelineRef.current, timelineWindow, isTimelineSourceActive);
|
|
10784
|
+
seedTimelineSource(stateHost, appliedTimelineRef.current, SHARED_SOURCE_ID, sharedSlices, timelineWindow, timelineFieldsNow);
|
|
10785
|
+
applyTimelineWindow(stateHost, appliedTimelineRef.current, timelineWindow, isTimelineSourceActive, timelineFieldsNow);
|
|
10699
10786
|
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
10700
10787
|
const traceSource = map.current.getSource(TRACE_SOURCE_ID);
|
|
10701
10788
|
const tracePaint = paintTraceAt(paintedTraceGroups, traceIndexes, timelineWindow);
|
|
@@ -10712,7 +10799,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10712
10799
|
let sawArrowFeature = false;
|
|
10713
10800
|
const arrowLines = [];
|
|
10714
10801
|
const pushArrow = (styled, record) => {
|
|
10715
|
-
const { s, e } = record ? featureInterval(record) : { s: NaN, e: NaN };
|
|
10802
|
+
const { s, e } = record ? featureInterval(record, timelineFieldsNow) : { s: NaN, e: NaN };
|
|
10716
10803
|
arrowLines.push(isIntervalVisible(s, e, timelineWindow) ? styled : { ...styled, properties: { ...styled.properties, "stroke-opacity": 0, "fill-opacity": 0 } });
|
|
10717
10804
|
};
|
|
10718
10805
|
sourceData.features.forEach((f, i) => {
|
|
@@ -10775,7 +10862,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10775
10862
|
const timelineWindow = timelineWindowRef.current;
|
|
10776
10863
|
const visibleIn = (features) => {
|
|
10777
10864
|
if (timelineWindow === null) return [...features];
|
|
10778
|
-
const index = getTimelineIndex(features);
|
|
10865
|
+
const index = getTimelineIndex(features, timelineFieldsRef.current);
|
|
10779
10866
|
return features.filter((_, p) => isVisibleAt(index, p, timelineWindow));
|
|
10780
10867
|
};
|
|
10781
10868
|
const allFeatures = [];
|
|
@@ -10786,7 +10873,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10786
10873
|
if (((_a = l.traceConfig) == null ? void 0 : _a.enabled) !== true) continue;
|
|
10787
10874
|
for (const featureId of l.featureIds) traceFeatureIds.add(featureId);
|
|
10788
10875
|
}
|
|
10789
|
-
const drawFeatures = draw.current.getAll().features.filter((feature) => traceFeatureIds.has(feature.id) && isFeatureVisible(feature, timelineWindow));
|
|
10876
|
+
const drawFeatures = draw.current.getAll().features.filter((feature) => traceFeatureIds.has(feature.id) && isFeatureVisible(feature, timelineWindow, timelineFieldsRef.current));
|
|
10790
10877
|
pushAll(allFeatures, drawFeatures);
|
|
10791
10878
|
}
|
|
10792
10879
|
readOnlyFeatures.current.forEach((features, layerId2) => {
|
|
@@ -10798,7 +10885,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10798
10885
|
pushAll(allFeatures, visibleIn(features));
|
|
10799
10886
|
}
|
|
10800
10887
|
});
|
|
10801
|
-
const flightPaths = extract3DFlightPaths(allFeatures);
|
|
10888
|
+
const flightPaths = extract3DFlightPaths(allFeatures, timelineFieldsRef.current);
|
|
10802
10889
|
if (flightPaths.length === 0) {
|
|
10803
10890
|
if (flightPath3DLayerId.current) {
|
|
10804
10891
|
try {
|
|
@@ -10901,7 +10988,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10901
10988
|
appliedTimelineRef.current,
|
|
10902
10989
|
shardSourceId(layer.id, index),
|
|
10903
10990
|
[{ features, start, end }],
|
|
10904
|
-
timelineWindowRef.current
|
|
10991
|
+
timelineWindowRef.current,
|
|
10992
|
+
timelineFieldsRef.current
|
|
10905
10993
|
);
|
|
10906
10994
|
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10907
10995
|
overlayRestyled = true;
|
|
@@ -10946,6 +11034,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10946
11034
|
return () => clearTimeout(timer);
|
|
10947
11035
|
}
|
|
10948
11036
|
}, [layers, is3DTerrainEnabled]);
|
|
11037
|
+
const layerDatesUnder = useCallback((layerId, features, fields) => {
|
|
11038
|
+
const cached = layerTemporalCacheRef.current.get(layerId);
|
|
11039
|
+
if (!cached) return anyTimelineDate(features, fields);
|
|
11040
|
+
return (cached.fieldsKey ?? "") === timelineFieldsKey(fields) ? cached.hasTemporal : anyTimelineDate(features, fields);
|
|
11041
|
+
}, []);
|
|
10949
11042
|
const updateTimelineStore = useCallback(() => {
|
|
10950
11043
|
const drawFeatures = draw.current ? draw.current.getAll().features : [];
|
|
10951
11044
|
const currentLayers = layersRef.current;
|
|
@@ -10956,24 +11049,55 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10956
11049
|
}
|
|
10957
11050
|
}
|
|
10958
11051
|
const scan = { temporal: [], untimedIds: [] };
|
|
11052
|
+
const fields = timelineFieldsRef.current;
|
|
11053
|
+
const fieldsKey = timelineFieldsKey(fields);
|
|
10959
11054
|
scanTemporalFeatures(
|
|
10960
11055
|
drawFeatures,
|
|
10961
11056
|
(id) => featureToLayer.get(id) || "default",
|
|
10962
|
-
scan
|
|
11057
|
+
scan,
|
|
11058
|
+
fields
|
|
10963
11059
|
);
|
|
10964
11060
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10965
11061
|
const layer = currentLayers.find((l) => l.id === layerId);
|
|
10966
11062
|
if (!(layer == null ? void 0 : layer.visible)) return;
|
|
10967
11063
|
const cached = layerTemporalCacheRef.current.get(layerId);
|
|
10968
|
-
if (cached && cached.featureCount === features.length && !cached.hasTemporal) {
|
|
11064
|
+
if (cached && (cached.fieldsKey ?? "") === fieldsKey && cached.featureCount === features.length && !cached.hasTemporal) {
|
|
10969
11065
|
for (const f of features) scan.untimedIds.push(f.id);
|
|
10970
11066
|
return;
|
|
10971
11067
|
}
|
|
10972
|
-
const layerHasTemporal = scanTemporalFeatures(features, () => layerId, scan);
|
|
10973
|
-
layerTemporalCacheRef.current.set(layerId, { featureCount: features.length, hasTemporal: layerHasTemporal });
|
|
11068
|
+
const layerHasTemporal = scanTemporalFeatures(features, () => layerId, scan, fields);
|
|
11069
|
+
layerTemporalCacheRef.current.set(layerId, { featureCount: features.length, hasTemporal: layerHasTemporal, fieldsKey });
|
|
10974
11070
|
});
|
|
10975
11071
|
timelineStoreApi.getState().setTemporalFeatures(scan.temporal, scan.untimedIds);
|
|
11072
|
+
mapPerfLog("timeline", "store scanned", { timed: scan.temporal.length, untimed: scan.untimedIds.length });
|
|
10976
11073
|
}, [timelineStoreApi]);
|
|
11074
|
+
useEffect(() => {
|
|
11075
|
+
if (timelineFieldsKey(timelineFieldsRef.current) === timelineFieldsKey(timelineFields)) return;
|
|
11076
|
+
timelineFieldsRef.current = timelineFields;
|
|
11077
|
+
if (timelineUpdateTimerRef.current) {
|
|
11078
|
+
clearTimeout(timelineUpdateTimerRef.current);
|
|
11079
|
+
timelineUpdateTimerRef.current = null;
|
|
11080
|
+
}
|
|
11081
|
+
fieldsChangingRef.current = true;
|
|
11082
|
+
try {
|
|
11083
|
+
updateTimelineStore();
|
|
11084
|
+
const store = timelineStoreApi.getState();
|
|
11085
|
+
store.setPlaying(false);
|
|
11086
|
+
store.setRange(store.globalMinDate, store.globalMaxDate);
|
|
11087
|
+
} finally {
|
|
11088
|
+
fieldsChangingRef.current = false;
|
|
11089
|
+
}
|
|
11090
|
+
if (map.current) {
|
|
11091
|
+
reindexTimelineSources(
|
|
11092
|
+
featureStateHostFor(map.current),
|
|
11093
|
+
appliedTimelineRef.current,
|
|
11094
|
+
timelineWindowRef.current,
|
|
11095
|
+
isTimelineSourceActive,
|
|
11096
|
+
timelineFields
|
|
11097
|
+
);
|
|
11098
|
+
}
|
|
11099
|
+
scheduleSync();
|
|
11100
|
+
}, [timelineFields, updateTimelineStore, timelineStoreApi, scheduleSync, isTimelineSourceActive]);
|
|
10977
11101
|
const scheduleTimelineUpdate = useCallback(() => {
|
|
10978
11102
|
if (timelineUpdateTimerRef.current) clearTimeout(timelineUpdateTimerRef.current);
|
|
10979
11103
|
timelineUpdateTimerRef.current = setTimeout(() => {
|
|
@@ -11125,8 +11249,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11125
11249
|
}, [layers, isMapLoaded, cleanupOrphanLayerSources]);
|
|
11126
11250
|
const applyHistoryState = useCallback(
|
|
11127
11251
|
(featureIds, layerIds, targetFeatures, targetLayers) => {
|
|
11252
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
11128
11253
|
isApiAddingRef.current = true;
|
|
11129
11254
|
isSelectingReadOnlyRef.current = true;
|
|
11255
|
+
const notify = onFeatureUpdateRef.current;
|
|
11256
|
+
const drawnBefore = /* @__PURE__ */ new Map();
|
|
11257
|
+
if (notify) {
|
|
11258
|
+
featureIds.forEach((id) => {
|
|
11259
|
+
var _a, _b;
|
|
11260
|
+
if (((_a = targetFeatures.get(id)) == null ? void 0 : _a.store) !== "draw") return;
|
|
11261
|
+
const feature = (_b = draw.current) == null ? void 0 : _b.get(id);
|
|
11262
|
+
if (feature) drawnBefore.set(id, feature);
|
|
11263
|
+
});
|
|
11264
|
+
}
|
|
11130
11265
|
try {
|
|
11131
11266
|
featureIds.forEach((id) => {
|
|
11132
11267
|
var _a;
|
|
@@ -11185,8 +11320,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11185
11320
|
});
|
|
11186
11321
|
layersRef.current = next;
|
|
11187
11322
|
setLayers(next);
|
|
11323
|
+
drawnBefore.forEach((before, id) => {
|
|
11324
|
+
var _a;
|
|
11325
|
+
const target = targetFeatures.get(id);
|
|
11326
|
+
if (!target || historyFeatureContentEqual(before, target.feature)) return;
|
|
11327
|
+
const restored = (_a = draw.current) == null ? void 0 : _a.get(id);
|
|
11328
|
+
if (restored) notify == null ? void 0 : notify(restored);
|
|
11329
|
+
});
|
|
11188
11330
|
} finally {
|
|
11189
|
-
isApiAddingRef.current =
|
|
11331
|
+
isApiAddingRef.current = wasApiAdding;
|
|
11190
11332
|
}
|
|
11191
11333
|
cleanupOrphanLayerSources(new Set(layersRef.current.map((l) => l.id)));
|
|
11192
11334
|
layerTemporalCacheRef.current.clear();
|
|
@@ -12395,6 +12537,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12395
12537
|
if (wantedVisible) {
|
|
12396
12538
|
const hidden = hiddenFeatures.current.get(layerId) || [];
|
|
12397
12539
|
const newIds = [];
|
|
12540
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
12398
12541
|
isApiAddingRef.current = true;
|
|
12399
12542
|
try {
|
|
12400
12543
|
hidden.forEach((f) => {
|
|
@@ -12402,7 +12545,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12402
12545
|
newIds.push(ids[0]);
|
|
12403
12546
|
});
|
|
12404
12547
|
} finally {
|
|
12405
|
-
isApiAddingRef.current =
|
|
12548
|
+
isApiAddingRef.current = wasApiAdding;
|
|
12406
12549
|
}
|
|
12407
12550
|
hiddenFeatures.current.delete(layerId);
|
|
12408
12551
|
next.visible = true;
|
|
@@ -12561,6 +12704,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12561
12704
|
}
|
|
12562
12705
|
} else if (draw.current) {
|
|
12563
12706
|
const capped = capFeatures(geojson.features, { max });
|
|
12707
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
12564
12708
|
isApiAddingRef.current = true;
|
|
12565
12709
|
try {
|
|
12566
12710
|
const addedIds = capped.features.map((f) => {
|
|
@@ -12569,7 +12713,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12569
12713
|
});
|
|
12570
12714
|
newLayer.featureIds = addedIds;
|
|
12571
12715
|
} finally {
|
|
12572
|
-
isApiAddingRef.current =
|
|
12716
|
+
isApiAddingRef.current = wasApiAdding;
|
|
12573
12717
|
}
|
|
12574
12718
|
addedFeatures = capped.features;
|
|
12575
12719
|
capDropped = capped.dropped;
|
|
@@ -12665,6 +12809,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12665
12809
|
if (visible) {
|
|
12666
12810
|
const hidden = hiddenFeatures.current.get(layerId) || [];
|
|
12667
12811
|
const newIds = [];
|
|
12812
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
12668
12813
|
isApiAddingRef.current = true;
|
|
12669
12814
|
try {
|
|
12670
12815
|
hidden.forEach((f) => {
|
|
@@ -12672,7 +12817,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12672
12817
|
newIds.push(ids[0]);
|
|
12673
12818
|
});
|
|
12674
12819
|
} finally {
|
|
12675
|
-
isApiAddingRef.current =
|
|
12820
|
+
isApiAddingRef.current = wasApiAdding;
|
|
12676
12821
|
}
|
|
12677
12822
|
hiddenFeatures.current.delete(layerId);
|
|
12678
12823
|
nextLayers = layersRef.current.map(
|
|
@@ -12698,7 +12843,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12698
12843
|
scheduleSync();
|
|
12699
12844
|
},
|
|
12700
12845
|
addFeatures: (layerId, features, options) => {
|
|
12701
|
-
var _a;
|
|
12702
12846
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
12703
12847
|
if (!layer || !isMapLoadedRef.current) return [];
|
|
12704
12848
|
if (options == null ? void 0 : options.recordHistory) saveStateForUndo("add features");
|
|
@@ -12720,10 +12864,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12720
12864
|
existing: existing.length
|
|
12721
12865
|
});
|
|
12722
12866
|
}
|
|
12723
|
-
const
|
|
12867
|
+
const fields = timelineFieldsRef.current;
|
|
12868
|
+
const addsDates = fields ? anyTimelineDate(prepared.features, fields) : prepared.hasTemporal;
|
|
12869
|
+
const layerHasTemporal = layerDatesUnder(layerId, existing, fields) || addsDates;
|
|
12724
12870
|
const combined = [...existing, ...prepared.features];
|
|
12725
12871
|
readOnlyFeatures.current.set(layerId, combined);
|
|
12726
|
-
layerTemporalCacheRef.current.set(layerId, {
|
|
12872
|
+
layerTemporalCacheRef.current.set(layerId, {
|
|
12873
|
+
featureCount: combined.length,
|
|
12874
|
+
hasTemporal: layerHasTemporal,
|
|
12875
|
+
fieldsKey: timelineFieldsKey(fields)
|
|
12876
|
+
});
|
|
12727
12877
|
const addedIds2 = prepared.featureIds;
|
|
12728
12878
|
const updatedLayers2 = layersRef.current.map(
|
|
12729
12879
|
(l) => l.id === layerId ? { ...l, featureIds: [...l.featureIds, ...addedIds2], importing: isShardEligible(l, combined.length, shardSizeRef.current) || void 0 } : l
|
|
@@ -12756,6 +12906,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12756
12906
|
existing: existingInLayer
|
|
12757
12907
|
});
|
|
12758
12908
|
}
|
|
12909
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
12759
12910
|
isApiAddingRef.current = true;
|
|
12760
12911
|
try {
|
|
12761
12912
|
cappedForDraw.features.forEach((f) => {
|
|
@@ -12772,7 +12923,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12772
12923
|
addedIds.push(ids[0]);
|
|
12773
12924
|
});
|
|
12774
12925
|
} finally {
|
|
12775
|
-
isApiAddingRef.current =
|
|
12926
|
+
isApiAddingRef.current = wasApiAdding;
|
|
12776
12927
|
}
|
|
12777
12928
|
const updatedLayers = layersRef.current.map(
|
|
12778
12929
|
(l) => l.id === layerId ? { ...l, featureIds: [...l.featureIds, ...addedIds] } : l
|
|
@@ -12887,6 +13038,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12887
13038
|
existing: existingInLayer
|
|
12888
13039
|
});
|
|
12889
13040
|
}
|
|
13041
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
12890
13042
|
isApiAddingRef.current = true;
|
|
12891
13043
|
try {
|
|
12892
13044
|
capped.features.forEach((f) => {
|
|
@@ -12903,7 +13055,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12903
13055
|
addedIds.push(ids[0]);
|
|
12904
13056
|
});
|
|
12905
13057
|
} finally {
|
|
12906
|
-
isApiAddingRef.current =
|
|
13058
|
+
isApiAddingRef.current = wasApiAdding;
|
|
12907
13059
|
}
|
|
12908
13060
|
setLayers((prev) => prev.map(
|
|
12909
13061
|
(l) => l.id === layerId ? { ...l, featureIds: [...l.featureIds, ...addedIds] } : l
|
|
@@ -13008,9 +13160,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13008
13160
|
source: "api"
|
|
13009
13161
|
});
|
|
13010
13162
|
}
|
|
13163
|
+
const fields = timelineFieldsRef.current;
|
|
13164
|
+
const hadDates = fields ? layerDatesUnder(layerId, readOnlyFeatures.current.get(layerId) ?? [], fields) : false;
|
|
13165
|
+
const hasDates = fields ? anyTimelineDate(prepared.features, fields) : prepared.hasTemporal;
|
|
13011
13166
|
readOnlyFeatures.current.set(layerId, prepared.features);
|
|
13012
|
-
layerTemporalCacheRef.current.set(layerId, {
|
|
13013
|
-
|
|
13167
|
+
layerTemporalCacheRef.current.set(layerId, {
|
|
13168
|
+
featureCount: prepared.features.length,
|
|
13169
|
+
hasTemporal: hasDates,
|
|
13170
|
+
fieldsKey: timelineFieldsKey(fields)
|
|
13171
|
+
});
|
|
13172
|
+
if (hasDates || hadDates) {
|
|
13014
13173
|
scheduleTimelineUpdate();
|
|
13015
13174
|
}
|
|
13016
13175
|
const newFeatureIds = prepared.featureIds;
|
|
@@ -13158,6 +13317,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13158
13317
|
}
|
|
13159
13318
|
return cloneFeatures(features);
|
|
13160
13319
|
},
|
|
13320
|
+
readLayerFeatures: (layerId) => {
|
|
13321
|
+
const readOnly = readOnlyFeatures.current.get(layerId);
|
|
13322
|
+
if (readOnly) return readOnly;
|
|
13323
|
+
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
13324
|
+
if (!layer) return [];
|
|
13325
|
+
if (!layer.visible) return hiddenFeatures.current.get(layerId) ?? [];
|
|
13326
|
+
return layer.featureIds.flatMap((id) => {
|
|
13327
|
+
var _a;
|
|
13328
|
+
return ((_a = draw.current) == null ? void 0 : _a.get(id)) ?? [];
|
|
13329
|
+
});
|
|
13330
|
+
},
|
|
13161
13331
|
getTimelineRange: () => {
|
|
13162
13332
|
const ts = timelineStoreApi.getState();
|
|
13163
13333
|
return {
|
|
@@ -13761,6 +13931,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13761
13931
|
}
|
|
13762
13932
|
let featureId = oldId;
|
|
13763
13933
|
const targetId = newId !== oldId ? newId : oldId;
|
|
13934
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
13764
13935
|
isApiAddingRef.current = true;
|
|
13765
13936
|
try {
|
|
13766
13937
|
if (newId !== oldId) {
|
|
@@ -13769,7 +13940,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13769
13940
|
draw.current.add({ ...feature, id: targetId, properties: updatedProps });
|
|
13770
13941
|
featureId = targetId;
|
|
13771
13942
|
} finally {
|
|
13772
|
-
isApiAddingRef.current =
|
|
13943
|
+
isApiAddingRef.current = wasApiAdding;
|
|
13773
13944
|
}
|
|
13774
13945
|
if (draw.current.get(featureId)) {
|
|
13775
13946
|
draw.current.setFeatureProperty(featureId, "_unsaved", false);
|
|
@@ -13860,6 +14031,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13860
14031
|
} else {
|
|
13861
14032
|
const features = hiddenFeatures.current.get(layerId) || [];
|
|
13862
14033
|
const newIds = [];
|
|
14034
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
13863
14035
|
isApiAddingRef.current = true;
|
|
13864
14036
|
try {
|
|
13865
14037
|
features.forEach((f) => {
|
|
@@ -13867,7 +14039,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13867
14039
|
newIds.push(ids[0]);
|
|
13868
14040
|
});
|
|
13869
14041
|
} finally {
|
|
13870
|
-
isApiAddingRef.current =
|
|
14042
|
+
isApiAddingRef.current = wasApiAdding;
|
|
13871
14043
|
}
|
|
13872
14044
|
hiddenFeatures.current.delete(layerId);
|
|
13873
14045
|
nextLayers = currentLayers.map(
|
|
@@ -14579,8 +14751,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14579
14751
|
}, [layers, traceFieldSource]);
|
|
14580
14752
|
const getSuggestedTraceField = useCallback((layerId) => {
|
|
14581
14753
|
const layer = layers.find((l) => l.id === layerId);
|
|
14582
|
-
return layer ? suggestTraceGroupField(traceFieldSource(layer), getAvailableTraceFields(layerId)) : null;
|
|
14583
|
-
}, [layers, traceFieldSource, getAvailableTraceFields]);
|
|
14754
|
+
return layer ? suggestTraceGroupField(traceFieldSource(layer), getAvailableTraceFields(layerId), pickedTimelineFields) : null;
|
|
14755
|
+
}, [layers, traceFieldSource, getAvailableTraceFields, pickedTimelineFields]);
|
|
14584
14756
|
const handleMeasureModeChange = useCallback((mode) => {
|
|
14585
14757
|
setMeasureMode(mode);
|
|
14586
14758
|
setMeasurePoints([]);
|
|
@@ -14768,7 +14940,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14768
14940
|
trace.window = next;
|
|
14769
14941
|
endpointsMoved = traceDiff.endpointOn.length;
|
|
14770
14942
|
}
|
|
14771
|
-
const flipped = applyTimelineWindow(
|
|
14943
|
+
const flipped = applyTimelineWindow(
|
|
14944
|
+
featureStateHostFor(m),
|
|
14945
|
+
appliedTimelineRef.current,
|
|
14946
|
+
next,
|
|
14947
|
+
isTimelineSourceActive,
|
|
14948
|
+
timelineFieldsRef.current
|
|
14949
|
+
);
|
|
14772
14950
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
14773
14951
|
const count = countVisibleFeatures(threshold);
|
|
14774
14952
|
if (tickCountTimerRef.current) clearTimeout(tickCountTimerRef.current);
|
|
@@ -15695,6 +15873,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15695
15873
|
existing: existingInActive
|
|
15696
15874
|
});
|
|
15697
15875
|
const addedIds = [];
|
|
15876
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
15698
15877
|
isApiAddingRef.current = true;
|
|
15699
15878
|
try {
|
|
15700
15879
|
capped.features.forEach((f) => {
|
|
@@ -15711,7 +15890,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15711
15890
|
addedIds.push(ids[0]);
|
|
15712
15891
|
});
|
|
15713
15892
|
} finally {
|
|
15714
|
-
isApiAddingRef.current =
|
|
15893
|
+
isApiAddingRef.current = wasApiAdding;
|
|
15715
15894
|
}
|
|
15716
15895
|
let targetLayerId;
|
|
15717
15896
|
let targetLayerName;
|
|
@@ -15829,13 +16008,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15829
16008
|
if (isReadOnly) {
|
|
15830
16009
|
readOnlyFeatures.current.set(layerId, featuresWithIds);
|
|
15831
16010
|
} else if (draw.current) {
|
|
16011
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
15832
16012
|
isApiAddingRef.current = true;
|
|
15833
16013
|
try {
|
|
15834
16014
|
for (const f of featuresWithIds) {
|
|
15835
16015
|
draw.current.add(f);
|
|
15836
16016
|
}
|
|
15837
16017
|
} finally {
|
|
15838
|
-
isApiAddingRef.current =
|
|
16018
|
+
isApiAddingRef.current = wasApiAdding;
|
|
15839
16019
|
}
|
|
15840
16020
|
}
|
|
15841
16021
|
newLayers.push({
|
|
@@ -16176,14 +16356,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16176
16356
|
const addedIds = addedFeatures.map((f) => String(f.id));
|
|
16177
16357
|
const existing = readOnlyFeatures.current.get(targetId) || [];
|
|
16178
16358
|
readOnlyFeatures.current.set(targetId, [...existing, ...addedFeatures]);
|
|
16179
|
-
|
|
16180
|
-
layerTemporalCacheRef.current.set(targetId, {
|
|
16181
|
-
featureCount: ((cached == null ? void 0 : cached.featureCount) ?? existing.length) + addedFeatures.length,
|
|
16182
|
-
hasTemporal: ((cached == null ? void 0 : cached.hasTemporal) ?? false) || fileHasTemporal
|
|
16183
|
-
});
|
|
16359
|
+
layerTemporalCacheRef.current.delete(targetId);
|
|
16184
16360
|
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
16185
16361
|
} else if (targetLayer.visible) {
|
|
16186
16362
|
const addedIds = [];
|
|
16363
|
+
const wasApiAdding = isApiAddingRef.current;
|
|
16187
16364
|
isApiAddingRef.current = true;
|
|
16188
16365
|
try {
|
|
16189
16366
|
appendFeatures.forEach((f) => {
|
|
@@ -16191,7 +16368,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16191
16368
|
addedIds.push(ids[0]);
|
|
16192
16369
|
});
|
|
16193
16370
|
} finally {
|
|
16194
|
-
isApiAddingRef.current =
|
|
16371
|
+
isApiAddingRef.current = wasApiAdding;
|
|
16195
16372
|
}
|
|
16196
16373
|
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
16197
16374
|
} else {
|
|
@@ -17065,11 +17242,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
17065
17242
|
] })
|
|
17066
17243
|
}
|
|
17067
17244
|
),
|
|
17068
|
-
enableTimeline && timelineHasData && /* @__PURE__ */ jsx(
|
|
17245
|
+
enableTimeline && (timelineHasData || timelineFields || keepTimebarExtra) && /* @__PURE__ */ jsx(
|
|
17069
17246
|
"div",
|
|
17070
17247
|
{
|
|
17071
17248
|
className: "absolute left-4 z-[200] transition-all",
|
|
17072
|
-
style: { bottom: timelineEnabled ?
|
|
17249
|
+
style: { bottom: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 48 },
|
|
17073
17250
|
children: /* @__PURE__ */ jsx(Tooltip, { title: "Timeline", placement: "right", children: /* @__PURE__ */ jsx(
|
|
17074
17251
|
Button,
|
|
17075
17252
|
{
|
|
@@ -17225,7 +17402,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
17225
17402
|
selectedFeatureIds,
|
|
17226
17403
|
selectedFeatureColors,
|
|
17227
17404
|
selectionDisplay: "line",
|
|
17228
|
-
timebarExtra
|
|
17405
|
+
timebarExtra,
|
|
17406
|
+
keepExtraWhenEmpty: !!timelineFields || keepTimebarExtra
|
|
17229
17407
|
}
|
|
17230
17408
|
),
|
|
17231
17409
|
contextMenu && /* @__PURE__ */ jsx(
|
|
@@ -17242,7 +17420,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
17242
17420
|
IngestProgressOverlay,
|
|
17243
17421
|
{
|
|
17244
17422
|
store: ingestProgressStore,
|
|
17245
|
-
bottomPx: timelineEnabled ?
|
|
17423
|
+
bottomPx: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 32
|
|
17246
17424
|
}
|
|
17247
17425
|
),
|
|
17248
17426
|
/* @__PURE__ */ jsx(
|
|
@@ -18294,6 +18472,7 @@ export {
|
|
|
18294
18472
|
isValidIconValue,
|
|
18295
18473
|
normalizeTemporalProperties,
|
|
18296
18474
|
parseKMLToGeoJSON,
|
|
18475
|
+
readTimelineDates,
|
|
18297
18476
|
useToast as toast,
|
|
18298
18477
|
useTimelineStore,
|
|
18299
18478
|
useTimelineStoreApi,
|