@loaders.gl/geospatial 5.0.0-beta.4 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/WKT-README.md +1 -1
  3. package/dist/dbf-loader-types.cjs +1 -1
  4. package/dist/dbf-worker.js +391 -104
  5. package/dist/flatgeobuf/flatgeobuf-loader-types.cjs +1 -1
  6. package/dist/flatgeobuf/flatgeobuf-loader-types.js +1 -1
  7. package/dist/flatgeobuf/flatgeobuf-source-loader.cjs +1 -1
  8. package/dist/flatgeobuf/flatgeobuf-source-loader.js +1 -1
  9. package/dist/flatgeobuf-loader-types.cjs +1 -1
  10. package/dist/flatgeobuf-source-loader.cjs +1 -1
  11. package/dist/flatgeobuf-worker.js +853 -535
  12. package/dist/geopackage/geopackage-source-loader.cjs +1 -1
  13. package/dist/geopackage/geopackage-source-loader.js +1 -1
  14. package/dist/geopackage-source-loader.cjs +1 -1
  15. package/dist/gpx-loader-types.cjs +1 -1
  16. package/dist/kml/gpx-loader-types.cjs +1 -1
  17. package/dist/kml/gpx-loader-types.js +1 -1
  18. package/dist/kml/kml-loader-types.cjs +1 -1
  19. package/dist/kml/kml-loader-types.js +1 -1
  20. package/dist/kml/kml-writer.cjs +1 -1
  21. package/dist/kml/kml-writer.js +1 -1
  22. package/dist/kml/kmz-loader-types.cjs +1 -1
  23. package/dist/kml/kmz-loader-types.js +1 -1
  24. package/dist/kml/kmz-source.cjs +1 -1
  25. package/dist/kml/kmz-source.js +1 -1
  26. package/dist/kml/tcx-loader-types.cjs +1 -1
  27. package/dist/kml/tcx-loader-types.js +1 -1
  28. package/dist/kml-loader-types.cjs +1 -1
  29. package/dist/kml-writer.cjs +1 -1
  30. package/dist/kmz-loader-types.cjs +1 -1
  31. package/dist/kmz-source.cjs +1 -1
  32. package/dist/shapefile/dbf-loader-types.cjs +1 -1
  33. package/dist/shapefile/dbf-loader-types.js +1 -1
  34. package/dist/shapefile/lib/shapefile-worker-transport.cjs +3 -3
  35. package/dist/shapefile/lib/shapefile-worker-transport.cjs.map +2 -2
  36. package/dist/shapefile/lib/shapefile-worker-transport.js +1 -1
  37. package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -1
  38. package/dist/shapefile/shapefile-loader-types.cjs +1 -1
  39. package/dist/shapefile/shapefile-loader-types.js +1 -1
  40. package/dist/shapefile/shp-loader-types.cjs +1 -1
  41. package/dist/shapefile/shp-loader-types.js +1 -1
  42. package/dist/shapefile-loader-types.cjs +1 -1
  43. package/dist/shapefile-worker.js +2705 -2342
  44. package/dist/shp-loader-types.cjs +1 -1
  45. package/dist/shp-worker.js +2447 -2188
  46. package/dist/tcx-loader-types.cjs +1 -1
  47. package/dist/wkt/lib/version.cjs +1 -1
  48. package/dist/wkt/lib/version.js +1 -1
  49. package/dist/wkt/wkt-format.cjs +2 -2
  50. package/dist/wkt/wkt-format.cjs.map +2 -2
  51. package/dist/wkt/wkt-format.js +1 -1
  52. package/dist/wkt/wkt-format.js.map +1 -1
  53. package/dist/wkt-worker.js +251 -51
  54. package/package.json +6 -5
  55. package/src/shapefile/lib/shapefile-worker-transport.ts +1 -1
  56. package/src/wkt/wkt-format.ts +1 -1
@@ -15,15 +15,15 @@
15
15
  __defProp(target, name, { get: all[name], enumerable: true });
16
16
  };
17
17
 
18
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
18
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
19
19
  var parentPort;
20
20
  var init_worker_threads_browser = __esm({
21
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js"() {
21
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js"() {
22
22
  parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
23
23
  }
24
24
  });
25
25
 
26
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
26
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
27
27
  function getTransferList(object2, recursive = true, transfers) {
28
28
  const transfersSet = transfers || /* @__PURE__ */ new Set();
29
29
  const seen = /* @__PURE__ */ new Set();
@@ -74,11 +74,11 @@
74
74
  return false;
75
75
  }
76
76
  var init_get_transfer_list = __esm({
77
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
77
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
78
78
  }
79
79
  });
80
80
 
81
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
81
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
82
82
  async function getParentPort() {
83
83
  return parentPort;
84
84
  }
@@ -91,7 +91,7 @@
91
91
  }
92
92
  var onMessageWrapperMap, WorkerBody;
93
93
  var init_worker_body = __esm({
94
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js"() {
94
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js"() {
95
95
  init_get_transfer_list();
96
96
  init_worker_threads_browser();
97
97
  onMessageWrapperMap = /* @__PURE__ */ new Map();
@@ -172,10 +172,10 @@
172
172
  }
173
173
  });
174
174
 
175
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
175
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
176
176
  var AsyncQueue;
177
177
  var init_async_queue = __esm({
178
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js"() {
178
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js"() {
179
179
  AsyncQueue = class {
180
180
  constructor() {
181
181
  this._values = [];
@@ -244,10 +244,10 @@
244
244
  }
245
245
  });
246
246
 
247
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
247
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
248
248
  var SharedWorkerState;
249
249
  var init_shared_state = __esm({
250
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js"() {
250
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js"() {
251
251
  SharedWorkerState = class {
252
252
  constructor(buffer) {
253
253
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -288,18 +288,18 @@
288
288
  }
289
289
  });
290
290
 
291
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
291
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
292
292
  function validateOutputOwnership(ownership) {
293
293
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
294
294
  throw new Error("Invalid worker output ownership");
295
295
  }
296
296
  }
297
297
  var init_validate_output_ownership = __esm({
298
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
298
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js"() {
299
299
  }
300
300
  });
301
301
 
302
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
302
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
303
303
  async function createWorker(process2, processInBatches, preload2) {
304
304
  if (!await WorkerBody.inWorkerThread()) {
305
305
  return;
@@ -504,7 +504,7 @@
504
504
  }
505
505
  var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
506
506
  var init_create_worker = __esm({
507
- "../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js"() {
507
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js"() {
508
508
  init_shared_state();
509
509
  init_async_queue();
510
510
  init_worker_body();
@@ -516,19 +516,20 @@
516
516
  }
517
517
  });
518
518
 
519
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
519
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
520
520
  var import_meta, path, moduleUrl;
521
521
  var init_worker_utils = __esm({
522
- "../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
522
+ "../../node_modules/@math.gl/tasks/dist/worker-utils/index.js"() {
523
523
  init_worker_body();
524
524
  init_create_worker();
525
+ init_get_transfer_list();
525
526
  import_meta = {};
526
527
  path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
527
528
  moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
528
529
  }
529
530
  });
530
531
 
531
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
532
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
532
533
  function preloadTaskCode(task, signal) {
533
534
  if (!task.preload)
534
535
  return Promise.resolve();
@@ -564,23 +565,193 @@
564
565
  }
565
566
  var pending, loaded;
566
567
  var init_task_preload = __esm({
567
- "../../node_modules/@math.gl/core/dist/tasks/task-preload.js"() {
568
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js"() {
568
569
  pending = /* @__PURE__ */ new WeakMap();
569
570
  loaded = /* @__PURE__ */ new WeakSet();
570
571
  }
571
572
  });
572
573
 
573
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
574
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
575
+ var TaskRequestError, TaskChannel;
576
+ var init_task_channel = __esm({
577
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js"() {
578
+ TaskRequestError = class extends Error {
579
+ };
580
+ TaskChannel = class {
581
+ constructor(options) {
582
+ this.options = options;
583
+ this.nextId = 1;
584
+ this.pending = /* @__PURE__ */ new Map();
585
+ this.incoming = /* @__PURE__ */ new Map();
586
+ }
587
+ /** Send a request without serializing other in-flight requests. */
588
+ request(operation2, value2, signal, transfer = []) {
589
+ if (this.failure)
590
+ return Promise.reject(this.failure.reason);
591
+ if (signal?.aborted)
592
+ return Promise.reject(signal.reason);
593
+ const id = this.nextId++;
594
+ return new Promise((resolve, reject) => {
595
+ const abort = () => {
596
+ const pending2 = this.pending.get(id);
597
+ if (!pending2)
598
+ return;
599
+ this.pending.delete(id);
600
+ pending2.cleanup();
601
+ reject(signal?.reason);
602
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
603
+ };
604
+ this.pending.set(id, {
605
+ resolve,
606
+ reject,
607
+ cleanup: () => signal?.removeEventListener("abort", abort)
608
+ });
609
+ signal?.addEventListener("abort", abort, { once: true });
610
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation: operation2, value: value2 }, transfer);
611
+ });
612
+ }
613
+ /** Send a one-way notification. */
614
+ emit(operation2, value2, transfer = []) {
615
+ if (this.failure)
616
+ throw this.failure.reason;
617
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation: operation2, value: value2 }, transfer);
618
+ }
619
+ /** Dispatch a transport message; unrelated protocols are ignored. */
620
+ receive(message) {
621
+ if (this.failure || message?.source !== "math.gl/tasks")
622
+ return;
623
+ if (message.kind === "failure") {
624
+ const reason = new Error(message.error?.message ?? "Task channel failed");
625
+ this.close(reason);
626
+ this.options.onFailure?.(reason);
627
+ } else if (message.kind === "result" || message.kind === "error") {
628
+ const pending2 = this.pending.get(message.id);
629
+ if (!pending2)
630
+ return;
631
+ this.pending.delete(message.id);
632
+ pending2.cleanup();
633
+ if (message.kind === "result")
634
+ pending2.resolve(message.value);
635
+ else {
636
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
637
+ error.name = message.error?.name ?? "Error";
638
+ pending2.reject(error);
639
+ }
640
+ } else if (message.kind === "cancel") {
641
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
642
+ } else if (message.kind === "event") {
643
+ try {
644
+ this.options.handleEvent?.(message.operation, message.value);
645
+ } catch (error) {
646
+ this.fail(error);
647
+ }
648
+ } else if (message.kind === "request") {
649
+ if (this.incoming.has(message.id)) {
650
+ this.fail(new Error("Duplicate task request identifier"));
651
+ return;
652
+ }
653
+ const controller = new AbortController();
654
+ this.incoming.set(message.id, controller);
655
+ void Promise.resolve().then(() => {
656
+ controller.signal.throwIfAborted();
657
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
658
+ }).then((value2) => {
659
+ if (!controller.signal.aborted && !this.failure) {
660
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value: value2 }, this.options.getResultTransferList?.(value2, message.value));
661
+ }
662
+ }).catch((reason) => {
663
+ if (!controller.signal.aborted && !this.failure) {
664
+ this.send({
665
+ source: "math.gl/tasks",
666
+ kind: "error",
667
+ id: message.id,
668
+ error: {
669
+ name: reason instanceof Error ? reason.name : "Error",
670
+ message: reason instanceof Error ? reason.message : String(reason)
671
+ }
672
+ });
673
+ }
674
+ }).finally(() => this.incoming.delete(message.id));
675
+ }
676
+ }
677
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
678
+ close(reason = new Error("Task channel closed")) {
679
+ if (this.failure)
680
+ return;
681
+ this.failure = { reason };
682
+ for (const pending2 of this.pending.values()) {
683
+ pending2.cleanup();
684
+ pending2.reject(reason);
685
+ }
686
+ this.pending.clear();
687
+ for (const controller of this.incoming.values())
688
+ controller.abort(reason);
689
+ this.incoming.clear();
690
+ }
691
+ send(message, transfer = []) {
692
+ if (this.failure)
693
+ return;
694
+ try {
695
+ this.options.send(message, transfer);
696
+ } catch (error) {
697
+ this.fail(error);
698
+ }
699
+ }
700
+ /** Invalidate the channel and notify the peer when the transport still works. */
701
+ fail(reason) {
702
+ if (this.failure)
703
+ return;
704
+ this.close(reason);
705
+ try {
706
+ this.options.send({
707
+ source: "math.gl/tasks",
708
+ kind: "failure",
709
+ id: 0,
710
+ error: {
711
+ name: reason instanceof Error ? reason.name : "Error",
712
+ message: reason instanceof Error ? reason.message : String(reason)
713
+ }
714
+ }, []);
715
+ } catch {
716
+ }
717
+ this.options.onFailure?.(reason);
718
+ }
719
+ };
720
+ }
721
+ });
722
+
723
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
574
724
  function assertPayload(value2) {
575
725
  if (!value2 || typeof value2 !== "object" || Object.getPrototypeOf(value2) !== Object.prototype) {
576
726
  throw new TypeError("Task payloads must be plain objects with named fields");
577
727
  }
578
728
  }
