@ac-kit/math-map-projection 0.0.0-stage → 0.2.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 +126 -0
- package/LICENSE +28 -0
- package/README.md +126 -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 +4 -0
- package/dist/cylindrical/index.d.ts.map +1 -0
- package/dist/cylindrical/index.js +4 -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/cylindrical/transverse-mercator.d.ts +32 -0
- package/dist/cylindrical/transverse-mercator.d.ts.map +1 -0
- package/dist/cylindrical/transverse-mercator.js +103 -0
- package/dist/cylindrical/transverse-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 +116 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +408 -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,67 @@
|
|
|
1
|
+
import { elementCount_ } from "../_array-length.js";
|
|
2
|
+
const HALF_PI_ = Math.PI / 2;
|
|
3
|
+
/**
|
|
4
|
+
* The equirectangular (plate carrée) projection (Snyder, _Map Projections — A
|
|
5
|
+
* Working Manual_, 1987, §12 with the equator as standard parallel): the plane
|
|
6
|
+
* x is the longitude and y the latitude, in radians. Neither is conformal nor
|
|
7
|
+
* equal-area; every meridian and parallel is true to scale. Inputs are
|
|
8
|
+
* longitude–latitude pairs in radians, a longitude outside `(−π, π]` kept as it
|
|
9
|
+
* is (wrap it first with `angleNormalizeRad`); a latitude outside `[−π/2, π/2]`
|
|
10
|
+
* gives `NaN`, as does a `NaN` component.
|
|
11
|
+
*/
|
|
12
|
+
/** Writes the plane point of `coords` into `out`. */
|
|
13
|
+
export function equirectangularProject(out, coords) {
|
|
14
|
+
const latitude = coords[1];
|
|
15
|
+
out[0] = coords[0];
|
|
16
|
+
out[1] = Math.abs(latitude) <= HALF_PI_ ? latitude : Number.NaN;
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
21
|
+
* point outside the rectangle `[−π, π] × [−π/2, π/2]` gives `NaN`.
|
|
22
|
+
*/
|
|
23
|
+
export function equirectangularUnproject(out, point) {
|
|
24
|
+
const x = point[0];
|
|
25
|
+
const y = point[1];
|
|
26
|
+
const inside = Math.abs(x) <= Math.PI && Math.abs(y) <= HALF_PI_;
|
|
27
|
+
out[0] = inside ? x : Number.NaN;
|
|
28
|
+
out[1] = inside ? y : Number.NaN;
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
33
|
+
* (as many numbers), as {@link equirectangularProject} does for one. `out` may
|
|
34
|
+
* be `input`. O(n).
|
|
35
|
+
*
|
|
36
|
+
* @returns `out`.
|
|
37
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
38
|
+
*/
|
|
39
|
+
export function equirectangularProjectArray(out, input) {
|
|
40
|
+
const count = elementCount_("equirectangularProjectArray", out, input, 2, 2);
|
|
41
|
+
for (let index = 0; index < count; index++) {
|
|
42
|
+
const latitude = input[2 * index + 1];
|
|
43
|
+
out[2 * index] = input[2 * index];
|
|
44
|
+
out[2 * index + 1] = Math.abs(latitude) <= HALF_PI_ ? latitude : Number.NaN;
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
50
|
+
* (as many numbers), as {@link equirectangularUnproject} does for one. `out` may
|
|
51
|
+
* be `input`. O(n).
|
|
52
|
+
*
|
|
53
|
+
* @returns `out`.
|
|
54
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
55
|
+
*/
|
|
56
|
+
export function equirectangularUnprojectArray(out, input) {
|
|
57
|
+
const count = elementCount_("equirectangularUnprojectArray", out, input, 2, 2);
|
|
58
|
+
for (let index = 0; index < count; index++) {
|
|
59
|
+
const x = input[2 * index];
|
|
60
|
+
const y = input[2 * index + 1];
|
|
61
|
+
const inside = Math.abs(x) <= Math.PI && Math.abs(y) <= HALF_PI_;
|
|
62
|
+
out[2 * index] = inside ? x : Number.NaN;
|
|
63
|
+
out[2 * index + 1] = inside ? y : Number.NaN;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=equirectangular.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equirectangular.js","sourceRoot":"","sources":["../../src/cylindrical/equirectangular.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE7B;;;;;;;;GAQG;AAEH,qDAAqD;AACrD,MAAM,UAAU,sBAAsB,CACrC,GAAS,EACT,MAAiC;IAEjC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAChE,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACvC,GAAsB,EACtB,KAAmB;IAEnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC;IACjE,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACjC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;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,IAAI,QAAQ,CAAC;QACjE,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QACzC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cylindrical/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cylindrical/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { LongitudeLatitude, ReadonlyLongitudeLatitude } from "@ac-kit/math-geometry";
|
|
2
|
+
import type { ReadonlyVec2, Vec2 } from "@ac-kit/math-linear";
|
|
3
|
+
/**
|
|
4
|
+
* The Mercator projection (Snyder, _Map Projections — A Working Manual_, 1987,
|
|
5
|
+
* §7, spherical form): conformal, every rhumb line a straight line. The plane x
|
|
6
|
+
* is the longitude and y is `ln tan(π/4 + φ/2)`, written `asinh(tan φ)` (the
|
|
7
|
+
* same function, which keeps its digits to within a double of the pole), in
|
|
8
|
+
* radians; the poles go to `±∞`. Inputs are longitude–latitude pairs in
|
|
9
|
+
* radians, a longitude outside `(−π, π]` kept as it is (wrap it first with
|
|
10
|
+
* `angleNormalizeRad`); a latitude outside `[−π/2, π/2]` gives `NaN`, as does a
|
|
11
|
+
* `NaN` component.
|
|
12
|
+
*/
|
|
13
|
+
/** Writes the plane point of `coords` into `out`; a pole gives `y = ±∞`. */
|
|
14
|
+
export declare function mercatorProject(out: Vec2, coords: ReadonlyLongitudeLatitude): Vec2;
|
|
15
|
+
/**
|
|
16
|
+
* Writes the longitude and latitude of the plane point `point` into `out`
|
|
17
|
+
* (`atan(sinh y)`; `y = ±∞` is a pole); a point with `|x| > π` gives `NaN`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mercatorUnproject(out: LongitudeLatitude, point: ReadonlyVec2): LongitudeLatitude;
|
|
20
|
+
/**
|
|
21
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
22
|
+
* (as many numbers), as {@link mercatorProject} does for one. `out` may be
|
|
23
|
+
* `input`. O(n).
|
|
24
|
+
*
|
|
25
|
+
* @returns `out`.
|
|
26
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mercatorProjectArray<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
29
|
+
/**
|
|
30
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
31
|
+
* (as many numbers), as {@link mercatorUnproject} does for one. `out` may be
|
|
32
|
+
* `input`. O(n).
|
|
33
|
+
*
|
|
34
|
+
* @returns `out`.
|
|
35
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mercatorUnprojectArray<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
38
|
+
//# sourceMappingURL=mercator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mercator.d.ts","sourceRoot":"","sources":["../../src/cylindrical/mercator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAK9D;;;;;;;;;GASG;AAEH,4EAA4E;AAC5E,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,GAC/B,IAAI,CAIN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAQnB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAC1D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAOH;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,YAAY,EAC5D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAUH"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { elementCount_ } from "../_array-length.js";
|
|
2
|
+
import { isometricLatitude_ } from "../_isometric.js";
|
|
3
|
+
/**
|
|
4
|
+
* The Mercator projection (Snyder, _Map Projections — A Working Manual_, 1987,
|
|
5
|
+
* §7, spherical form): conformal, every rhumb line a straight line. The plane x
|
|
6
|
+
* is the longitude and y is `ln tan(π/4 + φ/2)`, written `asinh(tan φ)` (the
|
|
7
|
+
* same function, which keeps its digits to within a double of the pole), in
|
|
8
|
+
* radians; the poles go to `±∞`. Inputs are longitude–latitude pairs in
|
|
9
|
+
* radians, a longitude outside `(−π, π]` kept as it is (wrap it first with
|
|
10
|
+
* `angleNormalizeRad`); a latitude outside `[−π/2, π/2]` gives `NaN`, as does a
|
|
11
|
+
* `NaN` component.
|
|
12
|
+
*/
|
|
13
|
+
/** Writes the plane point of `coords` into `out`; a pole gives `y = ±∞`. */
|
|
14
|
+
export function mercatorProject(out, coords) {
|
|
15
|
+
out[0] = coords[0];
|
|
16
|
+
out[1] = isometricLatitude_(coords[1]);
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Writes the longitude and latitude of the plane point `point` into `out`
|
|
21
|
+
* (`atan(sinh y)`; `y = ±∞` is a pole); a point with `|x| > π` gives `NaN`.
|
|
22
|
+
*/
|
|
23
|
+
export function mercatorUnproject(out, point) {
|
|
24
|
+
const x = point[0];
|
|
25
|
+
const y = point[1];
|
|
26
|
+
// Any y is a latitude (a far one a pole); only x bounds the map.
|
|
27
|
+
const valid = Math.abs(x) <= Math.PI && !Number.isNaN(y);
|
|
28
|
+
out[0] = valid ? x : Number.NaN;
|
|
29
|
+
out[1] = valid ? Math.atan(Math.sinh(y)) : Number.NaN;
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
34
|
+
* (as many numbers), as {@link mercatorProject} does for one. `out` may be
|
|
35
|
+
* `input`. O(n).
|
|
36
|
+
*
|
|
37
|
+
* @returns `out`.
|
|
38
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
39
|
+
*/
|
|
40
|
+
export function mercatorProjectArray(out, input) {
|
|
41
|
+
const count = elementCount_("mercatorProjectArray", out, input, 2, 2);
|
|
42
|
+
for (let index = 0; index < count; index++) {
|
|
43
|
+
out[2 * index] = input[2 * index];
|
|
44
|
+
out[2 * index + 1] = isometricLatitude_(input[2 * index + 1]);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
50
|
+
* (as many numbers), as {@link mercatorUnproject} does for one. `out` may be
|
|
51
|
+
* `input`. O(n).
|
|
52
|
+
*
|
|
53
|
+
* @returns `out`.
|
|
54
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
55
|
+
*/
|
|
56
|
+
export function mercatorUnprojectArray(out, input) {
|
|
57
|
+
const count = elementCount_("mercatorUnprojectArray", out, input, 2, 2);
|
|
58
|
+
for (let index = 0; index < count; index++) {
|
|
59
|
+
const x = input[2 * index];
|
|
60
|
+
const y = input[2 * index + 1];
|
|
61
|
+
const valid = Math.abs(x) <= Math.PI && !Number.isNaN(y);
|
|
62
|
+
out[2 * index] = valid ? x : Number.NaN;
|
|
63
|
+
out[2 * index + 1] = valid ? Math.atan(Math.sinh(y)) : Number.NaN;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=mercator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mercator.js","sourceRoot":"","sources":["../../src/cylindrical/mercator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;GASG;AAEH,4EAA4E;AAC5E,MAAM,UAAU,eAAe,CAC9B,GAAS,EACT,MAAiC;IAEjC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,GAAG,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAChC,GAAsB,EACtB,KAAmB;IAEnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,iEAAiE;IACjE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAChC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAA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CAAC;QACzD,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QACxC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LongitudeLatitude, ReadonlyLongitudeLatitude } from "@ac-kit/math-geometry";
|
|
2
|
+
import type { ReadonlyVec2, Vec2 } from "@ac-kit/math-linear";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the plane point of `coords` into `out`; finite for every finite input,
|
|
5
|
+
* x growing without bound towards the singular points `(±π/2, 0)`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function transverseMercatorProject(out: Vec2, coords: ReadonlyLongitudeLatitude): Vec2;
|
|
8
|
+
/**
|
|
9
|
+
* Writes the longitude and latitude of the plane point `point` into `out`
|
|
10
|
+
* (`atan2(sinh x, cos y)` and `asin(sin y / cosh x)`; `x = ±∞` is one of the
|
|
11
|
+
* two singular points); a point with `|y| > π` gives `NaN`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function transverseMercatorUnproject(out: LongitudeLatitude, point: ReadonlyVec2): LongitudeLatitude;
|
|
14
|
+
/**
|
|
15
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
16
|
+
* (as many numbers), as {@link transverseMercatorProject} does for one. `out`
|
|
17
|
+
* may be `input`. O(n).
|
|
18
|
+
*
|
|
19
|
+
* @returns `out`.
|
|
20
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
21
|
+
*/
|
|
22
|
+
export declare function transverseMercatorProjectArray<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
23
|
+
/**
|
|
24
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
25
|
+
* (as many numbers), as {@link transverseMercatorUnproject} does for one. `out`
|
|
26
|
+
* may be `input`. O(n).
|
|
27
|
+
*
|
|
28
|
+
* @returns `out`.
|
|
29
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
30
|
+
*/
|
|
31
|
+
export declare function transverseMercatorUnprojectArray<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
32
|
+
//# sourceMappingURL=transverse-mercator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transverse-mercator.d.ts","sourceRoot":"","sources":["../../src/cylindrical/transverse-mercator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAqC9D;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,GAC/B,IAAI,CAYN;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAOnB;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,YAAY,EACpE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAuBH;AAED;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,YAAY,EACtE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAkBH"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { elementCount_ } from "../_array-length.js";
|
|
2
|
+
/**
|
|
3
|
+
* The transverse Mercator projection on the sphere (Snyder, _Map Projections —
|
|
4
|
+
* A Working Manual_, 1987, §8, spherical form, equations 8-1 to 8-7): the
|
|
5
|
+
* Mercator projection turned a quarter so that the central meridian, longitude
|
|
6
|
+
* 0, plays the equator's part: conformal, true to scale along that meridian,
|
|
7
|
+
* the base of UTM for a narrow zone around it. The plane x is `atanh(cos φ ·
|
|
8
|
+
* sin λ)` and y is `atan2(tan φ, cos λ)`, in radians: the two points of the
|
|
9
|
+
* equator a quarter turn from the central meridian are singular (x → ±∞), and
|
|
10
|
+
* the image is the strip `−π < y ≤ π`. x is evaluated as `asinh(cos φ · sin λ /
|
|
11
|
+
* hypot(sin φ, cos φ · cos λ))`, the same function, which keeps its accuracy
|
|
12
|
+
* near the meridian a quarter turn away, where `cos φ · sin λ` rounds to 1 and
|
|
13
|
+
* `atanh` would give ∞ (`(π/2, 10⁻⁹)` is 21.4164). No double is a singular
|
|
14
|
+
* point, so x is finite for every finite input: at `(±Math.PI / 2, 0)`, which
|
|
15
|
+
* misses π/2 by 6 × 10⁻¹⁷, it is ±38.03. Inputs are longitude–latitude pairs in
|
|
16
|
+
* radians (any longitude: the map is periodic in it); a latitude outside
|
|
17
|
+
* `[−π/2, π/2]` gives `NaN`, as does a `NaN` component. The ellipsoidal form
|
|
18
|
+
* (the Krüger series of UTM) is another projection.
|
|
19
|
+
*/
|
|
20
|
+
// x from cos φ: 1 − (cos φ sin λ)² is sin² φ + (cos φ cos λ)², a sum of
|
|
21
|
+
// squares with no cancellation.
|
|
22
|
+
function transverseX_(cosLatitude, sinLatitude, longitude, cosLongitudeTerm) {
|
|
23
|
+
return Math.asinh((cosLatitude * Math.sin(longitude)) /
|
|
24
|
+
Math.hypot(sinLatitude, cosLongitudeTerm));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Writes the plane point of `coords` into `out`; finite for every finite input,
|
|
28
|
+
* x growing without bound towards the singular points `(±π/2, 0)`.
|
|
29
|
+
*/
|
|
30
|
+
export function transverseMercatorProject(out, coords) {
|
|
31
|
+
const longitude = coords[0];
|
|
32
|
+
const latitude = coords[1];
|
|
33
|
+
const cosLatitude = Math.cos(latitude);
|
|
34
|
+
const sinLatitude = Math.sin(latitude);
|
|
35
|
+
const cosLongitudeTerm = cosLatitude * Math.cos(longitude);
|
|
36
|
+
const valid = Math.abs(latitude) <= Math.PI / 2;
|
|
37
|
+
out[0] = valid
|
|
38
|
+
? transverseX_(cosLatitude, sinLatitude, longitude, cosLongitudeTerm)
|
|
39
|
+
: Number.NaN;
|
|
40
|
+
out[1] = valid ? Math.atan2(sinLatitude, cosLongitudeTerm) : Number.NaN;
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Writes the longitude and latitude of the plane point `point` into `out`
|
|
45
|
+
* (`atan2(sinh x, cos y)` and `asin(sin y / cosh x)`; `x = ±∞` is one of the
|
|
46
|
+
* two singular points); a point with `|y| > π` gives `NaN`.
|
|
47
|
+
*/
|
|
48
|
+
export function transverseMercatorUnproject(out, point) {
|
|
49
|
+
const x = point[0];
|
|
50
|
+
const y = point[1];
|
|
51
|
+
const valid = Math.abs(y) <= Math.PI && !Number.isNaN(x);
|
|
52
|
+
out[0] = valid ? Math.atan2(Math.sinh(x), Math.cos(y)) : Number.NaN;
|
|
53
|
+
out[1] = valid ? Math.asin(Math.sin(y) / Math.cosh(x)) : Number.NaN;
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
58
|
+
* (as many numbers), as {@link transverseMercatorProject} does for one. `out`
|
|
59
|
+
* may be `input`. O(n).
|
|
60
|
+
*
|
|
61
|
+
* @returns `out`.
|
|
62
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
63
|
+
*/
|
|
64
|
+
export function transverseMercatorProjectArray(out, input) {
|
|
65
|
+
const count = elementCount_("transverseMercatorProjectArray", out, input, 2, 2);
|
|
66
|
+
for (let index = 0; index < count; index++) {
|
|
67
|
+
const longitude = input[2 * index];
|
|
68
|
+
const latitude = input[2 * index + 1];
|
|
69
|
+
const cosLatitude = Math.cos(latitude);
|
|
70
|
+
const sinLatitude = Math.sin(latitude);
|
|
71
|
+
const cosLongitudeTerm = cosLatitude * Math.cos(longitude);
|
|
72
|
+
const valid = Math.abs(latitude) <= Math.PI / 2;
|
|
73
|
+
out[2 * index] = valid
|
|
74
|
+
? transverseX_(cosLatitude, sinLatitude, longitude, cosLongitudeTerm)
|
|
75
|
+
: Number.NaN;
|
|
76
|
+
out[2 * index + 1] = valid
|
|
77
|
+
? Math.atan2(sinLatitude, cosLongitudeTerm)
|
|
78
|
+
: Number.NaN;
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
84
|
+
* (as many numbers), as {@link transverseMercatorUnproject} does for one. `out`
|
|
85
|
+
* may be `input`. O(n).
|
|
86
|
+
*
|
|
87
|
+
* @returns `out`.
|
|
88
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
89
|
+
*/
|
|
90
|
+
export function transverseMercatorUnprojectArray(out, input) {
|
|
91
|
+
const count = elementCount_("transverseMercatorUnprojectArray", out, input, 2, 2);
|
|
92
|
+
for (let index = 0; index < count; index++) {
|
|
93
|
+
const x = input[2 * index];
|
|
94
|
+
const y = input[2 * index + 1];
|
|
95
|
+
const valid = Math.abs(y) <= Math.PI && !Number.isNaN(x);
|
|
96
|
+
out[2 * index] = valid ? Math.atan2(Math.sinh(x), Math.cos(y)) : Number.NaN;
|
|
97
|
+
out[2 * index + 1] = valid
|
|
98
|
+
? Math.asin(Math.sin(y) / Math.cosh(x))
|
|
99
|
+
: Number.NaN;
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=transverse-mercator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transverse-mercator.js","source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C,CAAC;QACzD,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QAC5E,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK;YACzB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACf,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Path_ } from "./_path.js";
|
|
2
|
+
/**
|
|
3
|
+
* The open pieces of the polyline `vectors` (three numbers per vertex) on each
|
|
4
|
+
* side of the antimeridian, crossings written as vertices at longitude `±π`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function cutLinesAtAntimeridian_(vectors: Float64Array): Path_[];
|
|
7
|
+
/**
|
|
8
|
+
* The whole outline of the rotated sphere as a counter-clockwise ring of the
|
|
9
|
+
* (longitude, latitude) rectangle.
|
|
10
|
+
*/
|
|
11
|
+
export declare function outlinePath_(step: number): Path_;
|
|
12
|
+
/**
|
|
13
|
+
* The closed pieces a ring is cut into: the ring itself when it does not cross
|
|
14
|
+
* the antimeridian (preceded by the outline when it is a clockwise exterior
|
|
15
|
+
* ring, whose interior is the rest of the sphere); otherwise the pieces between
|
|
16
|
+
* crossings joined along the boundary of the cut sphere (counter-clockwise, the
|
|
17
|
+
* interior being on the left of the ring), through the poles' edges where a
|
|
18
|
+
* ring encloses a pole. `crossed` tells which.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cutRingAtAntimeridian_(vectors: Float64Array, exterior: boolean, step: number): {
|
|
21
|
+
paths: Path_[];
|
|
22
|
+
crossed: boolean;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=_cut-antimeridian.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_cut-antimeridian.d.ts","sourceRoot":"","sources":["../../src/geometry/_cut-antimeridian.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,KAAK,EAMV,MAAM,YAAY,CAAC;AA8DpB;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,CAEtE;AAqED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAKhD;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,GACV;IAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA2EtC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { HALF_PI } from "@ac-kit/math-scalar";
|
|
2
|
+
import { pathAppend_, pathCreate_, pathPush_, pathPushVector_, pathSignedArea_, } from "./_path.js";
|
|
3
|
+
/**
|
|
4
|
+
* Cutting at the antimeridian of the rotated sphere, the half great circle of
|
|
5
|
+
* longitude `±π` (the plane `y = 0` with `x < 0`) where a longitude–latitude
|
|
6
|
+
* projection tears the sphere open. Input vertices are unit vectors of the
|
|
7
|
+
* rotated frame; edges are minor great-circle arcs. A vertex with `y ≥ 0` is on
|
|
8
|
+
* the `+π` side, one with `y < 0` on the `−π` side, so a vertex exactly on the
|
|
9
|
+
* cut belongs to the `+π` side.
|
|
10
|
+
*/
|
|
11
|
+
/** The perimeter of the (longitude, latitude) rectangle, `2π + π + 2π + π`. */
|
|
12
|
+
const PERIMETER_ = 6 * Math.PI;
|
|
13
|
+
/**
|
|
14
|
+
* Walks the polyline (closed: back to the first vertex, which then ends the
|
|
15
|
+
* last piece), starting a new piece at every crossing of the antimeridian.
|
|
16
|
+
*/
|
|
17
|
+
function walk_(vectors, closed) {
|
|
18
|
+
const count = vectors.length / 3;
|
|
19
|
+
const paths = [];
|
|
20
|
+
if (count === 0) {
|
|
21
|
+
return { paths, crossings: 0 };
|
|
22
|
+
}
|
|
23
|
+
let current = pathCreate_();
|
|
24
|
+
paths.push(current);
|
|
25
|
+
pathPushVector_(current, vectors[0], vectors[1], vectors[2]);
|
|
26
|
+
let crossings = 0;
|
|
27
|
+
const total = closed ? count + 1 : count;
|
|
28
|
+
for (let index = 1; index < total; index++) {
|
|
29
|
+
const from = 3 * (index - 1);
|
|
30
|
+
const to = 3 * (index % count);
|
|
31
|
+
const fromY = vectors[from + 1];
|
|
32
|
+
const toY = vectors[to + 1];
|
|
33
|
+
if (fromY < 0 !== toY < 0) {
|
|
34
|
+
// The point of the arc with y = 0, a convex combination of the ends
|
|
35
|
+
// (the chord's, normalised: same direction).
|
|
36
|
+
const along = fromY - toY;
|
|
37
|
+
const pointX = (fromY * vectors[to] - toY * vectors[from]) / along;
|
|
38
|
+
const pointZ = (fromY * vectors[to + 2] - toY * vectors[from + 2]) / along;
|
|
39
|
+
// A line through a pole (to rounding) meets every meridian there and
|
|
40
|
+
// crosses none: the resampler draws it over the pole. A ring is cut
|
|
41
|
+
// there, its pieces closed along the pole's edge.
|
|
42
|
+
const throughPole = !closed && -pointX <= 1e-12 * Math.abs(pointZ);
|
|
43
|
+
if (pointX < 0 && !throughPole) {
|
|
44
|
+
const latitude = Math.atan2(pointZ, -pointX);
|
|
45
|
+
const exit = fromY < 0 ? -Math.PI : Math.PI;
|
|
46
|
+
pathPush_(current, exit, latitude, 0);
|
|
47
|
+
crossings++;
|
|
48
|
+
current = pathCreate_();
|
|
49
|
+
paths.push(current);
|
|
50
|
+
pathPush_(current, -exit, latitude, 0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
pathPushVector_(current, vectors[to], vectors[to + 1], vectors[to + 2]);
|
|
54
|
+
}
|
|
55
|
+
return { paths, crossings };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The open pieces of the polyline `vectors` (three numbers per vertex) on each
|
|
59
|
+
* side of the antimeridian, crossings written as vertices at longitude `±π`.
|
|
60
|
+
*/
|
|
61
|
+
export function cutLinesAtAntimeridian_(vectors) {
|
|
62
|
+
return walk_(vectors, false).paths;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The boundary parameter of the point `(longitude, latitude)` of the cut
|
|
66
|
+
* rectangle, counter-clockwise from the south-west corner.
|
|
67
|
+
*/
|
|
68
|
+
function boundaryParameter_(longitude, latitude) {
|
|
69
|
+
return longitude > 0
|
|
70
|
+
? 2 * Math.PI + (latitude + HALF_PI)
|
|
71
|
+
: 5 * Math.PI + (HALF_PI - latitude);
|
|
72
|
+
}
|
|
73
|
+
function boundaryPoint_(parameter, out) {
|
|
74
|
+
if (parameter < 2 * Math.PI) {
|
|
75
|
+
out.push(-Math.PI + parameter, -HALF_PI);
|
|
76
|
+
}
|
|
77
|
+
else if (parameter < 3 * Math.PI) {
|
|
78
|
+
out.push(Math.PI, -HALF_PI + (parameter - 2 * Math.PI));
|
|
79
|
+
}
|
|
80
|
+
else if (parameter < 5 * Math.PI) {
|
|
81
|
+
out.push(Math.PI - (parameter - 3 * Math.PI), HALF_PI);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
out.push(-Math.PI, HALF_PI - (parameter - 5 * Math.PI));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const CORNERS_ = [2 * Math.PI, 3 * Math.PI, 5 * Math.PI, 6 * Math.PI];
|
|
88
|
+
/**
|
|
89
|
+
* Appends to `path` the points of the rectangle's boundary strictly between
|
|
90
|
+
* `from` and `from + length` (counter-clockwise, wrapping), the corners
|
|
91
|
+
* included and no two further apart than `step`; all are marked as sampled (and
|
|
92
|
+
* so is the edge leaving the path's last vertex).
|
|
93
|
+
*/
|
|
94
|
+
function boundarySamples_(path, from, length, step) {
|
|
95
|
+
if (path.fixed.length > 0) {
|
|
96
|
+
path.fixed[path.fixed.length - 1] = 1;
|
|
97
|
+
}
|
|
98
|
+
const marks = [0];
|
|
99
|
+
for (const corner of CORNERS_) {
|
|
100
|
+
const offset = (((corner - from) % PERIMETER_) + PERIMETER_) % PERIMETER_;
|
|
101
|
+
if (offset > 0 && offset < length) {
|
|
102
|
+
marks.push(offset);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
marks.sort((a, b) => a - b);
|
|
106
|
+
marks.push(length);
|
|
107
|
+
const point = [];
|
|
108
|
+
for (let index = 0; index + 1 < marks.length; index++) {
|
|
109
|
+
const start = marks[index];
|
|
110
|
+
const span = marks[index + 1] - start;
|
|
111
|
+
const pieces = Math.max(1, Math.ceil(span / step));
|
|
112
|
+
for (let piece = 0; piece < pieces; piece++) {
|
|
113
|
+
if (index === 0 && piece === 0) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
point.length = 0;
|
|
117
|
+
boundaryPoint_((from + start + (piece * span) / pieces) % PERIMETER_, point);
|
|
118
|
+
pathPush_(path, point[0], point[1], 1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The whole outline of the rotated sphere as a counter-clockwise ring of the
|
|
124
|
+
* (longitude, latitude) rectangle.
|
|
125
|
+
*/
|
|
126
|
+
export function outlinePath_(step) {
|
|
127
|
+
const path = pathCreate_();
|
|
128
|
+
pathPush_(path, -Math.PI, -HALF_PI, 1);
|
|
129
|
+
boundarySamples_(path, 0, PERIMETER_, step);
|
|
130
|
+
return path;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The closed pieces a ring is cut into: the ring itself when it does not cross
|
|
134
|
+
* the antimeridian (preceded by the outline when it is a clockwise exterior
|
|
135
|
+
* ring, whose interior is the rest of the sphere); otherwise the pieces between
|
|
136
|
+
* crossings joined along the boundary of the cut sphere (counter-clockwise, the
|
|
137
|
+
* interior being on the left of the ring), through the poles' edges where a
|
|
138
|
+
* ring encloses a pole. `crossed` tells which.
|
|
139
|
+
*/
|
|
140
|
+
export function cutRingAtAntimeridian_(vectors, exterior, step) {
|
|
141
|
+
const { paths, crossings } = walk_(vectors, true);
|
|
142
|
+
if (paths.length === 0) {
|
|
143
|
+
return { paths: [], crossed: false };
|
|
144
|
+
}
|
|
145
|
+
if (crossings === 0) {
|
|
146
|
+
const ring = paths[0];
|
|
147
|
+
// The walk closed the ring on its first vertex.
|
|
148
|
+
ring.coordinates.length -= 2;
|
|
149
|
+
ring.fixed.length -= 1;
|
|
150
|
+
return {
|
|
151
|
+
paths: exterior && pathSignedArea_(ring) < 0
|
|
152
|
+
? [outlinePath_(step), ring]
|
|
153
|
+
: [ring],
|
|
154
|
+
crossed: false,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const first = paths.shift();
|
|
158
|
+
const merged = paths.pop();
|
|
159
|
+
// `merged` ends on the ring's first vertex, where `first` begins.
|
|
160
|
+
for (let index = 1; index < first.fixed.length; index++) {
|
|
161
|
+
pathPush_(merged, first.coordinates[2 * index], first.coordinates[2 * index + 1], first.fixed[index]);
|
|
162
|
+
}
|
|
163
|
+
const pieces = [merged, ...paths];
|
|
164
|
+
const entries = pieces.map((piece) => boundaryParameter_(piece.coordinates[0], piece.coordinates[1]));
|
|
165
|
+
const exits = pieces.map((piece) => {
|
|
166
|
+
const last = piece.fixed.length - 1;
|
|
167
|
+
return boundaryParameter_(piece.coordinates[2 * last], piece.coordinates[2 * last + 1]);
|
|
168
|
+
});
|
|
169
|
+
const used = new Uint8Array(pieces.length);
|
|
170
|
+
const rings = [];
|
|
171
|
+
for (let start = 0; start < pieces.length; start++) {
|
|
172
|
+
if (used[start] === 1) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const ring = pathCreate_();
|
|
176
|
+
let current = start;
|
|
177
|
+
for (let guard = 0; guard <= pieces.length; guard++) {
|
|
178
|
+
used[current] = 1;
|
|
179
|
+
pathAppend_(ring, pieces[current]);
|
|
180
|
+
let next = -1;
|
|
181
|
+
let nextDistance = Number.POSITIVE_INFINITY;
|
|
182
|
+
for (let candidate = 0; candidate < pieces.length; candidate++) {
|
|
183
|
+
if (used[candidate] === 1 && candidate !== start) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const distance = (((entries[candidate] - exits[current]) % PERIMETER_) +
|
|
187
|
+
PERIMETER_) %
|
|
188
|
+
PERIMETER_;
|
|
189
|
+
if (distance < nextDistance) {
|
|
190
|
+
next = candidate;
|
|
191
|
+
nextDistance = distance;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
boundarySamples_(ring, exits[current], nextDistance, step);
|
|
195
|
+
if (next === start || next < 0) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
current = next;
|
|
199
|
+
}
|
|
200
|
+
rings.push(ring);
|
|
201
|
+
}
|
|
202
|
+
return { paths: rings, crossed: true };
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=_cut-antimeridian.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_cut-antimeridian.js","sourceRoot":"","sources":["../../src/geometry/_cut-antimeridian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAEN,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,eAAe,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AAEH,+EAA+E;AAC/E,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAI/B;;;GAGG;AACH,SAAS,KAAK,CAAC,OAAqB,EAAE,MAAe;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,MAAM,KAAK,GAAY,EAA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AAE,YAAY,EAAE,IAAI,CAAC,CAAC;YAC5D,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;gBAChC,MAAM;YACP,CAAC;YACD,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Path_ } from "./_path.js";
|
|
2
|
+
/**
|
|
3
|
+
* The whole clip circle as a path, counter-clockwise on the plane, or clockwise
|
|
4
|
+
* when `counterClockwise` is false.
|
|
5
|
+
*/
|
|
6
|
+
export declare function circlePath_(radius: number, step: number, counterClockwise: boolean): Path_;
|
|
7
|
+
/** The open pieces of a polyline inside the cap (at least two vertices each). */
|
|
8
|
+
export declare function cutLinesAtCap_(vectors: Float64Array, radius: number): Path_[];
|
|
9
|
+
export type CapRing_ = {
|
|
10
|
+
/**
|
|
11
|
+
* The closed pieces cut from the ring (rings of the cap, closed along its
|
|
12
|
+
* boundary).
|
|
13
|
+
*/
|
|
14
|
+
paths: Path_[];
|
|
15
|
+
/** Whether the ring lies wholly in the cap, `paths` being that ring alone. */
|
|
16
|
+
inside: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* For a ring with no part in the cap, whether the cap lies on the ring's
|
|
19
|
+
* interior (left) side.
|
|
20
|
+
*/
|
|
21
|
+
coversCenter: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The part of the ring `vectors` (three numbers per vertex, not repeating the
|
|
25
|
+
* first) in the cap, as rings closed along the cap's boundary (the interior on
|
|
26
|
+
* the left of the ring and of the counter-clockwise boundary).
|
|
27
|
+
*/
|
|
28
|
+
export declare function cutRingAtCap_(vectors: Float64Array, radius: number, step: number): CapRing_;
|
|
29
|
+
//# sourceMappingURL=_cut-cap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_cut-cap.d.ts","sourceRoot":"","sources":["../../src/geometry/_cut-cap.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,KAAK,KAAK,EAIV,MAAM,YAAY,CAAC;AA+CpB;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,OAAO,GACvB,KAAK,CAoBP;AAeD,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,CAsB7E;AAiHD,MAAM,MAAM,QAAQ,GAAG;IACtB;;;OAGG;IACH,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,8EAA8E;IAC9E,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACV,QAAQ,CAkFV"}
|