@ac-kit/math-map-projection 0.0.0-stage → 0.1.0
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/CHANGELOG.md +68 -0
- package/LICENSE +28 -0
- package/README.md +124 -2
- package/dist/_array-length.d.ts +7 -0
- package/dist/_array-length.d.ts.map +1 -0
- package/dist/_array-length.js +13 -0
- package/dist/_array-length.js.map +1 -0
- package/dist/_isometric.d.ts +8 -0
- package/dist/_isometric.d.ts.map +1 -0
- package/dist/_isometric.js +19 -0
- package/dist/_isometric.js.map +1 -0
- package/dist/azimuthal/azimuthal-equal-area.d.ts +55 -0
- package/dist/azimuthal/azimuthal-equal-area.d.ts.map +1 -0
- package/dist/azimuthal/azimuthal-equal-area.js +155 -0
- package/dist/azimuthal/azimuthal-equal-area.js.map +1 -0
- package/dist/azimuthal/azimuthal-equidistant.d.ts +55 -0
- package/dist/azimuthal/azimuthal-equidistant.d.ts.map +1 -0
- package/dist/azimuthal/azimuthal-equidistant.js +164 -0
- package/dist/azimuthal/azimuthal-equidistant.js.map +1 -0
- package/dist/azimuthal/azimuthal-projection-kind.d.ts +28 -0
- package/dist/azimuthal/azimuthal-projection-kind.d.ts.map +1 -0
- package/dist/azimuthal/azimuthal-projection-kind.js +70 -0
- package/dist/azimuthal/azimuthal-projection-kind.js.map +1 -0
- package/dist/azimuthal/gnomonic.d.ts +61 -0
- package/dist/azimuthal/gnomonic.d.ts.map +1 -0
- package/dist/azimuthal/gnomonic.js +140 -0
- package/dist/azimuthal/gnomonic.js.map +1 -0
- package/dist/azimuthal/index.d.ts +7 -0
- package/dist/azimuthal/index.d.ts.map +1 -0
- package/dist/azimuthal/index.js +7 -0
- package/dist/azimuthal/index.js.map +1 -0
- package/dist/azimuthal/orthographic.d.ts +59 -0
- package/dist/azimuthal/orthographic.d.ts.map +1 -0
- package/dist/azimuthal/orthographic.js +145 -0
- package/dist/azimuthal/orthographic.js.map +1 -0
- package/dist/azimuthal/stereographic.d.ts +59 -0
- package/dist/azimuthal/stereographic.d.ts.map +1 -0
- package/dist/azimuthal/stereographic.js +168 -0
- package/dist/azimuthal/stereographic.js.map +1 -0
- package/dist/conic/_conic.d.ts +55 -0
- package/dist/conic/_conic.d.ts.map +1 -0
- package/dist/conic/_conic.js +68 -0
- package/dist/conic/_conic.js.map +1 -0
- package/dist/conic/conic-conformal.d.ts +52 -0
- package/dist/conic/conic-conformal.d.ts.map +1 -0
- package/dist/conic/conic-conformal.js +144 -0
- package/dist/conic/conic-conformal.js.map +1 -0
- package/dist/conic/conic-equal-area.d.ts +55 -0
- package/dist/conic/conic-equal-area.d.ts.map +1 -0
- package/dist/conic/conic-equal-area.js +122 -0
- package/dist/conic/conic-equal-area.js.map +1 -0
- package/dist/conic/conic-equidistant.d.ts +50 -0
- package/dist/conic/conic-equidistant.d.ts.map +1 -0
- package/dist/conic/conic-equidistant.js +113 -0
- package/dist/conic/conic-equidistant.js.map +1 -0
- package/dist/conic/index.d.ts +5 -0
- package/dist/conic/index.d.ts.map +1 -0
- package/dist/conic/index.js +4 -0
- package/dist/conic/index.js.map +1 -0
- package/dist/cylindrical/equirectangular.d.ts +37 -0
- package/dist/cylindrical/equirectangular.d.ts.map +1 -0
- package/dist/cylindrical/equirectangular.js +67 -0
- package/dist/cylindrical/equirectangular.js.map +1 -0
- package/dist/cylindrical/index.d.ts +3 -0
- package/dist/cylindrical/index.d.ts.map +1 -0
- package/dist/cylindrical/index.js +3 -0
- package/dist/cylindrical/index.js.map +1 -0
- package/dist/cylindrical/mercator.d.ts +38 -0
- package/dist/cylindrical/mercator.d.ts.map +1 -0
- package/dist/cylindrical/mercator.js +67 -0
- package/dist/cylindrical/mercator.js.map +1 -0
- package/dist/geometry/_cut-antimeridian.d.ts +24 -0
- package/dist/geometry/_cut-antimeridian.d.ts.map +1 -0
- package/dist/geometry/_cut-antimeridian.js +204 -0
- package/dist/geometry/_cut-antimeridian.js.map +1 -0
- package/dist/geometry/_cut-cap.d.ts +29 -0
- package/dist/geometry/_cut-cap.d.ts.map +1 -0
- package/dist/geometry/_cut-cap.js +258 -0
- package/dist/geometry/_cut-cap.js.map +1 -0
- package/dist/geometry/_path.d.ts +36 -0
- package/dist/geometry/_path.d.ts.map +1 -0
- package/dist/geometry/_path.js +57 -0
- package/dist/geometry/_path.js.map +1 -0
- package/dist/geometry/_resample.d.ts +21 -0
- package/dist/geometry/_resample.d.ts.map +1 -0
- package/dist/geometry/_resample.js +190 -0
- package/dist/geometry/_resample.js.map +1 -0
- package/dist/geometry/graticule.d.ts +30 -0
- package/dist/geometry/graticule.d.ts.map +1 -0
- package/dist/geometry/graticule.js +78 -0
- package/dist/geometry/graticule.js.map +1 -0
- package/dist/geometry/index.d.ts +4 -0
- package/dist/geometry/index.d.ts.map +1 -0
- package/dist/geometry/index.js +4 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/project-geometry.d.ts +86 -0
- package/dist/geometry/project-geometry.d.ts.map +1 -0
- package/dist/geometry/project-geometry.js +269 -0
- package/dist/geometry/project-geometry.js.map +1 -0
- package/dist/geometry/vertex-runs.d.ts +37 -0
- package/dist/geometry/vertex-runs.d.ts.map +1 -0
- package/dist/geometry/vertex-runs.js +61 -0
- package/dist/geometry/vertex-runs.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/projection.d.ts +107 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +348 -0
- package/dist/projection.js.map +1 -0
- package/dist/pseudo-cylindrical/equal-earth.d.ts +28 -0
- package/dist/pseudo-cylindrical/equal-earth.d.ts.map +1 -0
- package/dist/pseudo-cylindrical/equal-earth.js +124 -0
- package/dist/pseudo-cylindrical/equal-earth.js.map +1 -0
- package/dist/pseudo-cylindrical/index.d.ts +3 -0
- package/dist/pseudo-cylindrical/index.d.ts.map +1 -0
- package/dist/pseudo-cylindrical/index.js +3 -0
- package/dist/pseudo-cylindrical/index.js.map +1 -0
- package/dist/pseudo-cylindrical/natural-earth.d.ts +28 -0
- package/dist/pseudo-cylindrical/natural-earth.d.ts.map +1 -0
- package/dist/pseudo-cylindrical/natural-earth.js +118 -0
- package/dist/pseudo-cylindrical/natural-earth.js.map +1 -0
- package/package.json +70 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { HALF_PI } from "@ac-kit/math-scalar";
|
|
3
|
+
import { MINIMUM_ANGLE_ } from "./_path.js";
|
|
4
|
+
import { assertVertexCount_, PROJECTION_MAXIMUM_VERTICES, vertexRunsFromArrays, } from "./vertex-runs.js";
|
|
5
|
+
const DEFAULT_STEP_ = Math.PI / 18;
|
|
6
|
+
const DEFAULT_MAXIMUM_ANGLE_ = Math.PI / 72;
|
|
7
|
+
const EPSILON_ = 1e-9;
|
|
8
|
+
function assertPositive_(name, value) {
|
|
9
|
+
if (!(value >= MINIMUM_ANGLE_) || !Number.isFinite(value)) {
|
|
10
|
+
throw new RangeError(`graticuleCreate: ${name} must be a finite number of at least ${MINIMUM_ANGLE_} radians, got ${describeValue(value)}.`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The graticule as polylines of longitude and latitude (radians, longitude
|
|
15
|
+
* first), before any rotation: the meridians at every multiple of
|
|
16
|
+
* `stepLongitude` in `(−π, π]`, and the parallels at every multiple of
|
|
17
|
+
* `stepLatitude` strictly between the poles, each sampled at most `maxAngle`
|
|
18
|
+
* apart (a parallel is not a great circle, so its samples stand for it).
|
|
19
|
+
* Meridians at multiples of `π / 2` run pole to pole, the others stop at the
|
|
20
|
+
* last parallel before the poles, where they would crowd. Meridians run south
|
|
21
|
+
* to north and parallels west to east. Project the result with
|
|
22
|
+
* `projectionPolylineProject`, or use `projectionGraticule`. O(n).
|
|
23
|
+
*
|
|
24
|
+
* @throws {RangeError} For a step or sample spacing that is not a finite number
|
|
25
|
+
* of at least `1e−5` radians, or settings that would make more than
|
|
26
|
+
* {@link PROJECTION_MAXIMUM_VERTICES} vertices (counted before any is made).
|
|
27
|
+
*/
|
|
28
|
+
export function graticuleCreate(options = {}) {
|
|
29
|
+
const stepLongitude = options.stepLongitude ?? DEFAULT_STEP_;
|
|
30
|
+
const stepLatitude = options.stepLatitude ?? DEFAULT_STEP_;
|
|
31
|
+
const maxAngle = options.maxAngle ?? DEFAULT_MAXIMUM_ANGLE_;
|
|
32
|
+
assertPositive_("stepLongitude", stepLongitude);
|
|
33
|
+
assertPositive_("stepLatitude", stepLatitude);
|
|
34
|
+
assertPositive_("maxAngle", maxAngle);
|
|
35
|
+
const lastParallel = Math.floor((HALF_PI - EPSILON_) / stepLatitude) * stepLatitude;
|
|
36
|
+
const first = Math.ceil((-Math.PI + EPSILON_) / stepLongitude);
|
|
37
|
+
const last = Math.floor((Math.PI + EPSILON_) / stepLongitude);
|
|
38
|
+
const meridianExtent = (index) => {
|
|
39
|
+
const quarters = (index * stepLongitude) / HALF_PI;
|
|
40
|
+
const major = Math.abs(quarters - Math.round(quarters)) < EPSILON_;
|
|
41
|
+
return major ? HALF_PI : lastParallel;
|
|
42
|
+
};
|
|
43
|
+
const meridianSegments = (extent) => Math.max(1, Math.ceil((2 * extent) / maxAngle));
|
|
44
|
+
const parallels = Math.floor((HALF_PI - EPSILON_) / stepLatitude);
|
|
45
|
+
const parallelSegments = Math.max(1, Math.ceil((2 * Math.PI) / maxAngle));
|
|
46
|
+
// The count first, so that no line is allocated past the cap.
|
|
47
|
+
let total = (2 * parallels + 1) * (parallelSegments + 1);
|
|
48
|
+
for (let index = first; index <= last && total <= PROJECTION_MAXIMUM_VERTICES; index++) {
|
|
49
|
+
const extent = meridianExtent(index);
|
|
50
|
+
if (extent > 0) {
|
|
51
|
+
total += meridianSegments(extent) + 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
assertVertexCount_("graticuleCreate", total);
|
|
55
|
+
const lines = [];
|
|
56
|
+
for (let index = first; index <= last; index++) {
|
|
57
|
+
const longitude = index * stepLongitude;
|
|
58
|
+
const extent = meridianExtent(index);
|
|
59
|
+
if (extent <= 0) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const segments = meridianSegments(extent);
|
|
63
|
+
const line = [];
|
|
64
|
+
for (let sample = 0; sample <= segments; sample++) {
|
|
65
|
+
line.push(longitude, -extent + (2 * extent * sample) / segments);
|
|
66
|
+
}
|
|
67
|
+
lines.push(line);
|
|
68
|
+
}
|
|
69
|
+
for (let index = -parallels; index <= parallels; index++) {
|
|
70
|
+
const line = [];
|
|
71
|
+
for (let sample = 0; sample <= parallelSegments; sample++) {
|
|
72
|
+
line.push(-Math.PI + (2 * Math.PI * sample) / parallelSegments, index * stepLatitude);
|
|
73
|
+
}
|
|
74
|
+
lines.push(line);
|
|
75
|
+
}
|
|
76
|
+
return vertexRunsFromArrays(lines);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=graticule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graticule.js","sourceRoot":"","sources":["../../src/geometry/graticule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAE3B,oBAAoB,GACpB,MAAM,kBAAkB,CAAC;AAe1B,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;AACnC,MAAM,sBAAsB,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;AAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,SAAS,eAAe,CAAC,IAAY,EAAE,KAAa;IACnD,IAAI,CAAC,CAAC,KAAK,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ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;QACV,CAAC;QACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,KAAK,IAAI,KAAK,GAAG,CAAC,SAAS,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,EAAE,EAAE,CAAC;YAC3D,IAAI,CAAC,IAAI,CACR,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,gBAAgB,EACpD,KAAK,GAAG,YAAY,CACpB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Projection } from "../projection.js";
|
|
2
|
+
import { type GraticuleOptions } from "./graticule.js";
|
|
3
|
+
import { type VertexRuns } from "./vertex-runs.js";
|
|
4
|
+
/** How finely the geometry functions sample. */
|
|
5
|
+
export type GeometryOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* The largest distance, in plane units, between the midpoint of a projected
|
|
8
|
+
* arc and the midpoint of its chord (default `0.001`, a thousandth of the
|
|
9
|
+
* sphere's radius): an arc is subdivided until it is that straight.
|
|
10
|
+
*/
|
|
11
|
+
tolerance?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The largest angle, in radians, an arc or a cut boundary spans between two
|
|
14
|
+
* samples (default `π / 72`, 2.5°).
|
|
15
|
+
*/
|
|
16
|
+
maxAngle?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Projects polylines, cut where the projection cannot draw them: the
|
|
20
|
+
* great-circle arcs between the vertices of each run of `lines`
|
|
21
|
+
* (longitude–latitude in radians, before the projection's rotation) are cut at
|
|
22
|
+
* the antimeridian of the rotated sphere (longitude–latitude projections) or at
|
|
23
|
+
* the clip circle (`projection.clipAngle`, the azimuthal ones), so a line that
|
|
24
|
+
* leaves the map comes back as several runs, then sampled until each arc is
|
|
25
|
+
* within `options.tolerance` of its chords. A run with fewer than two points
|
|
26
|
+
* left, and every point the projection cannot map (a pole in Mercator's), is
|
|
27
|
+
* dropped, a run being split there; so is an arc over such a pole, which runs
|
|
28
|
+
* up to it and down the far side. O(n · samples per arc).
|
|
29
|
+
*
|
|
30
|
+
* @throws {RangeError} For inconsistent `lines`, an option that is not
|
|
31
|
+
* positive, or a result of more than {@link PROJECTION_MAXIMUM_VERTICES}
|
|
32
|
+
* vertices.
|
|
33
|
+
*/
|
|
34
|
+
export declare function projectionPolylineProject(projection: Projection, lines: VertexRuns, options?: GeometryOptions): VertexRuns;
|
|
35
|
+
/**
|
|
36
|
+
* Projects polygons, cut where the projection cannot draw them. `rings` is one
|
|
37
|
+
* polygon: its first run is the exterior ring and the others its holes, each a
|
|
38
|
+
* closed ring of great-circle arcs (not repeating its first vertex;
|
|
39
|
+
* longitude–latitude in radians, before the projection's rotation) with the
|
|
40
|
+
* interior on its left, so exteriors run counter-clockwise seen from outside
|
|
41
|
+
* the sphere and holes clockwise (RFC 7946's convention). The rings are cut at
|
|
42
|
+
* the antimeridian of the rotated sphere (longitude–latitude projections) or at
|
|
43
|
+
* the clip circle (`projection.clipAngle`, the azimuthal ones) and closed along
|
|
44
|
+
* the cut, through a pole's edge where the polygon encloses it, then sampled
|
|
45
|
+
* until each arc is within `options.tolerance` of its chords. The result's
|
|
46
|
+
* rings are for a non-zero winding fill, a ring's contribution being `1` over
|
|
47
|
+
* its interior side (counter-clockwise on the plane around it; an exterior ring
|
|
48
|
+
* covering the whole map, a clockwise exterior ring, the rest of the sphere,
|
|
49
|
+
* coming with the outline ring) and `0` elsewhere, or for a hole `−1` over the
|
|
50
|
+
* disk it takes off: a cut hole comes with the outline ring reversed. Every
|
|
51
|
+
* point the projection cannot map (a pole in Mercator's) is dropped from its
|
|
52
|
+
* ring; a ring left with fewer than three points is dropped. O(n · samples per
|
|
53
|
+
* arc).
|
|
54
|
+
*
|
|
55
|
+
* A ring with no vertex in the clip circle of an azimuthal projection covers
|
|
56
|
+
* the circle (the exterior ring) or empties it (a hole) when the circle's
|
|
57
|
+
* centre lies on its interior side, decided by counting the crossings of an arc
|
|
58
|
+
* from the centre to a point just outside the ring.
|
|
59
|
+
*
|
|
60
|
+
* @throws {RangeError} For inconsistent `rings`, an option that is not
|
|
61
|
+
* positive, or a result of more than {@link PROJECTION_MAXIMUM_VERTICES}
|
|
62
|
+
* vertices.
|
|
63
|
+
*/
|
|
64
|
+
export declare function projectionPolygonProject(projection: Projection, rings: VertexRuns, options?: GeometryOptions): VertexRuns;
|
|
65
|
+
/**
|
|
66
|
+
* The graticule of {@link graticuleCreate} through the projection, cut and
|
|
67
|
+
* sampled as {@link projectionPolylineProject} does. O(n).
|
|
68
|
+
*
|
|
69
|
+
* @throws {RangeError} As {@link graticuleCreate} and
|
|
70
|
+
* {@link projectionPolylineProject} do.
|
|
71
|
+
*/
|
|
72
|
+
export declare function projectionGraticule(projection: Projection, graticule?: GraticuleOptions, options?: GeometryOptions): VertexRuns;
|
|
73
|
+
/**
|
|
74
|
+
* The outline of the map as one counter-clockwise ring of plane points (`x, y`
|
|
75
|
+
* pairs): the boundary of the cut sphere, which is the clip circle for an
|
|
76
|
+
* azimuthal projection and the projected edge of the longitude–latitude
|
|
77
|
+
* rectangle otherwise (the antimeridian on both sides, joined through the
|
|
78
|
+
* poles). A point the projection cannot map (Mercator's poles) is left out.
|
|
79
|
+
* O(n).
|
|
80
|
+
*
|
|
81
|
+
* @throws {RangeError} For `maxAngle` below 1e-5 radians (a map would hold
|
|
82
|
+
* millions of points per circle), a `tolerance` that is not positive, or an
|
|
83
|
+
* outline of more than {@link PROJECTION_MAXIMUM_VERTICES} vertices.
|
|
84
|
+
*/
|
|
85
|
+
export declare function projectionOutline(projection: Projection, options?: GeometryOptions): Float64Array;
|
|
86
|
+
//# sourceMappingURL=project-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/project-geometry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AASnD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAGN,KAAK,UAAU,EAEf,MAAM,kBAAkB,CAAC;AAE1B,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAAG;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AA6FF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACxC,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,eAAoB,GAC3B,UAAU,CAkCZ;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,eAAoB,GAC3B,UAAU,CAkFZ;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,UAAU,EACtB,SAAS,GAAE,gBAAqB,EAChC,OAAO,GAAE,eAAoB,GAC3B,UAAU,CAMZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,eAAoB,GAC3B,YAAY,CAmCd"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { longitudeLatitudeCreate, vec3FromLongitudeLatitude, } from "@ac-kit/math-geometry";
|
|
3
|
+
import { vec3Create } from "@ac-kit/math-linear";
|
|
4
|
+
import { cutLinesAtAntimeridian_, cutRingAtAntimeridian_, outlinePath_, } from "./_cut-antimeridian.js";
|
|
5
|
+
import { circlePath_, cutLinesAtCap_, cutRingAtCap_ } from "./_cut-cap.js";
|
|
6
|
+
import { MINIMUM_ANGLE_ } from "./_path.js";
|
|
7
|
+
import { resamplePath_ } from "./_resample.js";
|
|
8
|
+
import { graticuleCreate } from "./graticule.js";
|
|
9
|
+
import { assertVertexCount_, assertVertexRuns_, vertexRunsFromArrays, } from "./vertex-runs.js";
|
|
10
|
+
const DEFAULT_TOLERANCE_ = 0.001;
|
|
11
|
+
const DEFAULT_MAXIMUM_ANGLE_ = Math.PI / 72;
|
|
12
|
+
const COORDINATES_ = longitudeLatitudeCreate();
|
|
13
|
+
const UNIT_ = vec3Create();
|
|
14
|
+
function resolve_(name, options) {
|
|
15
|
+
const tolerance = options.tolerance ?? DEFAULT_TOLERANCE_;
|
|
16
|
+
const maxAngle = options.maxAngle ?? DEFAULT_MAXIMUM_ANGLE_;
|
|
17
|
+
if (!(tolerance > 0) || !Number.isFinite(tolerance)) {
|
|
18
|
+
throw new RangeError(`${name}: tolerance must be a positive finite number, got ${describeValue(tolerance)}.`);
|
|
19
|
+
}
|
|
20
|
+
if (!(maxAngle >= MINIMUM_ANGLE_) || !Number.isFinite(maxAngle)) {
|
|
21
|
+
throw new RangeError(`${name}: maxAngle must be a finite number of at least ${MINIMUM_ANGLE_} radians, got ${describeValue(maxAngle)}.`);
|
|
22
|
+
}
|
|
23
|
+
return { tolerance, maxAngle, budget: { name, used: 0 } };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The run `from..to` of `vertices` as unit vectors of the projection's rotated
|
|
27
|
+
* frame.
|
|
28
|
+
*/
|
|
29
|
+
function rotatedVectors_(projection, vertices, from, to) {
|
|
30
|
+
const rotation = projection.rotation;
|
|
31
|
+
const out = new Float64Array(3 * (to - from));
|
|
32
|
+
for (let index = from; index < to; index++) {
|
|
33
|
+
COORDINATES_[0] = vertices[2 * index];
|
|
34
|
+
COORDINATES_[1] = vertices[2 * index + 1];
|
|
35
|
+
vec3FromLongitudeLatitude(UNIT_, COORDINATES_);
|
|
36
|
+
const x = UNIT_[0];
|
|
37
|
+
const y = UNIT_[1];
|
|
38
|
+
const z = UNIT_[2];
|
|
39
|
+
const base = 3 * (index - from);
|
|
40
|
+
out[base] = rotation[0] * x + rotation[3] * y + rotation[6] * z;
|
|
41
|
+
out[base + 1] = rotation[1] * x + rotation[4] * y + rotation[7] * z;
|
|
42
|
+
out[base + 2] = rotation[2] * x + rotation[5] * y + rotation[8] * z;
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Splits `points` (`x, y` pairs) at every pair that is not finite, keeping the
|
|
48
|
+
* runs of at least `minimum` points.
|
|
49
|
+
*/
|
|
50
|
+
function splitAtNonFinite_(points, minimum, runs) {
|
|
51
|
+
let run = [];
|
|
52
|
+
for (let index = 0; index < points.length; index += 2) {
|
|
53
|
+
const x = points[index];
|
|
54
|
+
const y = points[index + 1];
|
|
55
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
56
|
+
run.push(x, y);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (run.length >= 2 * minimum) {
|
|
60
|
+
runs.push(run);
|
|
61
|
+
}
|
|
62
|
+
run = [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (run.length >= 2 * minimum) {
|
|
66
|
+
runs.push(run);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function signedArea_(points) {
|
|
70
|
+
const count = points.length / 2;
|
|
71
|
+
let sum = 0;
|
|
72
|
+
for (let index = 0; index < count; index++) {
|
|
73
|
+
const next = (index + 1) % count;
|
|
74
|
+
sum +=
|
|
75
|
+
points[2 * index] * points[2 * next + 1] -
|
|
76
|
+
points[2 * next] * points[2 * index + 1];
|
|
77
|
+
}
|
|
78
|
+
return sum / 2;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Projects polylines, cut where the projection cannot draw them: the
|
|
82
|
+
* great-circle arcs between the vertices of each run of `lines`
|
|
83
|
+
* (longitude–latitude in radians, before the projection's rotation) are cut at
|
|
84
|
+
* the antimeridian of the rotated sphere (longitude–latitude projections) or at
|
|
85
|
+
* the clip circle (`projection.clipAngle`, the azimuthal ones), so a line that
|
|
86
|
+
* leaves the map comes back as several runs, then sampled until each arc is
|
|
87
|
+
* within `options.tolerance` of its chords. A run with fewer than two points
|
|
88
|
+
* left, and every point the projection cannot map (a pole in Mercator's), is
|
|
89
|
+
* dropped, a run being split there; so is an arc over such a pole, which runs
|
|
90
|
+
* up to it and down the far side. O(n · samples per arc).
|
|
91
|
+
*
|
|
92
|
+
* @throws {RangeError} For inconsistent `lines`, an option that is not
|
|
93
|
+
* positive, or a result of more than {@link PROJECTION_MAXIMUM_VERTICES}
|
|
94
|
+
* vertices.
|
|
95
|
+
*/
|
|
96
|
+
export function projectionPolylineProject(projection, lines, options = {}) {
|
|
97
|
+
assertVertexRuns_("projectionPolylineProject", lines);
|
|
98
|
+
const { tolerance, maxAngle, budget } = resolve_("projectionPolylineProject", options);
|
|
99
|
+
const runs = [];
|
|
100
|
+
const { vertices, offsets } = lines;
|
|
101
|
+
for (let run = 0; run + 1 < offsets.length; run++) {
|
|
102
|
+
const vectors = rotatedVectors_(projection, vertices, offsets[run], offsets[run + 1]);
|
|
103
|
+
const paths = projection.family === "azimuthal"
|
|
104
|
+
? cutLinesAtCap_(vectors, projection.clipAngle)
|
|
105
|
+
: cutLinesAtAntimeridian_(vectors);
|
|
106
|
+
for (const path of paths) {
|
|
107
|
+
const points = [];
|
|
108
|
+
resamplePath_(projection, path, false, tolerance, maxAngle, points, budget);
|
|
109
|
+
splitAtNonFinite_(points, 2, runs);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return vertexRunsFromArrays(runs);
|
|
113
|
+
}
|
|
114
|
+
function reversedPoints_(points) {
|
|
115
|
+
const out = [];
|
|
116
|
+
for (let index = points.length / 2 - 1; index >= 0; index--) {
|
|
117
|
+
out.push(points[2 * index], points[2 * index + 1]);
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
/** The ring of the whole clip circle, projected. */
|
|
122
|
+
function circleRing_(projection, maxAngle, tolerance, counterClockwise, budget) {
|
|
123
|
+
const points = [];
|
|
124
|
+
resamplePath_(projection, circlePath_(projection.clipAngle, maxAngle / 2, counterClockwise), true, tolerance, maxAngle, points, budget);
|
|
125
|
+
return points;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Projects polygons, cut where the projection cannot draw them. `rings` is one
|
|
129
|
+
* polygon: its first run is the exterior ring and the others its holes, each a
|
|
130
|
+
* closed ring of great-circle arcs (not repeating its first vertex;
|
|
131
|
+
* longitude–latitude in radians, before the projection's rotation) with the
|
|
132
|
+
* interior on its left, so exteriors run counter-clockwise seen from outside
|
|
133
|
+
* the sphere and holes clockwise (RFC 7946's convention). The rings are cut at
|
|
134
|
+
* the antimeridian of the rotated sphere (longitude–latitude projections) or at
|
|
135
|
+
* the clip circle (`projection.clipAngle`, the azimuthal ones) and closed along
|
|
136
|
+
* the cut, through a pole's edge where the polygon encloses it, then sampled
|
|
137
|
+
* until each arc is within `options.tolerance` of its chords. The result's
|
|
138
|
+
* rings are for a non-zero winding fill, a ring's contribution being `1` over
|
|
139
|
+
* its interior side (counter-clockwise on the plane around it; an exterior ring
|
|
140
|
+
* covering the whole map, a clockwise exterior ring, the rest of the sphere,
|
|
141
|
+
* coming with the outline ring) and `0` elsewhere, or for a hole `−1` over the
|
|
142
|
+
* disk it takes off: a cut hole comes with the outline ring reversed. Every
|
|
143
|
+
* point the projection cannot map (a pole in Mercator's) is dropped from its
|
|
144
|
+
* ring; a ring left with fewer than three points is dropped. O(n · samples per
|
|
145
|
+
* arc).
|
|
146
|
+
*
|
|
147
|
+
* A ring with no vertex in the clip circle of an azimuthal projection covers
|
|
148
|
+
* the circle (the exterior ring) or empties it (a hole) when the circle's
|
|
149
|
+
* centre lies on its interior side, decided by counting the crossings of an arc
|
|
150
|
+
* from the centre to a point just outside the ring.
|
|
151
|
+
*
|
|
152
|
+
* @throws {RangeError} For inconsistent `rings`, an option that is not
|
|
153
|
+
* positive, or a result of more than {@link PROJECTION_MAXIMUM_VERTICES}
|
|
154
|
+
* vertices.
|
|
155
|
+
*/
|
|
156
|
+
export function projectionPolygonProject(projection, rings, options = {}) {
|
|
157
|
+
assertVertexRuns_("projectionPolygonProject", rings);
|
|
158
|
+
const { tolerance, maxAngle, budget } = resolve_("projectionPolygonProject", options);
|
|
159
|
+
const output = [];
|
|
160
|
+
const { vertices, offsets } = rings;
|
|
161
|
+
const emit = (path) => {
|
|
162
|
+
const points = [];
|
|
163
|
+
resamplePath_(projection, path, true, tolerance, maxAngle, points, budget);
|
|
164
|
+
return points;
|
|
165
|
+
};
|
|
166
|
+
for (let ring = 0; ring + 1 < offsets.length; ring++) {
|
|
167
|
+
// Rings of fewer than three vertices enclose nothing: an empty hole must not
|
|
168
|
+
// be classified (it would look like a hole around the clip circle).
|
|
169
|
+
if (offsets[ring + 1] - offsets[ring] < 3) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const exterior = ring === 0;
|
|
173
|
+
const vectors = rotatedVectors_(projection, vertices, offsets[ring], offsets[ring + 1]);
|
|
174
|
+
const pieces = [];
|
|
175
|
+
if (projection.family === "azimuthal") {
|
|
176
|
+
const cut = cutRingAtCap_(vectors, projection.clipAngle, maxAngle / 2);
|
|
177
|
+
if (cut.inside) {
|
|
178
|
+
const points = emit(cut.paths[0]);
|
|
179
|
+
if (exterior && signedArea_(points) < 0) {
|
|
180
|
+
pieces.push(circleRing_(projection, maxAngle, tolerance, true, budget));
|
|
181
|
+
}
|
|
182
|
+
pieces.push(points);
|
|
183
|
+
}
|
|
184
|
+
else if (cut.paths.length > 0) {
|
|
185
|
+
for (const path of cut.paths) {
|
|
186
|
+
pieces.push(emit(path));
|
|
187
|
+
}
|
|
188
|
+
if (!exterior) {
|
|
189
|
+
// The pieces cover the hole's interior side within the circle; a hole
|
|
190
|
+
// takes the circle's whole disk off it.
|
|
191
|
+
pieces.push(circleRing_(projection, maxAngle, tolerance, false, budget));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if (exterior ? cut.coversCenter : !cut.coversCenter) {
|
|
195
|
+
// No vertex in the cap: the exterior ring either contains it or not;
|
|
196
|
+
// a hole that contains it cancels the exterior's circle.
|
|
197
|
+
pieces.push(circleRing_(projection, maxAngle, tolerance, exterior, budget));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const cut = cutRingAtAntimeridian_(vectors, exterior, maxAngle);
|
|
202
|
+
for (const path of cut.paths) {
|
|
203
|
+
pieces.push(emit(path));
|
|
204
|
+
}
|
|
205
|
+
if (!exterior && cut.crossed) {
|
|
206
|
+
// A hole's pieces cover its interior side, the rest of the sphere
|
|
207
|
+
// beyond the hole: the whole map is taken off them.
|
|
208
|
+
pieces.push(reversedPoints_(emit(outlinePath_(maxAngle))));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const points of pieces) {
|
|
212
|
+
const kept = [];
|
|
213
|
+
for (let index = 0; index < points.length; index += 2) {
|
|
214
|
+
if (Number.isFinite(points[index]) &&
|
|
215
|
+
Number.isFinite(points[index + 1])) {
|
|
216
|
+
kept.push(points[index], points[index + 1]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (kept.length >= 6) {
|
|
220
|
+
output.push(kept);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return vertexRunsFromArrays(output);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The graticule of {@link graticuleCreate} through the projection, cut and
|
|
228
|
+
* sampled as {@link projectionPolylineProject} does. O(n).
|
|
229
|
+
*
|
|
230
|
+
* @throws {RangeError} As {@link graticuleCreate} and
|
|
231
|
+
* {@link projectionPolylineProject} do.
|
|
232
|
+
*/
|
|
233
|
+
export function projectionGraticule(projection, graticule = {}, options = {}) {
|
|
234
|
+
return projectionPolylineProject(projection, graticuleCreate(graticule), options);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The outline of the map as one counter-clockwise ring of plane points (`x, y`
|
|
238
|
+
* pairs): the boundary of the cut sphere, which is the clip circle for an
|
|
239
|
+
* azimuthal projection and the projected edge of the longitude–latitude
|
|
240
|
+
* rectangle otherwise (the antimeridian on both sides, joined through the
|
|
241
|
+
* poles). A point the projection cannot map (Mercator's poles) is left out.
|
|
242
|
+
* O(n).
|
|
243
|
+
*
|
|
244
|
+
* @throws {RangeError} For `maxAngle` below 1e-5 radians (a map would hold
|
|
245
|
+
* millions of points per circle), a `tolerance` that is not positive, or an
|
|
246
|
+
* outline of more than {@link PROJECTION_MAXIMUM_VERTICES} vertices.
|
|
247
|
+
*/
|
|
248
|
+
export function projectionOutline(projection, options = {}) {
|
|
249
|
+
const { tolerance, maxAngle, budget } = resolve_("projectionOutline", options);
|
|
250
|
+
// The rectangle's boundary, 6π long, is sampled `maxAngle` apart at most
|
|
251
|
+
// (the clip circle, 2π long, half that).
|
|
252
|
+
assertVertexCount_("projectionOutline", Math.ceil((6 * Math.PI) / maxAngle) + 5);
|
|
253
|
+
let points = [];
|
|
254
|
+
if (projection.family === "azimuthal") {
|
|
255
|
+
points = circleRing_(projection, maxAngle, tolerance, true, budget);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
resamplePath_(projection, outlinePath_(maxAngle), true, tolerance, maxAngle, points, budget);
|
|
259
|
+
}
|
|
260
|
+
const kept = [];
|
|
261
|
+
for (let index = 0; index < points.length; index += 2) {
|
|
262
|
+
if (Number.isFinite(points[index]) &&
|
|
263
|
+
Number.isFinite(points[index + 1])) {
|
|
264
|
+
kept.push(points[index], points[index + 1]);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return Float64Array.from(kept);
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=project-geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-geometry.js","sourceRoot":"","sources":["../../src/geometry/project-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACN,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;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AI,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACvC,MAAM,GAAG,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACP,aAAa,CACZ,UAAU,EACV,YAAY,CAAC,QAAQ,CAAC,EACtB,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,MAAM,CACN,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACvD,IACC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC;YAC/B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,EAClC,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAE,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list of runs of vertices in two buffers, the layout of a polyline set or of
|
|
3
|
+
* the rings of a polygon: `vertices` holds the pairs (longitude and latitude in
|
|
4
|
+
* radians for an input, plane x and y for a result), and run `r` is the pairs
|
|
5
|
+
* from index `offsets[r]` (a vertex index, not a number index) up to `offsets[r +
|
|
6
|
+
* 1]`, so `offsets` has one more entry than there are runs. A ring does not
|
|
7
|
+
* repeat its first vertex at the end.
|
|
8
|
+
*/
|
|
9
|
+
export type VertexRuns = {
|
|
10
|
+
vertices: Float64Array;
|
|
11
|
+
offsets: Uint32Array;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The most vertices (`x, y` or longitude–latitude pairs) a graticule or a
|
|
15
|
+
* projected geometry may hold, `2²⁴` (256 MiB of pairs): `graticuleCreate`,
|
|
16
|
+
* `projectionPolylineProject`, `projectionPolygonProject`,
|
|
17
|
+
* `projectionGraticule` and `projectionOutline` throw a `RangeError` naming it
|
|
18
|
+
* rather than sample more.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PROJECTION_MAXIMUM_VERTICES: number;
|
|
21
|
+
/**
|
|
22
|
+
* Throws the `RangeError` of {@link PROJECTION_MAXIMUM_VERTICES} when `count`
|
|
23
|
+
* passes it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function assertVertexCount_(name: string, count: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Packs `runs`, each an array of `x, y` pairs, into a {@link VertexRuns}. O(n).
|
|
28
|
+
*
|
|
29
|
+
* @throws {RangeError} When a run holds an odd count of numbers.
|
|
30
|
+
*/
|
|
31
|
+
export declare function vertexRunsFromArrays(runs: ReadonlyArray<ArrayLike<number>>): VertexRuns;
|
|
32
|
+
/**
|
|
33
|
+
* Throws `RangeError` unless `runs` is consistent: an even count of numbers,
|
|
34
|
+
* `offsets` starting at `0`, never decreasing, ending at the vertex count.
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertVertexRuns_(name: string, runs: VertexRuns): void;
|
|
37
|
+
//# sourceMappingURL=vertex-runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex-runs.d.ts","sourceRoot":"","sources":["../../src/geometry/vertex-runs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,QAAU,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMpE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GACpC,UAAU,CAsBZ;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAetE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most vertices (`x, y` or longitude–latitude pairs) a graticule or a
|
|
3
|
+
* projected geometry may hold, `2²⁴` (256 MiB of pairs): `graticuleCreate`,
|
|
4
|
+
* `projectionPolylineProject`, `projectionPolygonProject`,
|
|
5
|
+
* `projectionGraticule` and `projectionOutline` throw a `RangeError` naming it
|
|
6
|
+
* rather than sample more.
|
|
7
|
+
*/
|
|
8
|
+
export const PROJECTION_MAXIMUM_VERTICES = 2 ** 24;
|
|
9
|
+
/**
|
|
10
|
+
* Throws the `RangeError` of {@link PROJECTION_MAXIMUM_VERTICES} when `count`
|
|
11
|
+
* passes it.
|
|
12
|
+
*/
|
|
13
|
+
export function assertVertexCount_(name, count) {
|
|
14
|
+
if (count > PROJECTION_MAXIMUM_VERTICES) {
|
|
15
|
+
throw new RangeError(`${name}: the result would hold more than ${PROJECTION_MAXIMUM_VERTICES} vertices (PROJECTION_MAXIMUM_VERTICES); raise maxAngle, tolerance or the steps, or split the input.`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Packs `runs`, each an array of `x, y` pairs, into a {@link VertexRuns}. O(n).
|
|
20
|
+
*
|
|
21
|
+
* @throws {RangeError} When a run holds an odd count of numbers.
|
|
22
|
+
*/
|
|
23
|
+
export function vertexRunsFromArrays(runs) {
|
|
24
|
+
let total = 0;
|
|
25
|
+
for (const run of runs) {
|
|
26
|
+
if (run.length % 2 !== 0) {
|
|
27
|
+
throw new RangeError(`vertexRunsFromArrays: a run holds ${run.length} numbers, not a multiple of 2.`);
|
|
28
|
+
}
|
|
29
|
+
total += run.length;
|
|
30
|
+
}
|
|
31
|
+
const vertices = new Float64Array(total);
|
|
32
|
+
const offsets = new Uint32Array(runs.length + 1);
|
|
33
|
+
let written = 0;
|
|
34
|
+
for (let index = 0; index < runs.length; index++) {
|
|
35
|
+
const run = runs[index];
|
|
36
|
+
for (let item = 0; item < run.length; item++) {
|
|
37
|
+
vertices[written + item] = run[item];
|
|
38
|
+
}
|
|
39
|
+
written += run.length;
|
|
40
|
+
offsets[index + 1] = written / 2;
|
|
41
|
+
}
|
|
42
|
+
return { vertices, offsets };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Throws `RangeError` unless `runs` is consistent: an even count of numbers,
|
|
46
|
+
* `offsets` starting at `0`, never decreasing, ending at the vertex count.
|
|
47
|
+
*/
|
|
48
|
+
export function assertVertexRuns_(name, runs) {
|
|
49
|
+
const { vertices, offsets } = runs;
|
|
50
|
+
let valid = vertices.length % 2 === 0 &&
|
|
51
|
+
offsets.length >= 1 &&
|
|
52
|
+
offsets[0] === 0 &&
|
|
53
|
+
offsets[offsets.length - 1] === vertices.length / 2;
|
|
54
|
+
for (let index = 1; valid && index < offsets.length; index++) {
|
|
55
|
+
valid = offsets[index] >= offsets[index - 1];
|
|
56
|
+
}
|
|
57
|
+
if (!valid) {
|
|
58
|
+
throw new RangeError(`${name}: the offsets do not describe the vertices (${vertices.length} numbers, ${offsets.length} offsets).`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=vertex-runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex-runs.js","sourceRoot":"","sources":["../../src/geometry/vertex-runs.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE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;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAAgB;IAC/D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACnC,IAAI,KAAK,GACR,QAAQ,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;QACzB,OAAO,CAAC,MAAM,IAAI,CAAC;QACnB,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAChB,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAC9D,KAAK,GAAG,OAAO,CAAC,KAAK,CAAE,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;IAChD,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,MAAM,IAAI,UAAU,CACnB,GAAG,IAAI,+CAA+C,QAAQ,CAAC,MAAM,aAAa,OAAO,CAAC,MAAM,YAAY,CAC5G,CAAC;IACH,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./azimuthal/index.js";
|
|
2
|
+
export * from "./conic/index.js";
|
|
3
|
+
export * from "./cylindrical/index.js";
|
|
4
|
+
export * from "./geometry/index.js";
|
|
5
|
+
export * from "./projection.js";
|
|
6
|
+
export * from "./pseudo-cylindrical/index.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./azimuthal/index.js";
|
|
2
|
+
export * from "./conic/index.js";
|
|
3
|
+
export * from "./cylindrical/index.js";
|
|
4
|
+
export * from "./geometry/index.js";
|
|
5
|
+
export * from "./projection.js";
|
|
6
|
+
export * from "./pseudo-cylindrical/index.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC"}
|