729
+ function clonePayload(value2, ownership = "copy") {
730
+ assertPayload(value2);
731
+ if (!["copy", "transfer", "share"].includes(ownership))
732
+ throw new TypeError("Invalid input ownership");
733
+ const transfer = getTransferList(value2);
734
+ if (ownership === "share" && transfer.length)
735
+ throw new TypeError("Share requires shared storage");
736
+ return structuredClone(value2, {
737
+ transfer: ownership === "transfer" ? transfer : []
738
+ });
739
+ }
579
740
  function taskContext(state, context = {}) {
580
741
  const signal = context.signal ?? new AbortController().signal;
581
742
  return {
582
743
  state,
583
744
  signal,
745
+ requestHost: async (operation2, payload, controls) => {
746
+ signal.throwIfAborted();
747
+ if (!context.requestHost)
748
+ throw new Error("No host request handler configured");
749
+ return context.requestHost(operation2, payload, controls);
750
+ },
751
+ emitHost: (operation2, payload) => {
752
+ signal.throwIfAborted();
753
+ context.emitHost?.(operation2, payload);
754
+ },
584
755
  throwIfAborted: () => {
585
756
  signal.throwIfAborted();
586
757
  context.throwIfAborted?.();
@@ -599,6 +770,69 @@
599
770
  throw new Error("A task is already installed in this worker");
600
771
  installed = true;
601
772
  const runtime = new TaskRuntime(task);
773
+ let channelStream;
774
+ const channel = new TaskChannel({
775
+ getResultTransferList: (value2, request) => request.outputOwnership === "transfer" ? getTransferList(value2) : [],
776
+ send: (message, transfer) => {
777
+ const snapshot = structuredClone(message, { transfer });
778
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
779
+ },
780
+ handleRequest: async (operation2, value2, signal) => {
781
+ const request = value2;
782
+ const context = {
783
+ signal,
784
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
785
+ requestHost: (operation3, payload, controls = {}) => {
786
+ const request2 = {
787
+ operation: operation3,
788
+ payload: clonePayload(payload, controls.inputOwnership),
789
+ outputOwnership: controls.outputOwnership ?? "copy"
790
+ };
791
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
792
+ },
793
+ emitHost: (operation3, payload) => channel.emit("task:host-event", { operation: operation3, payload, id: request.progressId })
794
+ };
795
+ switch (operation2) {
796
+ case "initialize":
797
+ return runtime.initialize(request.input, context);
798
+ case "process":
799
+ return runtime.process(request.input, request.options, context);
800
+ case "stream-open": {
801
+ if (channelStream)
802
+ throw new Error("A task stream is already open");
803
+ async function* inputs() {
804
+ while (true) {
805
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
806
+ if (result.done)
807
+ return;
808
+ yield result.value;
809
+ }
810
+ }
811
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
812
+ return {};
813
+ }
814
+ case "stream-next":
815
+ if (!channelStream)
816
+ throw new Error("No active task stream");
817
+ return channelStream.next();
818
+ case "stream-close":
819
+ try {
820
+ await channelStream?.return?.();
821
+ } finally {
822
+ channelStream = void 0;
823
+ }
824
+ return {};
825
+ case "destroy":
826
+ return runtime.destroy();
827
+ default:
828
+ throw new Error("Unknown task channel operation");
829
+ }
830
+ }
831
+ });
832
+ await WorkerBody.addEventListener((type, payload) => {
833
+ if (type === "task-channel")
834
+ channel.receive(payload);
835
+ });
602
836
  let streamOptions = {};
603
837
  return createWorker(async (request, _options, context) => {
604
838
  switch (request.operation) {
@@ -630,9 +864,10 @@
630
864
  }
631
865
  var TaskRuntime, installed;
632
866
  var init_task_runtime = __esm({
633
- "../../node_modules/@math.gl/core/dist/tasks/task-runtime.js"() {
867
+ "../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js"() {
634
868
  init_worker_utils();
635
869
  init_task_preload();
870
+ init_task_channel();
636
871
  TaskRuntime = class {
637
872
  constructor(task) {
638
873
  this.task = task;
@@ -683,13 +918,20 @@
683
918
  }
684
919
  });
685
920
 
686
- // ../../node_modules/@math.gl/core/dist/tasks/index.js
921
+ // ../../node_modules/@math.gl/tasks/dist/tasks/index.js
687
922
  var init_tasks = __esm({
688
- "../../node_modules/@math.gl/core/dist/tasks/index.js"() {
923
+ "../../node_modules/@math.gl/tasks/dist/tasks/index.js"() {
689
924
  init_task_runtime();
690
925
  }
691
926
  });
692
927
 
928
+ // ../../node_modules/@math.gl/tasks/dist/index.js
929
+ var init_dist = __esm({
930
+ "../../node_modules/@math.gl/tasks/dist/index.js"() {
931
+ init_tasks();
932
+ }
933
+ });
934
+
693
935
  // ../core/src/worker-utils/lib/node/worker_threads-browser.ts
694
936
  var worker_threads_browser_exports = {};
695
937
  __export(worker_threads_browser_exports, {
@@ -734,7 +976,7 @@
734
976
  var init_task_runtime2 = __esm({
735
977
  "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
736
978
  "use strict";
737
- init_tasks();
979
+ init_dist();
738
980
  initializeTaskWorker2 = initializeTaskWorker;
739
981
  }
740
982
  });
@@ -1962,7 +2204,7 @@
1962
2204
  });
1963
2205
 
1964
2206
  // ../../node_modules/@math.gl/core/dist/index.js
1965
- var init_dist = __esm({
2207
+ var init_dist2 = __esm({
1966
2208
  "../../node_modules/@math.gl/core/dist/index.js"() {
1967
2209
  init_math_utils();
1968
2210
  init_spheroid();
@@ -3377,12 +3619,6 @@
3377
3619
  }
3378
3620
  });
3379
3621
 
3380
- // ../../node_modules/@math.gl/geospatial/dist/entries/ellipsoid.js
3381
- var init_ellipsoid = __esm({
3382
- "../../node_modules/@math.gl/geospatial/dist/entries/ellipsoid.js"() {
3383
- }
3384
- });
3385
-
3386
3622
  // ../../node_modules/@math.gl/geometry/dist/polygon/polygon-utils.js
3387
3623
  function getPolygonSignedArea(points, options = {}) {
3388
3624
  const { start = 0, end = points.length, plane = "xy" } = options;
@@ -3969,487 +4205,12 @@
3969
4205
  });
3970
4206
 
3971
4207
  // ../../node_modules/@math.gl/geometry/dist/index.js
3972
- var init_dist2 = __esm({
4208
+ var init_dist3 = __esm({
3973
4209
  "../../node_modules/@math.gl/geometry/dist/index.js"() {
3974
4210
  init_polygon();
3975
4211
  }
3976
4212
  });
3977
4213
 
3978
- // ../../node_modules/@math.gl/geospatial/dist/globe.js
3979
- var init_globe = __esm({
3980
- "../../node_modules/@math.gl/geospatial/dist/globe.js"() {
3981
- }
3982
- });
3983
-
3984
- // ../../node_modules/@math.gl/geospatial/dist/tiles.js
3985
- var init_tiles = __esm({
3986
- "../../node_modules/@math.gl/geospatial/dist/tiles.js"() {
3987
- }
3988
- });
3989
-
3990
- // ../../node_modules/@math.gl/geospatial/dist/wkb/types.js
3991
- function getWellKnownDimensionSize(dimension) {
3992
- switch (dimension) {
3993
- case "xy":
3994
- return 2;
3995
- case "xyz":
3996
- case "xym":
3997
- return 3;
3998
- case "xyzm":
3999
- return 4;
4000
- }
4001
- }
4002
- function inferWellKnownGeometryDimension(geometry) {
4003
- const size = getGeometryDimensionSize(geometry);
4004
- return size >= 4 ? "xyzm" : size === 3 ? "xyz" : "xy";
4005
- }
4006
- function getGeometryDimensionSize(geometry) {
4007
- if (geometry.type === "GeometryCollection") {
4008
- return Math.max(2, ...geometry.geometries.map(getGeometryDimensionSize));
4009
- }
4010
- return getCoordinateDimension(geometry.coordinates);
4011
- }
4012
- function getCoordinateDimension(value2) {
4013
- if (value2.length === 0)
4014
- return 2;
4015
- if (typeof value2[0] === "number")
4016
- return value2.length;
4017
- return Math.max(2, ...value2.map((child2) => getCoordinateDimension(child2)));
4018
- }
4019
- var init_types = __esm({
4020
- "../../node_modules/@math.gl/geospatial/dist/wkb/types.js"() {
4021
- }
4022
- });
4023
-
4024
- // ../../node_modules/@math.gl/geospatial/dist/wkb/wkb.js
4025
- function writeWKB(geometry, dimension = inferWellKnownGeometryDimension(geometry)) {
4026
- const bytes = [];
4027
- writeWKBGeometry(bytes, geometry, dimension);
4028
- return Uint8Array.from(bytes);
4029
- }
4030
- function writeWKBGeometry(bytes, geometry, dimension) {
4031
- bytes.push(1);
4032
- const size = getWellKnownDimensionSize(dimension);
4033
- const dimensionOffset = dimension === "xyz" ? 1e3 : dimension === "xym" ? 2e3 : dimension === "xyzm" ? 3e3 : 0;
4034
- writeUint32(bytes, getWKBType(geometry.type) + dimensionOffset);
4035
- const writeCoordinate = (coordinate) => {
4036
- for (let index = 0; index < size; index++)
4037
- writeFloat64(bytes, coordinate[index] ?? 0);
4038
- };
4039
- const writeCoordinates = (coordinates) => {
4040
- writeUint32(bytes, coordinates.length);
4041
- for (const coordinate of coordinates)
4042
- writeCoordinate(coordinate);
4043
- };
4044
- switch (geometry.type) {
4045
- case "Point":
4046
- writeCoordinate(geometry.coordinates.length === 0 ? new Array(size).fill(Number.NaN) : geometry.coordinates);
4047
- break;
4048
- case "LineString":
4049
- writeCoordinates(geometry.coordinates);
4050
- break;
4051
- case "Polygon":
4052
- writeUint32(bytes, geometry.coordinates.length);
4053
- for (const ring of geometry.coordinates)
4054
- writeCoordinates(ring);
4055
- break;
4056
- case "MultiPoint":
4057
- writeUint32(bytes, geometry.coordinates.length);
4058
- for (const coordinate of geometry.coordinates) {
4059
- writeWKBGeometry(bytes, { type: "Point", coordinates: coordinate }, dimension);
4060
- }
4061
- break;
4062
- case "MultiLineString":
4063
- writeUint32(bytes, geometry.coordinates.length);
4064
- for (const coordinates of geometry.coordinates) {
4065
- writeWKBGeometry(bytes, { type: "LineString", coordinates }, dimension);
4066
- }
4067
- break;
4068
- case "MultiPolygon":
4069
- writeUint32(bytes, geometry.coordinates.length);
4070
- for (const coordinates of geometry.coordinates) {
4071
- writeWKBGeometry(bytes, { type: "Polygon", coordinates }, dimension);
4072
- }
4073
- break;
4074
- case "GeometryCollection":
4075
- writeUint32(bytes, geometry.geometries.length);
4076
- for (const child2 of geometry.geometries)
4077
- writeWKBGeometry(bytes, child2, dimension);
4078
- break;
4079
- }
4080
- }
4081
- function getWKBType(type) {
4082
- return [
4083
- "Point",
4084
- "LineString",
4085
- "Polygon",
4086
- "MultiPoint",
4087
- "MultiLineString",
4088
- "MultiPolygon",
4089
- "GeometryCollection"
4090
- ].indexOf(type) + 1;
4091
- }
4092
- function writeUint32(bytes, value2) {
4093
- bytes.push(value2 & 255, value2 >>> 8 & 255, value2 >>> 16 & 255, value2 >>> 24 & 255);
4094
- }
4095
- function writeFloat64(bytes, value2) {
4096
- const buffer = new ArrayBuffer(8);
4097
- new DataView(buffer).setFloat64(0, value2, true);
4098
- bytes.push(...new Uint8Array(buffer));
4099
- }
4100
- var init_wkb = __esm({
4101
- "../../node_modules/@math.gl/geospatial/dist/wkb/wkb.js"() {
4102
- init_types();
4103
- }
4104
- });
4105
-
4106
- // ../../node_modules/@math.gl/geospatial/dist/wkb/wkb-builder.js
4107
- function measureGeometry(geometryWriter, options) {
4108
- const builder = new WKBBuilder({ ...options, mode: "measure" });
4109
- geometryWriter(builder);
4110
- return builder.finishGeometry();
4111
- }
4112
- function getTargetDataView(target) {
4113
- return ArrayBuffer.isView(target) ? new DataView(target.buffer, target.byteOffset, target.byteLength) : new DataView(target);
4114
- }
4115
- function getWKBTypeCode(geometryType, dimension, hasSrid) {
4116
- const geometryCode = GEOMETRY_TYPE_CODES[geometryType];
4117
- if (hasSrid) {
4118
- const dimensionFlags = dimension === "xyz" ? 2147483648 : dimension === "xym" ? 1073741824 : dimension === "xyzm" ? 3221225472 : 0;
4119
- return (geometryCode | dimensionFlags | 536870912) >>> 0;
4120
- }
4121
- const dimensionOffset = dimension === "xyz" ? 1e3 : dimension === "xym" ? 2e3 : dimension === "xyzm" ? 3e3 : 0;
4122
- return geometryCode + dimensionOffset;
4123
- }
4124
- function makeCoordinate(dimension, x, y, z, m) {
4125
- switch (dimension) {
4126
- case "xy":
4127
- return [x, y];
4128
- case "xyz":
4129
- return [x, y, z ?? Number.NaN];
4130
- case "xym":
4131
- return [x, y, m ?? Number.NaN];
4132
- case "xyzm":
4133
- return [x, y, z ?? Number.NaN, m ?? Number.NaN];
4134
- }
4135
- }
4136
- function getDimensionSize(dimension) {
4137
- return dimension === "xy" ? 2 : dimension === "xyzm" ? 4 : 3;
4138
- }
4139
- function validateSrid(srid) {
4140
- if (srid !== void 0 && (!Number.isSafeInteger(srid) || srid < 0 || srid > 4294967295)) {
4141
- throw new Error("WKBBuilder srid must be an unsigned 32-bit integer");
4142
- }
4143
- }
4144
- function makeNullBitmap(geometryWriters) {
4145
- const nullBitmap = new Uint8Array(Math.ceil(geometryWriters.length / 8));
4146
- let nullCount = 0;
4147
- for (let geometryIndex = 0; geometryIndex < geometryWriters.length; geometryIndex++) {
4148
- if (geometryWriters[geometryIndex]) {
4149
- nullBitmap[geometryIndex >> 3] |= 1 << (geometryIndex & 7);
4150
- } else {
4151
- nullCount++;
4152
- }
4153
- }
4154
- return { nullBitmap, nullCount };
4155
- }
4156
- var GEOMETRY_TYPE_CODES, WKBBuilder;
4157
- var init_wkb_builder = __esm({
4158
- "../../node_modules/@math.gl/geospatial/dist/wkb/wkb-builder.js"() {
4159
- GEOMETRY_TYPE_CODES = {
4160
- Point: 1,
4161
- LineString: 2,
4162
- Polygon: 3,
4163
- MultiPoint: 4,
4164
- MultiLineString: 5,
4165
- MultiPolygon: 6,
4166
- GeometryCollection: 7
4167
- };
4168
- WKBBuilder = class _WKBBuilder {
4169
- constructor(options) {
4170
- this.mode = options.mode;
4171
- this.dimension = options.dimension ?? "xy";
4172
- this.littleEndian = options.byteOrder !== "big-endian";
4173
- this.srid = options.srid;
4174
- this.transform = options.transform;
4175
- validateSrid(this.srid);
4176
- if (options.mode === "write") {
4177
- const dataView = getTargetDataView(options.target);
4178
- const byteOffset = options.byteOffset ?? 0;
4179
- if (!Number.isSafeInteger(byteOffset) || byteOffset < 0 || byteOffset > dataView.byteLength) {
4180
- throw new Error("WKBBuilder byteOffset is outside the target");
4181
- }
4182
- this.dataView = dataView;
4183
- this.startByteOffset = byteOffset;
4184
- this.endByteOffset = dataView.byteLength;
4185
- this.byteOffset = byteOffset;
4186
- } else {
4187
- this.dataView = null;
4188
- this.startByteOffset = 0;
4189
- this.endByteOffset = Number.POSITIVE_INFINITY;
4190
- this.byteOffset = 0;
4191
- }
4192
- }
4193
- /** Begins a geometry and writes its count field when required. */
4194
- beginGeometry(type, count) {
4195
- switch (type) {
4196
- case "Point":
4197
- this.beginPoint();
4198
- break;
4199
- case "LineString":
4200
- this.beginLineString(count ?? 0);
4201
- break;
4202
- case "Polygon":
4203
- this.beginPolygon(count ?? 0);
4204
- break;
4205
- case "MultiPoint":
4206
- this.beginMultiPoint(count ?? 0);
4207
- break;
4208
- case "MultiLineString":
4209
- this.beginMultiLineString(count ?? 0);
4210
- break;
4211
- case "MultiPolygon":
4212
- this.beginMultiPolygon(count ?? 0);
4213
- break;
4214
- case "GeometryCollection":
4215
- this.writeHeader("GeometryCollection");
4216
- this.writeUint32(count ?? 0);
4217
- break;
4218
- }
4219
- }
4220
- /** Begins one point geometry. */
4221
- beginPoint() {
4222
- this.writeHeader("Point");
4223
- }
4224
- /** Begins one linestring geometry. */
4225
- beginLineString(pointCount) {
4226
- this.writeHeader("LineString");
4227
- this.writeUint32(pointCount);
4228
- }
4229
- /** Begins one polygon geometry. */
4230
- beginPolygon(ringCount) {
4231
- this.writeHeader("Polygon");
4232
- this.writeUint32(ringCount);
4233
- }
4234
- /** Begins one linear ring inside a polygon. */
4235
- beginLinearRing(pointCount) {
4236
- this.writeUint32(pointCount);
4237
- }
4238
- /** Begins one multipoint geometry. */
4239
- beginMultiPoint(pointCount) {
4240
- this.writeHeader("MultiPoint");
4241
- this.writeUint32(pointCount);
4242
- }
4243
- /** Begins one multilinestring geometry. */
4244
- beginMultiLineString(lineCount) {
4245
- this.writeHeader("MultiLineString");
4246
- this.writeUint32(lineCount);
4247
- }
4248
- /** Begins one multipolygon geometry. */
4249
- beginMultiPolygon(polygonCount) {
4250
- this.writeHeader("MultiPolygon");
4251
- this.writeUint32(polygonCount);
4252
- }
4253
- /** Writes one coordinate using the builder's semantic dimension. */
4254
- writeCoordinate(x, y, z, m) {
4255
- let coordinate = makeCoordinate(this.dimension, x, y, z, m);
4256
- if (this.transform)
4257
- coordinate = this.transform(coordinate, this.dimension);
4258
- const coordinateSize = getDimensionSize(this.dimension);
4259
- for (let index = 0; index < coordinateSize; index++) {
4260
- this.writeFloat64(coordinate[index] ?? Number.NaN);
4261
- }
4262
- }
4263
- /** Temporarily changes the semantic dimension for a nested geometry. */
4264
- withDimension(dimension, callback) {
4265
- const previous = this.dimension;
4266
- this.dimension = dimension;
4267
- try {
4268
- return callback();
4269
- } finally {
4270
- this.dimension = previous;
4271
- }
4272
- }
4273
- /** Returns the number of bytes measured or written. */
4274
- finishGeometry() {
4275
- return this.byteOffset - this.startByteOffset;
4276
- }
4277
- /** Measures geometry callbacks and returns contiguous Binary offsets. */
4278
- static measureGeometryArray(geometryWriters, options = {}) {
4279
- const valueOffsets = new Int32Array(geometryWriters.length + 1);
4280
- for (let geometryIndex = 0; geometryIndex < geometryWriters.length; geometryIndex++) {
4281
- const geometryWriter = geometryWriters[geometryIndex];
4282
- const byteLength = geometryWriter ? measureGeometry(geometryWriter, {
4283
- ...options,
4284
- dimension: options.dimensionResolver?.(geometryIndex) ?? options.dimension
4285
- }) : 0;
4286
- const nextOffset = valueOffsets[geometryIndex] + byteLength;
4287
- if (nextOffset > 2147483647)
4288
- throw new Error("WKB geometry array exceeds Int32 offsets");
4289
- valueOffsets[geometryIndex + 1] = nextOffset;
4290
- }
4291
- return valueOffsets;
4292
- }
4293
- /** Writes geometry callbacks into an existing contiguous values buffer. */
4294
- static writeGeometryArray(geometryWriters, valueOffsets, values, options = {}) {
4295
- if (valueOffsets.length !== geometryWriters.length + 1) {
4296
- throw new Error("WKB valueOffsets length must equal geometry count plus one");
4297
- }
4298
- for (let i = 0; i < valueOffsets.length; i++) {
4299
- if (!Number.isInteger(valueOffsets[i]) || valueOffsets[i] < 0 || i > 0 && valueOffsets[i] < valueOffsets[i - 1]) {
4300
- throw new Error("WKB valueOffsets must be nonnegative and nondecreasing");
4301
- }
4302
- }
4303
- if (valueOffsets[valueOffsets.length - 1] > values.byteLength) {
4304
- throw new Error("WKB values buffer is smaller than its final offset");
4305
- }
4306
- for (let geometryIndex = 0; geometryIndex < geometryWriters.length; geometryIndex++) {
4307
- const geometryWriter = geometryWriters[geometryIndex];
4308
- if (!geometryWriter)
4309
- continue;
4310
- const builder = new _WKBBuilder({
4311
- ...options,
4312
- mode: "write",
4313
- target: values,
4314
- byteOffset: valueOffsets[geometryIndex],
4315
- dimension: options.dimensionResolver?.(geometryIndex) ?? options.dimension
4316
- });
4317
- geometryWriter(builder);
4318
- const byteLength = builder.finishGeometry();
4319
- if (valueOffsets[geometryIndex] + byteLength !== valueOffsets[geometryIndex + 1]) {
4320
- throw new Error("WKB measure and write passes produced different byte lengths");
4321
- }
4322
- }
4323
- return values;
4324
- }
4325
- /** Builds plain offsets, values, and validity buffers in two passes. */
4326
- static buildGeometryArray(geometryWriters, options = {}) {
4327
- const valueOffsets = _WKBBuilder.measureGeometryArray(geometryWriters, options);
4328
- const values = new Uint8Array(valueOffsets[valueOffsets.length - 1]);
4329
- _WKBBuilder.writeGeometryArray(geometryWriters, valueOffsets, values, options);
4330
- const { nullBitmap, nullCount } = makeNullBitmap(geometryWriters);
4331
- return {
4332
- valueOffsets,
4333
- values,
4334
- ...nullCount > 0 ? { nullBitmap } : {},
4335
- nullCount
4336
- };
4337
- }
4338
- writeHeader(geometryType) {
4339
- this.writeUint8(this.littleEndian ? 1 : 0);
4340
- this.writeUint32(getWKBTypeCode(geometryType, this.dimension, this.srid !== void 0));
4341
- if (this.srid !== void 0)
4342
- this.writeUint32(this.srid);
4343
- }
4344
- writeUint8(value2) {
4345
- this.ensureSize(1);
4346
- this.dataView?.setUint8(this.byteOffset, value2);
4347
- this.byteOffset++;
4348
- }
4349
- writeUint32(value2) {
4350
- if (!Number.isSafeInteger(value2) || value2 < 0 || value2 > 4294967295) {
4351
- throw new Error("WKB count must be an unsigned 32-bit integer");
4352
- }
4353
- this.ensureSize(4);
4354
- this.dataView?.setUint32(this.byteOffset, value2, this.littleEndian);
4355
- this.byteOffset += 4;
4356
- }
4357
- writeFloat64(value2) {
4358
- this.ensureSize(8);
4359
- this.dataView?.setFloat64(this.byteOffset, value2, this.littleEndian);
4360
- this.byteOffset += 8;
4361
- }
4362
- ensureSize(byteLength) {
4363
- if (this.byteOffset + byteLength > this.endByteOffset) {
4364
- throw new Error("WKBBuilder target buffer overflow");
4365
- }
4366
- }
4367
- };
4368
- }
4369
- });
4370
-
4371
- // ../../node_modules/@math.gl/geospatial/dist/wkb/wkt.js
4372
- function formatWKT(geometry, dimension) {
4373
- if (isWKTParseResult(geometry)) {
4374
- return dimension === void 0 ? formatWKTResult(geometry) : formatWKTGeometry(geometry.geometry, dimension);
4375
- }
4376
- return formatWKTGeometry(geometry, dimension ?? inferWellKnownGeometryDimension(geometry));
4377
- }
4378
- function formatWKTResult(result) {
4379
- return formatWKTGeometry(result.geometry, result.dimension, result.children);
4380
- }
4381
- function formatWKTGeometry(geometry, dimension, children2) {
4382
- const dimensionToken = dimension === "xy" ? "" : " " + dimension.slice(2).toUpperCase();
4383
- if (geometry.type === "GeometryCollection") {
4384
- if (geometry.geometries.length === 0)
4385
- return "GEOMETRYCOLLECTION" + dimensionToken + " EMPTY";
4386
- const formattedChildren = children2 ? children2.map(formatWKTResult) : geometry.geometries.map((child2) => formatWKTGeometry(child2, dimension));
4387
- return "GEOMETRYCOLLECTION" + dimensionToken + " (" + formattedChildren.join(", ") + ")";
4388
- }
4389
- const type = geometry.type.toUpperCase();
4390
- const isEmpty = geometry.type === "MultiPoint" ? geometry.coordinates.length === 0 : isEmptyCoordinates(geometry.coordinates);
4391
- if (isEmpty)
4392
- return type + dimensionToken + " EMPTY";
4393
- return type + dimensionToken + " " + formatCoordinateNesting(geometry.coordinates, getGeometryDepth(geometry.type), geometry.type === "MultiPoint");
4394
- }
4395
- function isWKTParseResult(value2) {
4396
- return "geometry" in value2 && "dimension" in value2;
4397
- }
4398
- function formatCoordinateNesting(value2, depth, allowEmptyPoints = false) {
4399
- if (depth === 0)
4400
- return `(${value2.map(formatNumber).join(" ")})`;
4401
- return `(${value2.map((child2) => {
4402
- if (depth === 1) {
4403
- const coordinate = child2;
4404
- if (allowEmptyPoints && isEmptyCoordinates(coordinate))
4405
- return "EMPTY";
4406
- return coordinate.map(formatNumber).join(" ");
4407
- }
4408
- return formatCoordinateNesting(child2, depth - 1);
4409
- }).join(", ")})`;
4410
- }
4411
- function formatNumber(value2) {
4412
- if (!Number.isFinite(value2))
4413
- return "NaN";
4414
- return String(value2);
4415
- }
4416
- function getGeometryDepth(type) {
4417
- switch (type) {
4418
- case "Point":
4419
- return 0;
4420
- case "LineString":
4421
- case "MultiPoint":
4422
- return 1;
4423
- case "Polygon":
4424
- case "MultiLineString":
4425
- return 2;
4426
- case "MultiPolygon":
4427
- return 3;
4428
- }
4429
- }
4430
- function isEmptyCoordinates(value2) {
4431
- if (value2.length === 0)
4432
- return true;
4433
- if (typeof value2[0] === "number") {
4434
- return value2.every((component) => !Number.isFinite(component));
4435
- }
4436
- return value2.every((child2) => isEmptyCoordinates(child2));
4437
- }
4438
- var init_wkt = __esm({
4439
- "../../node_modules/@math.gl/geospatial/dist/wkb/wkt.js"() {
4440
- init_types();
4441
- }
4442
- });
4443
-
4444
- // ../../node_modules/@math.gl/geospatial/dist/wkb/index.js
4445
- var init_wkb2 = __esm({
4446
- "../../node_modules/@math.gl/geospatial/dist/wkb/index.js"() {
4447
- init_wkb();
4448
- init_wkb_builder();
4449
- init_wkt();
4450
- }
4451
- });
4452
-
4453
4214
  // ../../node_modules/@math.gl/geospatial/dist/projection/experimental/parameters.js
4454
4215
  function numberParameter(parameters, name, fallback) {
4455
4216
  if (!Object.prototype.hasOwnProperty.call(parameters, name))
@@ -6140,16 +5901,6 @@
6140
5901
  }
6141
5902
  });
6142
5903
 
6143
- // ../../node_modules/@math.gl/geospatial/dist/index.js
6144
- var init_dist3 = __esm({
6145
- "../../node_modules/@math.gl/geospatial/dist/index.js"() {
6146
- init_ellipsoid();
6147
- init_globe();
6148
- init_tiles();
6149
- init_wkb2();
6150
- }
6151
- });
6152
-
6153
5904
  // ../core/src/loader-utils/index.ts
6154
5905
  var init_loader_utils = __esm({
6155
5906
  "../core/src/loader-utils/index.ts"() {
@@ -21157,7 +20908,7 @@ return true;`);
21157
20908
  throw new TypeScriptCRSError("missing-transform-stage", message);
21158
20909
  }
21159
20910
  var _a5, CRS_ERROR, TypeScriptCRSError;
21160
- var init_types2 = __esm({
20911
+ var init_types = __esm({
21161
20912
  "../../node_modules/@math.gl/geospatial/dist/projection/experimental/crs/types.js"() {
21162
20913
  CRS_ERROR = /* @__PURE__ */ Symbol.for("@math.gl/projection/TypeScriptCRSError");
21163
20914
  TypeScriptCRSError = class _TypeScriptCRSError extends Error {
@@ -21251,7 +21002,7 @@ return true;`);
21251
21002
  }
21252
21003
  var init_spatial_reference2 = __esm({
21253
21004
  "../../node_modules/@math.gl/geospatial/dist/projection/experimental/crs/spatial-reference.js"() {
21254
- init_types2();
21005
+ init_types();
21255
21006
  }
21256
21007
  });
21257
21008
 
@@ -21761,7 +21512,7 @@ return true;`);
21761
21512
  init_ellipsoid_table();
21762
21513
  init_primemeridian_table();
21763
21514
  init_crs_metadata();
21764
- init_types2();
21515
+ init_types();
21765
21516
  ALIASES = {
21766
21517
  WGS84: "+proj=longlat +datum=WGS84",
21767
21518
  "EPSG:4326": "+proj=longlat +datum=WGS84",
@@ -21932,7 +21683,7 @@ return true;`);
21932
21683
  var ARC_SECOND, WGS84;
21933
21684
  var init_datum = __esm({
21934
21685
  "../../node_modules/@math.gl/geospatial/dist/projection/experimental/datum.js"() {
21935
- init_dist();
21686
+ init_dist2();
21936
21687
  ARC_SECOND = Math.PI / (180 * 3600);
21937
21688
  WGS84 = {
21938
21689
  ellipsoid: {
@@ -22002,7 +21753,60 @@ return true;`);
22002
21753
  }
22003
21754
  var init_vertical_datum = __esm({
22004
21755
  "../../node_modules/@math.gl/geospatial/dist/projection/experimental/vertical-datum.js"() {
22005
- init_types2();
21756
+ init_types();
21757
+ }
21758
+ });
21759
+
21760
+ // ../../node_modules/@math.gl/geospatial/dist/projection/experimental/transform-description.js
21761
+ function describeCRS(crs) {
21762
+ const ellipsoid = Object.freeze({ ...crs.ellipsoid });
21763
+ return Object.freeze({
21764
+ kind: crs.kind,
21765
+ projection: crs.projection,
21766
+ parameters: Object.freeze(Object.fromEntries(Object.entries(crs.parameters).map(([name, value2]) => [name, value2 ?? null]))),
21767
+ ellipsoid,
21768
+ datum: Object.freeze({
21769
+ ellipsoid: Object.freeze({ ...crs.datum.ellipsoid }),
21770
+ towgs84: crs.datum.towgs84 && Object.freeze([...crs.datum.towgs84]),
21771
+ grids: crs.datum.grids && Object.freeze(crs.datum.grids.map((reference) => Object.freeze({
21772
+ name: reference.name,
21773
+ optional: reference.optional,
21774
+ loaded: Boolean(reference.grid)
21775
+ })))
21776
+ }),
21777
+ angularUnit: crs.angularUnit,
21778
+ toMeter: crs.toMeter,
21779
+ verticalUnit: crs.verticalUnit,
21780
+ primeMeridian: crs.primeMeridian,
21781
+ axis: crs.axis,
21782
+ storedAxis: crs.storedAxis,
21783
+ longitudeWrap: crs.longitudeWrap,
21784
+ areaOfUse: crs.areaOfUse && Object.freeze([...crs.areaOfUse]),
21785
+ lossy: crs.lossy,
21786
+ algorithm: crs.algorithm && Object.freeze({ ...crs.algorithm })
21787
+ });
21788
+ }
21789
+ function describeTransform(source, target, forward33, inverse33) {
21790
+ const opaqueReasons = [];
21791
+ if (!source.algorithm)
21792
+ opaqueReasons.push("source-algorithm");
21793
+ if (!target.algorithm)
21794
+ opaqueReasons.push("target-algorithm");
21795
+ if (source.datum.grids || target.datum.grids || source.parameters["geoidgrids"] || target.parameters["geoidgrids"])
21796
+ opaqueReasons.push("grid-resource");
21797
+ return Object.freeze({
21798
+ version: 1,
21799
+ source,
21800
+ target,
21801
+ forward: forward33,
21802
+ inverse: inverse33,
21803
+ lossy: source.lossy || target.lossy,
21804
+ complete: opaqueReasons.length === 0,
21805
+ opaqueReasons: Object.freeze(opaqueReasons)
21806
+ });
21807
+ }
21808
+ var init_transform_description = __esm({
21809
+ "../../node_modules/@math.gl/geospatial/dist/projection/experimental/transform-description.js"() {
22006
21810
  }
22007
21811
  });
22008
21812
 
@@ -22075,7 +21879,8 @@ return true;`);
22075
21879
  const verticalGrid = compileVerticalGrid(crs.parameters["geoidgrids"], options.verticalGrids);
22076
21880
  if (verticalGrid && (crs.kind === "geocentric" || crs.kind === "identity" || crs.lossy))
22077
21881
  unsupportedStage("Vertical grids require a non-lossy geographic or projected CRS");
22078
- return { ...crs, datum, implementation, verticalGrid };
21882
+ const algorithm = plugin ? plugin.semantics : { id: "@math.gl/geospatial/" + crs.kind, version: 1 };
21883
+ return { ...crs, datum, implementation, verticalGrid, algorithm };
22079
21884
  }
22080
21885
  function finite(point) {
22081
21886
  return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z);
@@ -22118,9 +21923,51 @@ return true;`);
22118
21923
  if (from.kind === "projected" && to.kind === "geographic")
22119
21924
  flat = from.implementation?.createInverseFlat?.(context);
22120
21925
  }
21926
+ const requiresInputZ = Boolean(from.verticalGrid || to.verticalGrid) || from.kind === "geocentric" || /[ud]/.test(fromAxis.slice(0, 2)) || /[ud]/.test(toAxis.slice(0, 2));
21927
+ const stages = [];
21928
+ if (inputAxis)
21929
+ stages.push("input-axis");
21930
+ if (horizontalOnly)
21931
+ stages.push("discard-height");
21932
+ if (inputScale !== 1)
21933
+ stages.push("input-scale");
21934
+ if (source)
21935
+ stages.push("source-inverse");
21936
+ if (inputVerticalScale !== 1)
21937
+ stages.push("input-height-scale");
21938
+ stages.push("geographic-domain-check");
21939
+ if (fromPrime)
21940
+ stages.push("source-prime-meridian");
21941
+ if (from.verticalGrid)
21942
+ stages.push("source-vertical-grid");
21943
+ if (datum)
21944
+ stages.push("datum");
21945
+ if (to.verticalGrid)
21946
+ stages.push("target-vertical-grid");
21947
+ if (toPrime)
21948
+ stages.push("target-prime-meridian");
21949
+ if (longitudeWrap !== void 0)
21950
+ stages.push("longitude-wrap");
21951
+ if (target)
21952
+ stages.push("target-forward");
21953
+ if (outputScale !== 1)
21954
+ stages.push("output-scale");
21955
+ if (outputVerticalScale !== 1)
21956
+ stages.push("output-height-scale");
21957
+ if (horizontalOnly)
21958
+ stages.push("restore-height");
21959
+ if (outputAxis)
21960
+ stages.push("output-axis");
22121
21961
  return {
21962
+ description: Object.freeze({
21963
+ inputAxis: fromAxis,
21964
+ outputAxis: toAxis,
21965
+ requiresInputZ,
21966
+ geocentricOutput: to.kind === "geocentric",
21967
+ stages: Object.freeze(stages)
21968
+ }),
22122
21969
  flat,
22123
- requiresInputZ: Boolean(from.verticalGrid || to.verticalGrid) || from.kind === "geocentric" || /[ud]/.test(fromAxis.slice(0, 2)) || /[ud]/.test(toAxis.slice(0, 2)),
21970
+ requiresInputZ,
22124
21971
  geocentricOutput: to.kind === "geocentric",
22125
21972
  run(point) {
22126
21973
  if (!finite(point))
@@ -22229,11 +22076,12 @@ return true;`);
22229
22076
  init_projection_scratch();
22230
22077
  init_scalar_output();
22231
22078
  init_normalize();
22232
- init_types2();
22079
+ init_types();
22233
22080
  init_datum();
22234
22081
  init_parameters();
22235
22082
  init_geographic_rendering_profile();
22236
22083
  init_vertical_datum();
22084
+ init_transform_description();
22237
22085
  ProjectionTransform = class _ProjectionTransform {
22238
22086
  /** Resolve required descriptors once, then return an ordinary synchronous instance. */
22239
22087
  static async create(options = {}) {
@@ -22247,6 +22095,10 @@ return true;`);
22247
22095
  getTargetRenderingProfile(coverage) {
22248
22096
  return this.targetRenderingProfile && resolveRenderingProfile(this.targetRenderingProfile, coverage);
22249
22097
  }
22098
+ /** Deferred transforms expose metadata only once their implementations are prepared. */
22099
+ get description() {
22100
+ return this.deferred?.implementation?.description ?? this.resolvedDescription;
22101
+ }
22250
22102
  constructor(options = {}) {
22251
22103
  this.coordinateScratch = new ProjectionScratch();
22252
22104
  this.targetLongitudeOrigin = 0;
@@ -22272,6 +22124,7 @@ return true;`);
22272
22124
  unsupportedStage("Horizontal extraction cannot be combined with vertical grids");
22273
22125
  this.forwardTransform = compileTransform(from, to, Boolean(options.enforceAxis));
22274
22126
  this.inverseTransform = compileTransform(to, from, Boolean(options.enforceAxis));
22127
+ this.resolvedDescription = describeTransform(describeCRS(from), describeCRS(to), this.forwardTransform.description, this.inverseTransform.description);
22275
22128
  }
22276
22129
  this.project = this.project.bind(this);
22277
22130
  this.unproject = this.unproject.bind(this);
@@ -22783,6 +22636,7 @@ return true;`);
22783
22636
  init_rendering_bounds();
22784
22637
  mercator = {
22785
22638
  name: "merc",
22639
+ semantics: { id: "@math.gl/geospatial/merc", version: 1 },
22786
22640
  aliases: [
22787
22641
  "Mercator",
22788
22642
  "Popular Visualisation Pseudo Mercator",
@@ -22876,6 +22730,7 @@ return true;`);
22876
22730
  init_rendering_bounds();
22877
22731
  equidistantCylindrical = {
22878
22732
  name: "eqc",
22733
+ semantics: { id: "@math.gl/geospatial/eqc", version: 1 },
22879
22734
  aliases: ["Equirectangular", "Equidistant_Cylindrical", "Equidistant_Cylindrical_Spherical"],
22880
22735
  parameters: ["lon_0", "lat_0", "lat_ts", "x_0", "y_0"],
22881
22736
  create({ semiMajorAxis: a, parameters, primeMeridian: primeMeridian2 = 0 }) {
@@ -27823,7 +27678,7 @@ return true;`);
27823
27678
  init_geographic_rendering_profile();
27824
27679
  init_parameters();
27825
27680
  init_rendering_profile();
27826
- init_types2();
27681
+ init_types();
27827
27682
  init_rectangular_rendering_profile();
27828
27683
  init_geographic_bounds();
27829
27684
  init_spherical_rendering_domain();
@@ -28176,7 +28031,7 @@ return true;`);
28176
28031
  "../../node_modules/@math.gl/geospatial/dist/projection/experimental/crs/structured.js"() {
28177
28032
  init_datum_catalog();
28178
28033
  init_parameters();
28179
- init_types2();
28034
+ init_types();
28180
28035
  METHODS = {
28181
28036
  hotineobliquemercator: "omerc",
28182
28037
  hotineobliquemercatorvarianta: "omerc",
@@ -28462,11 +28317,11 @@ return true;`);
28462
28317
  return result;
28463
28318
  }
28464
28319
  var wktCRSParser;
28465
- var init_wkt2 = __esm({
28320
+ var init_wkt = __esm({
28466
28321
  "../../node_modules/@math.gl/geospatial/dist/projection/experimental/crs/wkt.js"() {
28467
28322
  init_spatial_reference();
28468
28323
  init_wkt_crs();
28469
- init_types2();
28324
+ init_types();
28470
28325
  init_structured();
28471
28326
  wktCRSParser = {
28472
28327
  name: "wkt",
@@ -28549,7 +28404,7 @@ return true;`);
28549
28404
  init_tpers2();
28550
28405
  init_vandg2();
28551
28406
  init_ob_tran();
28552
- init_wkt2();
28407
+ init_wkt();
28553
28408
  init_projjson();
28554
28409
  init_projection_pipeline();
28555
28410
  }
@@ -30213,7 +30068,7 @@ return true;`);
30213
30068
  var init_convert_geojson_to_flat_geojson = __esm({
30214
30069
  "../core/src/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.ts"() {
30215
30070
  "use strict";
30216
- init_dist2();
30071
+ init_dist3();
30217
30072
  }
30218
30073
  });
30219
30074
 
@@ -30507,7 +30362,7 @@ return true;`);
30507
30362
  var init_convert_flat_geojson_to_binary_features = __esm({
30508
30363
  "../core/src/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.ts"() {
30509
30364
  "use strict";
30510
- init_dist2();
30365
+ init_dist3();
30511
30366
  }
30512
30367
  });
30513
30368
 
@@ -30565,6 +30420,469 @@ return true;`);
30565
30420
  }
30566
30421
  });
30567
30422
 
30423
+ // ../../node_modules/@math.gl/arrow/dist/wkb/types.js
30424
+ function getWellKnownDimensionSize(dimension) {
30425
+ switch (dimension) {
30426
+ case "xy":
30427
+ return 2;
30428
+ case "xyz":
30429
+ case "xym":
30430
+ return 3;
30431
+ case "xyzm":
30432
+ return 4;
30433
+ }
30434
+ }
30435
+ function inferWellKnownGeometryDimension(geometry) {
30436
+ const size = getGeometryDimensionSize(geometry);
30437
+ return size >= 4 ? "xyzm" : size === 3 ? "xyz" : "xy";
30438
+ }
30439
+ function getGeometryDimensionSize(geometry) {
30440
+ if (geometry.type === "GeometryCollection") {
30441
+ return Math.max(2, ...geometry.geometries.map(getGeometryDimensionSize));
30442
+ }
30443
+ return getCoordinateDimension(geometry.coordinates);
30444
+ }
30445
+ function getCoordinateDimension(value2) {
30446
+ if (value2.length === 0)
30447
+ return 2;
30448
+ if (typeof value2[0] === "number")
30449
+ return value2.length;
30450
+ return Math.max(2, ...value2.map((child2) => getCoordinateDimension(child2)));
30451
+ }
30452
+ var init_types2 = __esm({
30453
+ "../../node_modules/@math.gl/arrow/dist/wkb/types.js"() {
30454
+ }
30455
+ });
30456
+
30457
+ // ../../node_modules/@math.gl/arrow/dist/wkb/wkb.js
30458
+ function writeWKB(geometry, dimension = inferWellKnownGeometryDimension(geometry)) {
30459
+ const bytes = [];
30460
+ writeWKBGeometry(bytes, geometry, dimension);
30461
+ return Uint8Array.from(bytes);
30462
+ }
30463
+ function writeWKBGeometry(bytes, geometry, dimension) {
30464
+ bytes.push(1);
30465
+ const size = getWellKnownDimensionSize(dimension);
30466
+ const dimensionOffset = dimension === "xyz" ? 1e3 : dimension === "xym" ? 2e3 : dimension === "xyzm" ? 3e3 : 0;
30467
+ writeUint32(bytes, getWKBType(geometry.type) + dimensionOffset);
30468
+ const writeCoordinate = (coordinate) => {
30469
+ for (let index = 0; index < size; index++)
30470
+ writeFloat64(bytes, coordinate[index] ?? 0);
30471
+ };
30472
+ const writeCoordinates = (coordinates) => {
30473
+ writeUint32(bytes, coordinates.length);
30474
+ for (const coordinate of coordinates)
30475
+ writeCoordinate(coordinate);
30476
+ };
30477
+ switch (geometry.type) {
30478
+ case "Point":
30479
+ writeCoordinate(geometry.coordinates.length === 0 ? new Array(size).fill(Number.NaN) : geometry.coordinates);
30480
+ break;
30481
+ case "LineString":
30482
+ writeCoordinates(geometry.coordinates);
30483
+ break;
30484
+ case "Polygon":
30485
+ writeUint32(bytes, geometry.coordinates.length);
30486
+ for (const ring of geometry.coordinates)
30487
+ writeCoordinates(ring);
30488
+ break;
30489
+ case "MultiPoint":
30490
+ writeUint32(bytes, geometry.coordinates.length);
30491
+ for (const coordinate of geometry.coordinates) {
30492
+ writeWKBGeometry(bytes, { type: "Point", coordinates: coordinate }, dimension);
30493
+ }
30494
+ break;
30495
+ case "MultiLineString":
30496
+ writeUint32(bytes, geometry.coordinates.length);
30497
+ for (const coordinates of geometry.coordinates) {
30498
+ writeWKBGeometry(bytes, { type: "LineString", coordinates }, dimension);
30499
+ }
30500
+ break;
30501
+ case "MultiPolygon":
30502
+ writeUint32(bytes, geometry.coordinates.length);
30503
+ for (const coordinates of geometry.coordinates) {
30504
+ writeWKBGeometry(bytes, { type: "Polygon", coordinates }, dimension);
30505
+ }
30506
+ break;
30507
+ case "GeometryCollection":
30508
+ writeUint32(bytes, geometry.geometries.length);
30509
+ for (const child2 of geometry.geometries)
30510
+ writeWKBGeometry(bytes, child2, dimension);
30511
+ break;
30512
+ }
30513
+ }
30514
+ function getWKBType(type) {
30515
+ return [
30516
+ "Point",
30517
+ "LineString",
30518
+ "Polygon",
30519
+ "MultiPoint",
30520
+ "MultiLineString",
30521
+ "MultiPolygon",
30522
+ "GeometryCollection"
30523
+ ].indexOf(type) + 1;
30524
+ }
30525
+ function writeUint32(bytes, value2) {
30526
+ bytes.push(value2 & 255, value2 >>> 8 & 255, value2 >>> 16 & 255, value2 >>> 24 & 255);
30527
+ }
30528
+ function writeFloat64(bytes, value2) {
30529
+ const buffer = new ArrayBuffer(8);
30530
+ new DataView(buffer).setFloat64(0, value2, true);
30531
+ bytes.push(...new Uint8Array(buffer));
30532
+ }
30533
+ var init_wkb = __esm({
30534
+ "../../node_modules/@math.gl/arrow/dist/wkb/wkb.js"() {
30535
+ init_types2();
30536
+ }
30537
+ });
30538
+
30539
+ // ../../node_modules/@math.gl/arrow/dist/wkb/wkb-builder.js
30540
+ function measureGeometry(geometryWriter, options) {
30541
+ const builder = new WKBBuilder({ ...options, mode: "measure" });
30542
+ geometryWriter(builder);
30543
+ return builder.finishGeometry();
30544
+ }
30545
+ function getTargetDataView(target) {
30546
+ return ArrayBuffer.isView(target) ? new DataView(target.buffer, target.byteOffset, target.byteLength) : new DataView(target);
30547
+ }
30548
+ function getWKBTypeCode(geometryType, dimension, hasSrid) {
30549
+ const geometryCode = GEOMETRY_TYPE_CODES[geometryType];
30550
+ if (hasSrid) {
30551
+ const dimensionFlags = dimension === "xyz" ? 2147483648 : dimension === "xym" ? 1073741824 : dimension === "xyzm" ? 3221225472 : 0;
30552
+ return (geometryCode | dimensionFlags | 536870912) >>> 0;
30553
+ }
30554
+ const dimensionOffset = dimension === "xyz" ? 1e3 : dimension === "xym" ? 2e3 : dimension === "xyzm" ? 3e3 : 0;
30555
+ return geometryCode + dimensionOffset;
30556
+ }
30557
+ function makeCoordinate(dimension, x, y, z, m) {
30558
+ switch (dimension) {
30559
+ case "xy":
30560
+ return [x, y];
30561
+ case "xyz":
30562
+ return [x, y, z ?? Number.NaN];
30563
+ case "xym":
30564
+ return [x, y, m ?? Number.NaN];
30565
+ case "xyzm":
30566
+ return [x, y, z ?? Number.NaN, m ?? Number.NaN];
30567
+ }
30568
+ }
30569
+ function getDimensionSize(dimension) {
30570
+ return dimension === "xy" ? 2 : dimension === "xyzm" ? 4 : 3;
30571
+ }
30572
+ function validateSrid(srid) {
30573
+ if (srid !== void 0 && (!Number.isSafeInteger(srid) || srid < 0 || srid > 4294967295)) {
30574
+ throw new Error("WKBBuilder srid must be an unsigned 32-bit integer");
30575
+ }
30576
+ }
30577
+ function makeNullBitmap(geometryWriters) {
30578
+ const nullBitmap = new Uint8Array(Math.ceil(geometryWriters.length / 8));
30579
+ let nullCount = 0;
30580
+ for (let geometryIndex = 0; geometryIndex < geometryWriters.length; geometryIndex++) {
30581
+ if (geometryWriters[geometryIndex]) {
30582
+ nullBitmap[geometryIndex >> 3] |= 1 << (geometryIndex & 7);
30583
+ } else {
30584
+ nullCount++;
30585
+ }
30586
+ }
30587
+ return { nullBitmap, nullCount };
30588
+ }
30589
+ var GEOMETRY_TYPE_CODES, WKBBuilder;
30590
+ var init_wkb_builder = __esm({
30591
+ "../../node_modules/@math.gl/arrow/dist/wkb/wkb-builder.js"() {
30592
+ GEOMETRY_TYPE_CODES = {
30593
+ Point: 1,
30594
+ LineString: 2,
30595
+ Polygon: 3,
30596
+ MultiPoint: 4,
30597
+ MultiLineString: 5,
30598
+ MultiPolygon: 6,
30599
+ GeometryCollection: 7
30600
+ };
30601
+ WKBBuilder = class _WKBBuilder {
30602
+ constructor(options) {
30603
+ this.mode = options.mode;
30604
+ this.dimension = options.dimension ?? "xy";
30605
+ this.littleEndian = options.byteOrder !== "big-endian";
30606
+ this.srid = options.srid;
30607
+ this.transform = options.transform;
30608
+ validateSrid(this.srid);
30609
+ if (options.mode === "write") {
30610
+ const dataView = getTargetDataView(options.target);
30611
+ const byteOffset = options.byteOffset ?? 0;
30612
+ if (!Number.isSafeInteger(byteOffset) || byteOffset < 0 || byteOffset > dataView.byteLength) {
30613
+ throw new Error("WKBBuilder byteOffset is outside the target");
30614
+ }
30615
+ this.dataView = dataView;
30616
+ this.startByteOffset = byteOffset;
30617
+ this.endByteOffset = dataView.byteLength;
30618
+ this.byteOffset = byteOffset;
30619
+ } else {
30620
+ this.dataView = null;
30621
+ this.startByteOffset = 0;
30622
+ this.endByteOffset = Number.POSITIVE_INFINITY;
30623
+ this.byteOffset = 0;
30624
+ }
30625
+ }
30626
+ /** Begins a geometry and writes its count field when required. */
30627
+ beginGeometry(type, count) {
30628
+ switch (type) {
30629
+ case "Point":
30630
+ this.beginPoint();
30631
+ break;
30632
+ case "LineString":
30633
+ this.beginLineString(count ?? 0);
30634
+ break;
30635
+ case "Polygon":
30636
+ this.beginPolygon(count ?? 0);
30637
+ break;
30638
+ case "MultiPoint":
30639
+ this.beginMultiPoint(count ?? 0);
30640
+ break;
30641
+ case "MultiLineString":
30642
+ this.beginMultiLineString(count ?? 0);
30643
+ break;
30644
+ case "MultiPolygon":
30645
+ this.beginMultiPolygon(count ?? 0);
30646
+ break;
30647
+ case "GeometryCollection":
30648
+ this.writeHeader("GeometryCollection");
30649
+ this.writeUint32(count ?? 0);
30650
+ break;
30651
+ }
30652
+ }
30653
+ /** Begins one point geometry. */
30654
+ beginPoint() {
30655
+ this.writeHeader("Point");
30656
+ }
30657
+ /** Begins one linestring geometry. */
30658
+ beginLineString(pointCount) {
30659
+ this.writeHeader("LineString");
30660
+ this.writeUint32(pointCount);
30661
+ }
30662
+ /** Begins one polygon geometry. */
30663
+ beginPolygon(ringCount) {
30664
+ this.writeHeader("Polygon");
30665
+ this.writeUint32(ringCount);
30666
+ }
30667
+ /** Begins one linear ring inside a polygon. */
30668
+ beginLinearRing(pointCount) {
30669
+ this.writeUint32(pointCount);
30670
+ }
30671
+ /** Begins one multipoint geometry. */
30672
+ beginMultiPoint(pointCount) {
30673
+ this.writeHeader("MultiPoint");
30674
+ this.writeUint32(pointCount);
30675
+ }
30676
+ /** Begins one multilinestring geometry. */
30677
+ beginMultiLineString(lineCount) {
30678
+ this.writeHeader("MultiLineString");
30679
+ this.writeUint32(lineCount);
30680
+ }
30681
+ /** Begins one multipolygon geometry. */
30682
+ beginMultiPolygon(polygonCount) {
30683
+ this.writeHeader("MultiPolygon");
30684
+ this.writeUint32(polygonCount);
30685
+ }
30686
+ /** Writes one coordinate using the builder's semantic dimension. */
30687
+ writeCoordinate(x, y, z, m) {
30688
+ let coordinate = makeCoordinate(this.dimension, x, y, z, m);
30689
+ if (this.transform)
30690
+ coordinate = this.transform(coordinate, this.dimension);
30691
+ const coordinateSize = getDimensionSize(this.dimension);
30692
+ for (let index = 0; index < coordinateSize; index++) {
30693
+ this.writeFloat64(coordinate[index] ?? Number.NaN);
30694
+ }
30695
+ }
30696
+ /** Temporarily changes the semantic dimension for a nested geometry. */
30697
+ withDimension(dimension, callback) {
30698
+ const previous = this.dimension;
30699
+ this.dimension = dimension;
30700
+ try {
30701
+ return callback();
30702
+ } finally {
30703
+ this.dimension = previous;
30704
+ }
30705
+ }
30706
+ /** Returns the number of bytes measured or written. */
30707
+ finishGeometry() {
30708
+ return this.byteOffset - this.startByteOffset;
30709
+ }
30710
+ /** Measures geometry callbacks and returns contiguous Binary offsets. */
30711
+ static measureGeometryArray(geometryWriters, options = {}) {
30712
+ const valueOffsets = new Int32Array(geometryWriters.length + 1);
30713
+ for (let geometryIndex = 0; geometryIndex < geometryWriters.length; geometryIndex++) {
30714
+ const geometryWriter = geometryWriters[geometryIndex];
30715
+ const byteLength = geometryWriter ? measureGeometry(geometryWriter, {
30716
+ ...options,
30717
+ dimension: options.dimensionResolver?.(geometryIndex) ?? options.dimension
30718
+ }) : 0;
30719
+ const nextOffset = valueOffsets[geometryIndex] + byteLength;
30720
+ if (nextOffset > 2147483647)
30721
+ throw new Error("WKB geometry array exceeds Int32 offsets");
30722
+ valueOffsets[geometryIndex + 1] = nextOffset;
30723
+ }
30724
+ return valueOffsets;
30725
+ }
30726
+ /** Writes geometry callbacks into an existing contiguous values buffer. */
30727
+ static writeGeometryArray(geometryWriters, valueOffsets, values, options = {}) {
30728
+ if (valueOffsets.length !== geometryWriters.length + 1) {
30729
+ throw new Error("WKB valueOffsets length must equal geometry count plus one");
30730
+ }
30731
+ for (let i = 0; i < valueOffsets.length; i++) {
30732
+ if (!Number.isInteger(valueOffsets[i]) || valueOffsets[i] < 0 || i > 0 && valueOffsets[i] < valueOffsets[i - 1]) {
30733
+ throw new Error("WKB valueOffsets must be nonnegative and nondecreasing");
30734
+ }
30735
+ }
30736
+ if (valueOffsets[valueOffsets.length - 1] > values.byteLength) {
30737
+ throw new Error("WKB values buffer is smaller than its final offset");
30738
+ }
30739
+ for (let geometryIndex = 0; geometryIndex < geometryWriters.length; geometryIndex++) {
30740
+ const geometryWriter = geometryWriters[geometryIndex];
30741
+ if (!geometryWriter)
30742
+ continue;
30743
+ const builder = new _WKBBuilder({
30744
+ ...options,
30745
+ mode: "write",
30746
+ target: values,
30747
+ byteOffset: valueOffsets[geometryIndex],
30748
+ dimension: options.dimensionResolver?.(geometryIndex) ?? options.dimension
30749
+ });
30750
+ geometryWriter(builder);
30751
+ const byteLength = builder.finishGeometry();
30752
+ if (valueOffsets[geometryIndex] + byteLength !== valueOffsets[geometryIndex + 1]) {
30753
+ throw new Error("WKB measure and write passes produced different byte lengths");
30754
+ }
30755
+ }
30756
+ return values;
30757
+ }
30758
+ /** Builds plain offsets, values, and validity buffers in two passes. */
30759
+ static buildGeometryArray(geometryWriters, options = {}) {
30760
+ const valueOffsets = _WKBBuilder.measureGeometryArray(geometryWriters, options);
30761
+ const values = new Uint8Array(valueOffsets[valueOffsets.length - 1]);
30762
+ _WKBBuilder.writeGeometryArray(geometryWriters, valueOffsets, values, options);
30763
+ const { nullBitmap, nullCount } = makeNullBitmap(geometryWriters);
30764
+ return {
30765
+ valueOffsets,
30766
+ values,
30767
+ ...nullCount > 0 ? { nullBitmap } : {},
30768
+ nullCount
30769
+ };
30770
+ }
30771
+ writeHeader(geometryType) {
30772
+ this.writeUint8(this.littleEndian ? 1 : 0);
30773
+ this.writeUint32(getWKBTypeCode(geometryType, this.dimension, this.srid !== void 0));
30774
+ if (this.srid !== void 0)
30775
+ this.writeUint32(this.srid);
30776
+ }
30777
+ writeUint8(value2) {
30778
+ this.ensureSize(1);
30779
+ this.dataView?.setUint8(this.byteOffset, value2);
30780
+ this.byteOffset++;
30781
+ }
30782
+ writeUint32(value2) {
30783
+ if (!Number.isSafeInteger(value2) || value2 < 0 || value2 > 4294967295) {
30784
+ throw new Error("WKB count must be an unsigned 32-bit integer");
30785
+ }
30786
+ this.ensureSize(4);
30787
+ this.dataView?.setUint32(this.byteOffset, value2, this.littleEndian);
30788
+ this.byteOffset += 4;
30789
+ }
30790
+ writeFloat64(value2) {
30791
+ this.ensureSize(8);
30792
+ this.dataView?.setFloat64(this.byteOffset, value2, this.littleEndian);
30793
+ this.byteOffset += 8;
30794
+ }
30795
+ ensureSize(byteLength) {
30796
+ if (this.byteOffset + byteLength > this.endByteOffset) {
30797
+ throw new Error("WKBBuilder target buffer overflow");
30798
+ }
30799
+ }
30800
+ };
30801
+ }
30802
+ });
30803
+
30804
+ // ../../node_modules/@math.gl/arrow/dist/wkb/wkt.js
30805
+ function formatWKT(geometry, dimension) {
30806
+ if (isWKTParseResult(geometry)) {
30807
+ return dimension === void 0 ? formatWKTResult(geometry) : formatWKTGeometry(geometry.geometry, dimension);
30808
+ }
30809
+ return formatWKTGeometry(geometry, dimension ?? inferWellKnownGeometryDimension(geometry));
30810
+ }
30811
+ function formatWKTResult(result) {
30812
+ return formatWKTGeometry(result.geometry, result.dimension, result.children);
30813
+ }
30814
+ function formatWKTGeometry(geometry, dimension, children2) {
30815
+ const dimensionToken = dimension === "xy" ? "" : " " + dimension.slice(2).toUpperCase();
30816
+ if (geometry.type === "GeometryCollection") {
30817
+ if (geometry.geometries.length === 0)
30818
+ return "GEOMETRYCOLLECTION" + dimensionToken + " EMPTY";
30819
+ const formattedChildren = children2 ? children2.map(formatWKTResult) : geometry.geometries.map((child2) => formatWKTGeometry(child2, dimension));
30820
+ return "GEOMETRYCOLLECTION" + dimensionToken + " (" + formattedChildren.join(", ") + ")";
30821
+ }
30822
+ const type = geometry.type.toUpperCase();
30823
+ const isEmpty = geometry.type === "MultiPoint" ? geometry.coordinates.length === 0 : isEmptyCoordinates(geometry.coordinates);
30824
+ if (isEmpty)
30825
+ return type + dimensionToken + " EMPTY";
30826
+ return type + dimensionToken + " " + formatCoordinateNesting(geometry.coordinates, getGeometryDepth(geometry.type), geometry.type === "MultiPoint");
30827
+ }
30828
+ function isWKTParseResult(value2) {
30829
+ return "geometry" in value2 && "dimension" in value2;
30830
+ }
30831
+ function formatCoordinateNesting(value2, depth, allowEmptyPoints = false) {
30832
+ if (depth === 0)
30833
+ return `(${value2.map(formatNumber).join(" ")})`;
30834
+ return `(${value2.map((child2) => {
30835
+ if (depth === 1) {
30836
+ const coordinate = child2;
30837
+ if (allowEmptyPoints && isEmptyCoordinates(coordinate))
30838
+ return "EMPTY";
30839
+ return coordinate.map(formatNumber).join(" ");
30840
+ }
30841
+ return formatCoordinateNesting(child2, depth - 1);
30842
+ }).join(", ")})`;
30843
+ }
30844
+ function formatNumber(value2) {
30845
+ if (!Number.isFinite(value2))
30846
+ return "NaN";
30847
+ return String(value2);
30848
+ }
30849
+ function getGeometryDepth(type) {
30850
+ switch (type) {
30851
+ case "Point":
30852
+ return 0;
30853
+ case "LineString":
30854
+ case "MultiPoint":
30855
+ return 1;
30856
+ case "Polygon":
30857
+ case "MultiLineString":
30858
+ return 2;
30859
+ case "MultiPolygon":
30860
+ return 3;
30861
+ }
30862
+ }
30863
+ function isEmptyCoordinates(value2) {
30864
+ if (value2.length === 0)
30865
+ return true;
30866
+ if (typeof value2[0] === "number") {
30867
+ return value2.every((component) => !Number.isFinite(component));
30868
+ }
30869
+ return value2.every((child2) => isEmptyCoordinates(child2));
30870
+ }
30871
+ var init_wkt2 = __esm({
30872
+ "../../node_modules/@math.gl/arrow/dist/wkb/wkt.js"() {
30873
+ init_types2();
30874
+ }
30875
+ });
30876
+
30877
+ // ../../node_modules/@math.gl/arrow/dist/wkb/index.js
30878
+ var init_wkb2 = __esm({
30879
+ "../../node_modules/@math.gl/arrow/dist/wkb/index.js"() {
30880
+ init_wkb();
30881
+ init_wkb_builder();
30882
+ init_wkt2();
30883
+ }
30884
+ });
30885
+
30568
30886
  // ../core/src/arrow-geometry/geometry-to-wkt.ts
30569
30887
  function convertGeometryToWKT(geometry, options) {
30570
30888
  const dimension = getWKTDimension(geometry, options);
@@ -30634,7 +30952,7 @@ return true;`);
30634
30952
  var init_geometry_to_wkt = __esm({
30635
30953
  "../core/src/arrow-geometry/geometry-to-wkt.ts"() {
30636
30954
  "use strict";
30637
- init_dist3();
30955
+ init_wkb2();
30638
30956
  }
30639
30957
  });
30640
30958
 
@@ -30674,7 +30992,7 @@ return true;`);
30674
30992
  var init_geometry_codecs = __esm({
30675
30993
  "../core/src/arrow-geometry/geometry-codecs.ts"() {
30676
30994
  "use strict";
30677
- init_dist3();
30995
+ init_wkb2();
30678
30996
  init_geometry_to_wkt();
30679
30997
  }
30680
30998
  });
@@ -31438,7 +31756,7 @@ return true;`);
31438
31756
  var init_wkb_builder2 = __esm({
31439
31757
  "../core/src/arrow-geometry/wkb-builder.ts"() {
31440
31758
  "use strict";
31441
- init_dist3();
31759
+ init_wkb2();
31442
31760
  init_wkb_types();
31443
31761
  WKBBuilder2 = class _WKBBuilder {
31444
31762
  mode;
@@ -33513,7 +33831,7 @@ return true;`);
33513
33831
  "src/flatgeobuf/flatgeobuf-loader-types.ts"() {
33514
33832
  "use strict";
33515
33833
  init_flatgeobuf_format();
33516
- VERSION = true ? "5.0.0-beta.4" : "latest";
33834
+ VERSION = true ? "5.0.0-beta.5" : "latest";
33517
33835
  FGB_MAGIC_NUMBER = [102, 103, 98, 3, 102, 103, 98, 1];
33518
33836
  FlatGeobufLoader = {
33519
33837
  ...FlatGeobufFormat,