@octostar/map-component 0.2.13 → 0.2.15
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 +1127 -271
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1130 -274
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +4 -0
- package/dist/types/components/cluster-pie-chart.d.ts.map +1 -1
- package/dist/types/components/ingest-progress-overlay.d.ts +12 -0
- package/dist/types/components/ingest-progress-overlay.d.ts.map +1 -0
- package/dist/types/components/layers-panel.d.ts +30 -4
- 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/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/cluster-count.d.ts +43 -0
- package/dist/types/lib/cluster-count.d.ts.map +1 -0
- package/dist/types/lib/cluster-gradient.d.ts +37 -0
- package/dist/types/lib/cluster-gradient.d.ts.map +1 -0
- package/dist/types/lib/color-utils.d.ts +67 -0
- package/dist/types/lib/color-utils.d.ts.map +1 -1
- package/dist/types/lib/ingest-client.d.ts +22 -4
- package/dist/types/lib/ingest-client.d.ts.map +1 -1
- package/dist/types/lib/ingest-pipeline.d.ts +52 -1
- package/dist/types/lib/ingest-pipeline.d.ts.map +1 -1
- package/dist/types/lib/ingest-progress.d.ts +21 -0
- package/dist/types/lib/ingest-progress.d.ts.map +1 -0
- package/dist/types/lib/ingest-stream.d.ts +50 -0
- package/dist/types/lib/ingest-stream.d.ts.map +1 -0
- package/dist/types/lib/label-pinning.d.ts +31 -0
- package/dist/types/lib/label-pinning.d.ts.map +1 -0
- package/dist/types/lib/map-editor-api.d.ts +13 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/dist/types/lib/property-utils.d.ts +7 -0
- package/dist/types/lib/property-utils.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs,
|
|
2
|
-
import { useState, useEffect, useCallback, useMemo, createContext, useContext, useRef, forwardRef, useImperativeHandle } from "react";
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useSyncExternalStore, useCallback, useMemo, createContext, useContext, useRef, forwardRef, useImperativeHandle } from "react";
|
|
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
6
|
import * as THREE from "three";
|
|
7
7
|
import proj4 from "proj4";
|
|
8
|
-
import { Button, Modal, Input, App, message, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Collapse, ColorPicker, Tabs, Card, Table, DatePicker } from "antd";
|
|
8
|
+
import { Button, Modal, Input, App, message, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Segmented, Collapse, ColorPicker, Tabs, Card, Table, DatePicker } from "antd";
|
|
9
9
|
import { clsx } from "clsx";
|
|
10
10
|
import { twMerge } from "tailwind-merge";
|
|
11
11
|
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
|
|
@@ -96,7 +96,7 @@ function featureCollectionBlobParts(collection, options) {
|
|
|
96
96
|
if (pending.length > 0) parts.push(pending.join(""));
|
|
97
97
|
return parts;
|
|
98
98
|
}
|
|
99
|
-
const ingestWorkerSource = '"use strict";(()=>{function
|
|
99
|
+
const ingestWorkerSource = '"use strict";(()=>{function p(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=w(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 w(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 S(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 i(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 b(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 I(e){let t=i(e.startDate)||i(e.startdate)||i(e.start_date)||i(e.start_time)||i(e.date)||i(e.timestamp)||i(e.flightDate)||i(e.time)||i(e.datetime),n=i(e.endDate)||i(e.enddate)||i(e.end_date)||i(e.end_time);return t&&n&&n<t&&([t,n]=[n,t]),{startDate:t,endDate:n}}function h(e){return"kind"in e&&e.kind==="ack"}function J(){let e=globalThis.crypto?.randomUUID?.bind(globalThis.crypto);return e?e():`f-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function D(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):J()}}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 M(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 x(e,t){let n;if(e.type==="text")try{n=JSON.parse(e.text)}catch(d){return{kind:"error",code:"parse-error",message:d instanceof Error?d.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}=p(n),a=!1,o=!1,u=[];n.features.forEach((d,G)=>{let m=D(d,G,t);!o&&S(d)&&(o=!0);let g=d.properties||{};if(!b(g)){u.push(t.idStrategy==="preserve"?d:{...d,id:m});return}let{startDate:y,endDate:k}=I(g);(y||k)&&(a=!0),u.push({...d,...m!==void 0&&{id:m},properties:{...g,startDate:y?.toISOString()||null,endDate:k?.toISOString()||null}})});let c=n.properties?.layerMetadata;return{kind:"features",features:u,featureCount:u.length,bbox:M(u),hasTemporal:a,hasAltitude:o,reprojected:!1,sourceCRS:r,...s&&{needsReprojection:s},...c&&{layerMetadata:c}}}var O=5e3;function P(e,t){let n=Number.isNaN(t)?O: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 A(e){for(let t=0;t<e.length;t++)if(!f(e[t]))return e;try{return JSON.stringify(e)}catch{return e}}function E(e){let{kind:t,features:n,...r}=e;return r}async function N(e,t,n,r){let s;try{s=x(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??A,o=P(s.features,r.chunkSize??O);r.post({kind:"head",id:e,summary:E(s)});let u=o.length>0?a(o[0]):null;for(let c=0;c<o.length;c++){let d=r.waitAck(c);r.post({kind:"chunk",id:e,seq:c,payload:u}),u=c+1<o.length?a(o[c+1]):null,await d}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 F=e=>self.postMessage(e),l=new Map;self.onmessage=async e=>{let t=e.data;if(h(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 N(n,o,s,{post:F,waitAck:u=>new Promise(c=>{l.set(`${n}:${u}`,c)}),...a?.chunkSize!==void 0&&{chunkSize:a.chunkSize},...a?.featureArrayChunks&&{encode:u=>u}})}catch(o){F({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';
|
|
100
100
|
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");
|
|
101
101
|
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");
|
|
102
102
|
proj4.defs("EPSG:32630", "+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs");
|
|
@@ -245,7 +245,11 @@ function runIngestPipeline(source, options) {
|
|
|
245
245
|
if (startDate || endDate) hasTemporal = true;
|
|
246
246
|
features.push({
|
|
247
247
|
...f,
|
|
248
|
-
id
|
|
248
|
+
// Omit the key rather than set `id: undefined` ('preserve' + id-less
|
|
249
|
+
// feature): an own undefined key survives structured clone but is
|
|
250
|
+
// dropped by JSON chunks, so it would make the transfer encoding
|
|
251
|
+
// observable. Never undefined for the other strategies.
|
|
252
|
+
...id !== void 0 && { id },
|
|
249
253
|
properties: {
|
|
250
254
|
...props,
|
|
251
255
|
startDate: (startDate == null ? void 0 : startDate.toISOString()) || null,
|
|
@@ -267,6 +271,9 @@ function runIngestPipeline(source, options) {
|
|
|
267
271
|
...layerMetadata && { layerMetadata }
|
|
268
272
|
};
|
|
269
273
|
}
|
|
274
|
+
function decodeChunkPayload(payload) {
|
|
275
|
+
return typeof payload === "string" ? JSON.parse(payload) : payload;
|
|
276
|
+
}
|
|
270
277
|
const fromStorage = (() => {
|
|
271
278
|
var _a;
|
|
272
279
|
try {
|
|
@@ -344,7 +351,10 @@ function createWorkerPort() {
|
|
|
344
351
|
return null;
|
|
345
352
|
}
|
|
346
353
|
}
|
|
347
|
-
const
|
|
354
|
+
const INGEST_STALL_TIMEOUT_MS = 12e4;
|
|
355
|
+
function assembleStreamResult(stream) {
|
|
356
|
+
return finalizeReprojection({ kind: "features", ...stream.summary, features: stream.features });
|
|
357
|
+
}
|
|
348
358
|
function createIngestClient(portFactory = createWorkerPort) {
|
|
349
359
|
let port = null;
|
|
350
360
|
let portUnavailable = false;
|
|
@@ -362,6 +372,138 @@ function createIngestClient(portFactory = createWorkerPort) {
|
|
|
362
372
|
port == null ? void 0 : port.terminate();
|
|
363
373
|
port = null;
|
|
364
374
|
};
|
|
375
|
+
const armWatchdog = (request) => {
|
|
376
|
+
clearTimeout(request.timeout);
|
|
377
|
+
request.timeout = setTimeout(() => {
|
|
378
|
+
console.warn(
|
|
379
|
+
`[map-component] Ingest worker unresponsive for "${request.label}" after ${INGEST_STALL_TIMEOUT_MS}ms; it will be respawned on next use.`
|
|
380
|
+
);
|
|
381
|
+
abandonPort("Ingest worker unresponsive — the file could not be parsed");
|
|
382
|
+
}, INGEST_STALL_TIMEOUT_MS);
|
|
383
|
+
};
|
|
384
|
+
const callHook = (request, invoke) => {
|
|
385
|
+
if (!request.hooks) return;
|
|
386
|
+
try {
|
|
387
|
+
invoke(request.hooks);
|
|
388
|
+
} catch (err) {
|
|
389
|
+
console.warn("[map-component] Ingest stream hook threw; progress reporting disabled for this request.", err);
|
|
390
|
+
request.hooks = void 0;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
const settle = (id, request) => {
|
|
394
|
+
pending.delete(id);
|
|
395
|
+
clearTimeout(request.timeout);
|
|
396
|
+
};
|
|
397
|
+
const handleChunk = (activePort, request, msg) => {
|
|
398
|
+
const stream = request.stream;
|
|
399
|
+
if (!stream || msg.seq !== stream.nextSeq) {
|
|
400
|
+
abandonPort("Ingest worker sent an out-of-order chunk");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
armWatchdog(request);
|
|
404
|
+
const features = decodeChunkPayload(msg.payload);
|
|
405
|
+
features.forEach((f) => stream.features.push(f));
|
|
406
|
+
stream.nextSeq += 1;
|
|
407
|
+
callHook(request, (hooks) => {
|
|
408
|
+
var _a;
|
|
409
|
+
return (_a = hooks.onProgress) == null ? void 0 : _a.call(hooks, stream.features.length, stream.summary.featureCount);
|
|
410
|
+
});
|
|
411
|
+
activePort.post({ kind: "ack", id: msg.id, seq: msg.seq });
|
|
412
|
+
};
|
|
413
|
+
const handleMessage = (activePort, msg) => {
|
|
414
|
+
const request = pending.get(msg.id);
|
|
415
|
+
if (!request) return;
|
|
416
|
+
switch (msg.kind) {
|
|
417
|
+
case "result": {
|
|
418
|
+
if (request.stream) {
|
|
419
|
+
abandonPort("Ingest worker sent a single-shot result mid-stream");
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (!msg.ok) {
|
|
423
|
+
settle(msg.id, request);
|
|
424
|
+
mapPerfLog("ingest", `worker request "${request.label}" finished`, {
|
|
425
|
+
ms: Math.round(performance.now() - request.startedAt),
|
|
426
|
+
ok: false
|
|
427
|
+
});
|
|
428
|
+
request.reject(new Error(msg.error));
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
let finalized;
|
|
432
|
+
try {
|
|
433
|
+
finalized = finalizeReprojection(msg.result);
|
|
434
|
+
} catch (err) {
|
|
435
|
+
settle(msg.id, request);
|
|
436
|
+
request.reject(err instanceof Error ? err : new Error(String(err)));
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
settle(msg.id, request);
|
|
440
|
+
mapPerfLog("ingest", `worker request "${request.label}" finished`, {
|
|
441
|
+
ms: Math.round(performance.now() - request.startedAt),
|
|
442
|
+
ok: true
|
|
443
|
+
});
|
|
444
|
+
request.resolve(finalized);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
case "head":
|
|
448
|
+
if (request.stream) {
|
|
449
|
+
abandonPort("Ingest worker restarted a stream mid-request");
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
armWatchdog(request);
|
|
453
|
+
request.stream = {
|
|
454
|
+
summary: msg.summary,
|
|
455
|
+
features: [],
|
|
456
|
+
nextSeq: 0
|
|
457
|
+
};
|
|
458
|
+
callHook(request, (hooks) => {
|
|
459
|
+
var _a;
|
|
460
|
+
return (_a = hooks.onHead) == null ? void 0 : _a.call(hooks, msg.summary);
|
|
461
|
+
});
|
|
462
|
+
return;
|
|
463
|
+
case "chunk":
|
|
464
|
+
try {
|
|
465
|
+
handleChunk(activePort, request, msg);
|
|
466
|
+
} catch (err) {
|
|
467
|
+
console.warn("[map-component] Ingest chunk could not be processed; abandoning the worker.", err);
|
|
468
|
+
abandonPort("Ingest worker sent an unreadable chunk");
|
|
469
|
+
}
|
|
470
|
+
return;
|
|
471
|
+
case "done": {
|
|
472
|
+
const stream = request.stream;
|
|
473
|
+
if (!stream) {
|
|
474
|
+
abandonPort("Ingest worker completed a stream that never started");
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (msg.chunkCount !== stream.nextSeq) {
|
|
478
|
+
abandonPort("Ingest worker stream ended with missing chunks");
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
let assembled;
|
|
482
|
+
try {
|
|
483
|
+
assembled = assembleStreamResult(stream);
|
|
484
|
+
} catch (err) {
|
|
485
|
+
settle(msg.id, request);
|
|
486
|
+
request.reject(err instanceof Error ? err : new Error(String(err)));
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
settle(msg.id, request);
|
|
490
|
+
mapPerfLog("ingest", `worker request "${request.label}" streamed`, {
|
|
491
|
+
ms: Math.round(performance.now() - request.startedAt),
|
|
492
|
+
features: stream.features.length,
|
|
493
|
+
chunks: msg.chunkCount
|
|
494
|
+
});
|
|
495
|
+
request.resolve(assembled);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
case "error":
|
|
499
|
+
settle(msg.id, request);
|
|
500
|
+
mapPerfLog("ingest", `worker request "${request.label}" failed mid-stream`, {
|
|
501
|
+
ms: Math.round(performance.now() - request.startedAt)
|
|
502
|
+
});
|
|
503
|
+
request.reject(new Error(msg.message));
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
};
|
|
365
507
|
const ensurePort = () => {
|
|
366
508
|
if (portUnavailable || port) return port;
|
|
367
509
|
try {
|
|
@@ -373,22 +515,9 @@ function createIngestClient(portFactory = createWorkerPort) {
|
|
|
373
515
|
portUnavailable = true;
|
|
374
516
|
return null;
|
|
375
517
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
pending.delete(msg.id);
|
|
380
|
-
clearTimeout(request.timeout);
|
|
381
|
-
mapPerfLog("ingest", `worker request "${request.label}" finished`, {
|
|
382
|
-
ms: Math.round(performance.now() - request.startedAt),
|
|
383
|
-
ok: msg.ok
|
|
384
|
-
});
|
|
385
|
-
if (msg.ok) {
|
|
386
|
-
request.resolve(finalizeReprojection(msg.result));
|
|
387
|
-
} else {
|
|
388
|
-
request.reject(new Error(msg.error));
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
port.onError((err) => {
|
|
518
|
+
const activePort = port;
|
|
519
|
+
activePort.onMessage((msg) => handleMessage(activePort, msg));
|
|
520
|
+
activePort.onError((err) => {
|
|
392
521
|
console.warn("[map-component] Ingest worker crashed; it will be respawned on next use.", err);
|
|
393
522
|
abandonPort("Ingest worker crashed");
|
|
394
523
|
});
|
|
@@ -404,7 +533,7 @@ function createIngestClient(portFactory = createWorkerPort) {
|
|
|
404
533
|
return result;
|
|
405
534
|
};
|
|
406
535
|
return {
|
|
407
|
-
ingest(input, options) {
|
|
536
|
+
ingest(input, options, stream, tuning) {
|
|
408
537
|
if (typeof input === "object" && !(input instanceof Blob)) {
|
|
409
538
|
return Promise.resolve().then(
|
|
410
539
|
() => finalizeReprojection(runIngestPipeline({ type: "parsed", data: input }, options))
|
|
@@ -415,18 +544,26 @@ function createIngestClient(portFactory = createWorkerPort) {
|
|
|
415
544
|
const id = nextId++;
|
|
416
545
|
const label = input instanceof File ? input.name : typeof input === "string" ? "text" : "blob";
|
|
417
546
|
return new Promise((resolve, reject) => {
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
)
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
547
|
+
const request = {
|
|
548
|
+
resolve,
|
|
549
|
+
reject,
|
|
550
|
+
startedAt: performance.now(),
|
|
551
|
+
label,
|
|
552
|
+
hooks: stream
|
|
553
|
+
};
|
|
554
|
+
armWatchdog(request);
|
|
555
|
+
pending.set(id, request);
|
|
556
|
+
try {
|
|
557
|
+
activePort.post({
|
|
558
|
+
id,
|
|
559
|
+
source: typeof input === "string" ? { type: "text", text: input } : { type: "blob", blob: input },
|
|
560
|
+
options,
|
|
561
|
+
...tuning && { tuning }
|
|
562
|
+
});
|
|
563
|
+
} catch (err) {
|
|
564
|
+
settle(id, request);
|
|
565
|
+
throw err;
|
|
566
|
+
}
|
|
430
567
|
});
|
|
431
568
|
},
|
|
432
569
|
dispose() {
|
|
@@ -440,6 +577,54 @@ function getSharedIngestClient() {
|
|
|
440
577
|
if (!sharedClient) sharedClient = createIngestClient();
|
|
441
578
|
return sharedClient;
|
|
442
579
|
}
|
|
580
|
+
function createIngestProgressStore() {
|
|
581
|
+
const entries = /* @__PURE__ */ new Map();
|
|
582
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
583
|
+
let nextId = 0;
|
|
584
|
+
let snapshot = [];
|
|
585
|
+
let dirty = false;
|
|
586
|
+
const notify = () => {
|
|
587
|
+
dirty = true;
|
|
588
|
+
listeners.forEach((listener) => listener());
|
|
589
|
+
};
|
|
590
|
+
return {
|
|
591
|
+
begin(label) {
|
|
592
|
+
const id = nextId++;
|
|
593
|
+
entries.set(id, { label, received: 0, total: null });
|
|
594
|
+
notify();
|
|
595
|
+
return {
|
|
596
|
+
setTotal(total) {
|
|
597
|
+
const entry = entries.get(id);
|
|
598
|
+
if (!entry || entry.total === total) return;
|
|
599
|
+
entry.total = total;
|
|
600
|
+
notify();
|
|
601
|
+
},
|
|
602
|
+
update(received) {
|
|
603
|
+
const entry = entries.get(id);
|
|
604
|
+
if (!entry || entry.received === received) return;
|
|
605
|
+
entry.received = received;
|
|
606
|
+
notify();
|
|
607
|
+
},
|
|
608
|
+
end() {
|
|
609
|
+
if (entries.delete(id)) notify();
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
},
|
|
613
|
+
subscribe(listener) {
|
|
614
|
+
listeners.add(listener);
|
|
615
|
+
return () => listeners.delete(listener);
|
|
616
|
+
},
|
|
617
|
+
getSnapshot() {
|
|
618
|
+
if (dirty) {
|
|
619
|
+
const next = [];
|
|
620
|
+
entries.forEach((entry, id) => next.push({ id, ...entry }));
|
|
621
|
+
snapshot = next;
|
|
622
|
+
dirty = false;
|
|
623
|
+
}
|
|
624
|
+
return snapshot;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
443
628
|
function CursorCoordinatesOverlay({ map }) {
|
|
444
629
|
const [coords, setCoords] = useState(null);
|
|
445
630
|
useEffect(() => {
|
|
@@ -481,6 +666,45 @@ function CursorCoordinatesOverlay({ map }) {
|
|
|
481
666
|
}
|
|
482
667
|
);
|
|
483
668
|
}
|
|
669
|
+
const NO_IMPORTS = Object.freeze([]);
|
|
670
|
+
const getServerSnapshot = () => NO_IMPORTS;
|
|
671
|
+
function IngestProgressOverlay({
|
|
672
|
+
store,
|
|
673
|
+
bottomPx
|
|
674
|
+
}) {
|
|
675
|
+
const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
676
|
+
if (entries.length === 0) return null;
|
|
677
|
+
return /* @__PURE__ */ jsx(
|
|
678
|
+
"div",
|
|
679
|
+
{
|
|
680
|
+
className: "absolute left-1/2 z-10 flex -translate-x-1/2 flex-col gap-1 pointer-events-none",
|
|
681
|
+
style: { bottom: bottomPx },
|
|
682
|
+
"data-testid": "ingest-progress",
|
|
683
|
+
children: entries.map((entry) => /* @__PURE__ */ jsxs(
|
|
684
|
+
"div",
|
|
685
|
+
{
|
|
686
|
+
className: "rounded-md border bg-background/90 px-3 py-1.5 text-xs text-muted-foreground shadow-md",
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
689
|
+
"Importing ",
|
|
690
|
+
entry.label,
|
|
691
|
+
"…",
|
|
692
|
+
entry.total !== null ? ` ${entry.received.toLocaleString()} / ${entry.total.toLocaleString()} features` : ""
|
|
693
|
+
] }),
|
|
694
|
+
entry.total !== null && entry.total > 0 && /* @__PURE__ */ jsx("div", { className: "mt-1 h-1 w-48 overflow-hidden rounded bg-muted", children: /* @__PURE__ */ jsx(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
className: "h-full bg-primary",
|
|
698
|
+
style: { width: `${Math.min(100, entry.received / entry.total * 100)}%` }
|
|
699
|
+
}
|
|
700
|
+
) })
|
|
701
|
+
]
|
|
702
|
+
},
|
|
703
|
+
entry.id
|
|
704
|
+
))
|
|
705
|
+
}
|
|
706
|
+
);
|
|
707
|
+
}
|
|
484
708
|
const ICONS = [
|
|
485
709
|
// Location & Places
|
|
486
710
|
{ id: "map-pin", emoji: "📍", name: "Map Pin", category: "places" },
|
|
@@ -2092,6 +2316,85 @@ function hashStringToColor(str) {
|
|
|
2092
2316
|
const light = 45 + (hash >>> 16) % 18;
|
|
2093
2317
|
return hslToHex(hue, sat, light);
|
|
2094
2318
|
}
|
|
2319
|
+
const GRADIENT_RAMP = [
|
|
2320
|
+
"#fee5d9",
|
|
2321
|
+
"#fcae91",
|
|
2322
|
+
"#fb6a4a",
|
|
2323
|
+
"#de2d26",
|
|
2324
|
+
"#a50f15"
|
|
2325
|
+
];
|
|
2326
|
+
const GRADIENT_FALLBACK_COLOR = "#9ca3af";
|
|
2327
|
+
const NUMERIC_FIELD_RATIO_THRESHOLD = 0.8;
|
|
2328
|
+
const NUMERIC_FIELD_COVERAGE_FLOOR = 0.3;
|
|
2329
|
+
function coerceFiniteNumber(raw) {
|
|
2330
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : null;
|
|
2331
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
2332
|
+
const n = Number(raw);
|
|
2333
|
+
return Number.isFinite(n) ? n : null;
|
|
2334
|
+
}
|
|
2335
|
+
return null;
|
|
2336
|
+
}
|
|
2337
|
+
function parseHexColor(hex) {
|
|
2338
|
+
return [
|
|
2339
|
+
parseInt(hex.slice(1, 3), 16),
|
|
2340
|
+
parseInt(hex.slice(3, 5), 16),
|
|
2341
|
+
parseInt(hex.slice(5, 7), 16)
|
|
2342
|
+
];
|
|
2343
|
+
}
|
|
2344
|
+
function gradientColor(t, ramp = GRADIENT_RAMP) {
|
|
2345
|
+
const clamped = Math.max(0, Math.min(1, Number.isFinite(t) ? t : 0.5));
|
|
2346
|
+
const scaled = clamped * (ramp.length - 1);
|
|
2347
|
+
const i = Math.min(Math.floor(scaled), ramp.length - 2);
|
|
2348
|
+
const frac = scaled - i;
|
|
2349
|
+
const [r1, g1, b1] = parseHexColor(ramp[i]);
|
|
2350
|
+
const [r2, g2, b2] = parseHexColor(ramp[i + 1]);
|
|
2351
|
+
const channel = (a, b) => Math.round(a + (b - a) * frac).toString(16).padStart(2, "0");
|
|
2352
|
+
return `#${channel(r1, r2)}${channel(g1, g2)}${channel(b1, b2)}`;
|
|
2353
|
+
}
|
|
2354
|
+
function defaultColorScaleForField(field) {
|
|
2355
|
+
if (!field) return "categorical";
|
|
2356
|
+
return (field.numericRatio ?? 0) >= NUMERIC_FIELD_RATIO_THRESHOLD && (field.coverage ?? 0) >= NUMERIC_FIELD_COVERAGE_FLOOR ? "gradient" : "categorical";
|
|
2357
|
+
}
|
|
2358
|
+
function computeNumericRange(featureIds, getProperties, fieldName) {
|
|
2359
|
+
var _a;
|
|
2360
|
+
let min = Infinity;
|
|
2361
|
+
let max = -Infinity;
|
|
2362
|
+
for (const id of featureIds) {
|
|
2363
|
+
const v = coerceFiniteNumber((_a = getProperties(id)) == null ? void 0 : _a[fieldName]);
|
|
2364
|
+
if (v === null) continue;
|
|
2365
|
+
if (v < min) min = v;
|
|
2366
|
+
if (v > max) max = v;
|
|
2367
|
+
}
|
|
2368
|
+
return isFinite(min) ? { min, max } : null;
|
|
2369
|
+
}
|
|
2370
|
+
function resolveFeatureColor(colorConfig, properties, fallback, gradientRange) {
|
|
2371
|
+
if (!colorConfig) return fallback;
|
|
2372
|
+
if (colorConfig.mode === "fixed" && colorConfig.fixedColor) return colorConfig.fixedColor;
|
|
2373
|
+
if (colorConfig.mode === "field" && colorConfig.fieldName) {
|
|
2374
|
+
if (colorConfig.scale === "gradient") {
|
|
2375
|
+
const value = coerceFiniteNumber(properties == null ? void 0 : properties[colorConfig.fieldName]);
|
|
2376
|
+
if (value === null || !gradientRange) return GRADIENT_FALLBACK_COLOR;
|
|
2377
|
+
const t = gradientRange.max > gradientRange.min ? (value - gradientRange.min) / (gradientRange.max - gradientRange.min) : 0.5;
|
|
2378
|
+
return gradientColor(t);
|
|
2379
|
+
}
|
|
2380
|
+
if (properties) {
|
|
2381
|
+
const key = categoricalKey(properties[colorConfig.fieldName]);
|
|
2382
|
+
if (key !== null) return hashStringToColor(key);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
return fallback;
|
|
2386
|
+
}
|
|
2387
|
+
function formatGradientStop(value) {
|
|
2388
|
+
if (!Number.isFinite(value)) return "";
|
|
2389
|
+
const abs = Math.abs(value);
|
|
2390
|
+
if (abs >= 1e4) {
|
|
2391
|
+
return new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 }).format(value);
|
|
2392
|
+
}
|
|
2393
|
+
if (abs > 0 && abs < 1) {
|
|
2394
|
+
return new Intl.NumberFormat("en-US", { maximumSignificantDigits: 3 }).format(value);
|
|
2395
|
+
}
|
|
2396
|
+
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
2397
|
+
}
|
|
2095
2398
|
const MAP_STYLES = [
|
|
2096
2399
|
{ id: "streets", name: "Streets", icon: Map$1 },
|
|
2097
2400
|
{ id: "satellite", name: "Satellite", icon: Satellite },
|
|
@@ -2180,6 +2483,38 @@ function ColorByFieldLegend({
|
|
|
2180
2483
|
}
|
|
2181
2484
|
);
|
|
2182
2485
|
}
|
|
2486
|
+
function ColorGradientLegend({
|
|
2487
|
+
layerId,
|
|
2488
|
+
min,
|
|
2489
|
+
max,
|
|
2490
|
+
sampled
|
|
2491
|
+
}) {
|
|
2492
|
+
const degenerate = min === max;
|
|
2493
|
+
return /* @__PURE__ */ jsxs(
|
|
2494
|
+
"div",
|
|
2495
|
+
{
|
|
2496
|
+
className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
|
|
2497
|
+
"data-testid": `legend-gradient-${layerId}`,
|
|
2498
|
+
children: [
|
|
2499
|
+
/* @__PURE__ */ jsxs("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: [
|
|
2500
|
+
"Legend",
|
|
2501
|
+
sampled ? " (sampled)" : ""
|
|
2502
|
+
] }),
|
|
2503
|
+
/* @__PURE__ */ jsx(
|
|
2504
|
+
"div",
|
|
2505
|
+
{
|
|
2506
|
+
className: "h-2.5 rounded-sm border border-black/10",
|
|
2507
|
+
style: { background: degenerate ? gradientColor(0.5) : `linear-gradient(to right, ${GRADIENT_RAMP.join(", ")})` }
|
|
2508
|
+
}
|
|
2509
|
+
),
|
|
2510
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-between text-[11px] text-muted-foreground tabular-nums mt-0.5", children: degenerate ? /* @__PURE__ */ jsx("span", { className: "mx-auto", children: formatGradientStop(min) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2511
|
+
/* @__PURE__ */ jsx("span", { children: formatGradientStop(min) }),
|
|
2512
|
+
/* @__PURE__ */ jsx("span", { children: formatGradientStop(max) })
|
|
2513
|
+
] }) })
|
|
2514
|
+
]
|
|
2515
|
+
}
|
|
2516
|
+
);
|
|
2517
|
+
}
|
|
2183
2518
|
function LayersPanel({
|
|
2184
2519
|
layers,
|
|
2185
2520
|
onAddLayer,
|
|
@@ -2318,7 +2653,7 @@ function LayersPanel({
|
|
|
2318
2653
|
});
|
|
2319
2654
|
}, [onRemoveLayer]);
|
|
2320
2655
|
const renderLayerItem = (layer) => {
|
|
2321
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba;
|
|
2656
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da;
|
|
2322
2657
|
const customCount = featureCountProvider == null ? void 0 : featureCountProvider(layer.id);
|
|
2323
2658
|
const featureCount = customCount != null ? customCount : getFeatureCount(layer.id);
|
|
2324
2659
|
const isExpanded = expandedLayers.has(layer.id);
|
|
@@ -2431,6 +2766,41 @@ function LayersPanel({
|
|
|
2431
2766
|
label: "Save GeoJSON to desktop",
|
|
2432
2767
|
onClick: () => onSaveLayerGeoJSON(layer.id)
|
|
2433
2768
|
},
|
|
2769
|
+
...onUpdateVisualConfig ? [
|
|
2770
|
+
{ type: "divider" },
|
|
2771
|
+
{
|
|
2772
|
+
key: "never-hide-labels",
|
|
2773
|
+
label: /* @__PURE__ */ jsxs("div", { className: "px-1.5 py-1", onClick: (e) => e.stopPropagation(), children: [
|
|
2774
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2775
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2776
|
+
/* @__PURE__ */ jsx(Type, { className: "w-[18px] h-[18px]" }),
|
|
2777
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: "Never hide labels" })
|
|
2778
|
+
] }),
|
|
2779
|
+
/* @__PURE__ */ jsx(
|
|
2780
|
+
Switch,
|
|
2781
|
+
{
|
|
2782
|
+
size: "small",
|
|
2783
|
+
disabled: (_b = (_a = layer.visualConfig) == null ? void 0 : _a.label) == null ? void 0 : _b.hidden,
|
|
2784
|
+
checked: !!((_d = (_c = layer.visualConfig) == null ? void 0 : _c.label) == null ? void 0 : _d.neverHide),
|
|
2785
|
+
onChange: (checked) => {
|
|
2786
|
+
var _a2, _b2, _c2;
|
|
2787
|
+
return onUpdateVisualConfig(layer.id, {
|
|
2788
|
+
...layer.visualConfig,
|
|
2789
|
+
label: {
|
|
2790
|
+
...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label,
|
|
2791
|
+
mode: ((_c2 = (_b2 = layer.visualConfig) == null ? void 0 : _b2.label) == null ? void 0 : _c2.mode) ?? "standard",
|
|
2792
|
+
neverHide: checked
|
|
2793
|
+
}
|
|
2794
|
+
});
|
|
2795
|
+
},
|
|
2796
|
+
"data-testid": `switch-never-hide-labels-${layer.id}`
|
|
2797
|
+
}
|
|
2798
|
+
)
|
|
2799
|
+
] }),
|
|
2800
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground mt-1", children: ((_f = (_e = layer.visualConfig) == null ? void 0 : _e.label) == null ? void 0 : _f.hidden) ? "Labels are turned off for this layer" : "Show every label even when the map is crowded" })
|
|
2801
|
+
] })
|
|
2802
|
+
}
|
|
2803
|
+
] : [],
|
|
2434
2804
|
...onFitToLayerFeatures && (typeof featureCount === "string" ? featureCount.length > 0 : featureCount > 0) ? [
|
|
2435
2805
|
{ type: "divider" },
|
|
2436
2806
|
{
|
|
@@ -2483,14 +2853,14 @@ function LayersPanel({
|
|
|
2483
2853
|
]
|
|
2484
2854
|
}
|
|
2485
2855
|
),
|
|
2486
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
2856
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_g = layer.metadata) == null ? void 0 : _g.hidePointFeatures) && /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-1.5 bg-muted/30 rounded-md", children: [
|
|
2487
2857
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-1.5 text-xs font-medium", children: /* @__PURE__ */ jsx("span", { children: "Point Features" }) }),
|
|
2488
2858
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2489
2859
|
/* @__PURE__ */ jsx(
|
|
2490
2860
|
Switch,
|
|
2491
2861
|
{
|
|
2492
2862
|
size: "small",
|
|
2493
|
-
checked: ((
|
|
2863
|
+
checked: ((_h = layer.traceConfig) == null ? void 0 : _h.enabled) ?? false,
|
|
2494
2864
|
onChange: (checked) => {
|
|
2495
2865
|
var _a2;
|
|
2496
2866
|
return onUpdateTraceConfig(layer.id, {
|
|
@@ -2503,7 +2873,7 @@ function LayersPanel({
|
|
|
2503
2873
|
),
|
|
2504
2874
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "Trace Lines" })
|
|
2505
2875
|
] }),
|
|
2506
|
-
((
|
|
2876
|
+
((_i = layer.traceConfig) == null ? void 0 : _i.enabled) && /* @__PURE__ */ jsx(
|
|
2507
2877
|
Select,
|
|
2508
2878
|
{
|
|
2509
2879
|
size: "small",
|
|
@@ -2529,7 +2899,7 @@ function LayersPanel({
|
|
|
2529
2899
|
Switch,
|
|
2530
2900
|
{
|
|
2531
2901
|
size: "small",
|
|
2532
|
-
checked: ((
|
|
2902
|
+
checked: ((_j = layer.heatmapConfig) == null ? void 0 : _j.enabled) ?? false,
|
|
2533
2903
|
onChange: (checked) => {
|
|
2534
2904
|
var _a2, _b2;
|
|
2535
2905
|
return onUpdateHeatmapConfig(layer.id, {
|
|
@@ -2543,7 +2913,7 @@ function LayersPanel({
|
|
|
2543
2913
|
),
|
|
2544
2914
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "Heatmap" })
|
|
2545
2915
|
] }),
|
|
2546
|
-
((
|
|
2916
|
+
((_k = layer.heatmapConfig) == null ? void 0 : _k.enabled) && /* @__PURE__ */ jsxs("div", { className: "space-y-1 pl-4", children: [
|
|
2547
2917
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2548
2918
|
/* @__PURE__ */ jsx("span", { className: "text-[10px] w-12", children: "Intensity" }),
|
|
2549
2919
|
/* @__PURE__ */ jsx(
|
|
@@ -2587,10 +2957,11 @@ function LayersPanel({
|
|
|
2587
2957
|
Switch,
|
|
2588
2958
|
{
|
|
2589
2959
|
size: "small",
|
|
2590
|
-
checked: ((
|
|
2960
|
+
checked: ((_l = layer.clusterConfig) == null ? void 0 : _l.enabled) ?? false,
|
|
2591
2961
|
onChange: (checked) => {
|
|
2592
2962
|
var _a2, _b2;
|
|
2593
2963
|
return onUpdateClusterConfig(layer.id, {
|
|
2964
|
+
...layer.clusterConfig,
|
|
2594
2965
|
enabled: checked,
|
|
2595
2966
|
groupByField: ((_a2 = layer.clusterConfig) == null ? void 0 : _a2.groupByField) ?? null,
|
|
2596
2967
|
showPointDots: ((_b2 = layer.clusterConfig) == null ? void 0 : _b2.showPointDots) ?? false
|
|
@@ -2601,7 +2972,7 @@ function LayersPanel({
|
|
|
2601
2972
|
),
|
|
2602
2973
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "Clustering" })
|
|
2603
2974
|
] }),
|
|
2604
|
-
((
|
|
2975
|
+
((_m = layer.clusterConfig) == null ? void 0 : _m.enabled) && getLayerFields && /* @__PURE__ */ jsxs("div", { className: "space-y-1 pl-4", children: [
|
|
2605
2976
|
/* @__PURE__ */ jsx(
|
|
2606
2977
|
Select,
|
|
2607
2978
|
{
|
|
@@ -2634,6 +3005,53 @@ function LayersPanel({
|
|
|
2634
3005
|
}
|
|
2635
3006
|
),
|
|
2636
3007
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Show point dots" })
|
|
3008
|
+
] }),
|
|
3009
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
3010
|
+
/* @__PURE__ */ jsx(
|
|
3011
|
+
Switch,
|
|
3012
|
+
{
|
|
3013
|
+
size: "small",
|
|
3014
|
+
checked: layer.clusterConfig.countByFieldEnabled ?? false,
|
|
3015
|
+
onChange: (checked) => onUpdateClusterConfig(layer.id, {
|
|
3016
|
+
...layer.clusterConfig,
|
|
3017
|
+
countByFieldEnabled: checked
|
|
3018
|
+
}),
|
|
3019
|
+
"data-testid": `switch-cluster-count-by-${layer.id}`
|
|
3020
|
+
}
|
|
3021
|
+
),
|
|
3022
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Count by field" })
|
|
3023
|
+
] }),
|
|
3024
|
+
layer.clusterConfig.countByFieldEnabled && /* @__PURE__ */ jsx(
|
|
3025
|
+
Select,
|
|
3026
|
+
{
|
|
3027
|
+
size: "small",
|
|
3028
|
+
value: layer.clusterConfig.countByField ?? void 0,
|
|
3029
|
+
onChange: (val) => onUpdateClusterConfig(layer.id, {
|
|
3030
|
+
...layer.clusterConfig,
|
|
3031
|
+
countByField: val
|
|
3032
|
+
}),
|
|
3033
|
+
className: "w-full text-xs",
|
|
3034
|
+
placeholder: "Select numeric field...",
|
|
3035
|
+
showSearch: true,
|
|
3036
|
+
optionFilterProp: "label",
|
|
3037
|
+
options: getLayerFields(layer.id).filter((f) => f.isNumeric).map((f) => ({ value: f.name, label: f.name })),
|
|
3038
|
+
"data-testid": `select-cluster-count-field-${layer.id}`
|
|
3039
|
+
}
|
|
3040
|
+
),
|
|
3041
|
+
!layer.clusterConfig.groupByField && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
3042
|
+
/* @__PURE__ */ jsx(
|
|
3043
|
+
Switch,
|
|
3044
|
+
{
|
|
3045
|
+
size: "small",
|
|
3046
|
+
checked: layer.clusterConfig.bubbleGradient ?? false,
|
|
3047
|
+
onChange: (checked) => onUpdateClusterConfig(layer.id, {
|
|
3048
|
+
...layer.clusterConfig,
|
|
3049
|
+
bubbleGradient: checked
|
|
3050
|
+
}),
|
|
3051
|
+
"data-testid": `switch-cluster-gradient-${layer.id}`
|
|
3052
|
+
}
|
|
3053
|
+
),
|
|
3054
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Color bubbles by value" })
|
|
2637
3055
|
] })
|
|
2638
3056
|
] })
|
|
2639
3057
|
] })
|
|
@@ -2670,7 +3088,7 @@ function LayersPanel({
|
|
|
2670
3088
|
Switch,
|
|
2671
3089
|
{
|
|
2672
3090
|
size: "small",
|
|
2673
|
-
checked: !((
|
|
3091
|
+
checked: !((_o = (_n = layer.visualConfig) == null ? void 0 : _n.label) == null ? void 0 : _o.hidden),
|
|
2674
3092
|
onChange: (checked) => {
|
|
2675
3093
|
var _a2, _b2, _c2;
|
|
2676
3094
|
return onUpdateVisualConfig(layer.id, {
|
|
@@ -2686,8 +3104,8 @@ function LayersPanel({
|
|
|
2686
3104
|
Select,
|
|
2687
3105
|
{
|
|
2688
3106
|
size: "small",
|
|
2689
|
-
disabled: (
|
|
2690
|
-
value: ((
|
|
3107
|
+
disabled: (_q = (_p = layer.visualConfig) == null ? void 0 : _p.label) == null ? void 0 : _q.hidden,
|
|
3108
|
+
value: ((_s = (_r = layer.visualConfig) == null ? void 0 : _r.label) == null ? void 0 : _s.mode) ?? "standard",
|
|
2691
3109
|
onChange: (val) => {
|
|
2692
3110
|
var _a2;
|
|
2693
3111
|
return onUpdateVisualConfig(layer.id, {
|
|
@@ -2704,15 +3122,18 @@ function LayersPanel({
|
|
|
2704
3122
|
"data-testid": `select-label-mode-${layer.id}`
|
|
2705
3123
|
}
|
|
2706
3124
|
),
|
|
2707
|
-
((
|
|
3125
|
+
((_u = (_t = layer.visualConfig) == null ? void 0 : _t.label) == null ? void 0 : _u.mode) === "field" && /* @__PURE__ */ jsx(
|
|
2708
3126
|
Select,
|
|
2709
3127
|
{
|
|
2710
3128
|
size: "small",
|
|
2711
|
-
value: ((
|
|
2712
|
-
onChange: (val) =>
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
3129
|
+
value: ((_w = (_v = layer.visualConfig) == null ? void 0 : _v.label) == null ? void 0 : _w.fieldName) ?? "",
|
|
3130
|
+
onChange: (val) => {
|
|
3131
|
+
var _a2;
|
|
3132
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3133
|
+
...layer.visualConfig,
|
|
3134
|
+
label: { ...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label, mode: "field", fieldName: val }
|
|
3135
|
+
});
|
|
3136
|
+
},
|
|
2716
3137
|
className: "w-full text-sm",
|
|
2717
3138
|
placeholder: "Select field...",
|
|
2718
3139
|
showSearch: true,
|
|
@@ -2721,15 +3142,18 @@ function LayersPanel({
|
|
|
2721
3142
|
"data-testid": `select-label-field-${layer.id}`
|
|
2722
3143
|
}
|
|
2723
3144
|
),
|
|
2724
|
-
((
|
|
3145
|
+
((_y = (_x = layer.visualConfig) == null ? void 0 : _x.label) == null ? void 0 : _y.mode) === "fixed" && /* @__PURE__ */ jsx(
|
|
2725
3146
|
Input,
|
|
2726
3147
|
{
|
|
2727
3148
|
size: "small",
|
|
2728
|
-
value: ((
|
|
2729
|
-
onChange: (e) =>
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
3149
|
+
value: ((_A = (_z = layer.visualConfig) == null ? void 0 : _z.label) == null ? void 0 : _A.fixedText) ?? "",
|
|
3150
|
+
onChange: (e) => {
|
|
3151
|
+
var _a2;
|
|
3152
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3153
|
+
...layer.visualConfig,
|
|
3154
|
+
label: { ...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label, mode: "fixed", fixedText: e.target.value }
|
|
3155
|
+
});
|
|
3156
|
+
},
|
|
2733
3157
|
placeholder: "Enter label text...",
|
|
2734
3158
|
className: "text-sm",
|
|
2735
3159
|
"data-testid": `input-label-text-${layer.id}`
|
|
@@ -2743,7 +3167,7 @@ function LayersPanel({
|
|
|
2743
3167
|
Select,
|
|
2744
3168
|
{
|
|
2745
3169
|
size: "small",
|
|
2746
|
-
value: ((
|
|
3170
|
+
value: ((_C = (_B = layer.visualConfig) == null ? void 0 : _B.size) == null ? void 0 : _C.mode) ?? "standard",
|
|
2747
3171
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2748
3172
|
...layer.visualConfig,
|
|
2749
3173
|
size: { mode: val }
|
|
@@ -2757,11 +3181,11 @@ function LayersPanel({
|
|
|
2757
3181
|
"data-testid": `select-size-mode-${layer.id}`
|
|
2758
3182
|
}
|
|
2759
3183
|
),
|
|
2760
|
-
((
|
|
3184
|
+
((_E = (_D = layer.visualConfig) == null ? void 0 : _D.size) == null ? void 0 : _E.mode) === "field" && /* @__PURE__ */ jsx(
|
|
2761
3185
|
Select,
|
|
2762
3186
|
{
|
|
2763
3187
|
size: "small",
|
|
2764
|
-
value: ((
|
|
3188
|
+
value: ((_G = (_F = layer.visualConfig) == null ? void 0 : _F.size) == null ? void 0 : _G.fieldName) ?? "",
|
|
2765
3189
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2766
3190
|
...layer.visualConfig,
|
|
2767
3191
|
size: { mode: "field", fieldName: val }
|
|
@@ -2774,11 +3198,11 @@ function LayersPanel({
|
|
|
2774
3198
|
"data-testid": `select-size-field-${layer.id}`
|
|
2775
3199
|
}
|
|
2776
3200
|
),
|
|
2777
|
-
((
|
|
3201
|
+
((_I = (_H = layer.visualConfig) == null ? void 0 : _H.size) == null ? void 0 : _I.mode) === "override" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2778
3202
|
/* @__PURE__ */ jsx(
|
|
2779
3203
|
Slider,
|
|
2780
3204
|
{
|
|
2781
|
-
value: ((
|
|
3205
|
+
value: ((_K = (_J = layer.visualConfig) == null ? void 0 : _J.size) == null ? void 0 : _K.overrideValue) ?? 5,
|
|
2782
3206
|
min: 1,
|
|
2783
3207
|
max: 10,
|
|
2784
3208
|
step: 1,
|
|
@@ -2789,7 +3213,7 @@ function LayersPanel({
|
|
|
2789
3213
|
})
|
|
2790
3214
|
}
|
|
2791
3215
|
),
|
|
2792
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm w-4 text-right", children: ((
|
|
3216
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm w-4 text-right", children: ((_M = (_L = layer.visualConfig) == null ? void 0 : _L.size) == null ? void 0 : _M.overrideValue) ?? 5 })
|
|
2793
3217
|
] }),
|
|
2794
3218
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
2795
3219
|
/* @__PURE__ */ jsx("span", { className: "w-3.5 h-3.5 rounded-full bg-current" }),
|
|
@@ -2799,7 +3223,7 @@ function LayersPanel({
|
|
|
2799
3223
|
Select,
|
|
2800
3224
|
{
|
|
2801
3225
|
size: "small",
|
|
2802
|
-
value: ((
|
|
3226
|
+
value: ((_O = (_N = layer.visualConfig) == null ? void 0 : _N.color) == null ? void 0 : _O.mode) ?? "standard",
|
|
2803
3227
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2804
3228
|
...layer.visualConfig,
|
|
2805
3229
|
color: { mode: val }
|
|
@@ -2813,37 +3237,77 @@ function LayersPanel({
|
|
|
2813
3237
|
"data-testid": `select-color-mode-${layer.id}`
|
|
2814
3238
|
}
|
|
2815
3239
|
),
|
|
2816
|
-
((
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
3240
|
+
((_Q = (_P = layer.visualConfig) == null ? void 0 : _P.color) == null ? void 0 : _Q.mode) === "field" && (() => {
|
|
3241
|
+
var _a2, _b2, _c2, _d2;
|
|
3242
|
+
const fields = getLayerFields(layer.id);
|
|
3243
|
+
const colorField = (_b2 = (_a2 = layer.visualConfig) == null ? void 0 : _a2.color) == null ? void 0 : _b2.fieldName;
|
|
3244
|
+
const fieldStats = colorField ? fields.find((f) => f.name === colorField) : void 0;
|
|
3245
|
+
const fieldHasNumeric = (fieldStats == null ? void 0 : fieldStats.min) !== void 0;
|
|
3246
|
+
const scale = ((_d2 = (_c2 = layer.visualConfig) == null ? void 0 : _c2.color) == null ? void 0 : _d2.scale) ?? "categorical";
|
|
3247
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3248
|
+
/* @__PURE__ */ jsx(
|
|
3249
|
+
Select,
|
|
3250
|
+
{
|
|
3251
|
+
size: "small",
|
|
3252
|
+
value: colorField ?? "",
|
|
3253
|
+
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
3254
|
+
...layer.visualConfig,
|
|
3255
|
+
// The scale default is decided once, at pick time, and
|
|
3256
|
+
// stored — never re-inferred at render, so data drifting
|
|
3257
|
+
// later can't silently flip a user's choice.
|
|
3258
|
+
color: { mode: "field", fieldName: val, scale: defaultColorScaleForField(fields.find((f) => f.name === val)) }
|
|
3259
|
+
}),
|
|
3260
|
+
className: "w-full text-sm",
|
|
3261
|
+
placeholder: "Select field...",
|
|
3262
|
+
showSearch: true,
|
|
3263
|
+
optionFilterProp: "label",
|
|
3264
|
+
options: fields.map((f) => ({ value: f.name, label: f.name })),
|
|
3265
|
+
"data-testid": `select-color-field-${layer.id}`
|
|
3266
|
+
}
|
|
3267
|
+
),
|
|
3268
|
+
colorField && /* @__PURE__ */ jsx(
|
|
3269
|
+
Segmented,
|
|
3270
|
+
{
|
|
3271
|
+
size: "small",
|
|
3272
|
+
block: true,
|
|
3273
|
+
value: scale,
|
|
3274
|
+
onChange: (val) => {
|
|
3275
|
+
var _a3;
|
|
3276
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3277
|
+
...layer.visualConfig,
|
|
3278
|
+
color: { ...(_a3 = layer.visualConfig) == null ? void 0 : _a3.color, mode: "field", scale: val }
|
|
3279
|
+
});
|
|
3280
|
+
},
|
|
3281
|
+
options: [
|
|
3282
|
+
{ label: "Categories", value: "categorical" },
|
|
3283
|
+
{ label: "Gradient", value: "gradient", disabled: !fieldHasNumeric && scale !== "gradient" }
|
|
3284
|
+
],
|
|
3285
|
+
"data-testid": `segmented-color-scale-${layer.id}`
|
|
3286
|
+
}
|
|
3287
|
+
),
|
|
3288
|
+
colorField && scale === "gradient" && fieldStats && fieldStats.min !== void 0 && fieldStats.max !== void 0 && /* @__PURE__ */ jsx(
|
|
3289
|
+
ColorGradientLegend,
|
|
3290
|
+
{
|
|
3291
|
+
layerId: layer.id,
|
|
3292
|
+
min: fieldStats.min,
|
|
3293
|
+
max: fieldStats.max,
|
|
3294
|
+
sampled: fieldStats.sampled
|
|
3295
|
+
}
|
|
3296
|
+
),
|
|
3297
|
+
colorField && scale !== "gradient" && getFieldValueDistribution && /* @__PURE__ */ jsx(
|
|
3298
|
+
ColorByFieldLegend,
|
|
3299
|
+
{
|
|
3300
|
+
layerId: layer.id,
|
|
3301
|
+
fieldName: colorField,
|
|
3302
|
+
getFieldValueDistribution
|
|
3303
|
+
}
|
|
3304
|
+
)
|
|
3305
|
+
] });
|
|
3306
|
+
})(),
|
|
3307
|
+
((_S = (_R = layer.visualConfig) == null ? void 0 : _R.color) == null ? void 0 : _S.mode) === "fixed" && /* @__PURE__ */ jsx(
|
|
2844
3308
|
ColorPickerPopover,
|
|
2845
3309
|
{
|
|
2846
|
-
value: ((
|
|
3310
|
+
value: ((_U = (_T = layer.visualConfig) == null ? void 0 : _T.color) == null ? void 0 : _U.fixedColor) ?? "#3b82f6",
|
|
2847
3311
|
onChange: (color) => {
|
|
2848
3312
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
2849
3313
|
...layer.visualConfig,
|
|
@@ -2856,7 +3320,7 @@ function LayersPanel({
|
|
|
2856
3320
|
testId: `color-fixed-${layer.id}`
|
|
2857
3321
|
}
|
|
2858
3322
|
),
|
|
2859
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
3323
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_V = layer.metadata) == null ? void 0 : _V.hidePointFeatures) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2860
3324
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
2861
3325
|
/* @__PURE__ */ jsx(Smile, { className: "w-3.5 h-3.5" }),
|
|
2862
3326
|
/* @__PURE__ */ jsx("span", { children: "Point Icon" })
|
|
@@ -2866,7 +3330,7 @@ function LayersPanel({
|
|
|
2866
3330
|
Switch,
|
|
2867
3331
|
{
|
|
2868
3332
|
size: "small",
|
|
2869
|
-
checked: ((
|
|
3333
|
+
checked: ((_X = (_W = layer.visualConfig) == null ? void 0 : _W.icon) == null ? void 0 : _X.enabled) ?? false,
|
|
2870
3334
|
onChange: (checked) => {
|
|
2871
3335
|
var _a2, _b2, _c2, _d2;
|
|
2872
3336
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -2881,11 +3345,11 @@ function LayersPanel({
|
|
|
2881
3345
|
"data-testid": `switch-icon-${layer.id}`
|
|
2882
3346
|
}
|
|
2883
3347
|
),
|
|
2884
|
-
((
|
|
3348
|
+
((_Z = (_Y = layer.visualConfig) == null ? void 0 : _Y.icon) == null ? void 0 : _Z.enabled) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
|
|
2885
3349
|
/* @__PURE__ */ jsx(
|
|
2886
3350
|
IconPicker,
|
|
2887
3351
|
{
|
|
2888
|
-
value: ((
|
|
3352
|
+
value: ((_$ = (__ = layer.visualConfig) == null ? void 0 : __.icon) == null ? void 0 : _$.icon) ?? "📍",
|
|
2889
3353
|
onChange: (icon) => {
|
|
2890
3354
|
var _a2, _b2;
|
|
2891
3355
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -2902,7 +3366,7 @@ function LayersPanel({
|
|
|
2902
3366
|
/* @__PURE__ */ jsx(
|
|
2903
3367
|
Slider,
|
|
2904
3368
|
{
|
|
2905
|
-
value: ((
|
|
3369
|
+
value: ((_ba = (_aa = layer.visualConfig) == null ? void 0 : _aa.icon) == null ? void 0 : _ba.size) ?? 24,
|
|
2906
3370
|
min: 12,
|
|
2907
3371
|
max: 48,
|
|
2908
3372
|
step: 2,
|
|
@@ -2920,7 +3384,7 @@ function LayersPanel({
|
|
|
2920
3384
|
}
|
|
2921
3385
|
}
|
|
2922
3386
|
),
|
|
2923
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm w-6 text-right", children: ((
|
|
3387
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm w-6 text-right", children: ((_da = (_ca = layer.visualConfig) == null ? void 0 : _ca.icon) == null ? void 0 : _da.size) ?? 24 })
|
|
2924
3388
|
] })
|
|
2925
3389
|
] })
|
|
2926
3390
|
] })
|
|
@@ -6253,13 +6717,282 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
6253
6717
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
6254
6718
|
return selectedIds;
|
|
6255
6719
|
}
|
|
6720
|
+
const CLUSTER_COUNT_VALUE_PROP = "__cluster_count_value";
|
|
6721
|
+
const CLUSTER_SUM_PROP = "value_sum";
|
|
6722
|
+
const CLUSTER_MEMBER_ID_PROP = "__cluster_fid";
|
|
6723
|
+
function clusterCountValue(raw) {
|
|
6724
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : 1;
|
|
6725
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
6726
|
+
const n = Number(raw);
|
|
6727
|
+
if (Number.isFinite(n)) return n;
|
|
6728
|
+
}
|
|
6729
|
+
return 1;
|
|
6730
|
+
}
|
|
6731
|
+
function injectClusterCountValues(features, fieldName) {
|
|
6732
|
+
return features.map((f) => {
|
|
6733
|
+
var _a;
|
|
6734
|
+
return {
|
|
6735
|
+
...f,
|
|
6736
|
+
properties: {
|
|
6737
|
+
...f.properties,
|
|
6738
|
+
[CLUSTER_COUNT_VALUE_PROP]: clusterCountValue((_a = f.properties) == null ? void 0 : _a[fieldName]),
|
|
6739
|
+
...f.id != null ? { [CLUSTER_MEMBER_ID_PROP]: String(f.id) } : {}
|
|
6740
|
+
}
|
|
6741
|
+
};
|
|
6742
|
+
});
|
|
6743
|
+
}
|
|
6744
|
+
function roundHalfAwayFromZero1(n) {
|
|
6745
|
+
return Math.sign(n) * Math.round(Math.abs(n) * 10) / 10;
|
|
6746
|
+
}
|
|
6747
|
+
function formatClusterBadge(value) {
|
|
6748
|
+
if (value >= 1e6) return `${roundHalfAwayFromZero1(value / 1e6)}M`;
|
|
6749
|
+
if (value >= 1e3) return `${roundHalfAwayFromZero1(value / 1e3)}k`;
|
|
6750
|
+
return String(roundHalfAwayFromZero1(value));
|
|
6751
|
+
}
|
|
6752
|
+
function clusterBadgeTextField(prop) {
|
|
6753
|
+
const value = ["get", prop];
|
|
6754
|
+
const round1 = (expr) => ["/", ["round", ["*", expr, 10]], 10];
|
|
6755
|
+
return [
|
|
6756
|
+
"step",
|
|
6757
|
+
value,
|
|
6758
|
+
["to-string", round1(value)],
|
|
6759
|
+
1e3,
|
|
6760
|
+
["concat", ["to-string", round1(["/", value, 1e3])], "k"],
|
|
6761
|
+
1e6,
|
|
6762
|
+
["concat", ["to-string", round1(["/", value, 1e6])], "M"]
|
|
6763
|
+
];
|
|
6764
|
+
}
|
|
6765
|
+
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
6766
|
+
"fill",
|
|
6767
|
+
"fill-opacity",
|
|
6768
|
+
"pointRadius",
|
|
6769
|
+
"pointIcon",
|
|
6770
|
+
"pointIconSize",
|
|
6771
|
+
"circleCenter",
|
|
6772
|
+
"circleRadius",
|
|
6773
|
+
"icon",
|
|
6774
|
+
"iconSize",
|
|
6775
|
+
"fontSize",
|
|
6776
|
+
"fontColor",
|
|
6777
|
+
"fontWeight",
|
|
6778
|
+
"arrowSize",
|
|
6779
|
+
"label",
|
|
6780
|
+
"entityType",
|
|
6781
|
+
"kind",
|
|
6782
|
+
"meta:type",
|
|
6783
|
+
"stroke",
|
|
6784
|
+
"stroke-width",
|
|
6785
|
+
"stroke-opacity",
|
|
6786
|
+
CLUSTER_COUNT_VALUE_PROP,
|
|
6787
|
+
CLUSTER_MEMBER_ID_PROP
|
|
6788
|
+
]);
|
|
6789
|
+
const STYLING_PROPERTY_KEYS = [
|
|
6790
|
+
"stroke",
|
|
6791
|
+
"stroke-width",
|
|
6792
|
+
"stroke-opacity",
|
|
6793
|
+
"fill",
|
|
6794
|
+
"fill-opacity",
|
|
6795
|
+
"pointRadius",
|
|
6796
|
+
"pointIcon",
|
|
6797
|
+
"pointIconSize",
|
|
6798
|
+
"icon",
|
|
6799
|
+
"iconSize",
|
|
6800
|
+
"circleCenter",
|
|
6801
|
+
"circleRadius",
|
|
6802
|
+
"fontSize",
|
|
6803
|
+
"fontColor",
|
|
6804
|
+
"fontWeight",
|
|
6805
|
+
"arrowSize"
|
|
6806
|
+
];
|
|
6807
|
+
const INTERNAL_PROPERTY_PREFIXES = [
|
|
6808
|
+
"IsHiddenBy",
|
|
6809
|
+
"isHidden",
|
|
6810
|
+
"isSelected",
|
|
6811
|
+
"isTrace",
|
|
6812
|
+
"isTimeline",
|
|
6813
|
+
"trace"
|
|
6814
|
+
];
|
|
6815
|
+
function isInternalProperty(key) {
|
|
6816
|
+
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
6817
|
+
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
6818
|
+
}
|
|
6819
|
+
function computeBubbleDomain(values) {
|
|
6820
|
+
let min = Infinity;
|
|
6821
|
+
let max = -Infinity;
|
|
6822
|
+
for (const v of values) {
|
|
6823
|
+
if (!Number.isFinite(v)) continue;
|
|
6824
|
+
if (v < min) min = v;
|
|
6825
|
+
if (v > max) max = v;
|
|
6826
|
+
}
|
|
6827
|
+
return isFinite(min) ? { min, max } : null;
|
|
6828
|
+
}
|
|
6829
|
+
function bubbleGradientColorExpression(prop, min, max) {
|
|
6830
|
+
if (!(max > min)) return gradientColor(0.5);
|
|
6831
|
+
const expr = ["interpolate", ["linear"], ["get", prop]];
|
|
6832
|
+
const span = max - min;
|
|
6833
|
+
GRADIENT_RAMP.forEach((color, i) => {
|
|
6834
|
+
expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
|
|
6835
|
+
});
|
|
6836
|
+
return expr;
|
|
6837
|
+
}
|
|
6838
|
+
function createClusterGradientManager(map, sourceId, options) {
|
|
6839
|
+
const clusterProp = options.valueProp ?? "point_count";
|
|
6840
|
+
let scheduled = false;
|
|
6841
|
+
let lastDomainKey = "";
|
|
6842
|
+
let reportedFailure = false;
|
|
6843
|
+
function reportFailure(stage, error) {
|
|
6844
|
+
if (reportedFailure) return;
|
|
6845
|
+
reportedFailure = true;
|
|
6846
|
+
console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
|
|
6847
|
+
}
|
|
6848
|
+
function apply() {
|
|
6849
|
+
scheduled = false;
|
|
6850
|
+
let values;
|
|
6851
|
+
try {
|
|
6852
|
+
if (!map.getSource(sourceId)) return;
|
|
6853
|
+
values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
|
|
6854
|
+
var _a;
|
|
6855
|
+
return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
|
|
6856
|
+
});
|
|
6857
|
+
if (options.singleLayerId) {
|
|
6858
|
+
const singles = map.querySourceFeatures(sourceId, {
|
|
6859
|
+
filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
|
|
6860
|
+
});
|
|
6861
|
+
values.push(...singles.map((f) => {
|
|
6862
|
+
var _a;
|
|
6863
|
+
return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
|
|
6864
|
+
}));
|
|
6865
|
+
}
|
|
6866
|
+
} catch (error) {
|
|
6867
|
+
reportFailure("domain query", error);
|
|
6868
|
+
return;
|
|
6869
|
+
}
|
|
6870
|
+
const domain = computeBubbleDomain(values);
|
|
6871
|
+
if (!domain) return;
|
|
6872
|
+
const key = `${domain.min}|${domain.max}`;
|
|
6873
|
+
if (key === lastDomainKey) return;
|
|
6874
|
+
lastDomainKey = key;
|
|
6875
|
+
try {
|
|
6876
|
+
if (map.getLayer(options.clustersLayerId)) {
|
|
6877
|
+
map.setPaintProperty(
|
|
6878
|
+
options.clustersLayerId,
|
|
6879
|
+
"circle-color",
|
|
6880
|
+
bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
|
|
6881
|
+
);
|
|
6882
|
+
}
|
|
6883
|
+
if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
|
|
6884
|
+
map.setPaintProperty(
|
|
6885
|
+
options.singleLayerId,
|
|
6886
|
+
"circle-color",
|
|
6887
|
+
bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
|
|
6888
|
+
);
|
|
6889
|
+
}
|
|
6890
|
+
} catch (error) {
|
|
6891
|
+
reportFailure("paint update", error);
|
|
6892
|
+
lastDomainKey = "";
|
|
6893
|
+
}
|
|
6894
|
+
}
|
|
6895
|
+
function schedule() {
|
|
6896
|
+
if (scheduled) return;
|
|
6897
|
+
scheduled = true;
|
|
6898
|
+
requestAnimationFrame(apply);
|
|
6899
|
+
}
|
|
6900
|
+
function onData(e) {
|
|
6901
|
+
if (e.sourceId === sourceId) schedule();
|
|
6902
|
+
}
|
|
6903
|
+
map.on("moveend", schedule);
|
|
6904
|
+
map.on("data", onData);
|
|
6905
|
+
schedule();
|
|
6906
|
+
return {
|
|
6907
|
+
destroy: () => {
|
|
6908
|
+
map.off("moveend", schedule);
|
|
6909
|
+
map.off("data", onData);
|
|
6910
|
+
}
|
|
6911
|
+
};
|
|
6912
|
+
}
|
|
6913
|
+
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
6914
|
+
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
6915
|
+
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
6916
|
+
function computeLabelNeverHide(label) {
|
|
6917
|
+
return (label == null ? void 0 : label.neverHide) && !label.hidden ? 1 : 0;
|
|
6918
|
+
}
|
|
6919
|
+
function buildCustomLabelLayout() {
|
|
6920
|
+
return {
|
|
6921
|
+
// Hide labels for trace points (except last point which has isTraceLabel),
|
|
6922
|
+
// arrows handled by the custom-arrow-labels layer. Features blanked by
|
|
6923
|
+
// heatmap/cluster/trace modes stay blank in BOTH layers: "never hide"
|
|
6924
|
+
// exempts labels from collision and density culling, it does not resurrect
|
|
6925
|
+
// labels other mode choices explicitly blank.
|
|
6926
|
+
"text-field": [
|
|
6927
|
+
"case",
|
|
6928
|
+
["==", ["get", "isHiddenByTrace"], true],
|
|
6929
|
+
"",
|
|
6930
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6931
|
+
"",
|
|
6932
|
+
["==", ["get", "isHiddenByCluster"], 1],
|
|
6933
|
+
"",
|
|
6934
|
+
["==", ["get", "kind"], "arrow"],
|
|
6935
|
+
"",
|
|
6936
|
+
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
6937
|
+
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
6938
|
+
"",
|
|
6939
|
+
["==", ["get", "kind"], "text"],
|
|
6940
|
+
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
6941
|
+
["coalesce", ["get", "name"], ""]
|
|
6942
|
+
],
|
|
6943
|
+
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
6944
|
+
"text-size": [
|
|
6945
|
+
"case",
|
|
6946
|
+
["==", ["get", "kind"], "text"],
|
|
6947
|
+
["coalesce", ["get", "fontSize"], 14],
|
|
6948
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6949
|
+
14,
|
|
6950
|
+
12
|
|
6951
|
+
],
|
|
6952
|
+
// Text features: center anchor; others: top anchor
|
|
6953
|
+
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
6954
|
+
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
6955
|
+
"text-padding": 2,
|
|
6956
|
+
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
6957
|
+
"text-font": [
|
|
6958
|
+
"case",
|
|
6959
|
+
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
6960
|
+
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
6961
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6962
|
+
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
6963
|
+
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
6964
|
+
]
|
|
6965
|
+
};
|
|
6966
|
+
}
|
|
6967
|
+
function buildCustomLabelPaint() {
|
|
6968
|
+
return {
|
|
6969
|
+
// Text features use fontColor; others use default
|
|
6970
|
+
"text-color": [
|
|
6971
|
+
"case",
|
|
6972
|
+
["==", ["get", "kind"], "text"],
|
|
6973
|
+
["coalesce", ["get", "fontColor"], "#000000"],
|
|
6974
|
+
"#1f2937"
|
|
6975
|
+
],
|
|
6976
|
+
"text-halo-color": "#ffffff",
|
|
6977
|
+
// Thicker halo for trace labels and text features
|
|
6978
|
+
"text-halo-width": [
|
|
6979
|
+
"case",
|
|
6980
|
+
["==", ["get", "kind"], "text"],
|
|
6981
|
+
2,
|
|
6982
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6983
|
+
2,
|
|
6984
|
+
1.5
|
|
6985
|
+
],
|
|
6986
|
+
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
6987
|
+
};
|
|
6988
|
+
}
|
|
6256
6989
|
const OTHER_BUCKET_KEY = "__other__";
|
|
6257
6990
|
const OTHER_BUCKET_LABEL = "Other";
|
|
6258
6991
|
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
6259
6992
|
function toDisplayName(name) {
|
|
6260
6993
|
return name === OTHER_BUCKET_KEY ? OTHER_BUCKET_LABEL : name;
|
|
6261
6994
|
}
|
|
6262
|
-
function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
6995
|
+
function createPieSVG(categories, total, size = 44, onSliceHover, badgeValue) {
|
|
6263
6996
|
const container = document.createElement("div");
|
|
6264
6997
|
container.style.width = `${size}px`;
|
|
6265
6998
|
container.style.height = `${size}px`;
|
|
@@ -6357,16 +7090,17 @@ function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
|
6357
7090
|
centerCircle.setAttribute("r", String(innerRadius - 2));
|
|
6358
7091
|
centerCircle.setAttribute("fill", "#1f2937");
|
|
6359
7092
|
svg.appendChild(centerCircle);
|
|
7093
|
+
const badgeText = formatClusterBadge(badgeValue ?? total);
|
|
6360
7094
|
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
6361
7095
|
text.setAttribute("x", String(radius));
|
|
6362
7096
|
text.setAttribute("y", String(radius));
|
|
6363
7097
|
text.setAttribute("text-anchor", "middle");
|
|
6364
7098
|
text.setAttribute("dominant-baseline", "central");
|
|
6365
7099
|
text.setAttribute("fill", "white");
|
|
6366
|
-
text.setAttribute("font-size",
|
|
7100
|
+
text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
|
|
6367
7101
|
text.setAttribute("font-weight", "bold");
|
|
6368
7102
|
text.setAttribute("font-family", "system-ui, sans-serif");
|
|
6369
|
-
text.textContent =
|
|
7103
|
+
text.textContent = badgeText;
|
|
6370
7104
|
svg.appendChild(text);
|
|
6371
7105
|
container.appendChild(svg);
|
|
6372
7106
|
return container;
|
|
@@ -6413,17 +7147,17 @@ function hideTooltip() {
|
|
|
6413
7147
|
tooltipEl.style.display = "none";
|
|
6414
7148
|
}
|
|
6415
7149
|
}
|
|
6416
|
-
function fingerprintCluster(pointCount, counts, size) {
|
|
6417
|
-
return `${size}|${pointCount}|${counts.join(",")}`;
|
|
7150
|
+
function fingerprintCluster(pointCount, counts, size, badgeValue) {
|
|
7151
|
+
return `${size}|${pointCount}|${badgeValue ?? ""}|${counts.join(",")}`;
|
|
6418
7152
|
}
|
|
6419
|
-
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords) {
|
|
7153
|
+
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue) {
|
|
6420
7154
|
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
6421
7155
|
if (cat) {
|
|
6422
7156
|
showTooltip(cat, event.clientX, event.clientY);
|
|
6423
7157
|
} else {
|
|
6424
7158
|
hideTooltip();
|
|
6425
7159
|
}
|
|
6426
|
-
});
|
|
7160
|
+
}, badgeValue);
|
|
6427
7161
|
el.addEventListener("click", () => {
|
|
6428
7162
|
source.getClusterExpansionZoom(clusterId).then((zoom) => {
|
|
6429
7163
|
if (typeof zoom === "number") {
|
|
@@ -6442,13 +7176,16 @@ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, mark
|
|
|
6442
7176
|
});
|
|
6443
7177
|
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
6444
7178
|
clusters.forEach((feature) => {
|
|
6445
|
-
var _a, _b;
|
|
7179
|
+
var _a, _b, _c;
|
|
6446
7180
|
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
6447
7181
|
if (clusterId === void 0) return;
|
|
6448
7182
|
const clusterKey = `${clusterId}`;
|
|
6449
7183
|
visibleClusterIds.add(clusterKey);
|
|
6450
7184
|
const coords = feature.geometry.coordinates;
|
|
6451
7185
|
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
7186
|
+
const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
|
|
7187
|
+
const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
|
|
7188
|
+
const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
|
|
6452
7189
|
const allCounts = categoryValues.map((_, i) => {
|
|
6453
7190
|
var _a2;
|
|
6454
7191
|
return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
|
|
@@ -6460,13 +7197,13 @@ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, mark
|
|
|
6460
7197
|
color: categoryColorMap[cat] || "#3b82f6"
|
|
6461
7198
|
})).filter((c) => c.count > 0);
|
|
6462
7199
|
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
6463
|
-
const fingerprint = fingerprintCluster(pointCount, allCounts, size);
|
|
7200
|
+
const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
|
|
6464
7201
|
const existing = markers.get(clusterKey);
|
|
6465
7202
|
if (existing && existing.fingerprint === fingerprint) {
|
|
6466
7203
|
existing.marker.setLngLat(coords);
|
|
6467
7204
|
return;
|
|
6468
7205
|
}
|
|
6469
|
-
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords);
|
|
7206
|
+
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue);
|
|
6470
7207
|
if (existing) {
|
|
6471
7208
|
existing.marker.remove();
|
|
6472
7209
|
}
|
|
@@ -6907,6 +7644,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6907
7644
|
const loadingBasemaps = useRef(/* @__PURE__ */ new Set());
|
|
6908
7645
|
const customBasemapRegistry = useRef(/* @__PURE__ */ new Map());
|
|
6909
7646
|
const clusterPieManagers = useRef(/* @__PURE__ */ new Map());
|
|
7647
|
+
const clusterGradientManagers = useRef(/* @__PURE__ */ new Map());
|
|
7648
|
+
const clusterLayerHandlers = useRef(/* @__PURE__ */ new Map());
|
|
6910
7649
|
const handleMapStyleChangeRef = useRef(null);
|
|
6911
7650
|
const flightPath3DLayerId = useRef(null);
|
|
6912
7651
|
const update3DFlightPathsRef = useRef(null);
|
|
@@ -6921,6 +7660,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6921
7660
|
const [selectedFeatureIds, setSelectedFeatureIds] = useState([]);
|
|
6922
7661
|
const [featureCount, setFeatureCount] = useState(0);
|
|
6923
7662
|
const [featureUpdateCounter, setFeatureUpdateCounter] = useState(0);
|
|
7663
|
+
const [clusterDataVersion, setClusterDataVersion] = useState(0);
|
|
6924
7664
|
const [showProperties, setShowProperties] = useState(false);
|
|
6925
7665
|
const [autoFocusLabel, setAutoFocusLabel] = useState(false);
|
|
6926
7666
|
const [showLayers, setShowLayers] = useState(false);
|
|
@@ -7252,6 +7992,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7252
7992
|
});
|
|
7253
7993
|
});
|
|
7254
7994
|
});
|
|
7995
|
+
const layerGradientRanges = /* @__PURE__ */ new Map();
|
|
7255
7996
|
selectedFeatureIds.forEach((fid) => {
|
|
7256
7997
|
var _a;
|
|
7257
7998
|
const feature = featById.get(fid);
|
|
@@ -7261,22 +8002,29 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7261
8002
|
colorMap.set(fid, tracePointColors.get(fid));
|
|
7262
8003
|
return;
|
|
7263
8004
|
}
|
|
7264
|
-
|
|
8005
|
+
const fallback = ((_a = feature == null ? void 0 : feature.properties) == null ? void 0 : _a.stroke) || "#3b82f6";
|
|
8006
|
+
let color = fallback;
|
|
7265
8007
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7266
8008
|
if (colorConfig && feature) {
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
8009
|
+
let range;
|
|
8010
|
+
if (layer && colorConfig.mode === "field" && colorConfig.scale === "gradient" && colorConfig.fieldName) {
|
|
8011
|
+
const cached = layerGradientRanges.get(layer.id);
|
|
8012
|
+
if (cached === void 0) {
|
|
8013
|
+
range = computeNumericRange(layer.featureIds, (id) => {
|
|
8014
|
+
var _a2;
|
|
8015
|
+
return (_a2 = featById.get(id)) == null ? void 0 : _a2.properties;
|
|
8016
|
+
}, colorConfig.fieldName);
|
|
8017
|
+
layerGradientRanges.set(layer.id, range);
|
|
8018
|
+
} else {
|
|
8019
|
+
range = cached;
|
|
7273
8020
|
}
|
|
7274
8021
|
}
|
|
8022
|
+
color = resolveFeatureColor(colorConfig, feature.properties, fallback, range);
|
|
7275
8023
|
}
|
|
7276
8024
|
colorMap.set(fid, color);
|
|
7277
8025
|
});
|
|
7278
8026
|
return colorMap;
|
|
7279
|
-
}, [selectedFeatureIds, layers, getAllFeatures
|
|
8027
|
+
}, [selectedFeatureIds, layers, getAllFeatures]);
|
|
7280
8028
|
const countVisibleFeatures = useCallback((threshold) => {
|
|
7281
8029
|
const m = map.current;
|
|
7282
8030
|
if (!m) return 0;
|
|
@@ -7427,27 +8175,38 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7427
8175
|
layer.featureIds.forEach((fid) => featureToLayer.set(fid, layer));
|
|
7428
8176
|
});
|
|
7429
8177
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
8178
|
+
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
7430
8179
|
currentLayers.forEach((layer) => {
|
|
7431
|
-
var _a;
|
|
8180
|
+
var _a, _b;
|
|
7432
8181
|
if (!layer.visible) return;
|
|
7433
8182
|
const sizeConfig = (_a = layer.visualConfig) == null ? void 0 : _a.size;
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
8183
|
+
const colorConfig = (_b = layer.visualConfig) == null ? void 0 : _b.color;
|
|
8184
|
+
const sizeField = (sizeConfig == null ? void 0 : sizeConfig.mode) === "field" && sizeConfig.fieldName ? sizeConfig.fieldName : null;
|
|
8185
|
+
const colorField = (colorConfig == null ? void 0 : colorConfig.mode) === "field" && colorConfig.scale === "gradient" && colorConfig.fieldName ? colorConfig.fieldName : null;
|
|
8186
|
+
if (!sizeField && !colorField) return;
|
|
8187
|
+
let sMin = Infinity, sMax = -Infinity;
|
|
8188
|
+
let cMin = Infinity, cMax = -Infinity;
|
|
8189
|
+
layer.featureIds.forEach((fid) => {
|
|
8190
|
+
var _a2;
|
|
8191
|
+
const props = (_a2 = featureById.get(fid)) == null ? void 0 : _a2.properties;
|
|
8192
|
+
if (!props) return;
|
|
8193
|
+
if (sizeField) {
|
|
8194
|
+
const v = coerceFiniteNumber(props[sizeField]);
|
|
8195
|
+
if (v !== null) {
|
|
8196
|
+
if (v < sMin) sMin = v;
|
|
8197
|
+
if (v > sMax) sMax = v;
|
|
7445
8198
|
}
|
|
7446
|
-
});
|
|
7447
|
-
if (isFinite(min) && isFinite(max)) {
|
|
7448
|
-
sizeFieldRanges.set(layer.id, { min, max });
|
|
7449
8199
|
}
|
|
7450
|
-
|
|
8200
|
+
if (colorField) {
|
|
8201
|
+
const v = coerceFiniteNumber(props[colorField]);
|
|
8202
|
+
if (v !== null) {
|
|
8203
|
+
if (v < cMin) cMin = v;
|
|
8204
|
+
if (v > cMax) cMax = v;
|
|
8205
|
+
}
|
|
8206
|
+
}
|
|
8207
|
+
});
|
|
8208
|
+
if (sizeField && isFinite(sMin)) sizeFieldRanges.set(layer.id, { min: sMin, max: sMax });
|
|
8209
|
+
if (colorField && isFinite(cMin)) colorFieldRanges.set(layer.id, { min: cMin, max: cMax });
|
|
7451
8210
|
});
|
|
7452
8211
|
const lastTracePointIds = /* @__PURE__ */ new Set();
|
|
7453
8212
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
@@ -7512,7 +8271,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7512
8271
|
const sourceData = {
|
|
7513
8272
|
type: "FeatureCollection",
|
|
7514
8273
|
features: allFeatures.map((f) => {
|
|
7515
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8274
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
7516
8275
|
const featureId = String(f.id);
|
|
7517
8276
|
const layer = featureToLayer.get(featureId);
|
|
7518
8277
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
@@ -7521,14 +8280,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7521
8280
|
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
7522
8281
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7523
8282
|
if (colorConfig) {
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
}
|
|
7531
|
-
}
|
|
8283
|
+
strokeColor = resolveFeatureColor(
|
|
8284
|
+
colorConfig,
|
|
8285
|
+
f.properties,
|
|
8286
|
+
strokeColor,
|
|
8287
|
+
layer ? colorFieldRanges.get(layer.id) : void 0
|
|
8288
|
+
);
|
|
7532
8289
|
}
|
|
7533
8290
|
let strokeWidth = ((_c = f.properties) == null ? void 0 : _c["stroke-width"]) || 2;
|
|
7534
8291
|
let pointRadius = Math.round(3 + strokeWidth);
|
|
@@ -7656,7 +8413,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7656
8413
|
pointRadius,
|
|
7657
8414
|
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
7658
8415
|
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
7659
|
-
_labelPriority: labelPriority
|
|
8416
|
+
_labelPriority: labelPriority,
|
|
8417
|
+
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_o = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _o.label)
|
|
7660
8418
|
}
|
|
7661
8419
|
};
|
|
7662
8420
|
})
|
|
@@ -7970,6 +8728,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7970
8728
|
clusterPieManagers.current.delete(layerId);
|
|
7971
8729
|
}
|
|
7972
8730
|
});
|
|
8731
|
+
clusterGradientManagers.current.forEach((mgr, layerId) => {
|
|
8732
|
+
if (!liveLayerIds.has(layerId)) {
|
|
8733
|
+
try {
|
|
8734
|
+
mgr.destroy();
|
|
8735
|
+
} catch {
|
|
8736
|
+
}
|
|
8737
|
+
clusterGradientManagers.current.delete(layerId);
|
|
8738
|
+
}
|
|
8739
|
+
});
|
|
7973
8740
|
const m = map.current;
|
|
7974
8741
|
if (!m) return;
|
|
7975
8742
|
let style;
|
|
@@ -7978,7 +8745,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7978
8745
|
} catch {
|
|
7979
8746
|
return;
|
|
7980
8747
|
}
|
|
7981
|
-
const layerPrefixes = ["heatmap-layer-", "cluster-count-", "clusters-", "unclustered-point-"];
|
|
8748
|
+
const layerPrefixes = ["heatmap-layer-", "cluster-count-", "cluster-single-count-", "cluster-single-", "clusters-", "unclustered-point-"];
|
|
7982
8749
|
const sourcePrefixes = ["heatmap-source-", "cluster-source-"];
|
|
7983
8750
|
((style == null ? void 0 : style.layers) ?? []).forEach((sl) => {
|
|
7984
8751
|
const prefix = layerPrefixes.find((p) => sl.id.startsWith(p));
|
|
@@ -8428,39 +9195,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8428
9195
|
id: "custom-labels",
|
|
8429
9196
|
type: "symbol",
|
|
8430
9197
|
source: "custom-features",
|
|
9198
|
+
filter: UNPINNED_LABEL_FILTER,
|
|
8431
9199
|
layout: {
|
|
9200
|
+
...buildCustomLabelLayout(),
|
|
8432
9201
|
"visibility": "none",
|
|
8433
|
-
// Hide labels for trace points (except last point which has isTraceLabel), arrows handled separately
|
|
8434
|
-
"text-field": [
|
|
8435
|
-
"case",
|
|
8436
|
-
["==", ["get", "isHiddenByTrace"], true],
|
|
8437
|
-
"",
|
|
8438
|
-
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
8439
|
-
"",
|
|
8440
|
-
["==", ["get", "isHiddenByCluster"], 1],
|
|
8441
|
-
"",
|
|
8442
|
-
["==", ["get", "kind"], "arrow"],
|
|
8443
|
-
"",
|
|
8444
|
-
// Arrows use custom-arrow-labels layer
|
|
8445
|
-
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
8446
|
-
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
8447
|
-
"",
|
|
8448
|
-
["==", ["get", "kind"], "text"],
|
|
8449
|
-
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
8450
|
-
["coalesce", ["get", "name"], ""]
|
|
8451
|
-
],
|
|
8452
|
-
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
8453
|
-
"text-size": [
|
|
8454
|
-
"case",
|
|
8455
|
-
["==", ["get", "kind"], "text"],
|
|
8456
|
-
["coalesce", ["get", "fontSize"], 14],
|
|
8457
|
-
["==", ["get", "isTraceLabel"], true],
|
|
8458
|
-
14,
|
|
8459
|
-
12
|
|
8460
|
-
],
|
|
8461
|
-
// Text features: center anchor; others: top anchor
|
|
8462
|
-
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
8463
|
-
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
8464
9202
|
// Native collision-based de-overlap.
|
|
8465
9203
|
//
|
|
8466
9204
|
// History: a prior PR turned collision off (`text-allow-overlap: true`)
|
|
@@ -8487,40 +9225,28 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8487
9225
|
"text-allow-overlap": false,
|
|
8488
9226
|
"text-ignore-placement": false,
|
|
8489
9227
|
"text-optional": true,
|
|
8490
|
-
"text-padding": 2,
|
|
8491
9228
|
// Lower value = higher collision priority (placed first).
|
|
8492
9229
|
// Computed per-feature in syncFeaturesToCustomLayers.
|
|
8493
|
-
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8494
|
-
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
8495
|
-
"text-font": [
|
|
8496
|
-
"case",
|
|
8497
|
-
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
8498
|
-
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
8499
|
-
["==", ["get", "isTraceLabel"], true],
|
|
8500
|
-
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
8501
|
-
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
8502
|
-
]
|
|
9230
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8503
9231
|
},
|
|
8504
|
-
paint:
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
"text-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
8523
|
-
}
|
|
9232
|
+
paint: buildCustomLabelPaint()
|
|
9233
|
+
});
|
|
9234
|
+
mapInstance.addLayer({
|
|
9235
|
+
id: "custom-labels-pinned",
|
|
9236
|
+
type: "symbol",
|
|
9237
|
+
source: "custom-features",
|
|
9238
|
+
filter: PINNED_LABEL_FILTER,
|
|
9239
|
+
layout: {
|
|
9240
|
+
...buildCustomLabelLayout(),
|
|
9241
|
+
"visibility": "visible",
|
|
9242
|
+
"text-allow-overlap": true,
|
|
9243
|
+
"text-ignore-placement": true,
|
|
9244
|
+
// With allow-overlap the collision pass is gone and the key only
|
|
9245
|
+
// orders painting, where HIGHER paints on top — negate so important
|
|
9246
|
+
// (low-priority-value) labels draw over their neighbours' halos.
|
|
9247
|
+
"symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
|
|
9248
|
+
},
|
|
9249
|
+
paint: buildCustomLabelPaint()
|
|
8524
9250
|
});
|
|
8525
9251
|
mapInstance.addSource("arrow-heads", {
|
|
8526
9252
|
type: "geojson",
|
|
@@ -9346,7 +10072,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9346
10072
|
scheduleSync();
|
|
9347
10073
|
});
|
|
9348
10074
|
mapInstance.on("click", (e) => {
|
|
9349
|
-
var _a;
|
|
10075
|
+
var _a, _b;
|
|
9350
10076
|
if (!enableSelectionRef.current) return;
|
|
9351
10077
|
if (e.originalEvent.button !== 0) return;
|
|
9352
10078
|
if (contextMenuFiredRef.current) return;
|
|
@@ -9355,14 +10081,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9355
10081
|
const features = mapInstance.queryRenderedFeatures(e.point, {
|
|
9356
10082
|
layers: ["custom-polygon-fill", "custom-line", "custom-point"]
|
|
9357
10083
|
});
|
|
10084
|
+
let clusteredFeatureId = null;
|
|
9358
10085
|
if (features.length === 0) {
|
|
9359
|
-
|
|
9360
|
-
|
|
10086
|
+
const clusterOverlayIds = layersRef.current.filter((l) => {
|
|
10087
|
+
var _a2;
|
|
10088
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
10089
|
+
}).flatMap((l) => [`clusters-${l.id}`, `cluster-single-${l.id}`, `cluster-single-count-${l.id}`, `unclustered-point-${l.id}`]).filter((id) => mapInstance.getLayer(id));
|
|
10090
|
+
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
10091
|
+
if (!clusterHit) {
|
|
10092
|
+
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
10093
|
+
applySelectionState([]);
|
|
10094
|
+
}
|
|
10095
|
+
return;
|
|
9361
10096
|
}
|
|
9362
|
-
|
|
10097
|
+
const memberId = (_a = clusterHit.properties) == null ? void 0 : _a[CLUSTER_MEMBER_ID_PROP];
|
|
10098
|
+
if (memberId == null || memberId === "") return;
|
|
10099
|
+
clusteredFeatureId = String(memberId);
|
|
9363
10100
|
}
|
|
9364
|
-
const
|
|
9365
|
-
const featureId = (_a = hitFeature.properties) == null ? void 0 : _a.id;
|
|
10101
|
+
const featureId = clusteredFeatureId ?? ((_b = features[0].properties) == null ? void 0 : _b.id);
|
|
9366
10102
|
if (!featureId) return;
|
|
9367
10103
|
let isReadOnly = false;
|
|
9368
10104
|
readOnlyFeatures.current.forEach((layerFeatures) => {
|
|
@@ -9629,6 +10365,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9629
10365
|
map.current.flyTo({ center: center.geometry.coordinates });
|
|
9630
10366
|
},
|
|
9631
10367
|
listLayers: () => [...layersRef.current],
|
|
10368
|
+
// Worker parse + streamed transfer + the canvas progress overlay, with
|
|
10369
|
+
// layer creation left to the host (see MapEditorHandle docs).
|
|
10370
|
+
parseGeoJSONText: (label, text) => ingestWithProgress(label, text, { idStrategy: "preserve" }),
|
|
9632
10371
|
addLayer: (name, geojson, options) => {
|
|
9633
10372
|
if (!isMapLoadedRef.current) return "";
|
|
9634
10373
|
if (options == null ? void 0 : options.recordHistory) saveStateForUndo(`add layer "${name}"`);
|
|
@@ -10660,10 +11399,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10660
11399
|
scheduleSync();
|
|
10661
11400
|
scheduleTimelineUpdate();
|
|
10662
11401
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11402
|
+
if (hasRealChange && !(options == null ? void 0 : options.fromRefresh) && layersRef.current.some((l) => {
|
|
11403
|
+
var _a2;
|
|
11404
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
11405
|
+
})) {
|
|
11406
|
+
setClusterDataVersion((c) => c + 1);
|
|
11407
|
+
}
|
|
10663
11408
|
const updated = draw.current.get(featureId);
|
|
10664
11409
|
if (updated) onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
10665
11410
|
} else {
|
|
10666
11411
|
let updatedFeature;
|
|
11412
|
+
let anyRealChange = false;
|
|
10667
11413
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10668
11414
|
var _a2;
|
|
10669
11415
|
const idx = features.findIndex((f) => String(f.id) === featureId);
|
|
@@ -10675,6 +11421,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10675
11421
|
const oldVal = (_a3 = f.properties) == null ? void 0 : _a3[key];
|
|
10676
11422
|
if (JSON.stringify(oldVal) !== JSON.stringify(value)) hasRealChange = true;
|
|
10677
11423
|
});
|
|
11424
|
+
if (hasRealChange) anyRealChange = true;
|
|
10678
11425
|
const currentUnsaved = (_a2 = f.properties) == null ? void 0 : _a2._unsaved;
|
|
10679
11426
|
const nextProperties = { ...f.properties, ...normalizedProperties };
|
|
10680
11427
|
if (!externalPersistence && hasRealChange && currentUnsaved !== false && !(options == null ? void 0 : options.fromRefresh)) {
|
|
@@ -10695,6 +11442,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10695
11442
|
scheduleSync();
|
|
10696
11443
|
scheduleTimelineUpdate();
|
|
10697
11444
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11445
|
+
if (anyRealChange && !(options == null ? void 0 : options.fromRefresh) && layersRef.current.some((l) => {
|
|
11446
|
+
var _a2;
|
|
11447
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
11448
|
+
})) {
|
|
11449
|
+
setClusterDataVersion((c) => c + 1);
|
|
11450
|
+
}
|
|
10698
11451
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updatedFeature);
|
|
10699
11452
|
}
|
|
10700
11453
|
}
|
|
@@ -10722,6 +11475,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10722
11475
|
draw.current.changeMode("simple_select", { featureIds: [featureId] });
|
|
10723
11476
|
scheduleSync();
|
|
10724
11477
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11478
|
+
if (layersRef.current.some((l) => {
|
|
11479
|
+
var _a;
|
|
11480
|
+
return (_a = l.clusterConfig) == null ? void 0 : _a.enabled;
|
|
11481
|
+
})) {
|
|
11482
|
+
setClusterDataVersion((c) => c + 1);
|
|
11483
|
+
}
|
|
10725
11484
|
const updated = draw.current.get(featureId);
|
|
10726
11485
|
if (updated) {
|
|
10727
11486
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
@@ -11076,11 +11835,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11076
11835
|
try {
|
|
11077
11836
|
if (firstVisibleBasemapSymbol) {
|
|
11078
11837
|
m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
|
|
11838
|
+
if (m.getLayer("custom-labels-pinned")) {
|
|
11839
|
+
m.moveLayer("custom-labels-pinned", firstVisibleBasemapSymbol.id);
|
|
11840
|
+
}
|
|
11079
11841
|
if (m.getLayer("custom-arrow-labels")) {
|
|
11080
11842
|
m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
|
|
11081
11843
|
}
|
|
11082
11844
|
} else {
|
|
11083
11845
|
m.moveLayer("custom-labels");
|
|
11846
|
+
if (m.getLayer("custom-labels-pinned")) {
|
|
11847
|
+
m.moveLayer("custom-labels-pinned");
|
|
11848
|
+
}
|
|
11084
11849
|
if (m.getLayer("custom-arrow-labels")) {
|
|
11085
11850
|
m.moveLayer("custom-arrow-labels");
|
|
11086
11851
|
}
|
|
@@ -11385,7 +12150,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11385
12150
|
const layer = layers.find((l) => l.id === layerId);
|
|
11386
12151
|
if (!layer) return [];
|
|
11387
12152
|
const fieldsMap = /* @__PURE__ */ new Map();
|
|
11388
|
-
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity"]);
|
|
12153
|
+
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity", ...STYLING_PROPERTY_KEYS]);
|
|
11389
12154
|
const MAX_SAMPLES = 1e4;
|
|
11390
12155
|
let features = [];
|
|
11391
12156
|
if (layer.readOnly) {
|
|
@@ -11395,22 +12160,41 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11395
12160
|
} else {
|
|
11396
12161
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
11397
12162
|
}
|
|
11398
|
-
const
|
|
12163
|
+
const sampled = !layer.readOnly && features.length > MAX_SAMPLES;
|
|
12164
|
+
const sampleFeatures = layer.readOnly ? features : features.slice(0, MAX_SAMPLES);
|
|
11399
12165
|
sampleFeatures.forEach((f) => {
|
|
11400
12166
|
if (f && f.properties) {
|
|
11401
12167
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
11402
|
-
if (
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
12168
|
+
if (excludedFields.has(key)) return;
|
|
12169
|
+
let acc = fieldsMap.get(key);
|
|
12170
|
+
if (!acc) {
|
|
12171
|
+
acc = { isNumeric: false, numericCount: 0, nonEmptyCount: 0, min: Infinity, max: -Infinity };
|
|
12172
|
+
fieldsMap.set(key, acc);
|
|
12173
|
+
}
|
|
12174
|
+
if (typeof value === "number" || typeof value === "string" && value.trim() !== "" && !isNaN(Number(value))) {
|
|
12175
|
+
acc.isNumeric = true;
|
|
12176
|
+
}
|
|
12177
|
+
if (!(value == null || typeof value === "string" && value.trim() === "")) {
|
|
12178
|
+
acc.nonEmptyCount++;
|
|
12179
|
+
}
|
|
12180
|
+
const num = coerceFiniteNumber(value);
|
|
12181
|
+
if (num !== null) {
|
|
12182
|
+
acc.numericCount++;
|
|
12183
|
+
if (num < acc.min) acc.min = num;
|
|
12184
|
+
if (num > acc.max) acc.max = num;
|
|
11409
12185
|
}
|
|
11410
12186
|
});
|
|
11411
12187
|
}
|
|
11412
12188
|
});
|
|
11413
|
-
|
|
12189
|
+
const sampledFeatureCount = sampleFeatures.length;
|
|
12190
|
+
return Array.from(fieldsMap.entries()).map(([name, acc]) => ({
|
|
12191
|
+
name,
|
|
12192
|
+
isNumeric: acc.isNumeric,
|
|
12193
|
+
numericRatio: acc.nonEmptyCount > 0 ? acc.numericCount / acc.nonEmptyCount : 0,
|
|
12194
|
+
coverage: sampledFeatureCount > 0 ? acc.nonEmptyCount / sampledFeatureCount : 0,
|
|
12195
|
+
sampled,
|
|
12196
|
+
...acc.numericCount > 0 ? { min: acc.min, max: acc.max } : {}
|
|
12197
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
11414
12198
|
}, [layers]);
|
|
11415
12199
|
const getFieldValueDistribution = useCallback(
|
|
11416
12200
|
(layerId, fieldName, maxValues = 50) => {
|
|
@@ -12766,10 +13550,22 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12766
13550
|
duration: 1e3
|
|
12767
13551
|
});
|
|
12768
13552
|
}, [layers, toast]);
|
|
13553
|
+
const [ingestProgressStore] = useState(createIngestProgressStore);
|
|
13554
|
+
const ingestWithProgress = useCallback(async (label, input, options) => {
|
|
13555
|
+
const progress = ingestProgressStore.begin(label);
|
|
13556
|
+
try {
|
|
13557
|
+
return await getSharedIngestClient().ingest(input, options, {
|
|
13558
|
+
onHead: (summary) => progress.setTotal(summary.featureCount),
|
|
13559
|
+
onProgress: (received) => progress.update(received)
|
|
13560
|
+
});
|
|
13561
|
+
} finally {
|
|
13562
|
+
progress.end();
|
|
13563
|
+
}
|
|
13564
|
+
}, [ingestProgressStore]);
|
|
12769
13565
|
const loadGeoJSONFile = useCallback(async (file, requestedTargetLayerId, createNewLayer) => {
|
|
12770
13566
|
let result;
|
|
12771
13567
|
try {
|
|
12772
|
-
result = await
|
|
13568
|
+
result = await ingestWithProgress(file.name, file, {
|
|
12773
13569
|
idStrategy: "uuid-fallback",
|
|
12774
13570
|
emptyIsError: true
|
|
12775
13571
|
});
|
|
@@ -12908,7 +13704,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12908
13704
|
title: "GeoJSON loaded",
|
|
12909
13705
|
description: `Added ${normalizedFeatures.length} features${reprojectMsg}${!(targetLayer == null ? void 0 : targetLayer.visible) ? " (layer hidden)" : ""}`
|
|
12910
13706
|
});
|
|
12911
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
13707
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad, ingestWithProgress]);
|
|
12912
13708
|
const handleFileChange = useCallback((e) => {
|
|
12913
13709
|
var _a;
|
|
12914
13710
|
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
@@ -12925,7 +13721,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12925
13721
|
const startedAt = performance.now();
|
|
12926
13722
|
let result;
|
|
12927
13723
|
try {
|
|
12928
|
-
result = await
|
|
13724
|
+
result = await ingestWithProgress(name, input, { idStrategy: "layer-index", layerId });
|
|
12929
13725
|
} catch (error) {
|
|
12930
13726
|
toast({
|
|
12931
13727
|
title: "Failed to load GeoJSON",
|
|
@@ -12992,7 +13788,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12992
13788
|
title: "Layer added",
|
|
12993
13789
|
description: `Created "${newLayer.name}" with ${addedIds.length} features${reprojectMsg} (high-performance)`
|
|
12994
13790
|
});
|
|
12995
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
13791
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad, ingestWithProgress]);
|
|
12996
13792
|
const handleDropGeoJSON = useCallback((name, data) => {
|
|
12997
13793
|
void ingestDroppedLayer(name, data);
|
|
12998
13794
|
}, [ingestDroppedLayer]);
|
|
@@ -13013,7 +13809,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13013
13809
|
prevTimelineEnabledRef.current = isNowEnabled;
|
|
13014
13810
|
if (!isNowEnabled || !timelineStore.hasTemporalData) {
|
|
13015
13811
|
timelineVisibleIdsRef.current = null;
|
|
13016
|
-
scheduleSync();
|
|
13812
|
+
scheduleSync("timeline");
|
|
13017
13813
|
} else if (!wasEnabled && isNowEnabled) {
|
|
13018
13814
|
updateTimelineStore();
|
|
13019
13815
|
}
|
|
@@ -13146,16 +13942,33 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13146
13942
|
mapInstance.once("idle", rebuildClusters);
|
|
13147
13943
|
return;
|
|
13148
13944
|
}
|
|
13945
|
+
clusterLayerHandlers.current.forEach((handlers, layerId) => {
|
|
13946
|
+
const clustersLayerId = `clusters-${layerId}`;
|
|
13947
|
+
try {
|
|
13948
|
+
mapInstance.off("click", clustersLayerId, handlers.click);
|
|
13949
|
+
mapInstance.off("mouseenter", clustersLayerId, handlers.enter);
|
|
13950
|
+
mapInstance.off("mouseleave", clustersLayerId, handlers.leave);
|
|
13951
|
+
} catch {
|
|
13952
|
+
}
|
|
13953
|
+
});
|
|
13954
|
+
clusterLayerHandlers.current.clear();
|
|
13149
13955
|
layers.forEach((layer) => {
|
|
13150
13956
|
const sourceId = `cluster-source-${layer.id}`;
|
|
13151
13957
|
const clustersLayerId = `clusters-${layer.id}`;
|
|
13152
13958
|
const clusterCountLayerId = `cluster-count-${layer.id}`;
|
|
13153
13959
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
13960
|
+
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
13961
|
+
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
13154
13962
|
const existingPieManager = clusterPieManagers.current.get(layer.id);
|
|
13155
13963
|
if (existingPieManager) {
|
|
13156
13964
|
existingPieManager.destroy();
|
|
13157
13965
|
clusterPieManagers.current.delete(layer.id);
|
|
13158
13966
|
}
|
|
13967
|
+
const existingGradientManager = clusterGradientManagers.current.get(layer.id);
|
|
13968
|
+
if (existingGradientManager) {
|
|
13969
|
+
existingGradientManager.destroy();
|
|
13970
|
+
clusterGradientManagers.current.delete(layer.id);
|
|
13971
|
+
}
|
|
13159
13972
|
try {
|
|
13160
13973
|
if (mapInstance.getLayer(clusterCountLayerId)) {
|
|
13161
13974
|
mapInstance.removeLayer(clusterCountLayerId);
|
|
@@ -13163,6 +13976,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13163
13976
|
if (mapInstance.getLayer(clustersLayerId)) {
|
|
13164
13977
|
mapInstance.removeLayer(clustersLayerId);
|
|
13165
13978
|
}
|
|
13979
|
+
if (mapInstance.getLayer(singleValueCountLayerId)) {
|
|
13980
|
+
mapInstance.removeLayer(singleValueCountLayerId);
|
|
13981
|
+
}
|
|
13982
|
+
if (mapInstance.getLayer(singleValueLayerId)) {
|
|
13983
|
+
mapInstance.removeLayer(singleValueLayerId);
|
|
13984
|
+
}
|
|
13166
13985
|
if (mapInstance.getLayer(unclusteredLayerId)) {
|
|
13167
13986
|
mapInstance.removeLayer(unclusteredLayerId);
|
|
13168
13987
|
}
|
|
@@ -13173,12 +13992,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13173
13992
|
}
|
|
13174
13993
|
});
|
|
13175
13994
|
layers.forEach((layer) => {
|
|
13176
|
-
var _a, _b, _c, _d;
|
|
13995
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13177
13996
|
if (!((_a = layer.clusterConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
13178
13997
|
const sourceId = `cluster-source-${layer.id}`;
|
|
13179
13998
|
const clustersLayerId = `clusters-${layer.id}`;
|
|
13180
13999
|
const clusterCountLayerId = `cluster-count-${layer.id}`;
|
|
13181
14000
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
14001
|
+
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
14002
|
+
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
13182
14003
|
let pointFeatures = [];
|
|
13183
14004
|
if (layer.visible) {
|
|
13184
14005
|
if (layer.readOnly) {
|
|
@@ -13205,10 +14026,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13205
14026
|
}
|
|
13206
14027
|
if (pointFeatures.length === 0) return;
|
|
13207
14028
|
const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
|
|
14029
|
+
const countByField = ((_c = layer.clusterConfig) == null ? void 0 : _c.countByFieldEnabled) && ((_d = layer.clusterConfig) == null ? void 0 : _d.countByField) || null;
|
|
14030
|
+
const bubbleGradient = !!((_e = layer.clusterConfig) == null ? void 0 : _e.bubbleGradient) && !groupByField;
|
|
13208
14031
|
const OTHER_COLOR = OTHER_BUCKET_COLOR;
|
|
13209
14032
|
const MAX_CATEGORIES = 15;
|
|
13210
14033
|
try {
|
|
13211
|
-
const layerColor = ((
|
|
14034
|
+
const layerColor = ((_g = (_f = layer.visualConfig) == null ? void 0 : _f.color) == null ? void 0 : _g.fixedColor) || "#3b82f6";
|
|
13212
14035
|
let clusterProperties = {};
|
|
13213
14036
|
let categoryValues = [];
|
|
13214
14037
|
let categoryColorMap = {};
|
|
@@ -13238,12 +14061,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13238
14061
|
const otherExpr = topKeys.length === 0 ? 1 : ["match", fieldAsString, topKeys, 0, 1];
|
|
13239
14062
|
clusterProperties[`cat_${categoryValues.length - 1}`] = ["+", otherExpr];
|
|
13240
14063
|
}
|
|
14064
|
+
if (countByField) {
|
|
14065
|
+
clusterProperties[CLUSTER_SUM_PROP] = ["+", ["get", CLUSTER_COUNT_VALUE_PROP]];
|
|
14066
|
+
}
|
|
14067
|
+
const sourceFeatures = countByField ? injectClusterCountValues(pointFeatures, countByField) : pointFeatures;
|
|
13241
14068
|
const mapStyleMaxZoom = typeof mapInstance.getMaxZoom === "function" ? mapInstance.getMaxZoom() : 24;
|
|
13242
14069
|
const clusterMaxZoom = Math.min(24, Math.max(1, mapStyleMaxZoom - 1));
|
|
13243
14070
|
const geojsonSourceMaxZoom = Math.min(24, Math.max(clusterMaxZoom + 1, mapStyleMaxZoom));
|
|
13244
14071
|
mapInstance.addSource(sourceId, {
|
|
13245
14072
|
type: "geojson",
|
|
13246
|
-
data: { type: "FeatureCollection", features:
|
|
14073
|
+
data: { type: "FeatureCollection", features: sourceFeatures },
|
|
13247
14074
|
maxzoom: geojsonSourceMaxZoom,
|
|
13248
14075
|
cluster: true,
|
|
13249
14076
|
clusterMaxZoom,
|
|
@@ -13301,12 +14128,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13301
14128
|
source: sourceId,
|
|
13302
14129
|
filter: ["has", "point_count"],
|
|
13303
14130
|
layout: {
|
|
13304
|
-
"text-field": ["get", "point_count_abbreviated"],
|
|
14131
|
+
"text-field": countByField ? clusterBadgeTextField(CLUSTER_SUM_PROP) : ["get", "point_count_abbreviated"],
|
|
13305
14132
|
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
13306
14133
|
"text-size": 12
|
|
13307
14134
|
},
|
|
13308
14135
|
paint: {
|
|
13309
|
-
"text-color": "#ffffff"
|
|
14136
|
+
"text-color": "#ffffff",
|
|
14137
|
+
// The gradient's pale end needs a dark halo for the white
|
|
14138
|
+
// badge text to stay readable at every ramp stop.
|
|
14139
|
+
...bubbleGradient ? { "text-halo-color": "#111827", "text-halo-width": 1.1 } : {}
|
|
13310
14140
|
}
|
|
13311
14141
|
});
|
|
13312
14142
|
}
|
|
@@ -13321,7 +14151,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13321
14151
|
id: unclusteredLayerId,
|
|
13322
14152
|
type: "circle",
|
|
13323
14153
|
source: sourceId,
|
|
13324
|
-
|
|
14154
|
+
// With count-by-field on, points whose value exceeds 1 render as
|
|
14155
|
+
// value bubbles below instead of plain dots.
|
|
14156
|
+
filter: countByField ? ["all", ["!", ["has", "point_count"]], ["<=", ["get", CLUSTER_COUNT_VALUE_PROP], 1]] : ["!", ["has", "point_count"]],
|
|
13325
14157
|
paint: {
|
|
13326
14158
|
"circle-color": unclusteredColor,
|
|
13327
14159
|
"circle-radius": 6,
|
|
@@ -13329,7 +14161,50 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13329
14161
|
"circle-stroke-color": "#ffffff"
|
|
13330
14162
|
}
|
|
13331
14163
|
});
|
|
13332
|
-
|
|
14164
|
+
if (countByField) {
|
|
14165
|
+
const singleValueFilter = ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]];
|
|
14166
|
+
mapInstance.addLayer({
|
|
14167
|
+
id: singleValueLayerId,
|
|
14168
|
+
type: "circle",
|
|
14169
|
+
source: sourceId,
|
|
14170
|
+
filter: singleValueFilter,
|
|
14171
|
+
paint: {
|
|
14172
|
+
"circle-color": unclusteredColor,
|
|
14173
|
+
"circle-radius": 14,
|
|
14174
|
+
"circle-stroke-width": 2,
|
|
14175
|
+
"circle-stroke-color": "#ffffff"
|
|
14176
|
+
}
|
|
14177
|
+
});
|
|
14178
|
+
mapInstance.addLayer({
|
|
14179
|
+
id: singleValueCountLayerId,
|
|
14180
|
+
type: "symbol",
|
|
14181
|
+
source: sourceId,
|
|
14182
|
+
filter: singleValueFilter,
|
|
14183
|
+
layout: {
|
|
14184
|
+
"text-field": clusterBadgeTextField(CLUSTER_COUNT_VALUE_PROP),
|
|
14185
|
+
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
14186
|
+
"text-size": 11,
|
|
14187
|
+
// A bubble without its number reads as broken - never cull.
|
|
14188
|
+
"text-allow-overlap": true,
|
|
14189
|
+
"text-ignore-placement": true
|
|
14190
|
+
},
|
|
14191
|
+
paint: {
|
|
14192
|
+
"text-color": "#ffffff",
|
|
14193
|
+
...bubbleGradient ? { "text-halo-color": "#111827", "text-halo-width": 1.1 } : {}
|
|
14194
|
+
}
|
|
14195
|
+
});
|
|
14196
|
+
}
|
|
14197
|
+
if (bubbleGradient) {
|
|
14198
|
+
clusterGradientManagers.current.set(
|
|
14199
|
+
layer.id,
|
|
14200
|
+
createClusterGradientManager(mapInstance, sourceId, {
|
|
14201
|
+
clustersLayerId,
|
|
14202
|
+
valueProp: countByField ? CLUSTER_SUM_PROP : null,
|
|
14203
|
+
...countByField ? { singleLayerId: singleValueLayerId } : {}
|
|
14204
|
+
})
|
|
14205
|
+
);
|
|
14206
|
+
}
|
|
14207
|
+
const handleClusterClick = async (e) => {
|
|
13333
14208
|
var _a2;
|
|
13334
14209
|
const features = mapInstance.queryRenderedFeatures(e.point, {
|
|
13335
14210
|
layers: [clustersLayerId]
|
|
@@ -13348,12 +14223,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13348
14223
|
}
|
|
13349
14224
|
} catch {
|
|
13350
14225
|
}
|
|
13351
|
-
}
|
|
13352
|
-
|
|
14226
|
+
};
|
|
14227
|
+
const handleClusterMouseEnter = () => {
|
|
13353
14228
|
mapInstance.getCanvas().style.cursor = "pointer";
|
|
13354
|
-
}
|
|
13355
|
-
|
|
14229
|
+
};
|
|
14230
|
+
const handleClusterMouseLeave = () => {
|
|
13356
14231
|
mapInstance.getCanvas().style.cursor = "";
|
|
14232
|
+
};
|
|
14233
|
+
mapInstance.on("click", clustersLayerId, handleClusterClick);
|
|
14234
|
+
mapInstance.on("mouseenter", clustersLayerId, handleClusterMouseEnter);
|
|
14235
|
+
mapInstance.on("mouseleave", clustersLayerId, handleClusterMouseLeave);
|
|
14236
|
+
clusterLayerHandlers.current.set(layer.id, {
|
|
14237
|
+
click: handleClusterClick,
|
|
14238
|
+
enter: handleClusterMouseEnter,
|
|
14239
|
+
leave: handleClusterMouseLeave
|
|
13357
14240
|
});
|
|
13358
14241
|
} catch (e) {
|
|
13359
14242
|
console.warn("Error creating cluster layer:", e);
|
|
@@ -13371,7 +14254,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13371
14254
|
} catch {
|
|
13372
14255
|
}
|
|
13373
14256
|
};
|
|
13374
|
-
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1]);
|
|
14257
|
+
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1, clusterDataVersion]);
|
|
13375
14258
|
if (mapError) {
|
|
13376
14259
|
return /* @__PURE__ */ jsx("div", { className: `flex items-center justify-center h-full bg-muted/30 ${className || ""}`, "data-testid": "map-error", children: /* @__PURE__ */ jsxs(Card, { className: "max-w-md", children: [
|
|
13377
14260
|
/* @__PURE__ */ jsx("div", { className: "p-4 border-b border-border", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
@@ -13868,6 +14751,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13868
14751
|
}
|
|
13869
14752
|
),
|
|
13870
14753
|
/* @__PURE__ */ jsx(CursorCoordinatesOverlay, { map: isMapLoaded ? map.current : null }),
|
|
14754
|
+
/* @__PURE__ */ jsx(
|
|
14755
|
+
IngestProgressOverlay,
|
|
14756
|
+
{
|
|
14757
|
+
store: ingestProgressStore,
|
|
14758
|
+
bottomPx: timelineStore.isEnabled ? TIMEBAR_HEIGHT + TIMEBAR_BOTTOM_OFFSET + 8 : 32
|
|
14759
|
+
}
|
|
14760
|
+
),
|
|
13871
14761
|
/* @__PURE__ */ jsx(
|
|
13872
14762
|
"input",
|
|
13873
14763
|
{
|
|
@@ -14884,40 +15774,6 @@ function DebugSidebar({ onAddRandomPoints, onImportKML, onAddDomMarkers, onRemov
|
|
|
14884
15774
|
}
|
|
14885
15775
|
);
|
|
14886
15776
|
}
|
|
14887
|
-
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
14888
|
-
"fill",
|
|
14889
|
-
"fill-opacity",
|
|
14890
|
-
"pointRadius",
|
|
14891
|
-
"pointIcon",
|
|
14892
|
-
"pointIconSize",
|
|
14893
|
-
"circleCenter",
|
|
14894
|
-
"circleRadius",
|
|
14895
|
-
"icon",
|
|
14896
|
-
"iconSize",
|
|
14897
|
-
"fontSize",
|
|
14898
|
-
"fontColor",
|
|
14899
|
-
"fontWeight",
|
|
14900
|
-
"arrowSize",
|
|
14901
|
-
"label",
|
|
14902
|
-
"entityType",
|
|
14903
|
-
"kind",
|
|
14904
|
-
"meta:type",
|
|
14905
|
-
"stroke",
|
|
14906
|
-
"stroke-width",
|
|
14907
|
-
"stroke-opacity"
|
|
14908
|
-
]);
|
|
14909
|
-
const INTERNAL_PROPERTY_PREFIXES = [
|
|
14910
|
-
"IsHiddenBy",
|
|
14911
|
-
"isHidden",
|
|
14912
|
-
"isSelected",
|
|
14913
|
-
"isTrace",
|
|
14914
|
-
"isTimeline",
|
|
14915
|
-
"trace"
|
|
14916
|
-
];
|
|
14917
|
-
function isInternalProperty(key) {
|
|
14918
|
-
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
14919
|
-
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
14920
|
-
}
|
|
14921
15777
|
export {
|
|
14922
15778
|
ActionPanel,
|
|
14923
15779
|
ClusterPieManager,
|