@math.gl/geospatial 5.0.0-beta.1 → 5.0.0-beta.3
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/crs/crs-identifier.d.ts +23 -0
- package/dist/crs/crs-identifier.d.ts.map +1 -0
- package/dist/crs/crs-identifier.js +74 -0
- package/dist/crs/crs-identifier.js.map +1 -0
- package/dist/crs/index.cjs +48 -0
- package/dist/crs/index.cjs.map +2 -2
- package/dist/crs/index.d.ts +1 -0
- package/dist/crs/index.d.ts.map +1 -1
- package/dist/crs/index.js +1 -0
- package/dist/crs/index.js.map +1 -1
- package/dist/discontinuous/cap-map.d.ts.map +1 -1
- package/dist/discontinuous/cap-map.js +197 -13
- package/dist/discontinuous/cap-map.js.map +1 -1
- package/dist/discontinuous/elastic/geometry.d.ts +1 -1
- package/dist/discontinuous/elastic/geometry.d.ts.map +1 -1
- package/dist/discontinuous/elastic/geometry.js +7 -7
- package/dist/discontinuous/elastic/geometry.js.map +1 -1
- package/dist/discontinuous/elastic/map.d.ts.map +1 -1
- package/dist/discontinuous/elastic/map.js +263 -23
- package/dist/discontinuous/elastic/map.js.map +1 -1
- package/dist/discontinuous/elastic/source-arc.d.ts +10 -0
- package/dist/discontinuous/elastic/source-arc.d.ts.map +1 -0
- package/dist/discontinuous/elastic/source-arc.js +111 -0
- package/dist/discontinuous/elastic/source-arc.js.map +1 -0
- package/dist/discontinuous/global-polygons.d.ts +1 -1
- package/dist/discontinuous/global-polygons.d.ts.map +1 -1
- package/dist/discontinuous/global-polygons.js +49 -1
- package/dist/discontinuous/global-polygons.js.map +1 -1
- package/dist/discontinuous/map-engine.d.ts +9 -0
- package/dist/discontinuous/map-engine.d.ts.map +1 -1
- package/dist/discontinuous/map-layout.d.ts +21 -0
- package/dist/discontinuous/map-layout.d.ts.map +1 -1
- package/dist/discontinuous/map-layout.js +116 -1
- package/dist/discontinuous/map-layout.js.map +1 -1
- package/dist/discontinuous/map-transition.d.ts.map +1 -1
- package/dist/discontinuous/map-transition.js +66 -3
- package/dist/discontinuous/map-transition.js.map +1 -1
- package/dist/discontinuous/mercator-map.d.ts +2 -2
- package/dist/discontinuous/mercator-map.d.ts.map +1 -1
- package/dist/discontinuous/mercator-map.js +123 -11
- package/dist/discontinuous/mercator-map.js.map +1 -1
- package/dist/discontinuous/polygon-constraints.d.ts +16 -0
- package/dist/discontinuous/polygon-constraints.d.ts.map +1 -0
- package/dist/discontinuous/polygon-constraints.js +157 -0
- package/dist/discontinuous/polygon-constraints.js.map +1 -0
- package/dist/discontinuous/prepare-features.d.ts +27 -0
- package/dist/discontinuous/prepare-features.d.ts.map +1 -1
- package/dist/discontinuous/prepare-features.js +106 -5
- package/dist/discontinuous/prepare-features.js.map +1 -1
- package/dist/discontinuous/rotated-map.d.ts +9 -0
- package/dist/discontinuous/rotated-map.d.ts.map +1 -1
- package/dist/discontinuous/source-arc.d.ts +4 -0
- package/dist/discontinuous/source-arc.d.ts.map +1 -0
- package/dist/discontinuous/source-arc.js +23 -0
- package/dist/discontinuous/source-arc.js.map +1 -0
- package/dist/discontinuous/world-kernels.d.ts +1 -1
- package/dist/discontinuous.cjs +1047 -75
- package/dist/discontinuous.cjs.map +3 -3
- package/dist/index.cjs +422 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/tasks/definitions.d.ts +90 -0
- package/dist/tasks/definitions.d.ts.map +1 -0
- package/dist/tasks/definitions.js +54 -0
- package/dist/tasks/definitions.js.map +1 -0
- package/dist/{workers → tasks}/index.cjs +1223 -191
- package/dist/tasks/index.cjs.map +6 -0
- package/dist/tasks/index.d.ts +12 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +30 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/{workers → tasks}/map-worker.d.ts.map +1 -1
- package/dist/tasks/map-worker.js +7 -0
- package/dist/tasks/map-worker.js.map +1 -0
- package/dist/{workers → tasks}/operations.d.ts +6 -4
- package/dist/tasks/operations.d.ts.map +1 -0
- package/dist/{workers → tasks}/operations.js +3 -5
- package/dist/tasks/operations.js.map +1 -0
- package/dist/tasks/projection-worker.d.ts.map +1 -0
- package/dist/tasks/projection-worker.js +7 -0
- package/dist/tasks/projection-worker.js.map +1 -0
- package/dist/terrain/filtered-pyramid.d.ts +22 -0
- package/dist/terrain/filtered-pyramid.d.ts.map +1 -0
- package/dist/terrain/filtered-pyramid.js +71 -0
- package/dist/terrain/filtered-pyramid.js.map +1 -0
- package/dist/terrain/index.cjs +375 -1
- package/dist/terrain/index.cjs.map +2 -2
- package/dist/terrain/index.d.ts +12 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +7 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/profile-horizon.d.ts +20 -0
- package/dist/terrain/profile-horizon.d.ts.map +1 -0
- package/dist/terrain/profile-horizon.js +69 -0
- package/dist/terrain/profile-horizon.js.map +1 -0
- package/dist/terrain/profile-slope.d.ts +3 -0
- package/dist/terrain/profile-slope.d.ts.map +1 -0
- package/dist/terrain/profile-slope.js +35 -0
- package/dist/terrain/profile-slope.js.map +1 -0
- package/dist/terrain/profile-viewshed.d.ts +17 -0
- package/dist/terrain/profile-viewshed.d.ts.map +1 -0
- package/dist/terrain/profile-viewshed.js +51 -0
- package/dist/terrain/profile-viewshed.js.map +1 -0
- package/dist/terrain/profile-visibility.d.ts +21 -0
- package/dist/terrain/profile-visibility.d.ts.map +1 -0
- package/dist/terrain/profile-visibility.js +61 -0
- package/dist/terrain/profile-visibility.js.map +1 -0
- package/dist/terrain/vertex-halo-invalidation.d.ts +16 -0
- package/dist/terrain/vertex-halo-invalidation.d.ts.map +1 -0
- package/dist/terrain/vertex-halo-invalidation.js +50 -0
- package/dist/terrain/vertex-halo-invalidation.js.map +1 -0
- package/dist/terrain/vertex-halo-update.d.ts +18 -0
- package/dist/terrain/vertex-halo-update.d.ts.map +1 -0
- package/dist/terrain/vertex-halo-update.js +76 -0
- package/dist/terrain/vertex-halo-update.js.map +1 -0
- package/dist/terrain/vertex-halos.d.ts +26 -0
- package/dist/terrain/vertex-halos.d.ts.map +1 -0
- package/dist/terrain/vertex-halos.js +80 -0
- package/dist/terrain/vertex-halos.js.map +1 -0
- package/dist/turf.cjs +69 -5
- package/dist/turf.cjs.map +2 -2
- package/dist/turf.d.ts +9 -0
- package/dist/turf.d.ts.map +1 -1
- package/dist/turf.js +67 -0
- package/dist/turf.js.map +1 -1
- package/package.json +10 -15
- package/src/crs/crs-identifier.ts +86 -0
- package/src/crs/index.ts +1 -0
- package/src/discontinuous/cap-map.ts +248 -19
- package/src/discontinuous/elastic/geometry.ts +18 -7
- package/src/discontinuous/elastic/map.ts +334 -30
- package/src/discontinuous/elastic/source-arc.ts +129 -0
- package/src/discontinuous/global-polygons.ts +56 -2
- package/src/discontinuous/map-layout.ts +165 -2
- package/src/discontinuous/map-transition.ts +67 -3
- package/src/discontinuous/mercator-map.ts +151 -12
- package/src/discontinuous/polygon-constraints.ts +184 -0
- package/src/discontinuous/prepare-features.ts +154 -6
- package/src/discontinuous/source-arc.ts +31 -0
- package/src/index.ts +13 -0
- package/src/tasks/definitions.ts +89 -0
- package/src/tasks/index.ts +39 -0
- package/src/tasks/map-worker.ts +6 -0
- package/src/{workers → tasks}/operations.ts +11 -7
- package/src/tasks/projection-worker.ts +6 -0
- package/src/terrain/filtered-pyramid.ts +95 -0
- package/src/terrain/index.ts +12 -0
- package/src/terrain/profile-horizon.ts +86 -0
- package/src/terrain/profile-slope.ts +32 -0
- package/src/terrain/profile-viewshed.ts +57 -0
- package/src/terrain/profile-visibility.ts +81 -0
- package/src/terrain/vertex-halo-invalidation.ts +57 -0
- package/src/terrain/vertex-halo-update.ts +91 -0
- package/src/terrain/vertex-halos.ts +101 -0
- package/src/turf.ts +86 -0
- package/dist/workers/index.cjs.map +0 -6
- package/dist/workers/index.d.ts +0 -12
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -41
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/map-worker.js +0 -7
- package/dist/workers/map-worker.js.map +0 -1
- package/dist/workers/operations.cjs +0 -20036
- package/dist/workers/operations.cjs.map +0 -6
- package/dist/workers/operations.d.ts.map +0 -1
- package/dist/workers/operations.js.map +0 -1
- package/dist/workers/projection-worker.d.ts.map +0 -1
- package/dist/workers/projection-worker.js +0 -7
- package/dist/workers/projection-worker.js.map +0 -1
- package/src/workers/index.ts +0 -59
- package/src/workers/map-worker.ts +0 -7
- package/src/workers/projection-worker.ts +0 -7
- /package/dist/{workers → tasks}/map-worker.d.ts +0 -0
- /package/dist/{workers → tasks}/projection-worker.d.ts +0 -0
|
@@ -809,8 +809,49 @@ function cutSphericalPolygon(rings, options) {
|
|
|
809
809
|
}
|
|
810
810
|
function projectSphericalPolygon(map, rings, options) {
|
|
811
811
|
const result = [];
|
|
812
|
+
if (options.polygonEdgeProvenance && (!map.regions || !map.seams))
|
|
813
|
+
throw new Error("Atlas provenance requires map region and seam metadata");
|
|
812
814
|
for (const part of cutSphericalPolygon(rings, options))
|
|
813
|
-
|
|
815
|
+
for (const polygon of map.projectPolygon(part.rings, options)) {
|
|
816
|
+
if (options.polygonEdgeProvenance) {
|
|
817
|
+
if (!polygon.edgeProvenance)
|
|
818
|
+
throw new Error("Map backend does not support polygon edge provenance");
|
|
819
|
+
const region = map.regions.find((r) => r.id === polygon.regionId);
|
|
820
|
+
polygon.edgeProvenance = polygon.edgeProvenance.map((edges, ring) => edges.map((edge2, i) => {
|
|
821
|
+
if (edge2.kind !== "source-boundary")
|
|
822
|
+
return edge2;
|
|
823
|
+
const parent = part.edges[edge2.ring][edge2.segment];
|
|
824
|
+
if (parent.kind === "source")
|
|
825
|
+
return {
|
|
826
|
+
...edge2,
|
|
827
|
+
ring: parent.ringIndex,
|
|
828
|
+
segment: parent.edgeIndex,
|
|
829
|
+
t0: parent.startFraction + edge2.t0 * (parent.endFraction - parent.startFraction),
|
|
830
|
+
t1: parent.startFraction + edge2.t1 * (parent.endFraction - parent.startFraction)
|
|
831
|
+
};
|
|
832
|
+
const a = geographic(polygon.sourceCoordinates[ring][i]), b = geographic(polygon.sourceCoordinates[ring][i + 1]), kinds = [];
|
|
833
|
+
region.boundary.forEach((p, j) => {
|
|
834
|
+
const normal = cross(geographic(p), geographic(region.boundary[(j + 1) % region.boundary.length]));
|
|
835
|
+
const length = Math.hypot(...normal);
|
|
836
|
+
if (length < 1e-12)
|
|
837
|
+
return;
|
|
838
|
+
if ([a, b].every((v) => Math.abs(dot(normal, v)) / length < 1e-10)) {
|
|
839
|
+
const seam = map.seams.find((s) => s.regions.some((id, k2) => id === region.id && s.edges[k2] === j));
|
|
840
|
+
if (seam)
|
|
841
|
+
kinds.push(seam.kind);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
return {
|
|
845
|
+
kind: kinds.includes("boundary") ? "coverage-boundary" : kinds.includes("cut") ? "chart-cut" : "continuous-chart-join",
|
|
846
|
+
ring: 4294967295,
|
|
847
|
+
segment: 4294967295,
|
|
848
|
+
t0: 0,
|
|
849
|
+
t1: 0
|
|
850
|
+
};
|
|
851
|
+
}));
|
|
852
|
+
}
|
|
853
|
+
result.push(polygon);
|
|
854
|
+
}
|
|
814
855
|
return result;
|
|
815
856
|
}
|
|
816
857
|
var import_polygon_clipping, TOL, arcCross, angle2;
|
|
@@ -841,33 +882,13 @@ function inRing(p, ring, includeBoundary = true) {
|
|
|
841
882
|
}
|
|
842
883
|
return inside;
|
|
843
884
|
}
|
|
844
|
-
function clipSegment(a, b, polygons) {
|
|
845
|
-
const ts = [0, 1], dx = b[0] - a[0], dy = b[1] - a[1];
|
|
846
|
-
for (const rings of polygons)
|
|
847
|
-
for (const ring of rings)
|
|
848
|
-
for (let i = 1; i < ring.length; i++) {
|
|
849
|
-
const c = ring[i - 1], d = ring[i], ex = d[0] - c[0], ey = d[1] - c[1], det = dx * ey - dy * ex;
|
|
850
|
-
if (Math.abs(det) < 1e-14)
|
|
851
|
-
continue;
|
|
852
|
-
const t = ((c[0] - a[0]) * ey - (c[1] - a[1]) * ex) / det;
|
|
853
|
-
const u = ((c[0] - a[0]) * dy - (c[1] - a[1]) * dx) / det;
|
|
854
|
-
if (t > 0 && t < 1 && u >= -1e-10 && u <= 1 + 1e-10)
|
|
855
|
-
ts.push(t);
|
|
856
|
-
}
|
|
857
|
-
ts.sort((a2, b2) => a2 - b2);
|
|
858
|
-
const result = [];
|
|
859
|
-
for (let i = 1; i < ts.length; i++)
|
|
860
|
-
if (ts[i] - ts[i - 1] > 1e-12 && contains(polygons, lerp(a, b, (ts[i] + ts[i - 1]) / 2)))
|
|
861
|
-
result.push([lerp(a, b, ts[i - 1]), lerp(a, b, ts[i])]);
|
|
862
|
-
return result;
|
|
863
|
-
}
|
|
864
885
|
function sampling(options) {
|
|
865
886
|
const step = options.maxAngularStep ?? 2, tolerance = options.tolerance ?? 1e-4;
|
|
866
887
|
if (!Number.isFinite(step) || step <= 0 || step > 90 || !Number.isFinite(tolerance) || tolerance <= 0)
|
|
867
888
|
throw new Error("Invalid map sampling options");
|
|
868
889
|
return { step, tolerance };
|
|
869
890
|
}
|
|
870
|
-
function sample(line, project, options, cellStep) {
|
|
891
|
+
function sample(line, project, options, cellStep, interpolate) {
|
|
871
892
|
const { step, tolerance } = sampling(options), source = [], xy = [];
|
|
872
893
|
const emit = (p, q) => {
|
|
873
894
|
if (source.length >= 1e5)
|
|
@@ -878,23 +899,23 @@ function sample(line, project, options, cellStep) {
|
|
|
878
899
|
const at = (p) => {
|
|
879
900
|
const q = project(p);
|
|
880
901
|
if (!q)
|
|
881
|
-
throw new Error(
|
|
902
|
+
throw new Error(`Elastic grid is undefined inside its coverage at ${p}`);
|
|
882
903
|
return q;
|
|
883
904
|
};
|
|
884
|
-
const visit = (a, b, qa, qb, depth) => {
|
|
885
|
-
const mid = lerp(a, b, 0.5), qm = at(mid), chord2 = lerp(qa, qb, 0.5);
|
|
905
|
+
const visit = (a, b, qa, qb, depth, segment, t0, t1) => {
|
|
906
|
+
const tm = (t0 + t1) / 2, mid = interpolate ? interpolate(segment, tm) : lerp(a, b, 0.5), qm = at(mid), chord2 = lerp(qa, qb, 0.5);
|
|
886
907
|
if (Math.hypot(b[0] - a[0], b[1] - a[1]) > Math.min(step, cellStep / 2) || Math.hypot(qm[0] - chord2[0], qm[1] - chord2[1]) > tolerance) {
|
|
887
908
|
if (depth >= 24)
|
|
888
909
|
throw new Error("Elastic sampling limit exceeded");
|
|
889
|
-
visit(a, mid, qa, qm, depth + 1);
|
|
890
|
-
visit(mid, b, qm, qb, depth + 1);
|
|
910
|
+
visit(a, mid, qa, qm, depth + 1, segment, t0, tm);
|
|
911
|
+
visit(mid, b, qm, qb, depth + 1, segment, tm, t1);
|
|
891
912
|
} else
|
|
892
913
|
emit(b, qb);
|
|
893
914
|
};
|
|
894
915
|
if (line.length) {
|
|
895
916
|
emit(line[0], at(line[0]));
|
|
896
917
|
for (let i = 1; i < line.length; i++)
|
|
897
|
-
visit(line[i - 1], line[i], at(line[i - 1]), at(line[i]), 0);
|
|
918
|
+
visit(line[i - 1], line[i], at(line[i - 1]), at(line[i]), 0, i - 1, 0, 1);
|
|
898
919
|
}
|
|
899
920
|
return { source, xy };
|
|
900
921
|
}
|
|
@@ -1001,7 +1022,7 @@ function fullCoverage(map) {
|
|
|
1001
1022
|
const overlaps = domains.some((domain, i) => domains.slice(i + 1).some((other) => import_polygon_clipping2.default.intersection(domain, other).length > 0));
|
|
1002
1023
|
covered = completeSections && !overlaps && import_polygon_clipping2.default.difference(world, ...domains).length === 0;
|
|
1003
1024
|
} else if (d.type === "world") {
|
|
1004
|
-
covered =
|
|
1025
|
+
covered = directWorldProjections.has(d.projection) && Object.keys(d.parameters ?? {}).length === 0;
|
|
1005
1026
|
}
|
|
1006
1027
|
coverageCache.set(map, covered);
|
|
1007
1028
|
return covered;
|
|
@@ -1016,12 +1037,71 @@ function geographicRings(rings, center3) {
|
|
|
1016
1037
|
});
|
|
1017
1038
|
});
|
|
1018
1039
|
}
|
|
1019
|
-
var import_polygon_clipping2, MapTransitionGeometry, MapTransition, coverageCache;
|
|
1040
|
+
var import_polygon_clipping2, directWorldProjections, MapTransitionGeometry, MapTransition, coverageCache;
|
|
1020
1041
|
var init_map_transition = __esm({
|
|
1021
1042
|
"dist/discontinuous/map-transition.js"() {
|
|
1022
1043
|
import_polygon_clipping2 = __toESM(require("polygon-clipping"), 1);
|
|
1023
1044
|
init_math2();
|
|
1024
1045
|
init_geometry();
|
|
1046
|
+
directWorldProjections = /* @__PURE__ */ new Set([
|
|
1047
|
+
"gilbert",
|
|
1048
|
+
"aitoff",
|
|
1049
|
+
"august",
|
|
1050
|
+
"baker",
|
|
1051
|
+
"boggs",
|
|
1052
|
+
"bromley",
|
|
1053
|
+
"collignon",
|
|
1054
|
+
"craster",
|
|
1055
|
+
"eckert1",
|
|
1056
|
+
"eckert2",
|
|
1057
|
+
"eckert3",
|
|
1058
|
+
"eckert4",
|
|
1059
|
+
"eckert5",
|
|
1060
|
+
"eckert6",
|
|
1061
|
+
"fahey",
|
|
1062
|
+
"foucaut",
|
|
1063
|
+
"ginzburg4",
|
|
1064
|
+
"ginzburg5",
|
|
1065
|
+
"ginzburg6",
|
|
1066
|
+
"ginzburg8",
|
|
1067
|
+
"ginzburg9",
|
|
1068
|
+
"homolosine",
|
|
1069
|
+
"kavrayskiy7",
|
|
1070
|
+
"larrivee",
|
|
1071
|
+
"laskowski",
|
|
1072
|
+
"miller",
|
|
1073
|
+
"mollweide",
|
|
1074
|
+
"mt-flat-polar-parabolic",
|
|
1075
|
+
"mt-flat-polar-quartic",
|
|
1076
|
+
"mt-flat-polar-sinusoidal",
|
|
1077
|
+
"natural-earth2",
|
|
1078
|
+
"nell-hammer",
|
|
1079
|
+
"patterson",
|
|
1080
|
+
"robinson",
|
|
1081
|
+
"sinusoidal",
|
|
1082
|
+
"times",
|
|
1083
|
+
"van-der-grinten",
|
|
1084
|
+
"van-der-grinten2",
|
|
1085
|
+
"van-der-grinten3",
|
|
1086
|
+
"van-der-grinten4",
|
|
1087
|
+
"wagner4",
|
|
1088
|
+
"wagner6",
|
|
1089
|
+
"winkel3",
|
|
1090
|
+
"bonne",
|
|
1091
|
+
"bottomley",
|
|
1092
|
+
"cylindrical-equal-area",
|
|
1093
|
+
"cylindrical-stereographic",
|
|
1094
|
+
"foucaut-sinusoidal",
|
|
1095
|
+
"hammer",
|
|
1096
|
+
"hill",
|
|
1097
|
+
"hufnagel",
|
|
1098
|
+
"hyperelliptical",
|
|
1099
|
+
"lagrange",
|
|
1100
|
+
"loximuthal",
|
|
1101
|
+
"wagner7",
|
|
1102
|
+
"quartic-authalic",
|
|
1103
|
+
"wagner"
|
|
1104
|
+
]);
|
|
1025
1105
|
MapTransitionGeometry = class {
|
|
1026
1106
|
constructor(parts, strategy, radius2) {
|
|
1027
1107
|
this.strategy = strategy;
|
|
@@ -1234,6 +1314,16 @@ function prepareMapFeatures(map, features, options = {}) {
|
|
|
1234
1314
|
throw new Error("Expected a feature array");
|
|
1235
1315
|
if (options.polygonOutlines !== void 0 && typeof options.polygonOutlines !== "boolean")
|
|
1236
1316
|
throw new Error("polygonOutlines must be boolean");
|
|
1317
|
+
const provenance = options.provenance;
|
|
1318
|
+
if (provenance !== void 0 && (!provenance || typeof provenance !== "object" || Array.isArray(provenance)))
|
|
1319
|
+
throw new Error("Unsupported provenance policy");
|
|
1320
|
+
if ((provenance == null ? void 0 : provenance.distances) !== void 0 && (!provenance.distances || typeof provenance.distances !== "object"))
|
|
1321
|
+
throw new Error("Unsupported provenance distance policy");
|
|
1322
|
+
if (provenance && (typeof provenance !== "object" || Object.keys(provenance).some((k2) => !["sourceSegments", "boundaries", "distances", "polygonEdges"].includes(k2)) || [provenance.sourceSegments, provenance.boundaries, provenance.polygonEdges].some((v) => v !== void 0 && typeof v !== "boolean") || provenance.distances && (provenance.distances.metric !== "spherical" || !Number.isFinite(provenance.distances.radius) || provenance.distances.radius <= 0)))
|
|
1323
|
+
throw new Error("Unsupported provenance policy");
|
|
1324
|
+
const edgeKinds = [], edgeRings = [], edgeSegments = [], edgeParameters = [];
|
|
1325
|
+
const lineage = Boolean((provenance == null ? void 0 : provenance.sourceSegments) || (provenance == null ? void 0 : provenance.boundaries) || (provenance == null ? void 0 : provenance.distances));
|
|
1326
|
+
const segments = [], parameters = [], originalVertices = [], distances = [], startReasons = [], endReasons = [];
|
|
1237
1327
|
const regionIds = map.regions.map((r) => r.id), regionIndices = new Map(regionIds.map((id, i) => [id, i]));
|
|
1238
1328
|
const points = vertices(), paths = vertices(), polygons = vertices();
|
|
1239
1329
|
const pointParts = [], pathParts = [], polygonParts = [];
|
|
@@ -1254,7 +1344,27 @@ function prepareMapFeatures(map, features, options = {}) {
|
|
|
1254
1344
|
const isRing = ringIndex !== void 0;
|
|
1255
1345
|
if (isRing && !closed(line))
|
|
1256
1346
|
line.push([...line[0]]);
|
|
1257
|
-
for (const p of map.projectLine(line,
|
|
1347
|
+
for (const p of map.projectLine(line, {
|
|
1348
|
+
...options.sampling,
|
|
1349
|
+
pathProvenance: lineage,
|
|
1350
|
+
pathDistances: Boolean(provenance == null ? void 0 : provenance.distances),
|
|
1351
|
+
pathBoundaries: Boolean(provenance == null ? void 0 : provenance.boundaries)
|
|
1352
|
+
})) {
|
|
1353
|
+
if (lineage) {
|
|
1354
|
+
if (!p.provenance)
|
|
1355
|
+
throw new Error("Map backend does not support path provenance");
|
|
1356
|
+
if (provenance == null ? void 0 : provenance.sourceSegments) {
|
|
1357
|
+
segments.push(...p.provenance.segments);
|
|
1358
|
+
parameters.push(...p.provenance.parameters);
|
|
1359
|
+
originalVertices.push(...p.provenance.vertices);
|
|
1360
|
+
}
|
|
1361
|
+
if (provenance == null ? void 0 : provenance.distances)
|
|
1362
|
+
distances.push(...p.provenance.angularDistances.map((d) => d * provenance.distances.radius));
|
|
1363
|
+
if (provenance == null ? void 0 : provenance.boundaries) {
|
|
1364
|
+
startReasons.push(p.provenance.startReason);
|
|
1365
|
+
endReasons.push(p.provenance.endReason);
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1258
1368
|
append(paths, p.coordinates, p.sourceCoordinates);
|
|
1259
1369
|
pathParts.push({
|
|
1260
1370
|
...part(featureIndex, geometryPath, p.regionId),
|
|
@@ -1266,12 +1376,41 @@ function prepareMapFeatures(map, features, options = {}) {
|
|
|
1266
1376
|
}
|
|
1267
1377
|
};
|
|
1268
1378
|
const addPolygon = (input, featureIndex, geometryPath) => {
|
|
1379
|
+
var _a3;
|
|
1269
1380
|
if (!input.length)
|
|
1270
1381
|
return;
|
|
1271
1382
|
const rings = input.map((r) => r.map(position));
|
|
1272
|
-
const parts = options.sphericalCuts ? map.projectGlobalPolygon(rings, {
|
|
1383
|
+
const parts = options.sphericalCuts ? map.projectGlobalPolygon(rings, {
|
|
1384
|
+
...options.sampling,
|
|
1385
|
+
...options.sphericalCuts,
|
|
1386
|
+
polygonEdgeProvenance: provenance == null ? void 0 : provenance.polygonEdges
|
|
1387
|
+
}) : map.projectPolygon(rings, {
|
|
1388
|
+
...options.sampling,
|
|
1389
|
+
polygonEdgeProvenance: provenance == null ? void 0 : provenance.polygonEdges
|
|
1390
|
+
});
|
|
1273
1391
|
for (const p of parts) {
|
|
1274
1392
|
for (let i = 0; i < p.coordinates.length; i++) {
|
|
1393
|
+
if (provenance == null ? void 0 : provenance.polygonEdges) {
|
|
1394
|
+
const edges = (_a3 = p.edgeProvenance) == null ? void 0 : _a3[i];
|
|
1395
|
+
if (!edges)
|
|
1396
|
+
throw new Error("Map backend does not support polygon edge provenance");
|
|
1397
|
+
const kinds = [
|
|
1398
|
+
"source-boundary",
|
|
1399
|
+
"coverage-boundary",
|
|
1400
|
+
"chart-cut",
|
|
1401
|
+
"continuous-chart-join"
|
|
1402
|
+
];
|
|
1403
|
+
for (const edge2 of edges) {
|
|
1404
|
+
edgeKinds.push(kinds.indexOf(edge2.kind) + 1);
|
|
1405
|
+
edgeRings.push(edge2.ring);
|
|
1406
|
+
edgeSegments.push(edge2.segment);
|
|
1407
|
+
edgeParameters.push(edge2.t0, edge2.t1);
|
|
1408
|
+
}
|
|
1409
|
+
edgeKinds.push(0);
|
|
1410
|
+
edgeRings.push(4294967295);
|
|
1411
|
+
edgeSegments.push(4294967295);
|
|
1412
|
+
edgeParameters.push(0, 0);
|
|
1413
|
+
}
|
|
1275
1414
|
append(polygons, p.coordinates[i], p.sourceCoordinates[i]);
|
|
1276
1415
|
ringStarts.push(polygons.positions.length / 2);
|
|
1277
1416
|
}
|
|
@@ -1335,12 +1474,38 @@ function prepareMapFeatures(map, features, options = {}) {
|
|
|
1335
1474
|
featureIds,
|
|
1336
1475
|
regionIds,
|
|
1337
1476
|
points: { ...pack(points), parts: pointParts },
|
|
1338
|
-
paths: {
|
|
1477
|
+
paths: {
|
|
1478
|
+
...pack(paths),
|
|
1479
|
+
parts: pathParts,
|
|
1480
|
+
pathStarts: new Uint32Array(pathStarts),
|
|
1481
|
+
...lineage ? {
|
|
1482
|
+
provenance: {
|
|
1483
|
+
...(provenance == null ? void 0 : provenance.sourceSegments) ? {
|
|
1484
|
+
sourceSegmentIndices: new Uint32Array(segments),
|
|
1485
|
+
sourceSegmentParameters: new Float64Array(parameters),
|
|
1486
|
+
sourceVertexIndices: new Uint32Array(originalVertices)
|
|
1487
|
+
} : {},
|
|
1488
|
+
...(provenance == null ? void 0 : provenance.distances) ? {
|
|
1489
|
+
sourceDistances: new Float64Array(distances),
|
|
1490
|
+
distanceRadius: provenance.distances.radius
|
|
1491
|
+
} : {},
|
|
1492
|
+
...(provenance == null ? void 0 : provenance.boundaries) ? { startReasons, endReasons } : {}
|
|
1493
|
+
}
|
|
1494
|
+
} : {}
|
|
1495
|
+
},
|
|
1339
1496
|
polygons: {
|
|
1340
1497
|
...pack(polygons),
|
|
1341
1498
|
parts: polygonParts,
|
|
1342
1499
|
ringStarts: new Uint32Array(ringStarts),
|
|
1343
|
-
polygonStarts: new Uint32Array(polygonStarts)
|
|
1500
|
+
polygonStarts: new Uint32Array(polygonStarts),
|
|
1501
|
+
...(provenance == null ? void 0 : provenance.polygonEdges) ? {
|
|
1502
|
+
edgeProvenance: {
|
|
1503
|
+
kinds: new Uint8Array(edgeKinds),
|
|
1504
|
+
sourceRingIndices: new Uint32Array(edgeRings),
|
|
1505
|
+
sourceSegmentIndices: new Uint32Array(edgeSegments),
|
|
1506
|
+
sourceParameterRanges: new Float64Array(edgeParameters)
|
|
1507
|
+
}
|
|
1508
|
+
} : {}
|
|
1344
1509
|
}
|
|
1345
1510
|
};
|
|
1346
1511
|
}
|
|
@@ -1355,6 +1520,181 @@ var init_prepare_features = __esm({
|
|
|
1355
1520
|
}
|
|
1356
1521
|
});
|
|
1357
1522
|
|
|
1523
|
+
// dist/discontinuous/polygon-constraints.js
|
|
1524
|
+
function tracePolygonConstraints(input, output, tolerance = 1e-10, priorities, accept, degenerate) {
|
|
1525
|
+
const constraints = input.flatMap((ring, r) => ring.slice(0, -1).map((a, i) => ({ a, b: ring[i + 1], r, i })));
|
|
1526
|
+
let work = 0;
|
|
1527
|
+
const tick = () => {
|
|
1528
|
+
if (++work > 2e7)
|
|
1529
|
+
throw new Error("Polygon constraint work limit exceeded");
|
|
1530
|
+
};
|
|
1531
|
+
const fraction = (p, a, b) => {
|
|
1532
|
+
const dx = b[0] - a[0], dy = b[1] - a[1], l = dx * dx + dy * dy;
|
|
1533
|
+
return l ? ((p[0] - a[0]) * dx + (p[1] - a[1]) * dy) / l : NaN;
|
|
1534
|
+
};
|
|
1535
|
+
const on = (p, a, b) => {
|
|
1536
|
+
tick();
|
|
1537
|
+
const t = fraction(p, a, b), length = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
1538
|
+
return length > 0 && t >= -tolerance && t <= 1 + tolerance && Math.hypot(p[0] - a[0] - t * (b[0] - a[0]), p[1] - a[1] - t * (b[1] - a[1])) <= tolerance * Math.max(1, length);
|
|
1539
|
+
};
|
|
1540
|
+
const boxes = constraints.map((c) => [
|
|
1541
|
+
Math.min(c.a[0], c.b[0]),
|
|
1542
|
+
Math.min(c.a[1], c.b[1]),
|
|
1543
|
+
Math.max(c.a[0], c.b[0]),
|
|
1544
|
+
Math.max(c.a[1], c.b[1])
|
|
1545
|
+
]);
|
|
1546
|
+
const build = (ids) => {
|
|
1547
|
+
const box = [Infinity, Infinity, -Infinity, -Infinity];
|
|
1548
|
+
for (const id of ids) {
|
|
1549
|
+
tick();
|
|
1550
|
+
const b = boxes[id];
|
|
1551
|
+
box[0] = Math.min(box[0], b[0]);
|
|
1552
|
+
box[1] = Math.min(box[1], b[1]);
|
|
1553
|
+
box[2] = Math.max(box[2], b[2]);
|
|
1554
|
+
box[3] = Math.max(box[3], b[3]);
|
|
1555
|
+
}
|
|
1556
|
+
if (ids.length <= 16)
|
|
1557
|
+
return { box, ids };
|
|
1558
|
+
const axis = box[2] - box[0] >= box[3] - box[1] ? 0 : 1;
|
|
1559
|
+
ids.sort((a, b) => {
|
|
1560
|
+
tick();
|
|
1561
|
+
return boxes[a][axis] + boxes[a][axis + 2] - boxes[b][axis] - boxes[b][axis + 2];
|
|
1562
|
+
});
|
|
1563
|
+
const middle = Math.floor(ids.length / 2);
|
|
1564
|
+
return { box, left: build(ids.slice(0, middle)), right: build(ids.slice(middle)) };
|
|
1565
|
+
};
|
|
1566
|
+
const root = build(constraints.map((_, i) => i));
|
|
1567
|
+
const padding = tolerance * Math.max(1, root.box[2] - root.box[0], root.box[3] - root.box[1]);
|
|
1568
|
+
const query = (a, b) => {
|
|
1569
|
+
const box = [
|
|
1570
|
+
Math.min(a[0], b[0]) - padding,
|
|
1571
|
+
Math.min(a[1], b[1]) - padding,
|
|
1572
|
+
Math.max(a[0], b[0]) + padding,
|
|
1573
|
+
Math.max(a[1], b[1]) + padding
|
|
1574
|
+
], ids = [];
|
|
1575
|
+
const overlaps = (b2) => b2[0] <= box[2] && b2[2] >= box[0] && b2[1] <= box[3] && b2[3] >= box[1];
|
|
1576
|
+
const visit = (node) => {
|
|
1577
|
+
tick();
|
|
1578
|
+
if (!overlaps(node.box))
|
|
1579
|
+
return;
|
|
1580
|
+
if (node.ids) {
|
|
1581
|
+
for (const id of node.ids) {
|
|
1582
|
+
tick();
|
|
1583
|
+
if (overlaps(boxes[id]))
|
|
1584
|
+
ids.push(id);
|
|
1585
|
+
}
|
|
1586
|
+
} else {
|
|
1587
|
+
visit(node.left);
|
|
1588
|
+
visit(node.right);
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
visit(root);
|
|
1592
|
+
return ids.map((id) => constraints[id]);
|
|
1593
|
+
};
|
|
1594
|
+
const rings = [], owners = [];
|
|
1595
|
+
for (const ring of output) {
|
|
1596
|
+
const points = [];
|
|
1597
|
+
for (let i = 1; i < ring.length; i++) {
|
|
1598
|
+
const a = ring[i - 1], b = ring[i];
|
|
1599
|
+
if (a.every((v, k2) => v === b[k2]))
|
|
1600
|
+
continue;
|
|
1601
|
+
const breaks = [{ t: 0, p: a }];
|
|
1602
|
+
for (const c of query(a, b))
|
|
1603
|
+
if (on(c.a, a, b) && (!accept || accept(c.a))) {
|
|
1604
|
+
const t = fraction(c.a, a, b);
|
|
1605
|
+
if (t > 1e-12 && t < 1 - 1e-12)
|
|
1606
|
+
breaks.push({ t, p: c.a });
|
|
1607
|
+
}
|
|
1608
|
+
breaks.sort((a2, b2) => a2.t - b2.t);
|
|
1609
|
+
for (const item of breaks)
|
|
1610
|
+
if (!points.length || Math.hypot(...points[points.length - 1].map((v, k2) => v - item.p[k2])) > 1e-14)
|
|
1611
|
+
points.push([...item.p]);
|
|
1612
|
+
}
|
|
1613
|
+
if (points.length < 3)
|
|
1614
|
+
continue;
|
|
1615
|
+
points.push([...points[0]]);
|
|
1616
|
+
const tags = [];
|
|
1617
|
+
for (let i = 1; i < points.length; i++) {
|
|
1618
|
+
const a = points[i - 1], b = points[i];
|
|
1619
|
+
if (degenerate == null ? void 0 : degenerate(a, b)) {
|
|
1620
|
+
tags.push(null);
|
|
1621
|
+
continue;
|
|
1622
|
+
}
|
|
1623
|
+
let candidates = query(a, b).filter((c) => on(a, c.a, c.b) && on(b, c.a, c.b));
|
|
1624
|
+
const same = (p, q) => Math.hypot(...p.map((v, k2) => v - q[k2])) <= 64 * Number.EPSILON * Math.max(1, ...p.map(Math.abs), ...q.map(Math.abs));
|
|
1625
|
+
const exact = candidates.filter((c) => same(a, c.a) && same(b, c.b) || same(a, c.b) && same(b, c.a));
|
|
1626
|
+
if (exact.length)
|
|
1627
|
+
candidates = exact;
|
|
1628
|
+
if (candidates.some((c) => {
|
|
1629
|
+
var _a3, _b2;
|
|
1630
|
+
return ((_b2 = (_a3 = priorities == null ? void 0 : priorities[c.r]) == null ? void 0 : _a3[c.i]) == null ? void 0 : _b2.kind) === "source-boundary";
|
|
1631
|
+
}))
|
|
1632
|
+
candidates = candidates.filter((c) => {
|
|
1633
|
+
var _a3, _b2;
|
|
1634
|
+
return ((_b2 = (_a3 = priorities == null ? void 0 : priorities[c.r]) == null ? void 0 : _a3[c.i]) == null ? void 0 : _b2.kind) === "source-boundary";
|
|
1635
|
+
});
|
|
1636
|
+
if (candidates.length > 1) {
|
|
1637
|
+
const score = (c) => Math.max(...[a, b].map((p) => {
|
|
1638
|
+
const t = Math.min(1, Math.max(0, fraction(p, c.a, c.b)));
|
|
1639
|
+
return Math.hypot(p[0] - c.a[0] - t * (c.b[0] - c.a[0]), p[1] - c.a[1] - t * (c.b[1] - c.a[1]));
|
|
1640
|
+
}));
|
|
1641
|
+
candidates.sort((a2, b2) => score(a2) - score(b2));
|
|
1642
|
+
const epsilon7 = 64 * Number.EPSILON * Math.max(1, ...a.map(Math.abs), ...b.map(Math.abs));
|
|
1643
|
+
if (score(candidates[1]) - score(candidates[0]) > epsilon7)
|
|
1644
|
+
candidates = [candidates[0]];
|
|
1645
|
+
else if (Math.hypot(a[0] - b[0], a[1] - b[1]) <= 2 * epsilon7)
|
|
1646
|
+
candidates = [];
|
|
1647
|
+
else
|
|
1648
|
+
throw new Error("Ambiguous polygon clipping constraint ancestry");
|
|
1649
|
+
}
|
|
1650
|
+
tags.push(candidates.length ? [candidates[0].r, candidates[0].i] : null);
|
|
1651
|
+
}
|
|
1652
|
+
rings.push(points);
|
|
1653
|
+
owners.push(tags);
|
|
1654
|
+
}
|
|
1655
|
+
return { rings, owners };
|
|
1656
|
+
}
|
|
1657
|
+
function composePolygonEdge(parent, a, b, start, end) {
|
|
1658
|
+
if (parent.kind !== "source-boundary")
|
|
1659
|
+
return { ...parent };
|
|
1660
|
+
const v = geographic(a), length = angle(v, geographic(b));
|
|
1661
|
+
const parameter = (p) => length ? Math.min(1, angle(v, geographic(p)) / length) : 0;
|
|
1662
|
+
return {
|
|
1663
|
+
...parent,
|
|
1664
|
+
t0: parent.t0 + parameter(start) * (parent.t1 - parent.t0),
|
|
1665
|
+
t1: parent.t0 + parameter(end) * (parent.t1 - parent.t0)
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
var init_polygon_constraints = __esm({
|
|
1669
|
+
"dist/discontinuous/polygon-constraints.js"() {
|
|
1670
|
+
init_math2();
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1674
|
+
// dist/discontinuous/source-arc.js
|
|
1675
|
+
function sourceArc(a, b) {
|
|
1676
|
+
const va = geographic(a), vb = geographic(b), length = angle(va, vb);
|
|
1677
|
+
const poleA = Math.abs(a[1]) === 90, poleB = Math.abs(b[1]) === 90;
|
|
1678
|
+
const start = poleA && !poleB ? [b[0], a[1]] : [...a], end = poleB && !poleA ? [a[0], b[1]] : [...b];
|
|
1679
|
+
return (t) => {
|
|
1680
|
+
if (t === 0)
|
|
1681
|
+
return [...start];
|
|
1682
|
+
if (t === 1)
|
|
1683
|
+
return [...end];
|
|
1684
|
+
if (length < 1e-14)
|
|
1685
|
+
return [a[0] + t * (b[0] - a[0]), a[1] + t * (b[1] - a[1])];
|
|
1686
|
+
const p = coordinates(unit(va.map((v, k2) => (Math.sin((1 - t) * length) * v + Math.sin(t * length) * vb[k2]) / Math.sin(length))));
|
|
1687
|
+
const reference = start[0] + t * (end[0] - start[0]);
|
|
1688
|
+
p[0] += 360 * Math.round((reference - p[0]) / 360);
|
|
1689
|
+
return p;
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
var init_source_arc = __esm({
|
|
1693
|
+
"dist/discontinuous/source-arc.js"() {
|
|
1694
|
+
init_math2();
|
|
1695
|
+
}
|
|
1696
|
+
});
|
|
1697
|
+
|
|
1358
1698
|
// dist/discontinuous/map-layout.js
|
|
1359
1699
|
function sampling2(options) {
|
|
1360
1700
|
const step = options.maxAngularStep ?? 2, tolerance = options.tolerance ?? 1e-4;
|
|
@@ -1402,7 +1742,7 @@ var init_map_layout = __esm({
|
|
|
1402
1742
|
EPS = 1e-10;
|
|
1403
1743
|
DiscontinuousMap = class {
|
|
1404
1744
|
constructor(definitions) {
|
|
1405
|
-
var
|
|
1745
|
+
var _a3, _b2;
|
|
1406
1746
|
if (!definitions.length)
|
|
1407
1747
|
throw new Error("At least one map region is required");
|
|
1408
1748
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -1469,12 +1809,12 @@ var init_map_layout = __esm({
|
|
|
1469
1809
|
const byId = new Map(this.regions.map((r) => [r.id, r]));
|
|
1470
1810
|
for (const r of this.regions) {
|
|
1471
1811
|
const visited = /* @__PURE__ */ new Set([r.id]);
|
|
1472
|
-
let parent = (
|
|
1812
|
+
let parent = (_a3 = r.layout) == null ? void 0 : _a3.parentId;
|
|
1473
1813
|
while (parent !== void 0) {
|
|
1474
1814
|
if (!byId.has(parent) || visited.has(parent))
|
|
1475
1815
|
throw new Error("Invalid region parent hierarchy");
|
|
1476
1816
|
visited.add(parent);
|
|
1477
|
-
parent = (
|
|
1817
|
+
parent = (_b2 = byId.get(parent).layout) == null ? void 0 : _b2.parentId;
|
|
1478
1818
|
}
|
|
1479
1819
|
}
|
|
1480
1820
|
this.seams = Object.freeze(this.buildSeams());
|
|
@@ -1546,6 +1886,10 @@ var init_map_layout = __esm({
|
|
|
1546
1886
|
for (let i = 1; i < points.length; i++)
|
|
1547
1887
|
validateArc(points[i - 1], points[i]);
|
|
1548
1888
|
const results = [];
|
|
1889
|
+
const cumulative = options.pathDistances ? [0] : void 0;
|
|
1890
|
+
if (cumulative)
|
|
1891
|
+
for (let i = 1; i < points.length; i++)
|
|
1892
|
+
cumulative.push(cumulative[i - 1] + angle(points[i - 1], points[i]));
|
|
1549
1893
|
for (const r of this.compiled) {
|
|
1550
1894
|
let current = null;
|
|
1551
1895
|
for (let i = 1; i < points.length; i++) {
|
|
@@ -1554,18 +1898,42 @@ var init_map_layout = __esm({
|
|
|
1554
1898
|
current = null;
|
|
1555
1899
|
continue;
|
|
1556
1900
|
}
|
|
1901
|
+
const reason = (p, endpoint, isEndpoint) => {
|
|
1902
|
+
if (isEndpoint && angle(p, endpoint) < 1e-12)
|
|
1903
|
+
return "source-endpoint";
|
|
1904
|
+
const kinds = r.normals.map((normal, edge2) => {
|
|
1905
|
+
var _a3;
|
|
1906
|
+
return Math.abs(dot(normal, p)) < 1e-9 ? (_a3 = this.seams.find((s) => s.regions.some((id, i2) => id === r.definition.id && s.edges[i2] === edge2))) == null ? void 0 : _a3.kind : void 0;
|
|
1907
|
+
}).filter(Boolean);
|
|
1908
|
+
return kinds.includes("boundary") ? "coverage-boundary" : kinds.includes("cut") ? "chart-cut" : kinds.includes("join") ? "continuous-chart-join" : "coverage-boundary";
|
|
1909
|
+
};
|
|
1557
1910
|
const sampled = this.sample(r, clipped[0], clipped[1], settings);
|
|
1558
1911
|
if (sampled.length < 2)
|
|
1559
1912
|
continue;
|
|
1560
1913
|
if (!current || angle(geographic(current.sourceCoordinates[current.sourceCoordinates.length - 1]), clipped[0]) > EPS || !this.sameProjectedPoint(current.coordinates[current.coordinates.length - 1], this.project(r, sampled[0]))) {
|
|
1561
1914
|
current = { regionId: r.definition.id, coordinates: [], sourceCoordinates: [] };
|
|
1915
|
+
if (options.pathProvenance)
|
|
1916
|
+
current.provenance = { segments: [], parameters: [], vertices: [], angularDistances: [] };
|
|
1917
|
+
if (current.provenance && options.pathBoundaries)
|
|
1918
|
+
current.provenance.startReason = reason(clipped[0], points[0], i === 1);
|
|
1562
1919
|
results.push(current);
|
|
1563
1920
|
} else
|
|
1564
1921
|
sampled.shift();
|
|
1565
1922
|
for (const p of sampled) {
|
|
1566
1923
|
current.coordinates.push(this.project(r, p));
|
|
1567
1924
|
current.sourceCoordinates.push(coordinates(p));
|
|
1925
|
+
if (current.provenance) {
|
|
1926
|
+
const length = angle(points[i - 1], points[i]);
|
|
1927
|
+
const t = length ? Math.min(1, Math.max(0, angle(points[i - 1], p) / length)) : 0;
|
|
1928
|
+
current.provenance.segments.push(i - 1);
|
|
1929
|
+
current.provenance.parameters.push(t);
|
|
1930
|
+
current.provenance.vertices.push(angle(points[i - 1], p) < 1e-12 ? i - 1 : angle(points[i], p) < 1e-12 ? i : 4294967295);
|
|
1931
|
+
if (cumulative)
|
|
1932
|
+
current.provenance.angularDistances.push(cumulative[i - 1] + t * length);
|
|
1933
|
+
}
|
|
1568
1934
|
}
|
|
1935
|
+
if (current.provenance && options.pathBoundaries)
|
|
1936
|
+
current.provenance.endReason = reason(clipped[1], points[points.length - 1], i === points.length - 1);
|
|
1569
1937
|
if (!this.contains(r, points[i]))
|
|
1570
1938
|
current = null;
|
|
1571
1939
|
}
|
|
@@ -1662,26 +2030,91 @@ var init_map_layout = __esm({
|
|
|
1662
2030
|
coordinates: [],
|
|
1663
2031
|
sourceCoordinates: []
|
|
1664
2032
|
};
|
|
2033
|
+
if (options.polygonEdgeProvenance)
|
|
2034
|
+
output.edgeProvenance = [];
|
|
1665
2035
|
polygon.forEach((ring, index) => {
|
|
1666
2036
|
const sphere = ring.map((p) => unit(add(center3, add(scale(x, p[0]), scale(y, p[1])))));
|
|
1667
2037
|
const points = [];
|
|
2038
|
+
const edges = [];
|
|
2039
|
+
const classify = (a, b) => {
|
|
2040
|
+
if (angle(a, b) < 64 * Number.EPSILON)
|
|
2041
|
+
return {
|
|
2042
|
+
kind: "continuous-chart-join",
|
|
2043
|
+
ring: 4294967295,
|
|
2044
|
+
segment: 4294967295,
|
|
2045
|
+
t0: 0,
|
|
2046
|
+
t1: 0
|
|
2047
|
+
};
|
|
2048
|
+
const candidates = [];
|
|
2049
|
+
vectors.forEach((source, ring2) => source.forEach((u, segment) => {
|
|
2050
|
+
const v = source[(segment + 1) % source.length], length = angle(u, v);
|
|
2051
|
+
if (length > 1e-12 && [a, b].every((p) => Math.abs(dot(unit(cross(u, v)), p)) < 1e-12 && Math.abs(angle(u, p) + angle(p, v) - length) < 1e-10))
|
|
2052
|
+
candidates.push({ ring: ring2, segment });
|
|
2053
|
+
}));
|
|
2054
|
+
if (candidates.length > 1)
|
|
2055
|
+
throw new Error("Ambiguous polygon boundary provenance");
|
|
2056
|
+
if (candidates.length) {
|
|
2057
|
+
const { ring: ring2, segment } = candidates[0], source = vectors[ring2], u = source[segment], length = angle(u, source[(segment + 1) % source.length]);
|
|
2058
|
+
return {
|
|
2059
|
+
kind: "source-boundary",
|
|
2060
|
+
ring: ring2,
|
|
2061
|
+
segment,
|
|
2062
|
+
t0: Math.min(1, angle(u, a) / length),
|
|
2063
|
+
t1: Math.min(1, angle(u, b) / length)
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
const kinds = r.normals.map((n, edge2) => {
|
|
2067
|
+
var _a3;
|
|
2068
|
+
return [a, b].every((p) => Math.abs(dot(n, p)) < 1e-9) ? (_a3 = this.seams.find((s) => s.regions.some((id, i) => id === r.definition.id && s.edges[i] === edge2))) == null ? void 0 : _a3.kind : void 0;
|
|
2069
|
+
}).filter(Boolean);
|
|
2070
|
+
if (!kinds.length)
|
|
2071
|
+
throw new Error("Unknown polygon clipping constraint");
|
|
2072
|
+
return {
|
|
2073
|
+
kind: kinds.includes("boundary") ? "coverage-boundary" : kinds.includes("cut") ? "chart-cut" : "continuous-chart-join",
|
|
2074
|
+
ring: 4294967295,
|
|
2075
|
+
segment: 4294967295,
|
|
2076
|
+
t0: 0,
|
|
2077
|
+
t1: 0
|
|
2078
|
+
};
|
|
2079
|
+
};
|
|
1668
2080
|
for (let i = 1; i < sphere.length; i++) {
|
|
2081
|
+
const origin2 = options.polygonEdgeProvenance && !sphere[i - 1].every((value2, k2) => value2 === sphere[i][k2]) ? classify(sphere[i - 1], sphere[i]) : void 0;
|
|
1669
2082
|
const sampled = this.sample(r, sphere[i - 1], sphere[i], settings);
|
|
1670
2083
|
for (const point of sampled) {
|
|
1671
2084
|
const previous = points[points.length - 1];
|
|
1672
|
-
if (!previous || !point.every((value2, k2) => value2 === previous[k2]))
|
|
2085
|
+
if (!previous || !point.every((value2, k2) => value2 === previous[k2])) {
|
|
2086
|
+
if (previous && origin2) {
|
|
2087
|
+
const edge2 = { ...origin2 };
|
|
2088
|
+
if (edge2.kind === "source-boundary") {
|
|
2089
|
+
const source = vectors[edge2.ring], u = source[edge2.segment], length = angle(u, source[(edge2.segment + 1) % source.length]);
|
|
2090
|
+
edge2.t0 = Math.min(1, angle(u, previous) / length);
|
|
2091
|
+
edge2.t1 = Math.min(1, angle(u, point) / length);
|
|
2092
|
+
}
|
|
2093
|
+
edges.push(edge2);
|
|
2094
|
+
}
|
|
1673
2095
|
points.push(point);
|
|
2096
|
+
}
|
|
1674
2097
|
}
|
|
1675
2098
|
}
|
|
1676
2099
|
if (points.length < 3)
|
|
1677
2100
|
return;
|
|
1678
2101
|
if (points[points.length - 1].every((value2, k2) => value2 === points[0][k2]))
|
|
1679
2102
|
points.pop();
|
|
2103
|
+
if (options.polygonEdgeProvenance && edges.length < points.length)
|
|
2104
|
+
edges.push(classify(points[points.length - 1], points[0]));
|
|
1680
2105
|
points.push(points[0]);
|
|
1681
2106
|
const xy = points.map((p) => this.project(r, p));
|
|
1682
2107
|
if (ringOrientation(xy) > 0 !== (index === 0)) {
|
|
1683
2108
|
xy.reverse();
|
|
1684
2109
|
points.reverse();
|
|
2110
|
+
edges.reverse();
|
|
2111
|
+
for (const e of edges)
|
|
2112
|
+
[e.t0, e.t1] = [e.t1, e.t0];
|
|
2113
|
+
}
|
|
2114
|
+
if (output.edgeProvenance) {
|
|
2115
|
+
if (edges.length !== points.length - 1)
|
|
2116
|
+
throw new Error("Mismatched polygon edge provenance");
|
|
2117
|
+
output.edgeProvenance.push(edges);
|
|
1685
2118
|
}
|
|
1686
2119
|
output.coordinates.push(xy);
|
|
1687
2120
|
output.sourceCoordinates.push(points.map(coordinates));
|
|
@@ -1794,6 +2227,8 @@ var CapMap;
|
|
|
1794
2227
|
var init_cap_map = __esm({
|
|
1795
2228
|
"dist/discontinuous/cap-map.js"() {
|
|
1796
2229
|
init_clip_circle();
|
|
2230
|
+
init_polygon_constraints();
|
|
2231
|
+
init_source_arc();
|
|
1797
2232
|
init_circle();
|
|
1798
2233
|
init_map_layout();
|
|
1799
2234
|
init_math2();
|
|
@@ -1850,10 +2285,11 @@ var init_cap_map = __esm({
|
|
|
1850
2285
|
unprojectPoint(p, id) {
|
|
1851
2286
|
return super.unprojectPoint(p, id).filter((q) => this.visible(q.position));
|
|
1852
2287
|
}
|
|
1853
|
-
clip(rings, polygon, options, regionId) {
|
|
2288
|
+
clip(rings, polygon, options, regionId, segmentIndices) {
|
|
1854
2289
|
const output = [];
|
|
1855
2290
|
const originals = /* @__PURE__ */ new Map();
|
|
1856
|
-
let ring = [];
|
|
2291
|
+
let ring = [], indices = [], activeSegment = 0;
|
|
2292
|
+
let previousInput, currentInput;
|
|
1857
2293
|
const precision = Math.min((options == null ? void 0 : options.maxAngularStep) ?? 2, Math.sqrt(((options == null ? void 0 : options.tolerance) ?? 1e-4) / this.radius) / RAD / 4) * RAD;
|
|
1858
2294
|
if (!Number.isFinite(precision) || 2 * Math.PI / precision > 1e6)
|
|
1859
2295
|
throw new Error("Projection sampling limit exceeded; relax tolerance");
|
|
@@ -1908,14 +2344,49 @@ var init_cap_map = __esm({
|
|
|
1908
2344
|
point: (x, y) => {
|
|
1909
2345
|
if (++emitted > 1e6)
|
|
1910
2346
|
throw new Error("Projection sampling limit exceeded; relax tolerance");
|
|
1911
|
-
|
|
2347
|
+
let source = originals.get(`${x},${y}`);
|
|
2348
|
+
if (!source && !polygon && this.nonlinear && previousInput && currentInput) {
|
|
2349
|
+
const a = geographic(previousInput), b = geographic(currentInput), length = angle(a, b);
|
|
2350
|
+
const at = (t) => length < 1e-14 ? [...currentInput] : coordinates(unit(a.map((v, k2) => (Math.sin((1 - t) * length) * v + Math.sin(t * length) * b[k2]) / Math.sin(length))));
|
|
2351
|
+
const value2 = (t) => geographic(local(at(t)))[0] - Math.cos(this.cap);
|
|
2352
|
+
const approximate = this.source([x / RAD, y / RAD]);
|
|
2353
|
+
const reference = length ? Math.min(1, angle(a, geographic(approximate)) / length) : 0;
|
|
2354
|
+
const roots = [];
|
|
2355
|
+
for (let j = 0; j < 32; j++) {
|
|
2356
|
+
let lo = j / 32, hi = (j + 1) / 32, f = value2(lo), g = value2(hi);
|
|
2357
|
+
if (Math.abs(f) < 1e-14)
|
|
2358
|
+
roots.push(lo);
|
|
2359
|
+
if (f * g >= 0)
|
|
2360
|
+
continue;
|
|
2361
|
+
for (let k2 = 0; k2 < 52; k2++) {
|
|
2362
|
+
const mid = (lo + hi) / 2;
|
|
2363
|
+
if (value2(mid) >= 0 === f >= 0)
|
|
2364
|
+
lo = mid;
|
|
2365
|
+
else
|
|
2366
|
+
hi = mid;
|
|
2367
|
+
}
|
|
2368
|
+
roots.push((lo + hi) / 2);
|
|
2369
|
+
}
|
|
2370
|
+
if (Math.abs(value2(1)) < 1e-14)
|
|
2371
|
+
roots.push(1);
|
|
2372
|
+
if (!roots.length)
|
|
2373
|
+
throw new Error("Unresolved nonlinear cap source intersection");
|
|
2374
|
+
roots.sort((a2, b2) => Math.abs(a2 - reference) - Math.abs(b2 - reference));
|
|
2375
|
+
source = at(roots[0]);
|
|
2376
|
+
}
|
|
2377
|
+
ring.push(source ?? this.source([x / RAD, y / RAD]));
|
|
2378
|
+
if (segmentIndices)
|
|
2379
|
+
indices.push(activeSegment);
|
|
1912
2380
|
},
|
|
1913
2381
|
lineStart: () => {
|
|
1914
2382
|
ring = [];
|
|
2383
|
+
indices = [];
|
|
1915
2384
|
},
|
|
1916
2385
|
lineEnd: () => {
|
|
1917
|
-
if (ring.length > 1)
|
|
2386
|
+
if (ring.length > 1) {
|
|
1918
2387
|
output.push(ring);
|
|
2388
|
+
segmentIndices == null ? void 0 : segmentIndices.push(indices);
|
|
2389
|
+
}
|
|
1919
2390
|
},
|
|
1920
2391
|
polygonStart: () => {
|
|
1921
2392
|
},
|
|
@@ -1932,7 +2403,9 @@ var init_cap_map = __esm({
|
|
|
1932
2403
|
}
|
|
1933
2404
|
const x = q[0] * RAD, y = q[1] * RAD;
|
|
1934
2405
|
originals.set(`${x},${y}`, [...p]);
|
|
2406
|
+
currentInput = p;
|
|
1935
2407
|
stream.point(x, y);
|
|
2408
|
+
previousInput = p;
|
|
1936
2409
|
};
|
|
1937
2410
|
const subdivide = (a, b, depth = 0) => {
|
|
1938
2411
|
if (this.nonlinear && depth < 20) {
|
|
@@ -1949,11 +2422,14 @@ var init_cap_map = __esm({
|
|
|
1949
2422
|
emit(b);
|
|
1950
2423
|
};
|
|
1951
2424
|
for (const points of rings) {
|
|
2425
|
+
previousInput = void 0;
|
|
1952
2426
|
stream.lineStart();
|
|
1953
2427
|
if (points.length)
|
|
1954
2428
|
emit(points[0]);
|
|
1955
|
-
for (let i = 1; i < points.length; i++)
|
|
2429
|
+
for (let i = 1; i < points.length; i++) {
|
|
2430
|
+
activeSegment = i - 1;
|
|
1956
2431
|
subdivide(points[i - 1], points[i]);
|
|
2432
|
+
}
|
|
1957
2433
|
if (polygon && points.length)
|
|
1958
2434
|
subdivide(points[points.length - 1], points[0]);
|
|
1959
2435
|
stream.lineEnd();
|
|
@@ -1965,7 +2441,41 @@ var init_cap_map = __esm({
|
|
|
1965
2441
|
projectLine(line, options) {
|
|
1966
2442
|
if (this.cap === Math.PI / 2 && !this.nonlinear)
|
|
1967
2443
|
return super.projectLine(line, options);
|
|
1968
|
-
return super.projectLine(line, options).flatMap((part) =>
|
|
2444
|
+
return super.projectLine(line, options).flatMap((part) => {
|
|
2445
|
+
const indices = part.provenance ? [] : void 0;
|
|
2446
|
+
const clipped = this.clip([part.sourceCoordinates], false, options, part.regionId, indices);
|
|
2447
|
+
return clipped.flatMap((points, piece) => super.projectLine(points, options).filter((q) => q.regionId === part.regionId).map((q) => {
|
|
2448
|
+
const parent = part.provenance, child2 = q.provenance;
|
|
2449
|
+
if (!parent || !child2)
|
|
2450
|
+
return q;
|
|
2451
|
+
const provenance = {
|
|
2452
|
+
segments: [],
|
|
2453
|
+
parameters: [],
|
|
2454
|
+
vertices: [],
|
|
2455
|
+
angularDistances: []
|
|
2456
|
+
};
|
|
2457
|
+
for (let j = 0; j < q.sourceCoordinates.length; j++) {
|
|
2458
|
+
const k2 = child2.segments[j];
|
|
2459
|
+
const edge2 = indices[piece][k2 + 1];
|
|
2460
|
+
const a = geographic(part.sourceCoordinates[edge2]), b = geographic(part.sourceCoordinates[edge2 + 1]), p = geographic(q.sourceCoordinates[j]);
|
|
2461
|
+
const length = angle(a, b), t = length ? Math.min(1, angle(a, p) / length) : 0;
|
|
2462
|
+
const endpoint = t < 1e-12 ? edge2 : t > 1 - 1e-12 ? edge2 + 1 : -1;
|
|
2463
|
+
const segment = parent.segments[edge2 + 1];
|
|
2464
|
+
const from = parent.segments[edge2] === segment ? parent.parameters[edge2] : 0;
|
|
2465
|
+
provenance.segments.push(endpoint >= 0 ? parent.segments[endpoint] : segment);
|
|
2466
|
+
provenance.parameters.push(endpoint >= 0 ? parent.parameters[endpoint] : from + t * (parent.parameters[edge2 + 1] - from));
|
|
2467
|
+
provenance.vertices.push(endpoint >= 0 ? parent.vertices[endpoint] : 4294967295);
|
|
2468
|
+
if (options == null ? void 0 : options.pathDistances)
|
|
2469
|
+
provenance.angularDistances.push(parent.angularDistances[edge2] + t * (parent.angularDistances[edge2 + 1] - parent.angularDistances[edge2]));
|
|
2470
|
+
}
|
|
2471
|
+
if (options == null ? void 0 : options.pathBoundaries) {
|
|
2472
|
+
const same = (a, b) => angle(geographic(a), geographic(b)) < 1e-12;
|
|
2473
|
+
provenance.startReason = same(q.sourceCoordinates[0], part.sourceCoordinates[0]) ? parent.startReason : "coverage-boundary";
|
|
2474
|
+
provenance.endReason = same(q.sourceCoordinates[q.sourceCoordinates.length - 1], part.sourceCoordinates[part.sourceCoordinates.length - 1]) ? parent.endReason : "coverage-boundary";
|
|
2475
|
+
}
|
|
2476
|
+
return { ...q, provenance };
|
|
2477
|
+
}));
|
|
2478
|
+
});
|
|
1969
2479
|
}
|
|
1970
2480
|
projectPolygon(rings, options) {
|
|
1971
2481
|
if (this.cap === Math.PI / 2 && !this.nonlinear)
|
|
@@ -2038,15 +2548,95 @@ var init_cap_map = __esm({
|
|
|
2038
2548
|
};
|
|
2039
2549
|
for (const ring of outer) {
|
|
2040
2550
|
const plane = ring.map(planar), sources = [ring, ...holes.filter((h2) => contains2(plane, planar(h2[0])))];
|
|
2551
|
+
const parentPlane = part.sourceCoordinates.map((r) => r.map(planar));
|
|
2552
|
+
const fromPlane = (p) => coordinates(unit(center3.map((v, k2) => v + x[k2] * p[0] + y[k2] * p[1])));
|
|
2553
|
+
const traced = tracePolygonConstraints(parentPlane, sources.map((r) => r.map(planar)), this.nonlinear ? 2e-6 : 1e-10, part.edgeProvenance, (p) => this.visible(fromPlane(p)));
|
|
2554
|
+
const resolved2 = traced.rings.map((r) => r.map(fromPlane));
|
|
2555
|
+
traced.owners.forEach((owners, r) => owners.forEach((owner, i) => {
|
|
2556
|
+
if (!owner)
|
|
2557
|
+
return;
|
|
2558
|
+
const [pr, pe] = owner, a = part.sourceCoordinates[pr][pe], b = part.sourceCoordinates[pr][pe + 1], at = sourceArc(a, b);
|
|
2559
|
+
for (const j of [i, i + 1]) {
|
|
2560
|
+
const point = resolved2[r][j], distance3 = angle(geographic(a), geographic(b)), fraction = distance3 ? angle(geographic(a), geographic(point)) / distance3 : 0;
|
|
2561
|
+
if (fraction < 1e-10)
|
|
2562
|
+
resolved2[r][j] = [...a];
|
|
2563
|
+
else if (fraction > 1 - 1e-10)
|
|
2564
|
+
resolved2[r][j] = [...b];
|
|
2565
|
+
else if (Math.hypot(...cross(geographic(a), geographic(b))) > 1e-14 && Math.abs(dot(unit(cross(geographic(a), geographic(b))), geographic(point))) < 1e-12) {
|
|
2566
|
+
resolved2[r][j] = at(Math.min(1, Math.max(0, fraction)));
|
|
2567
|
+
} else {
|
|
2568
|
+
const value2 = (t) => geographic(this.local(at(t)))[0] - Math.cos(this.cap), roots = [];
|
|
2569
|
+
for (let k2 = 0; k2 < 32; k2++) {
|
|
2570
|
+
let lo = k2 / 32, hi = (k2 + 1) / 32, f = value2(lo), g = value2(hi);
|
|
2571
|
+
if (Math.abs(f) < 1e-13)
|
|
2572
|
+
roots.push(lo);
|
|
2573
|
+
if (f * g >= 0)
|
|
2574
|
+
continue;
|
|
2575
|
+
for (let n = 0; n < 52; n++) {
|
|
2576
|
+
const mid = (lo + hi) / 2;
|
|
2577
|
+
if (value2(mid) >= 0 === f >= 0)
|
|
2578
|
+
lo = mid;
|
|
2579
|
+
else
|
|
2580
|
+
hi = mid;
|
|
2581
|
+
}
|
|
2582
|
+
roots.push((lo + hi) / 2);
|
|
2583
|
+
}
|
|
2584
|
+
if (Math.abs(value2(1)) < 1e-13)
|
|
2585
|
+
roots.push(1);
|
|
2586
|
+
if (!roots.length)
|
|
2587
|
+
throw new Error("Unresolved cap polygon source intersection");
|
|
2588
|
+
roots.sort((a2, b2) => Math.abs(a2 - fraction) - Math.abs(b2 - fraction));
|
|
2589
|
+
resolved2[r][j] = at(roots[0]);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
}));
|
|
2593
|
+
for (const ring2 of resolved2)
|
|
2594
|
+
ring2[ring2.length - 1] = [...ring2[0]];
|
|
2041
2595
|
result.push({
|
|
2042
2596
|
regionId: part.regionId,
|
|
2043
|
-
sourceCoordinates:
|
|
2044
|
-
coordinates:
|
|
2597
|
+
sourceCoordinates: resolved2,
|
|
2598
|
+
coordinates: resolved2.map((r) => r.map((p) => {
|
|
2045
2599
|
const q = super.projectPoint(p, part.regionId);
|
|
2046
2600
|
if (!q)
|
|
2047
|
-
throw new Error(
|
|
2601
|
+
throw new Error("Cap polygon source constraint left its owning chart");
|
|
2048
2602
|
return q.position;
|
|
2049
|
-
}))
|
|
2603
|
+
})),
|
|
2604
|
+
...(options == null ? void 0 : options.polygonEdgeProvenance) ? {
|
|
2605
|
+
edgeProvenance: traced.owners.map((owners, r) => owners.map((owner, i) => {
|
|
2606
|
+
const a = resolved2[r][i], b = resolved2[r][i + 1];
|
|
2607
|
+
if (owner) {
|
|
2608
|
+
const [pr, pe] = owner;
|
|
2609
|
+
return composePolygonEdge(part.edgeProvenance[pr][pe], part.sourceCoordinates[pr][pe], part.sourceCoordinates[pr][pe + 1], a, b);
|
|
2610
|
+
}
|
|
2611
|
+
if (angle(geographic(a), geographic(b)) < 64 * Number.EPSILON)
|
|
2612
|
+
return {
|
|
2613
|
+
kind: "continuous-chart-join",
|
|
2614
|
+
ring: 4294967295,
|
|
2615
|
+
segment: 4294967295,
|
|
2616
|
+
t0: 0,
|
|
2617
|
+
t1: 0
|
|
2618
|
+
};
|
|
2619
|
+
const kinds = [];
|
|
2620
|
+
region.boundary.forEach((p, j) => {
|
|
2621
|
+
const n = cross(geographic(p), geographic(region.boundary[(j + 1) % region.boundary.length])), length = Math.hypot(...n);
|
|
2622
|
+
if (length && [a, b].every((p2) => Math.abs(dot(n, geographic(p2))) / length < 1e-9)) {
|
|
2623
|
+
const seam = this.seams.find((s) => s.regions.some((id, k2) => id === region.id && s.edges[k2] === j));
|
|
2624
|
+
if (seam)
|
|
2625
|
+
kinds.push(seam.kind);
|
|
2626
|
+
}
|
|
2627
|
+
});
|
|
2628
|
+
const horizon = [a, b].every((p) => Math.abs(geographic(this.local(p))[0] - Math.cos(this.cap)) < 1e-7);
|
|
2629
|
+
if (!horizon && !kinds.length)
|
|
2630
|
+
throw new Error("Unknown cap polygon clipping constraint");
|
|
2631
|
+
return {
|
|
2632
|
+
kind: horizon ? "coverage-boundary" : kinds.includes("boundary") ? "coverage-boundary" : kinds.includes("cut") ? "chart-cut" : "continuous-chart-join",
|
|
2633
|
+
ring: 4294967295,
|
|
2634
|
+
segment: 4294967295,
|
|
2635
|
+
t0: 0,
|
|
2636
|
+
t1: 0
|
|
2637
|
+
};
|
|
2638
|
+
}))
|
|
2639
|
+
} : {}
|
|
2050
2640
|
});
|
|
2051
2641
|
}
|
|
2052
2642
|
}
|
|
@@ -3782,9 +4372,9 @@ function lazy(factory) {
|
|
|
3782
4372
|
return kernel2(x, y);
|
|
3783
4373
|
};
|
|
3784
4374
|
forward33.invert = (x, y) => {
|
|
3785
|
-
var
|
|
4375
|
+
var _a3;
|
|
3786
4376
|
kernel2 ?? (kernel2 = factory());
|
|
3787
|
-
return (
|
|
4377
|
+
return (_a3 = kernel2.invert) == null ? void 0 : _a3.call(kernel2, x, y);
|
|
3788
4378
|
};
|
|
3789
4379
|
return forward33;
|
|
3790
4380
|
}
|
|
@@ -4064,14 +4654,14 @@ function createKernelMap({ kernel: kernel2, radius: radius2 = 1, centralMeridian
|
|
|
4064
4654
|
const inside = (p) => (p == null ? void 0 : p.length) === 2 && p.every(Number.isFinite) && p[0] >= west - 1e-9 && p[0] <= east + 1e-9 && p[1] >= south - 1e-9 && p[1] <= north + 1e-9 && (!clipAngle || Math.cos(p[0]) * Math.cos(p[1]) >= Math.cos(cap2) - 1e-12);
|
|
4065
4655
|
const error = (p, target) => Math.hypot(p[0] - target[0], p[1] - target[1]);
|
|
4066
4656
|
const invert = (target) => {
|
|
4067
|
-
var
|
|
4657
|
+
var _a3;
|
|
4068
4658
|
const pole = sign5 * HALF, left = raw(west, pole), right = raw(east, pole);
|
|
4069
4659
|
const dx = right[0] - left[0], dy = right[1] - left[1], length = dx * dx + dy * dy;
|
|
4070
4660
|
const fraction = length ? clamp(((target[0] - left[0]) * dx + (target[1] - left[1]) * dy) / length, 0, 1) : 0.5;
|
|
4071
4661
|
const poleLambda = west + fraction * (east - west);
|
|
4072
4662
|
if (inside([poleLambda, pole]) && error(raw(poleLambda, pole), target) < 1e-13)
|
|
4073
4663
|
return [poleLambda, pole];
|
|
4074
|
-
const candidate = (
|
|
4664
|
+
const candidate = (_a3 = raw.invert) == null ? void 0 : _a3.call(raw, target[0], target[1]);
|
|
4075
4665
|
if (candidate && inside(candidate) && error(raw(candidate[0], candidate[1]), target) < 1e-10)
|
|
4076
4666
|
return [clamp(candidate[0], west, east), clamp(candidate[1], south, north)];
|
|
4077
4667
|
const ordered2 = seeds.map((p, j) => ({ p, error: error(projectedSeeds[j], target) })).filter((s) => Number.isFinite(s.error) && inside(s.p) && Math.abs(s.p[1]) < HALF - 1e-10).sort((a, b) => a.error - b.error);
|
|
@@ -4322,6 +4912,101 @@ var init_grid = __esm({
|
|
|
4322
4912
|
}
|
|
4323
4913
|
});
|
|
4324
4914
|
|
|
4915
|
+
// dist/discontinuous/elastic/source-arc.js
|
|
4916
|
+
function clipSourceArc(a, b, polygons) {
|
|
4917
|
+
const at = sourceArc(a, b), va = geographic(a), vb = geographic(b), omega = angle(va, vb), ts = [0, 1];
|
|
4918
|
+
let work = 0;
|
|
4919
|
+
const tick = () => {
|
|
4920
|
+
if (++work > 1e6)
|
|
4921
|
+
throw new Error("Elastic source clipping limit exceeded");
|
|
4922
|
+
};
|
|
4923
|
+
const linear = omega < 1e-14 || Math.abs(a[1]) < 1e-12 && Math.abs(b[1]) < 1e-12 || Math.abs(at(0)[0] - at(1)[0]) < 1e-12;
|
|
4924
|
+
const tangent = omega > 1e-14 ? va.map((v, k2) => (vb[k2] - v * Math.cos(omega)) / Math.sin(omega)) : [0, 0, 0];
|
|
4925
|
+
const momentum = Math.abs(omega * (va[0] * tangent[1] - va[1] * tangent[0])) + 64 * Number.EPSILON * omega;
|
|
4926
|
+
const vector = (t) => va.map((v, k2) => v * Math.cos(omega * t) + tangent[k2] * Math.sin(omega * t));
|
|
4927
|
+
const derivative = (t) => va.map((v, k2) => omega * (-v * Math.sin(omega * t) + tangent[k2] * Math.cos(omega * t)));
|
|
4928
|
+
for (const rings of polygons)
|
|
4929
|
+
for (const ring of rings)
|
|
4930
|
+
for (let edge2 = 1; edge2 < ring.length; edge2++) {
|
|
4931
|
+
const c = ring[edge2 - 1], d = ring[edge2], dx = d[0] - c[0], dy = d[1] - c[1], length = Math.hypot(dx, dy);
|
|
4932
|
+
if (!length)
|
|
4933
|
+
continue;
|
|
4934
|
+
const angular = omega / RAD, latitude = Math.min(90, Math.max(Math.abs(a[1]), Math.abs(b[1])) + angular), cosine2 = Math.cos(latitude * RAD), longitude3 = cosine2 > 1e-10 ? angular / cosine2 : 360;
|
|
4935
|
+
if (Math.max(c[1], d[1]) < Math.min(a[1], b[1]) - angular - 1e-10 || Math.min(c[1], d[1]) > Math.max(a[1], b[1]) + angular + 1e-10 || Math.max(c[0], d[0]) < Math.min(a[0], b[0]) - longitude3 - 1e-10 || Math.min(c[0], d[0]) > Math.max(a[0], b[0]) + longitude3 + 1e-10)
|
|
4936
|
+
continue;
|
|
4937
|
+
const value2 = (t) => {
|
|
4938
|
+
tick();
|
|
4939
|
+
const p = at(t);
|
|
4940
|
+
return ((p[0] - c[0]) * dy - (p[1] - c[1]) * dx) / length;
|
|
4941
|
+
};
|
|
4942
|
+
const put = (t) => {
|
|
4943
|
+
const p = at(t), u = ((p[0] - c[0]) * dx + (p[1] - c[1]) * dy) / (length * length);
|
|
4944
|
+
if (u >= -1e-10 && u <= 1 + 1e-10)
|
|
4945
|
+
ts.push(t);
|
|
4946
|
+
};
|
|
4947
|
+
const bisect = (lo, hi, f) => {
|
|
4948
|
+
for (let k2 = 0; k2 < 52; k2++) {
|
|
4949
|
+
const mid = (lo + hi) / 2;
|
|
4950
|
+
if (value2(mid) >= 0 === f >= 0)
|
|
4951
|
+
lo = mid;
|
|
4952
|
+
else
|
|
4953
|
+
hi = mid;
|
|
4954
|
+
}
|
|
4955
|
+
put((lo + hi) / 2);
|
|
4956
|
+
};
|
|
4957
|
+
const visit = (lo, hi, depth) => {
|
|
4958
|
+
tick();
|
|
4959
|
+
const f = value2(lo), g = value2(hi), mid = (lo + hi) / 2, h2 = (hi - lo) / 2;
|
|
4960
|
+
if (Math.abs(f) < 1e-12)
|
|
4961
|
+
put(lo);
|
|
4962
|
+
if (Math.abs(g) < 1e-12)
|
|
4963
|
+
put(hi);
|
|
4964
|
+
if (linear) {
|
|
4965
|
+
if (f * g < 0)
|
|
4966
|
+
bisect(lo, hi, f);
|
|
4967
|
+
return;
|
|
4968
|
+
}
|
|
4969
|
+
const v = vector(mid), dv = derivative(mid), r2 = v[0] * v[0] + v[1] * v[1];
|
|
4970
|
+
const df = ((v[0] * dv[1] - v[1] * dv[0]) / r2 * dy - dv[2] / Math.sqrt(r2) * dx) / (RAD * length);
|
|
4971
|
+
let z = Math.max(Math.abs(vector(lo)[2]), Math.abs(vector(hi)[2]));
|
|
4972
|
+
const phase = Math.atan2(tangent[2], va[2]);
|
|
4973
|
+
for (let k2 = -2; k2 <= 2; k2++) {
|
|
4974
|
+
const theta = phase + k2 * Math.PI;
|
|
4975
|
+
if (theta >= omega * lo && theta <= omega * hi)
|
|
4976
|
+
z = Math.max(z, Math.hypot(va[2], tangent[2]));
|
|
4977
|
+
}
|
|
4978
|
+
const r = Math.sqrt(Math.max(0, 1 - Math.min(1, z) ** 2));
|
|
4979
|
+
const second = r ? (2 * momentum * omega * Math.abs(dy) / r ** 4 + omega ** 2 * Math.abs(dx) * (1 / r + 1 / r ** 3)) / (RAD * length) : Infinity;
|
|
4980
|
+
if (Number.isFinite(df) && Math.abs(df) > second * h2 + 1e-12) {
|
|
4981
|
+
if (f * g < 0)
|
|
4982
|
+
bisect(lo, hi, f);
|
|
4983
|
+
return;
|
|
4984
|
+
}
|
|
4985
|
+
const speed = r ? (momentum * Math.abs(dy) / r ** 2 + omega * Math.abs(dx)) / (RAD * length) : Infinity;
|
|
4986
|
+
if (Math.abs(value2(mid)) > speed * h2 + 1e-12)
|
|
4987
|
+
return;
|
|
4988
|
+
if (depth >= 24)
|
|
4989
|
+
throw new Error("Unresolved Elastic source clipping tangent or pole");
|
|
4990
|
+
visit(lo, mid, depth + 1);
|
|
4991
|
+
visit(mid, hi, depth + 1);
|
|
4992
|
+
};
|
|
4993
|
+
visit(0, 1, 0);
|
|
4994
|
+
}
|
|
4995
|
+
ts.sort((a2, b2) => a2 - b2);
|
|
4996
|
+
const result = [];
|
|
4997
|
+
for (let i = 1; i < ts.length; i++)
|
|
4998
|
+
if (ts[i] - ts[i - 1] > 1e-12 && contains(polygons, at((ts[i] + ts[i - 1]) / 2)))
|
|
4999
|
+
result.push({ a: at(ts[i - 1]), b: at(ts[i]) });
|
|
5000
|
+
return result;
|
|
5001
|
+
}
|
|
5002
|
+
var init_source_arc2 = __esm({
|
|
5003
|
+
"dist/discontinuous/elastic/source-arc.js"() {
|
|
5004
|
+
init_math2();
|
|
5005
|
+
init_geometry();
|
|
5006
|
+
init_source_arc();
|
|
5007
|
+
}
|
|
5008
|
+
});
|
|
5009
|
+
|
|
4325
5010
|
// dist/discontinuous/elastic/map.js
|
|
4326
5011
|
function createElasticMap(data, options = {}) {
|
|
4327
5012
|
return new ElasticMap(data, options.radius ?? 1);
|
|
@@ -4331,7 +5016,7 @@ function wrap2(lon) {
|
|
|
4331
5016
|
return x > 180 ? x - 360 : x < -180 ? x + 360 : x;
|
|
4332
5017
|
}
|
|
4333
5018
|
function snapPolygon(rings) {
|
|
4334
|
-
return rings.map((
|
|
5019
|
+
return rings.map((r) => r.map((p) => p.map((v) => Math.round(v * 1e10) / 1e10)));
|
|
4335
5020
|
}
|
|
4336
5021
|
var import_polygon_clipping4, kernel, splitter, ElasticMap;
|
|
4337
5022
|
var init_map = __esm({
|
|
@@ -4341,15 +5026,18 @@ var init_map = __esm({
|
|
|
4341
5026
|
init_math2();
|
|
4342
5027
|
init_grid();
|
|
4343
5028
|
init_geometry();
|
|
5029
|
+
init_source_arc2();
|
|
5030
|
+
init_source_arc();
|
|
5031
|
+
init_polygon_constraints();
|
|
4344
5032
|
kernel = Object.assign((x, y) => [x, y], {
|
|
4345
5033
|
invert: (x, y) => [x, y]
|
|
4346
5034
|
});
|
|
4347
5035
|
splitter = createKernelMap({ kernel, radius: 1 / RAD });
|
|
4348
5036
|
ElasticMap = class {
|
|
4349
5037
|
constructor(data, radius2) {
|
|
4350
|
-
var
|
|
5038
|
+
var _a3;
|
|
4351
5039
|
this.charts = [];
|
|
4352
|
-
if (data.version !== 1 || typeof data.name !== "string" || !data.name || !Number.isFinite(data.radius) || data.radius <= 0 || !Number.isFinite(radius2) || radius2 <= 0 || !((
|
|
5040
|
+
if (data.version !== 1 || typeof data.name !== "string" || !data.name || !Number.isFinite(data.radius) || data.radius <= 0 || !Number.isFinite(radius2) || radius2 <= 0 || !((_a3 = data.sections) == null ? void 0 : _a3.length) || data.sections.length > 64)
|
|
4353
5041
|
throw new Error("Invalid Elastic dataset");
|
|
4354
5042
|
const ids = /* @__PURE__ */ new Set();
|
|
4355
5043
|
for (const section2 of data.sections) {
|
|
@@ -4468,7 +5156,7 @@ var init_map = __esm({
|
|
|
4468
5156
|
}
|
|
4469
5157
|
sourceOptions(options) {
|
|
4470
5158
|
const { step } = sampling(options);
|
|
4471
|
-
return { maxAngularStep: Math.min(step, 1), tolerance: 1e-5 };
|
|
5159
|
+
return { ...options, maxAngularStep: Math.min(step, 1), tolerance: 1e-5 };
|
|
4472
5160
|
}
|
|
4473
5161
|
sampled(c, line, options) {
|
|
4474
5162
|
return sample(line, (p) => c.grid.project(p), options, Math.min(180 / (c.grid.section.rows - 1), 360 / (c.grid.section.columns - 1)));
|
|
@@ -4477,23 +5165,70 @@ var init_map = __esm({
|
|
|
4477
5165
|
const out = [];
|
|
4478
5166
|
for (const part of splitter.projectLine(line, this.sourceOptions(options)))
|
|
4479
5167
|
for (const c of this.charts.filter((c2) => c2.baseId === part.regionId)) {
|
|
4480
|
-
let current
|
|
4481
|
-
const
|
|
4482
|
-
if (
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
5168
|
+
let current;
|
|
5169
|
+
const boundary = (point, vertex) => {
|
|
5170
|
+
if (vertex === 0 || vertex === line.length - 1)
|
|
5171
|
+
return "source-endpoint";
|
|
5172
|
+
let edge2 = 0;
|
|
5173
|
+
const kinds = [];
|
|
5174
|
+
for (const polygon of c.domain)
|
|
5175
|
+
for (const ring of polygon)
|
|
5176
|
+
for (let i = 1; i < ring.length; i++, edge2++)
|
|
5177
|
+
if (onSegment(point, ring[i - 1], ring[i])) {
|
|
5178
|
+
const seam = this.seams.find((s) => s.regions.some((id, j) => id === c.region.id && s.edges[j] === edge2));
|
|
5179
|
+
kinds.push((seam == null ? void 0 : seam.kind) ?? "boundary");
|
|
5180
|
+
}
|
|
5181
|
+
return kinds.includes("boundary") ? "coverage-boundary" : kinds.includes("cut") ? "chart-cut" : kinds.includes("join") ? "continuous-chart-join" : "coverage-boundary";
|
|
4487
5182
|
};
|
|
4488
|
-
for (let i = 1; i < part.
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
5183
|
+
for (let i = 1; i < part.sourceCoordinates.length; i++) {
|
|
5184
|
+
const a = part.coordinates[i - 1], b = part.coordinates[i];
|
|
5185
|
+
const intervals = clipSourceArc(a, b, c.domain);
|
|
5186
|
+
if (!intervals.length) {
|
|
5187
|
+
current = void 0;
|
|
5188
|
+
continue;
|
|
5189
|
+
}
|
|
5190
|
+
if (Math.hypot(intervals[0].a[0] - a[0], intervals[0].a[1] - a[1]) > 1e-8)
|
|
5191
|
+
current = void 0;
|
|
5192
|
+
for (const clipped of intervals) {
|
|
5193
|
+
const arc = sourceArc(clipped.a, clipped.b);
|
|
5194
|
+
const samples = sample([clipped.a, clipped.b], (p) => c.grid.project(p), options, Math.min(180 / (c.grid.section.rows - 1), 360 / (c.grid.section.columns - 1)), (_, t) => arc(t));
|
|
5195
|
+
const first = samples.source[0], last = samples.source[samples.source.length - 1];
|
|
5196
|
+
const joined = current && Math.hypot(...current.sourceCoordinates[current.sourceCoordinates.length - 1].map((v, k2) => v - first[k2])) < 1e-8;
|
|
5197
|
+
if (!joined) {
|
|
5198
|
+
current = { regionId: c.region.id, coordinates: [], sourceCoordinates: [] };
|
|
5199
|
+
if (part.provenance)
|
|
5200
|
+
current.provenance = {
|
|
5201
|
+
segments: [],
|
|
5202
|
+
parameters: [],
|
|
5203
|
+
vertices: [],
|
|
5204
|
+
angularDistances: []
|
|
5205
|
+
};
|
|
5206
|
+
out.push(current);
|
|
5207
|
+
}
|
|
5208
|
+
for (let j = joined ? 1 : 0; j < samples.source.length; j++) {
|
|
5209
|
+
const p = samples.source[j];
|
|
5210
|
+
current.sourceCoordinates.push(p);
|
|
5211
|
+
current.coordinates.push(samples.xy[j]);
|
|
5212
|
+
const parent = part.provenance, target = current.provenance;
|
|
5213
|
+
if (parent && target) {
|
|
5214
|
+
const length = angle(geographic(a), geographic(b)), t = length ? Math.min(1, angle(geographic(a), geographic(p)) / length) : 0;
|
|
5215
|
+
const endpoint = t < 1e-12 ? i - 1 : t > 1 - 1e-12 ? i : -1, segment = parent.segments[i], from = parent.segments[i - 1] === segment ? parent.parameters[i - 1] : 0;
|
|
5216
|
+
target.segments.push(endpoint >= 0 ? parent.segments[endpoint] : segment);
|
|
5217
|
+
target.parameters.push(endpoint >= 0 ? parent.parameters[endpoint] : from + t * (parent.parameters[i] - from));
|
|
5218
|
+
target.vertices.push(endpoint >= 0 ? parent.vertices[endpoint] : 4294967295);
|
|
5219
|
+
if (options.pathDistances)
|
|
5220
|
+
target.angularDistances.push(parent.angularDistances[i - 1] + t * (parent.angularDistances[i] - parent.angularDistances[i - 1]));
|
|
5221
|
+
if (options.pathBoundaries) {
|
|
5222
|
+
if (target.vertices.length === 1)
|
|
5223
|
+
target.startReason = boundary(p, target.vertices[0]);
|
|
5224
|
+
target.endReason = boundary(p, target.vertices[target.vertices.length - 1]);
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
if (Math.hypot(last[0] - b[0], last[1] - b[1]) > 1e-8)
|
|
5229
|
+
current = void 0;
|
|
4495
5230
|
}
|
|
4496
|
-
|
|
5231
|
+
}
|
|
4497
5232
|
}
|
|
4498
5233
|
return out;
|
|
4499
5234
|
}
|
|
@@ -4501,13 +5236,175 @@ var init_map = __esm({
|
|
|
4501
5236
|
const out = [];
|
|
4502
5237
|
for (const part of splitter.projectPolygon(rings, this.sourceOptions(options)))
|
|
4503
5238
|
for (const c of this.charts.filter((c2) => c2.baseId === part.regionId)) {
|
|
4504
|
-
const
|
|
5239
|
+
const prepared = [], preparedEdges = [];
|
|
5240
|
+
part.coordinates.forEach((ring, r) => {
|
|
5241
|
+
const points = [], edges = [];
|
|
5242
|
+
for (let i = 1; i < ring.length; i++) {
|
|
5243
|
+
const a = ring[i - 1], b = ring[i], arc = sourceArc(a, b), length = angle(geographic(a), geographic(b)), fractions = [0, 1];
|
|
5244
|
+
for (const interval of clipSourceArc(a, b, c.domain))
|
|
5245
|
+
for (const p of [interval.a, interval.b]) {
|
|
5246
|
+
const t = length > 1e-14 ? angle(geographic(a), geographic(p)) / length : Math.abs(b[0] - a[0]) > 1e-14 ? (p[0] - a[0]) / (b[0] - a[0]) : 0;
|
|
5247
|
+
if (t > 1e-12 && t < 1 - 1e-12)
|
|
5248
|
+
fractions.push(t);
|
|
5249
|
+
}
|
|
5250
|
+
fractions.sort((a2, b2) => a2 - b2);
|
|
5251
|
+
const split = fractions.filter((t, i2) => !i2 || t - fractions[i2 - 1] > 1e-12);
|
|
5252
|
+
const append2 = (point) => {
|
|
5253
|
+
if (points.length >= 1e5)
|
|
5254
|
+
throw new Error("Elastic polygon constraint vertex limit exceeded");
|
|
5255
|
+
if (points.length) {
|
|
5256
|
+
const previous = points[points.length - 1];
|
|
5257
|
+
if (options.polygonEdgeProvenance)
|
|
5258
|
+
edges.push(composePolygonEdge(part.edgeProvenance[r][i - 1], a, b, previous, point));
|
|
5259
|
+
}
|
|
5260
|
+
points.push(point);
|
|
5261
|
+
};
|
|
5262
|
+
const first = arc(0);
|
|
5263
|
+
if (!points.length)
|
|
5264
|
+
points.push(first);
|
|
5265
|
+
else if (points[points.length - 1].some((v, k2) => v !== first[k2])) {
|
|
5266
|
+
if (angle(geographic(points[points.length - 1]), geographic(first)) > 1e-10)
|
|
5267
|
+
throw new Error("Discontinuous Elastic input source constraint");
|
|
5268
|
+
if (options.polygonEdgeProvenance)
|
|
5269
|
+
edges.push({
|
|
5270
|
+
kind: "continuous-chart-join",
|
|
5271
|
+
ring: 4294967295,
|
|
5272
|
+
segment: 4294967295,
|
|
5273
|
+
t0: 0,
|
|
5274
|
+
t1: 0
|
|
5275
|
+
});
|
|
5276
|
+
points.push(first);
|
|
5277
|
+
}
|
|
5278
|
+
for (let j = 1; j < split.length; j++) {
|
|
5279
|
+
append2(arc((split[j - 1] + split[j]) / 2));
|
|
5280
|
+
append2(arc(split[j]));
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
if (points[points.length - 1].some((v, k2) => v !== points[0][k2])) {
|
|
5284
|
+
if (angle(geographic(points[points.length - 1]), geographic(points[0])) > 1e-10)
|
|
5285
|
+
throw new Error("Unclosed Elastic input source constraint");
|
|
5286
|
+
if (options.polygonEdgeProvenance)
|
|
5287
|
+
edges.push({
|
|
5288
|
+
kind: "continuous-chart-join",
|
|
5289
|
+
ring: 4294967295,
|
|
5290
|
+
segment: 4294967295,
|
|
5291
|
+
t0: 0,
|
|
5292
|
+
t1: 0
|
|
5293
|
+
});
|
|
5294
|
+
points.push([...points[0]]);
|
|
5295
|
+
}
|
|
5296
|
+
prepared.push(points);
|
|
5297
|
+
preparedEdges.push(edges);
|
|
5298
|
+
});
|
|
5299
|
+
const clipped = import_polygon_clipping4.default.intersection(snapPolygon(prepared), c.domain.map(snapPolygon));
|
|
4505
5300
|
for (const polygon of clipped) {
|
|
4506
|
-
const
|
|
5301
|
+
const input = snapPolygon(prepared), traced = tracePolygonConstraints(input, polygon, 1e-9, options.polygonEdgeProvenance ? preparedEdges : void 0, void 0, (a, b) => angle(geographic(a), geographic(b)) < 64 * Number.EPSILON), resolved2 = traced.rings.map((r) => r.map((p) => [...p]));
|
|
5302
|
+
traced.owners.forEach((owners, r) => owners.forEach((owner, i) => {
|
|
5303
|
+
if (!owner)
|
|
5304
|
+
return;
|
|
5305
|
+
const [pr, pe] = owner, a = prepared[pr][pe], b = prepared[pr][pe + 1], length = angle(geographic(a), geographic(b)), arc = sourceArc(a, b);
|
|
5306
|
+
for (const j of [i, i + 1]) {
|
|
5307
|
+
const q = traced.rings[r][j], start = input[pr][pe], end = input[pr][pe + 1];
|
|
5308
|
+
if (Math.hypot(q[0] - start[0], q[1] - start[1]) < 1e-8)
|
|
5309
|
+
resolved2[r][j] = [...a];
|
|
5310
|
+
else if (Math.hypot(q[0] - end[0], q[1] - end[1]) < 1e-8)
|
|
5311
|
+
resolved2[r][j] = [...b];
|
|
5312
|
+
else {
|
|
5313
|
+
const candidates = clipSourceArc(a, b, c.domain).flatMap((interval) => [
|
|
5314
|
+
interval.a,
|
|
5315
|
+
interval.b
|
|
5316
|
+
]);
|
|
5317
|
+
if (!candidates.length)
|
|
5318
|
+
throw new Error("Unresolved Elastic polygon source intersection");
|
|
5319
|
+
const reference = length ? angle(geographic(a), geographic(q)) / length : 0;
|
|
5320
|
+
candidates.sort((x, y) => Math.abs((length ? angle(geographic(a), geographic(x)) / length : 0) - reference) - Math.abs((length ? angle(geographic(a), geographic(y)) / length : 0) - reference));
|
|
5321
|
+
const fraction = length ? angle(geographic(a), geographic(candidates[0])) / length : 0;
|
|
5322
|
+
resolved2[r][j] = arc(Math.min(1, Math.max(0, fraction)));
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
}));
|
|
5326
|
+
for (const ring of resolved2)
|
|
5327
|
+
ring[ring.length - 1] = [...ring[0]];
|
|
5328
|
+
const generated = (a, b) => {
|
|
5329
|
+
if (angle(geographic(a), geographic(b)) < 64 * Number.EPSILON)
|
|
5330
|
+
return "continuous-chart-join";
|
|
5331
|
+
let edge2 = 0;
|
|
5332
|
+
const kinds = [];
|
|
5333
|
+
for (const polygon2 of c.domain)
|
|
5334
|
+
for (const ring of polygon2)
|
|
5335
|
+
for (let j = 1; j < ring.length; j++, edge2++)
|
|
5336
|
+
if (onSegment(a, ring[j - 1], ring[j]) && onSegment(b, ring[j - 1], ring[j])) {
|
|
5337
|
+
const seam = this.seams.find((s) => s.regions.some((id, k2) => id === c.region.id && s.edges[k2] === edge2));
|
|
5338
|
+
kinds.push((seam == null ? void 0 : seam.kind) ?? "boundary");
|
|
5339
|
+
}
|
|
5340
|
+
if (!kinds.length)
|
|
5341
|
+
throw new Error("Unknown Elastic polygon clipping constraint");
|
|
5342
|
+
return kinds.includes("boundary") ? "coverage-boundary" : kinds.includes("cut") ? "chart-cut" : "continuous-chart-join";
|
|
5343
|
+
};
|
|
5344
|
+
const coordinates2 = [], sourceCoordinates = [], edgeProvenance = [];
|
|
5345
|
+
resolved2.forEach((ring, r) => {
|
|
5346
|
+
const source = [], xy = [], edges = [];
|
|
5347
|
+
for (let i = 1; i < ring.length; i++) {
|
|
5348
|
+
const owner = traced.owners[r][i - 1], arc = owner ? sourceArc(ring[i - 1], ring[i]) : void 0;
|
|
5349
|
+
const samples = sample(arc ? [arc(0), arc(1)] : [ring[i - 1], ring[i]], (p) => c.grid.project(p), options, Math.min(180 / (c.grid.section.rows - 1), 360 / (c.grid.section.columns - 1)), arc ? (_, t) => arc(t) : void 0);
|
|
5350
|
+
if (!source.length) {
|
|
5351
|
+
source.push(samples.source[0]);
|
|
5352
|
+
xy.push(samples.xy[0]);
|
|
5353
|
+
} else if (source[source.length - 1].some((v, k2) => Math.abs(v - samples.source[0][k2]) > 1e-10)) {
|
|
5354
|
+
if (angle(geographic(source[source.length - 1]), geographic(samples.source[0])) > 1e-10)
|
|
5355
|
+
throw new Error("Discontinuous Elastic polygon source constraint");
|
|
5356
|
+
if (options.polygonEdgeProvenance)
|
|
5357
|
+
edges.push({
|
|
5358
|
+
kind: "continuous-chart-join",
|
|
5359
|
+
ring: 4294967295,
|
|
5360
|
+
segment: 4294967295,
|
|
5361
|
+
t0: 0,
|
|
5362
|
+
t1: 0
|
|
5363
|
+
});
|
|
5364
|
+
source.push(samples.source[0]);
|
|
5365
|
+
xy.push(samples.xy[0]);
|
|
5366
|
+
}
|
|
5367
|
+
for (let j = 1; j < samples.source.length; j++) {
|
|
5368
|
+
if (options.polygonEdgeProvenance) {
|
|
5369
|
+
if (owner) {
|
|
5370
|
+
const [pr, pe] = owner;
|
|
5371
|
+
edges.push(composePolygonEdge(preparedEdges[pr][pe], prepared[pr][pe], prepared[pr][pe + 1], source[source.length - 1], samples.source[j]));
|
|
5372
|
+
} else
|
|
5373
|
+
edges.push({
|
|
5374
|
+
kind: generated(ring[i - 1], ring[i]),
|
|
5375
|
+
ring: 4294967295,
|
|
5376
|
+
segment: 4294967295,
|
|
5377
|
+
t0: 0,
|
|
5378
|
+
t1: 0
|
|
5379
|
+
});
|
|
5380
|
+
}
|
|
5381
|
+
source.push(samples.source[j]);
|
|
5382
|
+
xy.push(samples.xy[j]);
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
if (source.length && source[source.length - 1].some((v, k2) => v !== source[0][k2])) {
|
|
5386
|
+
if (angle(geographic(source[source.length - 1]), geographic(source[0])) > 1e-10)
|
|
5387
|
+
throw new Error("Unclosed Elastic polygon source constraint");
|
|
5388
|
+
if (options.polygonEdgeProvenance)
|
|
5389
|
+
edges.push({
|
|
5390
|
+
kind: "continuous-chart-join",
|
|
5391
|
+
ring: 4294967295,
|
|
5392
|
+
segment: 4294967295,
|
|
5393
|
+
t0: 0,
|
|
5394
|
+
t1: 0
|
|
5395
|
+
});
|
|
5396
|
+
source.push([...source[0]]);
|
|
5397
|
+
xy.push([...xy[0]]);
|
|
5398
|
+
}
|
|
5399
|
+
coordinates2.push(xy);
|
|
5400
|
+
sourceCoordinates.push(source);
|
|
5401
|
+
edgeProvenance.push(edges);
|
|
5402
|
+
});
|
|
4507
5403
|
out.push({
|
|
4508
5404
|
regionId: c.region.id,
|
|
4509
|
-
coordinates:
|
|
4510
|
-
sourceCoordinates
|
|
5405
|
+
coordinates: coordinates2,
|
|
5406
|
+
sourceCoordinates,
|
|
5407
|
+
...options.polygonEdgeProvenance ? { edgeProvenance } : {}
|
|
4511
5408
|
});
|
|
4512
5409
|
}
|
|
4513
5410
|
}
|
|
@@ -4562,7 +5459,7 @@ var init_map = __esm({
|
|
|
4562
5459
|
// dist/discontinuous/layout.js
|
|
4563
5460
|
function getMapLayout(map, options = {}) {
|
|
4564
5461
|
const regions2 = map.regions.map((region) => {
|
|
4565
|
-
var
|
|
5462
|
+
var _a3, _b2, _c, _d, _e, _f;
|
|
4566
5463
|
const outlines = map.getRegionOutlines(region.id, options).map((p) => Object.freeze(p.map((point) => Object.freeze([...point]))));
|
|
4567
5464
|
const points = outlines.flat();
|
|
4568
5465
|
const interior = map.projectPoint(region.interior, region.id);
|
|
@@ -4572,8 +5469,8 @@ function getMapLayout(map, options = {}) {
|
|
|
4572
5469
|
throw new Error(`Cannot measure region ${region.id}`);
|
|
4573
5470
|
return Object.freeze({
|
|
4574
5471
|
id: region.id,
|
|
4575
|
-
label: ((
|
|
4576
|
-
kind: ((
|
|
5472
|
+
label: ((_a3 = region.layout) == null ? void 0 : _a3.label) ?? region.id,
|
|
5473
|
+
kind: ((_b2 = region.layout) == null ? void 0 : _b2.kind) ?? "panel",
|
|
4577
5474
|
parentId: (_c = region.layout) == null ? void 0 : _c.parentId,
|
|
4578
5475
|
relativeScale: (_d = region.layout) == null ? void 0 : _d.relativeScale,
|
|
4579
5476
|
drawOrder: ((_e = region.layout) == null ? void 0 : _e.drawOrder) ?? 0,
|
|
@@ -5056,7 +5953,7 @@ function interruptedMap(kind, value2, goode = false, layout = "default", central
|
|
|
5056
5953
|
return new DiscontinuousMap(regions2);
|
|
5057
5954
|
}
|
|
5058
5955
|
function createInterruptedMap(options) {
|
|
5059
|
-
var
|
|
5956
|
+
var _a3, _b2;
|
|
5060
5957
|
if (![
|
|
5061
5958
|
"sinusoidal",
|
|
5062
5959
|
"mollweide",
|
|
@@ -5072,7 +5969,7 @@ function createInterruptedMap(options) {
|
|
|
5072
5969
|
const centralMeridian = options.centralMeridian ?? 0;
|
|
5073
5970
|
if (!Number.isFinite(centralMeridian))
|
|
5074
5971
|
throw new Error("Expected finite centralMeridian");
|
|
5075
|
-
for (const hemisphere of [(
|
|
5972
|
+
for (const hemisphere of [(_a3 = options.lobes) == null ? void 0 : _a3.north, (_b2 = options.lobes) == null ? void 0 : _b2.south]) {
|
|
5076
5973
|
if (!Array.isArray(hemisphere) || !hemisphere.length)
|
|
5077
5974
|
throw new Error("Expected nonempty north and south lobe arrays");
|
|
5078
5975
|
let edge2 = -180;
|
|
@@ -5999,7 +6896,7 @@ var init_wiechel = __esm({
|
|
|
5999
6896
|
|
|
6000
6897
|
// dist/discontinuous/regional-map.js
|
|
6001
6898
|
function createRegionalMap(options) {
|
|
6002
|
-
var
|
|
6899
|
+
var _a3;
|
|
6003
6900
|
const { projection, radius: radius2 = 1 } = options;
|
|
6004
6901
|
if (!Number.isFinite(radius2) || radius2 <= 0)
|
|
6005
6902
|
throw new Error("Expected positive finite radius");
|
|
@@ -6039,7 +6936,7 @@ function createRegionalMap(options) {
|
|
|
6039
6936
|
"two-point-equidistant": ["controlPoints"]
|
|
6040
6937
|
};
|
|
6041
6938
|
for (const key2 of Object.keys(options))
|
|
6042
|
-
if (!["projection", "radius", "type"].includes(key2) && !((
|
|
6939
|
+
if (!["projection", "radius", "type"].includes(key2) && !((_a3 = allowed[projection]) == null ? void 0 : _a3.includes(key2)))
|
|
6043
6940
|
throw new Error(`Unsupported ${projection} option: ${key2}`);
|
|
6044
6941
|
const value2 = (key2, fallback, low, high) => {
|
|
6045
6942
|
const n = options[key2] ?? fallback;
|
|
@@ -7242,7 +8139,7 @@ function restoreLayout(data) {
|
|
|
7242
8139
|
const { mesh, panels, targetAngles } = data;
|
|
7243
8140
|
if (panels.length !== mesh.faces.length || targetAngles.length !== panels.length || !targetAngles.every(Number.isFinite) || data.rootTransform.length !== 16 || !data.rootTransform.every(Number.isFinite))
|
|
7244
8141
|
throw new Error("Invalid prepared hinge layout");
|
|
7245
|
-
const tree = new
|
|
8142
|
+
const tree = new import_geometry4.HingeTree(panels);
|
|
7246
8143
|
const rootTransform = new import_core2.Matrix4(data.rootTransform);
|
|
7247
8144
|
const poses = new Float64Array(panels.length * 16), angles = new Float64Array(panels.length);
|
|
7248
8145
|
const evaluate2 = (amount) => {
|
|
@@ -7285,11 +8182,11 @@ function countOverlaps(faces) {
|
|
|
7285
8182
|
}
|
|
7286
8183
|
return count;
|
|
7287
8184
|
}
|
|
7288
|
-
var import_core2,
|
|
8185
|
+
var import_core2, import_geometry4;
|
|
7289
8186
|
var init_unfold = __esm({
|
|
7290
8187
|
"dist/discontinuous/myriahedral/unfold.js"() {
|
|
7291
8188
|
import_core2 = require("@math.gl/core");
|
|
7292
|
-
|
|
8189
|
+
import_geometry4 = require("@math.gl/geometry");
|
|
7293
8190
|
init_mesh();
|
|
7294
8191
|
}
|
|
7295
8192
|
});
|
|
@@ -7433,8 +8330,8 @@ function regions(layout) {
|
|
|
7433
8330
|
});
|
|
7434
8331
|
}
|
|
7435
8332
|
function snapshotMesh(input) {
|
|
7436
|
-
var
|
|
7437
|
-
if (!((
|
|
8333
|
+
var _a3, _b2;
|
|
8334
|
+
if (!((_a3 = input.vertices) == null ? void 0 : _a3.length) || !((_b2 = input.faces) == null ? void 0 : _b2.length) || input.faces.length > 2e4)
|
|
7438
8335
|
throw new Error("Expected a nonempty mesh with at most 20000 panels");
|
|
7439
8336
|
const mesh = {
|
|
7440
8337
|
vertices: input.vertices.map((v) => [...v]),
|
|
@@ -7488,6 +8385,8 @@ var import_polygon_clipping5, MercatorMap;
|
|
|
7488
8385
|
var init_mercator_map = __esm({
|
|
7489
8386
|
"dist/discontinuous/mercator-map.js"() {
|
|
7490
8387
|
import_polygon_clipping5 = __toESM(require("polygon-clipping"), 1);
|
|
8388
|
+
init_polygon_constraints();
|
|
8389
|
+
init_source_arc();
|
|
7491
8390
|
init_map_layout();
|
|
7492
8391
|
init_math2();
|
|
7493
8392
|
MercatorMap = class extends DiscontinuousMap {
|
|
@@ -7567,17 +8466,65 @@ var init_mercator_map = __esm({
|
|
|
7567
8466
|
continue;
|
|
7568
8467
|
}
|
|
7569
8468
|
const at = (t) => [a[0] + (b[0] - a[0]) * t, a[1] + dy * t];
|
|
7570
|
-
const
|
|
8469
|
+
const endpoint = (t) => {
|
|
8470
|
+
if (t === 0 || t === 1)
|
|
8471
|
+
return { xy: at(t), source: part.sourceCoordinates[i - 1 + t], t };
|
|
8472
|
+
const va = geographic(part.sourceCoordinates[i - 1]), vb = geographic(part.sourceCoordinates[i]), arc = angle(va, vb);
|
|
8473
|
+
const sourceAt = (t2) => {
|
|
8474
|
+
if (!arc)
|
|
8475
|
+
return part.sourceCoordinates[i - 1];
|
|
8476
|
+
const a2 = Math.sin((1 - t2) * arc) / Math.sin(arc), b2 = Math.sin(t2 * arc) / Math.sin(arc);
|
|
8477
|
+
return coordinates(unit(va.map((v, k2) => a2 * v + b2 * vb[k2])));
|
|
8478
|
+
};
|
|
8479
|
+
const latitude = Math.sign(at(t)[1]) * this.limit;
|
|
8480
|
+
let lo = 0, hi = 1;
|
|
8481
|
+
for (let j = 0; j < 52; j++) {
|
|
8482
|
+
const mid = (lo + hi) / 2;
|
|
8483
|
+
if (sourceAt(mid)[1] < latitude === part.sourceCoordinates[i - 1][1] < latitude)
|
|
8484
|
+
lo = mid;
|
|
8485
|
+
else
|
|
8486
|
+
hi = mid;
|
|
8487
|
+
}
|
|
8488
|
+
const f = (lo + hi) / 2, source = sourceAt(f);
|
|
8489
|
+
const xy = super.projectPoint(source, part.regionId).position;
|
|
8490
|
+
return { xy, source, t: f };
|
|
8491
|
+
};
|
|
8492
|
+
const start = endpoint(t0), end = endpoint(t1);
|
|
8493
|
+
const append2 = (point, index) => {
|
|
8494
|
+
current.coordinates.push(point.xy);
|
|
8495
|
+
current.sourceCoordinates.push(point.source);
|
|
8496
|
+
const source = part.provenance, target = current.provenance;
|
|
8497
|
+
if (!source || !target)
|
|
8498
|
+
return;
|
|
8499
|
+
const segment = source.segments[i];
|
|
8500
|
+
const from = source.segments[i - 1] === segment ? source.parameters[i - 1] : 0;
|
|
8501
|
+
target.segments.push(point.t === 0 || point.t === 1 ? source.segments[index] : segment);
|
|
8502
|
+
target.parameters.push(point.t === 0 || point.t === 1 ? source.parameters[index] : from + point.t * (source.parameters[i] - from));
|
|
8503
|
+
target.vertices.push(point.t === 0 || point.t === 1 ? source.vertices[index] : 4294967295);
|
|
8504
|
+
if (options == null ? void 0 : options.pathDistances)
|
|
8505
|
+
target.angularDistances.push(source.angularDistances[i - 1] + point.t * (source.angularDistances[i] - source.angularDistances[i - 1]));
|
|
8506
|
+
};
|
|
7571
8507
|
if (!current || t0 > 0) {
|
|
7572
8508
|
current = {
|
|
7573
8509
|
regionId: part.regionId,
|
|
7574
|
-
coordinates: [
|
|
7575
|
-
sourceCoordinates: [
|
|
8510
|
+
coordinates: [],
|
|
8511
|
+
sourceCoordinates: [],
|
|
8512
|
+
...part.provenance ? {
|
|
8513
|
+
provenance: {
|
|
8514
|
+
segments: [],
|
|
8515
|
+
parameters: [],
|
|
8516
|
+
vertices: [],
|
|
8517
|
+
angularDistances: [],
|
|
8518
|
+
...(options == null ? void 0 : options.pathBoundaries) ? { startReason: t0 > 0 ? "coverage-boundary" : part.provenance.startReason } : {}
|
|
8519
|
+
}
|
|
8520
|
+
} : {}
|
|
7576
8521
|
};
|
|
7577
8522
|
result.push(current);
|
|
8523
|
+
append2(start, i - 1);
|
|
7578
8524
|
}
|
|
7579
|
-
|
|
7580
|
-
current.
|
|
8525
|
+
append2(end, i);
|
|
8526
|
+
if (current.provenance && (options == null ? void 0 : options.pathBoundaries))
|
|
8527
|
+
current.provenance.endReason = t1 < 1 ? "coverage-boundary" : part.provenance.endReason;
|
|
7581
8528
|
if (t1 < 1)
|
|
7582
8529
|
current = void 0;
|
|
7583
8530
|
}
|
|
@@ -7595,11 +8542,60 @@ var init_mercator_map = __esm({
|
|
|
7595
8542
|
[-x, -y]
|
|
7596
8543
|
]
|
|
7597
8544
|
];
|
|
7598
|
-
return super.projectPolygon(rings, options).flatMap((part) => import_polygon_clipping5.default.intersection(part.coordinates, box).map((
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
8545
|
+
return super.projectPolygon(rings, options).flatMap((part) => import_polygon_clipping5.default.intersection(part.coordinates, box).map((polygon) => {
|
|
8546
|
+
const traced = tracePolygonConstraints(part.coordinates, polygon, 1e-10, part.edgeProvenance);
|
|
8547
|
+
const sources = traced.rings.map((r) => r.map((p) => this.source(p)));
|
|
8548
|
+
traced.owners.forEach((owners, r) => owners.forEach((owner, i) => {
|
|
8549
|
+
if (!owner)
|
|
8550
|
+
return;
|
|
8551
|
+
const [parentRing, parentEdge] = owner, a = part.sourceCoordinates[parentRing][parentEdge], b = part.sourceCoordinates[parentRing][parentEdge + 1], at = sourceArc(a, b);
|
|
8552
|
+
for (const j of [i, i + 1]) {
|
|
8553
|
+
const q = traced.rings[r][j], first = part.coordinates[parentRing][parentEdge], last = part.coordinates[parentRing][parentEdge + 1];
|
|
8554
|
+
if (Math.hypot(q[0] - first[0], q[1] - first[1]) < 1e-10 * this.radius)
|
|
8555
|
+
sources[r][j] = [...a];
|
|
8556
|
+
else if (Math.hypot(q[0] - last[0], q[1] - last[1]) < 1e-10 * this.radius)
|
|
8557
|
+
sources[r][j] = [...b];
|
|
8558
|
+
else {
|
|
8559
|
+
const latitude = Math.sign(q[1]) * this.limit;
|
|
8560
|
+
let lo = 0, hi = 1;
|
|
8561
|
+
if (a[1] < latitude === b[1] < latitude)
|
|
8562
|
+
throw new Error("Unresolved Mercator source constraint intersection");
|
|
8563
|
+
for (let k2 = 0; k2 < 52; k2++) {
|
|
8564
|
+
const mid = (lo + hi) / 2;
|
|
8565
|
+
if (at(mid)[1] < latitude === a[1] < latitude)
|
|
8566
|
+
lo = mid;
|
|
8567
|
+
else
|
|
8568
|
+
hi = mid;
|
|
8569
|
+
}
|
|
8570
|
+
sources[r][j] = at((lo + hi) / 2);
|
|
8571
|
+
}
|
|
8572
|
+
}
|
|
8573
|
+
}));
|
|
8574
|
+
for (const r of sources)
|
|
8575
|
+
r[r.length - 1] = [...r[0]];
|
|
8576
|
+
return {
|
|
8577
|
+
regionId: part.regionId,
|
|
8578
|
+
sourceCoordinates: sources,
|
|
8579
|
+
coordinates: sources.map((r) => r.map((p) => super.projectPoint(p, part.regionId).position)),
|
|
8580
|
+
...(options == null ? void 0 : options.polygonEdgeProvenance) ? {
|
|
8581
|
+
edgeProvenance: traced.owners.map((owners, r) => owners.map((owner, i) => {
|
|
8582
|
+
if (owner) {
|
|
8583
|
+
const [pr, pe] = owner;
|
|
8584
|
+
return composePolygonEdge(part.edgeProvenance[pr][pe], part.sourceCoordinates[pr][pe], part.sourceCoordinates[pr][pe + 1], sources[r][i], sources[r][i + 1]);
|
|
8585
|
+
}
|
|
8586
|
+
if (!sources[r].slice(i, i + 2).every((p) => Math.abs(Math.abs(p[1]) - this.limit) < 1e-7))
|
|
8587
|
+
throw new Error("Unknown Mercator clipping constraint");
|
|
8588
|
+
return {
|
|
8589
|
+
kind: "coverage-boundary",
|
|
8590
|
+
ring: 4294967295,
|
|
8591
|
+
segment: 4294967295,
|
|
8592
|
+
t0: 0,
|
|
8593
|
+
t1: 0
|
|
8594
|
+
};
|
|
8595
|
+
}))
|
|
8596
|
+
} : {}
|
|
8597
|
+
};
|
|
8598
|
+
}));
|
|
7603
8599
|
}
|
|
7604
8600
|
};
|
|
7605
8601
|
}
|
|
@@ -7801,14 +8797,14 @@ var init_map_engine = __esm({
|
|
|
7801
8797
|
}
|
|
7802
8798
|
case "custom":
|
|
7803
8799
|
this.map = new DiscontinuousMap(d.charts.map((chart) => {
|
|
7804
|
-
var
|
|
7805
|
-
const projection = (
|
|
8800
|
+
var _a3, _b2;
|
|
8801
|
+
const projection = (_a3 = options.projections) == null ? void 0 : _a3[chart.projection];
|
|
7806
8802
|
if (!projection)
|
|
7807
8803
|
throw new Error(`Missing projection binding: ${chart.projection}`);
|
|
7808
8804
|
const placement = (chart.placement ?? [1, 0, 0, 1, 0, 0]).map((v) => v * radius2);
|
|
7809
8805
|
const layout = chart.layout ? {
|
|
7810
8806
|
...chart.layout,
|
|
7811
|
-
frame: (
|
|
8807
|
+
frame: (_b2 = chart.layout.frame) == null ? void 0 : _b2.map((v) => v * radius2)
|
|
7812
8808
|
} : void 0;
|
|
7813
8809
|
return { ...chart, ...projection, placement, layout };
|
|
7814
8810
|
}));
|
|
@@ -7830,8 +8826,8 @@ var init_map_engine = __esm({
|
|
|
7830
8826
|
this.capabilities = Object.freeze({
|
|
7831
8827
|
hasCuts: this.seams.some((s) => s.kind === "cut"),
|
|
7832
8828
|
hasInsets: this.regions.some((r) => {
|
|
7833
|
-
var
|
|
7834
|
-
return ((
|
|
8829
|
+
var _a3;
|
|
8830
|
+
return ((_a3 = r.layout) == null ? void 0 : _a3.kind) === "inset";
|
|
7835
8831
|
}),
|
|
7836
8832
|
disjoint: new Set(groups.values()).size > 1,
|
|
7837
8833
|
hinged: Boolean(this.motion),
|
|
@@ -8188,7 +9184,7 @@ function resolveCRSInput(input, options) {
|
|
|
8188
9184
|
return { definition: reference.definition, spatialReference, lossy };
|
|
8189
9185
|
}
|
|
8190
9186
|
function applySpatialReference(crs, reference) {
|
|
8191
|
-
var
|
|
9187
|
+
var _a3;
|
|
8192
9188
|
if (!reference)
|
|
8193
9189
|
return crs;
|
|
8194
9190
|
if (reference.coordinateFrame !== "unknown" && reference.coordinateFrame !== crs.kind)
|
|
@@ -8217,7 +9213,7 @@ function applySpatialReference(crs, reference) {
|
|
|
8217
9213
|
if (order.length > 4 || order.length > 3 && !["m", "measure"].includes(order[3]))
|
|
8218
9214
|
unsupportedStage("Unsupported fourth coordinate component");
|
|
8219
9215
|
}
|
|
8220
|
-
if ((
|
|
9216
|
+
if ((_a3 = reference.units) == null ? void 0 : _a3.length) {
|
|
8221
9217
|
const units2 = {
|
|
8222
9218
|
m: 1,
|
|
8223
9219
|
meter: 1,
|
|
@@ -8282,8 +9278,8 @@ var init_parameters = __esm({
|
|
|
8282
9278
|
|
|
8283
9279
|
// dist/projection/experimental/crs/datum-catalog.js
|
|
8284
9280
|
function getDatumDefinitions(options) {
|
|
8285
|
-
var
|
|
8286
|
-
if (!((
|
|
9281
|
+
var _a3;
|
|
9282
|
+
if (!((_a3 = options.datumCatalogs) == null ? void 0 : _a3.length))
|
|
8287
9283
|
return builtins;
|
|
8288
9284
|
const cached = resolved.get(options);
|
|
8289
9285
|
if ((cached == null ? void 0 : cached.catalogs) === options.datumCatalogs)
|
|
@@ -8681,7 +9677,7 @@ function resolveLocalCRSDefinition(input, options = {}) {
|
|
|
8681
9677
|
return definition;
|
|
8682
9678
|
}
|
|
8683
9679
|
function normalizeCRS(input, options = {}) {
|
|
8684
|
-
var
|
|
9680
|
+
var _a3;
|
|
8685
9681
|
const datums2 = getDatumDefinitions(options);
|
|
8686
9682
|
const resolved2 = resolveCRSInput(input, options);
|
|
8687
9683
|
const definition = resolveLocalCRSDefinition(resolved2.definition, options);
|
|
@@ -8695,7 +9691,7 @@ function normalizeCRS(input, options = {}) {
|
|
|
8695
9691
|
}
|
|
8696
9692
|
parsed = { parameters: parameters2 };
|
|
8697
9693
|
} else {
|
|
8698
|
-
const parser = (
|
|
9694
|
+
const parser = (_a3 = options.parsers) == null ? void 0 : _a3.find((candidate) => candidate.canParse(definition));
|
|
8699
9695
|
if (!parser) {
|
|
8700
9696
|
const serialized = ["wkt", "projjson"].includes(inferCRSRepresentation(definition));
|
|
8701
9697
|
throw new TypeScriptCRSError(serialized ? "missing-parser" : "unknown-syntax", inferCRSRepresentation(definition) === "identifier" ? "Unsupported CRS definition: " + definition + "; resolve it first" : "Unsupported CRS definition; register a WKT or PROJJSON parser for structured definitions");
|
|
@@ -9233,12 +10229,12 @@ async function prepareEngineOptions(options) {
|
|
|
9233
10229
|
return { ...captured, from, to };
|
|
9234
10230
|
}
|
|
9235
10231
|
async function prepareCRSInput(captured, options) {
|
|
9236
|
-
var
|
|
10232
|
+
var _a3;
|
|
9237
10233
|
const source = resolveCRSInput(captured, options);
|
|
9238
10234
|
const local = resolveLocalCRSDefinition(source.definition, options);
|
|
9239
10235
|
const reference = typeof captured === "string" || "type" in captured ? void 0 : "crs" in captured ? captured.crs : captured;
|
|
9240
10236
|
const representation = local === source.definition && reference ? reference.representation : inferCRSRepresentation(local);
|
|
9241
|
-
if (representation !== "identifier" || ((
|
|
10237
|
+
if (representation !== "identifier" || ((_a3 = options.parsers) == null ? void 0 : _a3.some((p) => p.canParse(local)))) {
|
|
9242
10238
|
return captured;
|
|
9243
10239
|
}
|
|
9244
10240
|
const result = await options.resolver.resolve({
|
|
@@ -9391,11 +10387,11 @@ function resolveRenderingProfile(getRenderingProfile, coverage) {
|
|
|
9391
10387
|
return resolveBounds(profile);
|
|
9392
10388
|
}
|
|
9393
10389
|
function resolveBounds(profile) {
|
|
9394
|
-
var
|
|
10390
|
+
var _a3;
|
|
9395
10391
|
const bounds = profile.bounds;
|
|
9396
10392
|
if (bounds.some((corner) => corner.some((value2) => !Number.isFinite(value2))))
|
|
9397
10393
|
throw new Error("Projection rendering bounds must be finite");
|
|
9398
|
-
return { bounds, normalize: (
|
|
10394
|
+
return { bounds, normalize: (_a3 = profile.normalize) == null ? void 0 : _a3.bind(profile) };
|
|
9399
10395
|
}
|
|
9400
10396
|
function createAngularNormalization(normalize2, primeMeridian2 = 0) {
|
|
9401
10397
|
return (point) => {
|
|
@@ -9423,11 +10419,11 @@ function combineRenderingProfiles(regions2, getProfile) {
|
|
|
9423
10419
|
return {
|
|
9424
10420
|
bounds: unionRenderingBounds(profiles.map((profile) => profile.bounds)),
|
|
9425
10421
|
normalize(point) {
|
|
9426
|
-
var
|
|
10422
|
+
var _a3;
|
|
9427
10423
|
let bestX = point.x, bestY = point.y, best = Infinity;
|
|
9428
10424
|
for (const profile of profiles) {
|
|
9429
10425
|
const candidate = { x: point.x, y: point.y, z: point.z };
|
|
9430
|
-
(
|
|
10426
|
+
(_a3 = profile.normalize) == null ? void 0 : _a3.call(profile, candidate);
|
|
9431
10427
|
const distance3 = Math.sin((candidate.y - point.y) * Math.PI / 360) ** 2 + Math.cos(point.y * Math.PI / 180) * Math.cos(candidate.y * Math.PI / 180) * Math.sin((candidate.x - point.x) * Math.PI / 360) ** 2;
|
|
9432
10428
|
if (distance3 < best) {
|
|
9433
10429
|
best = distance3;
|
|
@@ -9467,8 +10463,8 @@ function cache() {
|
|
|
9467
10463
|
return scope[CACHE_KEY];
|
|
9468
10464
|
}
|
|
9469
10465
|
function getLoadedProjection(projection) {
|
|
9470
|
-
var
|
|
9471
|
-
return "create" in projection ? projection : (
|
|
10466
|
+
var _a3;
|
|
10467
|
+
return "create" in projection ? projection : (_a3 = cache().get(projection)) == null ? void 0 : _a3.implementation;
|
|
9472
10468
|
}
|
|
9473
10469
|
function preloadProjection(projection) {
|
|
9474
10470
|
if ("create" in projection)
|
|
@@ -9518,9 +10514,9 @@ var init_projection_scratch = __esm({
|
|
|
9518
10514
|
return this.active;
|
|
9519
10515
|
}
|
|
9520
10516
|
acquire() {
|
|
9521
|
-
var
|
|
10517
|
+
var _a3;
|
|
9522
10518
|
const index = this.active++;
|
|
9523
|
-
(
|
|
10519
|
+
(_a3 = this.points)[index] || (_a3[index] = createPoint());
|
|
9524
10520
|
return this.points[index];
|
|
9525
10521
|
}
|
|
9526
10522
|
release(point) {
|
|
@@ -9626,8 +10622,8 @@ function createHelmert(values, inverse34) {
|
|
|
9626
10622
|
};
|
|
9627
10623
|
}
|
|
9628
10624
|
function shifted(datum) {
|
|
9629
|
-
var
|
|
9630
|
-
return Boolean((
|
|
10625
|
+
var _a3;
|
|
10626
|
+
return Boolean((_a3 = datum.towgs84) == null ? void 0 : _a3.some((value2) => value2 !== 0));
|
|
9631
10627
|
}
|
|
9632
10628
|
function createDatumTransform(source, destination) {
|
|
9633
10629
|
if (!source.towgs84 || !destination.towgs84)
|
|
@@ -9979,7 +10975,7 @@ function registry(projections) {
|
|
|
9979
10975
|
return plugins;
|
|
9980
10976
|
}
|
|
9981
10977
|
function compileCRS(definition, plugins, options) {
|
|
9982
|
-
var
|
|
10978
|
+
var _a3;
|
|
9983
10979
|
const crs = normalizeCRS(definition, options);
|
|
9984
10980
|
const plugin = plugins.get(pluginKey(crs.projection));
|
|
9985
10981
|
if (!["geographic", "identity"].includes(crs.kind) && !plugin)
|
|
@@ -9988,7 +10984,7 @@ function compileCRS(definition, plugins, options) {
|
|
|
9988
10984
|
for (const key2 of Object.keys(crs.parameters)) {
|
|
9989
10985
|
if (!allowed.has(key2))
|
|
9990
10986
|
throw new TypeScriptCRSError("missing-transform-stage", "Unsupported PROJ parameter: +" + key2);
|
|
9991
|
-
const flag = CORE_FLAGS.includes(key2) || ((
|
|
10987
|
+
const flag = CORE_FLAGS.includes(key2) || ((_a3 = plugin == null ? void 0 : plugin.flags) == null ? void 0 : _a3.includes(key2));
|
|
9992
10988
|
if (flag && crs.parameters[key2] !== void 0)
|
|
9993
10989
|
throw new Error("Expected a flag without a value: +" + key2);
|
|
9994
10990
|
if (!flag && !crs.parameters[key2])
|
|
@@ -10044,7 +11040,7 @@ function compileAxis(axis, inverse34) {
|
|
|
10044
11040
|
};
|
|
10045
11041
|
}
|
|
10046
11042
|
function compileTransform(from, to, enforceAxis) {
|
|
10047
|
-
var
|
|
11043
|
+
var _a3, _b2, _c, _d;
|
|
10048
11044
|
const fromAxis = from.storedAxis || (enforceAxis ? from.axis : "enu");
|
|
10049
11045
|
const toAxis = to.storedAxis || (enforceAxis ? to.axis : "enu");
|
|
10050
11046
|
const inputAxis = compileAxis(fromAxis, false), outputAxis = compileAxis(toAxis, true);
|
|
@@ -10062,7 +11058,7 @@ function compileTransform(from, to, enforceAxis) {
|
|
|
10062
11058
|
if (!datum && !from.verticalGrid && !to.verticalGrid && !horizontalOnly && !inputAxis && !outputAxis && !fromPrime && !toPrime && from.verticalUnit === 1 && to.verticalUnit === 1 && longitudeWrap === void 0) {
|
|
10063
11059
|
const context = Object.freeze({ inputScale, outputScale });
|
|
10064
11060
|
if (from.kind === "geographic" && to.kind === "projected")
|
|
10065
|
-
flat = (
|
|
11061
|
+
flat = (_b2 = (_a3 = to.implementation) == null ? void 0 : _a3.createForwardFlat) == null ? void 0 : _b2.call(_a3, context);
|
|
10066
11062
|
if (from.kind === "projected" && to.kind === "geographic")
|
|
10067
11063
|
flat = (_d = (_c = from.implementation) == null ? void 0 : _c.createInverseFlat) == null ? void 0 : _d.call(_c, context);
|
|
10068
11064
|
}
|
|
@@ -10196,7 +11192,7 @@ var init_typescript_projection = __esm({
|
|
|
10196
11192
|
return this.targetRenderingProfile && resolveRenderingProfile(this.targetRenderingProfile, coverage);
|
|
10197
11193
|
}
|
|
10198
11194
|
constructor(options = {}) {
|
|
10199
|
-
var
|
|
11195
|
+
var _a3, _b2, _c;
|
|
10200
11196
|
this.coordinateScratch = new ProjectionScratch();
|
|
10201
11197
|
this.targetLongitudeOrigin = 0;
|
|
10202
11198
|
const registrations = options.projections || [];
|
|
@@ -10211,7 +11207,7 @@ var init_typescript_projection = __esm({
|
|
|
10211
11207
|
const eagerPlugins = plugins;
|
|
10212
11208
|
const from = compileCRS(eager.from ?? "WGS84", eagerPlugins, eager);
|
|
10213
11209
|
const to = compileCRS(eager.to ?? "WGS84", eagerPlugins, eager);
|
|
10214
|
-
this.targetRenderingProfile = ((
|
|
11210
|
+
this.targetRenderingProfile = ((_b2 = (_a3 = to.implementation) == null ? void 0 : _a3.getRenderingProfile) == null ? void 0 : _b2.bind(to.implementation)) ?? (to.kind === "geographic" ? createGeographicProfile(to.parameters, to.primeMeridian) : to.kind === "identity" ? getIdentityRenderingProfile : void 0);
|
|
10215
11211
|
this.targetCoverage = to.areaOfUse;
|
|
10216
11212
|
this.targetLongitudeOrigin = ((_c = to.implementation) == null ? void 0 : _c.longitudeOrigin) ?? (to.kind === "geographic" ? to.longitudeWrap ?? 0 : 0);
|
|
10217
11213
|
this.lossy = from.lossy || to.lossy;
|
|
@@ -10255,10 +11251,10 @@ var init_typescript_projection = __esm({
|
|
|
10255
11251
|
if (!state)
|
|
10256
11252
|
return this;
|
|
10257
11253
|
if (!state.implementation) {
|
|
10258
|
-
const projections = requiredProjections(state.options).map((
|
|
10259
|
-
const plugin = getLoadedProjection(
|
|
11254
|
+
const projections = requiredProjections(state.options).map((descriptor) => {
|
|
11255
|
+
const plugin = getLoadedProjection(descriptor);
|
|
10260
11256
|
if (!plugin)
|
|
10261
|
-
throw new Error("Projection is not preloaded: " +
|
|
11257
|
+
throw new Error("Projection is not preloaded: " + descriptor.name + ". Call preload() first.");
|
|
10262
11258
|
return plugin;
|
|
10263
11259
|
});
|
|
10264
11260
|
state.implementation = new _ProjectionTransform({ ...state.options, projections });
|
|
@@ -19315,7 +20311,7 @@ function obliqueTransformation(wrapped) {
|
|
|
19315
20311
|
parameters: [...rotationParameters, "lon_0", ...geographic2 ? [] : wrapped.parameters],
|
|
19316
20312
|
flags: geographic2 ? [] : wrapped.flags,
|
|
19317
20313
|
create(context) {
|
|
19318
|
-
var
|
|
20314
|
+
var _a3;
|
|
19319
20315
|
const { parameters } = context;
|
|
19320
20316
|
const requested = parameters["o_proj"];
|
|
19321
20317
|
const accepted = geographic2 ? ["longlat", "latlong", "lonlat", "latlon", "identity"] : [wrapped.name, ...wrapped.aliases || []];
|
|
@@ -19369,18 +20365,18 @@ function obliqueTransformation(wrapped) {
|
|
|
19369
20365
|
inverse34(point);
|
|
19370
20366
|
unrotate(point);
|
|
19371
20367
|
});
|
|
19372
|
-
const getChildProfile = geographic2 ? createGeographicProfile(innerParameters) : (
|
|
20368
|
+
const getChildProfile = geographic2 ? createGeographicProfile(innerParameters) : (_a3 = inner.getRenderingProfile) == null ? void 0 : _a3.bind(inner);
|
|
19373
20369
|
if (!getChildProfile)
|
|
19374
20370
|
return implementation;
|
|
19375
20371
|
const wrapProfile = (child2, coverage) => {
|
|
19376
20372
|
const source = coverage && createRectangleRenderingProfile(() => child2.bounds, coverage, longitudeOrigin, context.primeMeridian ?? 0, over);
|
|
19377
20373
|
const normalizeRotated = createAngularNormalization((point) => {
|
|
19378
|
-
var
|
|
20374
|
+
var _a4;
|
|
19379
20375
|
const longitude3 = point.x, latitude = point.y;
|
|
19380
20376
|
rotate(point);
|
|
19381
20377
|
const x = point.x * 180 / Math.PI, y = point.y * 180 / Math.PI;
|
|
19382
20378
|
const rotated = { x, y, z: point.z };
|
|
19383
|
-
(
|
|
20379
|
+
(_a4 = child2.normalize) == null ? void 0 : _a4.call(child2, rotated);
|
|
19384
20380
|
if (rotated.x === x && rotated.y === y) {
|
|
19385
20381
|
point.x = longitude3;
|
|
19386
20382
|
point.y = latitude;
|
|
@@ -19471,8 +20467,8 @@ function parseWKTCRS(text, options) {
|
|
|
19471
20467
|
return ast;
|
|
19472
20468
|
}
|
|
19473
20469
|
function validateWKTCRS(ast, options) {
|
|
19474
|
-
var
|
|
19475
|
-
if (!ast || ast.type !== "wkt-crs" || ((
|
|
20470
|
+
var _a3;
|
|
20471
|
+
if (!ast || ast.type !== "wkt-crs" || ((_a3 = ast.root) == null ? void 0 : _a3.type) !== "node") {
|
|
19476
20472
|
throw new TypeError("validateWKTCRS expects a WKTCRSAst");
|
|
19477
20473
|
}
|
|
19478
20474
|
const profile = resolveProfile(ast.root.keyword, (options == null ? void 0 : options.profile) || "auto");
|
|
@@ -19661,8 +20657,8 @@ var init_wkt_crs = __esm({
|
|
|
19661
20657
|
WKTCRSValidationError = class extends Error {
|
|
19662
20658
|
/** Create an error from one or more validation issues. */
|
|
19663
20659
|
constructor(issues) {
|
|
19664
|
-
var
|
|
19665
|
-
super(((
|
|
20660
|
+
var _a3;
|
|
20661
|
+
super(((_a3 = issues[0]) == null ? void 0 : _a3.message) || "WKT validation failed");
|
|
19666
20662
|
this.name = "WKTCRSValidationError";
|
|
19667
20663
|
this.issues = issues;
|
|
19668
20664
|
}
|
|
@@ -20008,7 +21004,7 @@ function unit2(value2, fallback) {
|
|
|
20008
21004
|
return factor;
|
|
20009
21005
|
}
|
|
20010
21006
|
function readStructuredCRS(crs, options) {
|
|
20011
|
-
var
|
|
21007
|
+
var _a3, _b2, _c;
|
|
20012
21008
|
const type = String(crs["type"]);
|
|
20013
21009
|
const areaOfUse = readAreaOfUse(crs["bbox"]);
|
|
20014
21010
|
if (type === "CompoundCRS") {
|
|
@@ -20136,7 +21132,7 @@ function readStructuredCRS(crs, options) {
|
|
|
20136
21132
|
if (geocentric2)
|
|
20137
21133
|
parameters["proj"] = "geocent";
|
|
20138
21134
|
const angularUnit = unit2(base["angular_unit"], DEGREES_TO_RADIANS);
|
|
20139
|
-
const factor = unit2((
|
|
21135
|
+
const factor = unit2((_a3 = axes[0]) == null ? void 0 : _a3["unit"], type === "ProjectedCRS" || geocentric2 ? 1 : angularUnit);
|
|
20140
21136
|
if (axes[1] && unit2(axes[1]["unit"], factor) !== factor)
|
|
20141
21137
|
unsupportedStage("Mixed horizontal axis units are not supported");
|
|
20142
21138
|
if (geocentric2 && axes[2] && unit2(axes[2]["unit"], factor) !== factor)
|
|
@@ -20184,7 +21180,7 @@ function readStructuredCRS(crs, options) {
|
|
|
20184
21180
|
unsupportedStage("Pseudo-Mercator semi_minor must equal the semi-major axis");
|
|
20185
21181
|
continue;
|
|
20186
21182
|
}
|
|
20187
|
-
let name = ((
|
|
21183
|
+
let name = ((_b2 = METHOD_PARAMETERS[projection]) == null ? void 0 : _b2[parameterName]) || PARAMETERS[parameterName];
|
|
20188
21184
|
if (!name)
|
|
20189
21185
|
unsupportedStage("Unsupported conversion parameter: " + String(parameter["name"]));
|
|
20190
21186
|
if (name === "lat_1" && method === "stereographicnorthpole" && !polarTrueScale)
|
|
@@ -20260,7 +21256,7 @@ function readAreaOfUse(bbox) {
|
|
|
20260
21256
|
return areaOfUse;
|
|
20261
21257
|
}
|
|
20262
21258
|
function readAxisDirection(entry, parameters, projected) {
|
|
20263
|
-
var
|
|
21259
|
+
var _a3;
|
|
20264
21260
|
let direction = String(entry["direction"]);
|
|
20265
21261
|
let meridian = entry["meridian"];
|
|
20266
21262
|
const along = /^(north|south) along ([+-]?(?:\d+(?:\.\d*)?|\.\d+)) deg(?: (east|west))?$/i.exec(direction);
|
|
@@ -20269,7 +21265,7 @@ function readAxisDirection(entry, parameters, projected) {
|
|
|
20269
21265
|
throw new Error("Duplicate axis meridian");
|
|
20270
21266
|
direction = along[1];
|
|
20271
21267
|
meridian = {
|
|
20272
|
-
longitude: Number(along[2]) * (((
|
|
21268
|
+
longitude: Number(along[2]) * (((_a3 = along[3]) == null ? void 0 : _a3.toLowerCase()) === "west" ? -1 : 1)
|
|
20273
21269
|
};
|
|
20274
21270
|
}
|
|
20275
21271
|
if (meridian !== void 0) {
|
|
@@ -20785,29 +21781,28 @@ var init_projection = __esm({
|
|
|
20785
21781
|
}
|
|
20786
21782
|
});
|
|
20787
21783
|
|
|
20788
|
-
// dist/
|
|
21784
|
+
// dist/tasks/operations.js
|
|
20789
21785
|
var operations_exports = {};
|
|
20790
21786
|
__export(operations_exports, {
|
|
20791
21787
|
projectBulk: () => projectBulk,
|
|
20792
21788
|
setupMap: () => setupMap
|
|
20793
21789
|
});
|
|
20794
21790
|
function setupMap(description, context, options) {
|
|
20795
|
-
var
|
|
20796
|
-
(
|
|
21791
|
+
var _a3, _b2;
|
|
21792
|
+
(_a3 = context.reportProgress) == null ? void 0 : _a3.call(context, { phase: "map-setup", completed: 0, total: 1, unit: "tasks" });
|
|
20797
21793
|
const map = new MapEngine(description, options);
|
|
20798
21794
|
map.getLayout();
|
|
20799
|
-
(
|
|
21795
|
+
(_b2 = context.reportProgress) == null ? void 0 : _b2.call(context, { phase: "map-setup", completed: 1, total: 1, unit: "tasks" });
|
|
20800
21796
|
return map;
|
|
20801
21797
|
}
|
|
20802
|
-
async function projectBulk(input, context) {
|
|
20803
|
-
var
|
|
21798
|
+
async function projectBulk(input, context, preparedProjection) {
|
|
21799
|
+
var _a3, _b2, _c, _d, _e, _f;
|
|
20804
21800
|
const { coordinates: coordinates2, dimension = 2, chunkSize = 4096 } = input;
|
|
20805
21801
|
if (!(coordinates2 instanceof Float32Array || coordinates2 instanceof Float64Array) || !(coordinates2.buffer instanceof ArrayBuffer) || !Number.isSafeInteger(dimension) || dimension < 2 || coordinates2.length % dimension || !Number.isSafeInteger(chunkSize) || chunkSize < 1)
|
|
20806
21802
|
throw new Error("Expected ordinary floating-point buffers, complete records and positive chunk size");
|
|
20807
|
-
(
|
|
20808
|
-
const
|
|
20809
|
-
|
|
20810
|
-
(_b = context.reportProgress) == null ? void 0 : _b.call(context, { phase: "projection-setup", completed: 1, total: 1, unit: "tasks" });
|
|
21803
|
+
(_a3 = context.reportProgress) == null ? void 0 : _a3.call(context, { phase: "projection-setup", completed: 0, total: 1, unit: "tasks" });
|
|
21804
|
+
const projection = preparedProjection ?? new (await Promise.resolve().then(() => (init_projection(), projection_exports))).FullProjectionEngine().createProjection(input.projection);
|
|
21805
|
+
(_b2 = context.reportProgress) == null ? void 0 : _b2.call(context, { phase: "projection-setup", completed: 1, total: 1, unit: "tasks" });
|
|
20811
21806
|
const total = coordinates2.length / dimension;
|
|
20812
21807
|
(_c = context.reportProgress) == null ? void 0 : _c.call(context, { phase: "bulk-projection", completed: 0, total, unit: "records" });
|
|
20813
21808
|
for (let start = 0; start < total; start += chunkSize) {
|
|
@@ -20819,61 +21814,98 @@ async function projectBulk(input, context) {
|
|
|
20819
21814
|
projection.unprojectFlatSync(chunk, dimension);
|
|
20820
21815
|
else
|
|
20821
21816
|
projection.projectFlatSync(chunk, dimension);
|
|
20822
|
-
|
|
20823
|
-
(_f = context.sharedState) == null ? void 0 : _f.setProgress(end, total);
|
|
20824
|
-
(_g = context.reportProgress) == null ? void 0 : _g.call(context, { phase: "bulk-projection", completed: end, total, unit: "records" });
|
|
21817
|
+
(_f = context.reportProgress) == null ? void 0 : _f.call(context, { phase: "bulk-projection", completed: end, total, unit: "records" });
|
|
20825
21818
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
20826
21819
|
}
|
|
20827
21820
|
return coordinates2;
|
|
20828
21821
|
}
|
|
20829
21822
|
var init_operations = __esm({
|
|
20830
|
-
"dist/
|
|
21823
|
+
"dist/tasks/operations.js"() {
|
|
20831
21824
|
init_map_engine();
|
|
20832
21825
|
}
|
|
20833
21826
|
});
|
|
20834
21827
|
|
|
20835
|
-
// dist/
|
|
21828
|
+
// dist/tasks/index.js
|
|
20836
21829
|
var index_exports = {};
|
|
20837
21830
|
__export(index_exports, {
|
|
20838
|
-
|
|
20839
|
-
|
|
20840
|
-
projectBulkInWorker: () => projectBulkInWorker,
|
|
20841
|
-
setupMapInWorker: () => setupMapInWorker
|
|
21831
|
+
PrepareMapTask: () => PrepareMapTask2,
|
|
21832
|
+
ProjectCoordinatesTask: () => ProjectCoordinatesTask2
|
|
20842
21833
|
});
|
|
20843
21834
|
module.exports = __toCommonJS(index_exports);
|
|
20844
|
-
|
|
21835
|
+
|
|
21836
|
+
// dist/tasks/definitions.js
|
|
21837
|
+
var processCoordinates = async (input, options, context) => {
|
|
21838
|
+
const projection = input.projection ?? context.state.defaultOptions;
|
|
21839
|
+
if (!projection)
|
|
21840
|
+
throw new Error("Provide projection in the input or initializeTask");
|
|
21841
|
+
await prepareProjection(context.state, projection);
|
|
21842
|
+
const { projectBulk: projectBulk2 } = await Promise.resolve().then(() => (init_operations(), operations_exports));
|
|
21843
|
+
const coordinates2 = await projectBulk2({ ...input, projection, chunkSize: options.chunkSize }, context, context.state.projection);
|
|
21844
|
+
return { coordinates: coordinates2 };
|
|
21845
|
+
};
|
|
21846
|
+
var ProjectCoordinatesTask = {
|
|
21847
|
+
id: "project-coordinates",
|
|
21848
|
+
async preload() {
|
|
21849
|
+
await Promise.all([Promise.resolve().then(() => (init_operations(), operations_exports)), Promise.resolve().then(() => (init_projection(), projection_exports))]);
|
|
21850
|
+
},
|
|
21851
|
+
async initialize({ projection }) {
|
|
21852
|
+
const state = { defaultOptions: projection };
|
|
21853
|
+
if (projection)
|
|
21854
|
+
await prepareProjection(state, projection);
|
|
21855
|
+
return state;
|
|
21856
|
+
},
|
|
21857
|
+
destroy(state) {
|
|
21858
|
+
state.projection = void 0;
|
|
21859
|
+
state.defaultOptions = void 0;
|
|
21860
|
+
state.key = void 0;
|
|
21861
|
+
},
|
|
21862
|
+
process: processCoordinates,
|
|
21863
|
+
async *processInBatches(inputs, options, context) {
|
|
21864
|
+
for await (const input of inputs) {
|
|
21865
|
+
yield await processCoordinates(input, options, context);
|
|
21866
|
+
}
|
|
21867
|
+
}
|
|
21868
|
+
};
|
|
21869
|
+
var PrepareMapTask = {
|
|
21870
|
+
id: "prepare-map",
|
|
21871
|
+
async preload() {
|
|
21872
|
+
await Promise.resolve().then(() => (init_operations(), operations_exports));
|
|
21873
|
+
},
|
|
21874
|
+
async process({ description }, _options, context) {
|
|
21875
|
+
const { setupMap: setupMap2 } = await Promise.resolve().then(() => (init_operations(), operations_exports));
|
|
21876
|
+
return { map: setupMap2(description, context).toPrepared() };
|
|
21877
|
+
}
|
|
21878
|
+
};
|
|
21879
|
+
async function prepareProjection(state, options) {
|
|
21880
|
+
const key2 = JSON.stringify(options);
|
|
21881
|
+
if (!state.projection || state.key !== key2) {
|
|
21882
|
+
const { FullProjectionEngine: FullProjectionEngine2 } = await Promise.resolve().then(() => (init_projection(), projection_exports));
|
|
21883
|
+
const projection = new FullProjectionEngine2().createProjection(options);
|
|
21884
|
+
state.projection = projection;
|
|
21885
|
+
state.key = key2;
|
|
21886
|
+
}
|
|
21887
|
+
}
|
|
21888
|
+
|
|
21889
|
+
// dist/tasks/index.js
|
|
20845
21890
|
var import_meta = {};
|
|
21891
|
+
var _a2, _b;
|
|
21892
|
+
var isBrowser = !((_b = (_a2 = globalThis.process) == null ? void 0 : _a2.versions) == null ? void 0 : _b.node);
|
|
20846
21893
|
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
20847
21894
|
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
20848
|
-
var
|
|
20849
|
-
|
|
20850
|
-
|
|
20851
|
-
|
|
20852
|
-
|
|
20853
|
-
}
|
|
20854
|
-
|
|
20855
|
-
|
|
20856
|
-
id: "map-setup",
|
|
20857
|
-
name: "Map setup",
|
|
20858
|
-
process: async (input, _options, context) => (await Promise.resolve().then(() => (init_operations(), operations_exports))).setupMap(input, context || {}).toPrepared(),
|
|
20859
|
-
worker: new URL("./map-worker.js", moduleUrl).href,
|
|
20860
|
-
loadWorker: () => new Worker(new URL("./map-worker.js", import_meta.url), { type: "module" })
|
|
21895
|
+
var ProjectCoordinatesTask2 = {
|
|
21896
|
+
...ProjectCoordinatesTask,
|
|
21897
|
+
worker: {
|
|
21898
|
+
...!isBrowser ? { url: /* @__PURE__ */ (() => new URL("./projection-worker.js", moduleUrl).href)() } : {
|
|
21899
|
+
create: () => new Worker(new URL("./projection-worker.js", import_meta.url), { type: "module" })
|
|
21900
|
+
},
|
|
21901
|
+
capabilities: { atomic: true, streaming: true }
|
|
21902
|
+
}
|
|
20861
21903
|
};
|
|
20862
|
-
var
|
|
20863
|
-
...
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
|
|
20868
|
-
loadWorker: () => new Worker(new URL("./projection-worker.js", import_meta.url), { type: "module" })
|
|
21904
|
+
var PrepareMapTask2 = {
|
|
21905
|
+
...PrepareMapTask,
|
|
21906
|
+
worker: {
|
|
21907
|
+
...!isBrowser ? { url: /* @__PURE__ */ (() => new URL("./map-worker.js", moduleUrl).href)() } : { create: () => new Worker(new URL("./map-worker.js", import_meta.url), { type: "module" }) },
|
|
21908
|
+
capabilities: { atomic: true, streaming: false }
|
|
21909
|
+
}
|
|
20869
21910
|
};
|
|
20870
|
-
function setupMapInWorker(description, options = {}) {
|
|
20871
|
-
return (0, import_worker_utils.processOnWorker)(MapSetupWorker, description, { inputOwnership: "copy", ...options });
|
|
20872
|
-
}
|
|
20873
|
-
function projectBulkInWorker(input, options = {}) {
|
|
20874
|
-
return (0, import_worker_utils.processOnWorker)(BulkProjectionWorker, input, {
|
|
20875
|
-
inputOwnership: "copy",
|
|
20876
|
-
...options
|
|
20877
|
-
});
|
|
20878
|
-
}
|
|
20879
21911
|
//# sourceMappingURL=index.cjs.map
|