@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,144 @@
|
|
|
1
|
+
import { elementCount_ } from "../_array-length.js";
|
|
2
|
+
import { isometricLatitude_ } from "../_isometric.js";
|
|
3
|
+
import { assertParallels_, CONIC_CYLINDRICAL_LIMIT_, CONIC_PAIR_, CONIC_EDGE_TOLERANCE_, conicLongitude_, conicWrite_, } from "./_conic.js";
|
|
4
|
+
const HALF_PI_ = Math.PI / 2;
|
|
5
|
+
/**
|
|
6
|
+
* Lambert's conformal conic projection (Snyder, _Map Projections — A Working
|
|
7
|
+
* Manual_, 1987, §15, spherical form, on the unit sphere): with the standard
|
|
8
|
+
* parallels `φ₁`, `φ₂`, `ψ = asinh(tan φ)` (the isometric latitude, `ln tan(π/4 +
|
|
9
|
+
* φ/2)`), `n = ln(cos φ₁ / cos φ₂) / (ψ₂ − ψ₁)` (`sin φ₁` when the parallels
|
|
10
|
+
* are equal), `ρ = F·e^(−nψ)` and `F = cos φ₁·e^(nψ₁) / n`, `x = ρ·sin (nλ)`,
|
|
11
|
+
* `y = ρ₀ − ρ·cos(nλ)`. The formulas are rearranged so that no digits cancel as
|
|
12
|
+
* `n → 0`, where the map becomes Mercator's (a cone constant within `1e−12` of
|
|
13
|
+
* `0` is that limit exactly, inverted as Mercator's is, poles included). The
|
|
14
|
+
* pole farthest from the apex has no image: it gives `±∞` or `NaN`; the apex
|
|
15
|
+
* inverts to its pole. Inputs are longitude–latitude pairs in radians; a
|
|
16
|
+
* longitude outside `[−π, π]` or a latitude outside `[−π/2, π/2]` gives `NaN`,
|
|
17
|
+
* as does a `NaN` component. The inverses need plane coordinates below `1e150`
|
|
18
|
+
* in magnitude.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Makes the record for the standard parallels `standardParallel1` and
|
|
22
|
+
* `standardParallel2`, in radians, once; it is reused by every call.
|
|
23
|
+
*
|
|
24
|
+
* @throws {RangeError} Unless both parallels are strictly within `(−π/2, π/2)`:
|
|
25
|
+
* a pole is no standard parallel of a conformal cone.
|
|
26
|
+
*/
|
|
27
|
+
export function conicConformalCreate(standardParallel1, standardParallel2) {
|
|
28
|
+
assertParallels_("conicConformalCreate", standardParallel1, standardParallel2);
|
|
29
|
+
if (Math.abs(standardParallel1) === HALF_PI_ ||
|
|
30
|
+
Math.abs(standardParallel2) === HALF_PI_) {
|
|
31
|
+
throw new RangeError("conicConformalCreate: a pole is no standard parallel of a conformal cone.");
|
|
32
|
+
}
|
|
33
|
+
const cosine1 = Math.cos(standardParallel1);
|
|
34
|
+
const isometric1 = isometricLatitude_(standardParallel1);
|
|
35
|
+
// n = ln(cos φ₁ / cos φ₂) / (ψ₂ − ψ₁), with m = (φ₁ + φ₂) / 2 and h = (φ₂ −
|
|
36
|
+
// φ₁) / 2 as 2·atanh(tan m · tan h) / 2·atanh(sin h / cos m): no cancelling
|
|
37
|
+
// logarithms for close parallels, and sin φ₁ (the tangent cone) as h → 0.
|
|
38
|
+
const mean = (standardParallel1 + standardParallel2) / 2;
|
|
39
|
+
const half = (standardParallel2 - standardParallel1) / 2;
|
|
40
|
+
let n = half === 0
|
|
41
|
+
? Math.sin(mean)
|
|
42
|
+
: Math.atanh(Math.tan(mean) * Math.tan(half)) /
|
|
43
|
+
Math.atanh(Math.sin(half) / Math.cos(mean));
|
|
44
|
+
if (Math.abs(n) < CONIC_CYLINDRICAL_LIMIT_) {
|
|
45
|
+
n = 0;
|
|
46
|
+
}
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
kind: "conic-conformal",
|
|
49
|
+
n,
|
|
50
|
+
a: cosine1 * Math.exp(n * isometric1),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function project_(out, offset, longitude, latitude, projection) {
|
|
54
|
+
const n = projection.n;
|
|
55
|
+
const a = projection.a;
|
|
56
|
+
const valid = Math.abs(latitude) <= HALF_PI_ && Math.abs(longitude) <= Math.PI;
|
|
57
|
+
const isometric = isometricLatitude_(latitude);
|
|
58
|
+
const radius = n === 0 ? a : a * Math.exp(-n * isometric);
|
|
59
|
+
// ρ₀ − ρ, with `−expm1(−nψ) / n` (`ψ` at `n = 0`) keeping its digits.
|
|
60
|
+
const drop = n === 0 ? a * isometric : (-a * Math.expm1(-n * isometric)) / n;
|
|
61
|
+
conicWrite_(out, offset, n, radius, drop, longitude);
|
|
62
|
+
if (!valid) {
|
|
63
|
+
out[offset] = Number.NaN;
|
|
64
|
+
out[offset + 1] = Number.NaN;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function unproject_(out, offset, x, y, projection) {
|
|
68
|
+
const n = projection.n;
|
|
69
|
+
const a = projection.a;
|
|
70
|
+
if (n === 0) {
|
|
71
|
+
// The cylindrical limit is Mercator's map scaled by `G`; its inverse keeps
|
|
72
|
+
// the poles (`y = ±∞`), where η's `n·y` would be `0·∞`.
|
|
73
|
+
const longitude = x / a;
|
|
74
|
+
const valid = !Number.isNaN(y) &&
|
|
75
|
+
Math.abs(longitude) <= Math.PI * (1 + CONIC_EDGE_TOLERANCE_);
|
|
76
|
+
out[offset] = valid
|
|
77
|
+
? Math.max(-Math.PI, Math.min(Math.PI, longitude))
|
|
78
|
+
: Number.NaN;
|
|
79
|
+
out[offset + 1] = valid ? Math.atan(Math.sinh(y / a)) : Number.NaN;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// (r/G)² − 1 = n·η with η = −2y/G + n·(x² + y²)/G²: ψ = −ln(r/G) / n.
|
|
83
|
+
const eta = (-2 * y) / a + (n * (x * x + y * y)) / (a * a);
|
|
84
|
+
// (r/G)² − 1 ≥ −1; the apex (a pole) may round below it.
|
|
85
|
+
const epsilon = Math.max(-1, n * eta);
|
|
86
|
+
const factor = epsilon === 0 ? 1 : Math.log1p(epsilon) / epsilon;
|
|
87
|
+
const isometric = -0.5 * eta * factor;
|
|
88
|
+
const longitude = conicLongitude_(n, a, x, y);
|
|
89
|
+
// A `NaN` ψ is a point past the cone's far edge (or not a number).
|
|
90
|
+
const valid = !Number.isNaN(isometric) &&
|
|
91
|
+
Math.abs(longitude) <= Math.PI * (1 + CONIC_EDGE_TOLERANCE_);
|
|
92
|
+
out[offset] = valid
|
|
93
|
+
? Math.max(-Math.PI, Math.min(Math.PI, longitude))
|
|
94
|
+
: Number.NaN;
|
|
95
|
+
out[offset + 1] = valid ? Math.atan(Math.sinh(isometric)) : Number.NaN;
|
|
96
|
+
}
|
|
97
|
+
/** Writes the plane point of `coords` into `out`. */
|
|
98
|
+
export function conicConformalProject(out, coords, projection) {
|
|
99
|
+
project_(CONIC_PAIR_, 0, coords[0], coords[1], projection);
|
|
100
|
+
out[0] = CONIC_PAIR_[0];
|
|
101
|
+
out[1] = CONIC_PAIR_[1];
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
106
|
+
* point outside the map gives `NaN`.
|
|
107
|
+
*/
|
|
108
|
+
export function conicConformalUnproject(out, point, projection) {
|
|
109
|
+
unproject_(CONIC_PAIR_, 0, point[0], point[1], projection);
|
|
110
|
+
out[0] = CONIC_PAIR_[0];
|
|
111
|
+
out[1] = CONIC_PAIR_[1];
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
116
|
+
* (as many numbers), as {@link conicConformalProject} does for one. `out` may be
|
|
117
|
+
* `input`. O(n).
|
|
118
|
+
*
|
|
119
|
+
* @returns `out`.
|
|
120
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
121
|
+
*/
|
|
122
|
+
export function conicConformalProjectArray(out, input, projection) {
|
|
123
|
+
const count = elementCount_("conicConformalProjectArray", out, input, 2, 2);
|
|
124
|
+
for (let index = 0; index < count; index++) {
|
|
125
|
+
project_(out, 2 * index, input[2 * index], input[2 * index + 1], projection);
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
131
|
+
* (as many numbers), as {@link conicConformalUnproject} does for one. `out` may
|
|
132
|
+
* be `input`. O(n).
|
|
133
|
+
*
|
|
134
|
+
* @returns `out`.
|
|
135
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
136
|
+
*/
|
|
137
|
+
export function conicConformalUnprojectArray(out, input, projection) {
|
|
138
|
+
const count = elementCount_("conicConformalUnprojectArray", out, input, 2, 2);
|
|
139
|
+
for (let index = 0; index < count; index++) {
|
|
140
|
+
unproject_(out, 2 * index, input[2 * index], input[2 * index + 1], projection);
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=conic-conformal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conic-conformal.js","sourceRoot":"","sources":["../../src/conic/conic-conformal.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,qBAAqB,EAErB,eAAe,EACf,WAAW,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;;;;;GAcG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,iBAAyB,EACzB,iBAAyB;IAEzB,gBAAgB,CACf,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,CACjB,CAAC;IACF,IACC,IAAI,CAAC,GAAG,CAAC,iBAAiB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";
|
|
3
|
+
import { type ConicProjection } from "./_conic.js";
|
|
4
|
+
/**
|
|
5
|
+
* Albers' equal-area conic projection (Snyder, _Map Projections — A Working
|
|
6
|
+
* Manual_, 1987, §14, spherical form, on the unit sphere): with the standard
|
|
7
|
+
* parallels `φ₁`, `φ₂`, `n = (sin φ₁ + sin φ₂) / 2`, `C = cos²φ₁ + 2n·sin φ₁`,
|
|
8
|
+
* `ρ = √(C − 2n·sin φ) / n`, `ρ₀ = √C / n` (the equator), `x = ρ·sin(nλ)` and
|
|
9
|
+
* `y = ρ₀ − ρ·cos(nλ)`. The formulas are rearranged so that no digits cancel as
|
|
10
|
+
* `n → 0`, where the map becomes Lambert's cylindrical equal-area projection (a
|
|
11
|
+
* cone constant within `1e−12` of `0` is that limit exactly). Inputs are
|
|
12
|
+
* longitude–latitude pairs in radians; a longitude outside `[−π, π]` or a
|
|
13
|
+
* latitude outside `[−π/2, π/2]` gives `NaN`, as does a `NaN` component. The
|
|
14
|
+
* inverses need plane coordinates below `1e150` in magnitude.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The USGS standard parallels of the conterminous United States, `29.5°` and
|
|
18
|
+
* `45.5°`, in radians: `conicEqualAreaCreate(...ALBERS_PARALLELS)` is the
|
|
19
|
+
* projection the `albers` kind names.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ALBERS_PARALLELS: readonly [number, number];
|
|
22
|
+
/**
|
|
23
|
+
* Makes the record for the standard parallels `standardParallel1` and
|
|
24
|
+
* `standardParallel2`, in radians, once; it is reused by every call.
|
|
25
|
+
*
|
|
26
|
+
* @throws {RangeError} Unless both parallels are within `[−π/2, π/2]`, or when
|
|
27
|
+
* the pair is degenerate (opposite poles).
|
|
28
|
+
*/
|
|
29
|
+
export declare function conicEqualAreaCreate(standardParallel1: number, standardParallel2: number): ConicProjection;
|
|
30
|
+
/** Writes the plane point of `coords` into `out`. */
|
|
31
|
+
export declare function conicEqualAreaProject(out: Vec2, coords: ReadonlyLongitudeLatitude, projection: ConicProjection): Vec2;
|
|
32
|
+
/**
|
|
33
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
34
|
+
* point outside the map gives `NaN`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function conicEqualAreaUnproject(out: LongitudeLatitude, point: ReadonlyVec2, projection: ConicProjection): LongitudeLatitude;
|
|
37
|
+
/**
|
|
38
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
39
|
+
* (as many numbers), as {@link conicEqualAreaProject} does for one. `out` may be
|
|
40
|
+
* `input`. O(n).
|
|
41
|
+
*
|
|
42
|
+
* @returns `out`.
|
|
43
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
44
|
+
*/
|
|
45
|
+
export declare function conicEqualAreaProjectArray<T extends Float64Array>(out: T, input: Float64Array, projection: ConicProjection): T;
|
|
46
|
+
/**
|
|
47
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
48
|
+
* (as many numbers), as {@link conicEqualAreaUnproject} does for one. `out` may
|
|
49
|
+
* be `input`. O(n).
|
|
50
|
+
*
|
|
51
|
+
* @returns `out`.
|
|
52
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
53
|
+
*/
|
|
54
|
+
export declare function conicEqualAreaUnprojectArray<T extends Float64Array>(out: T, input: Float64Array, projection: ConicProjection): T;
|
|
55
|
+
//# sourceMappingURL=conic-equal-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conic-equal-area.d.ts","sourceRoot":"","sources":["../../src/conic/conic-equal-area.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;AAG9D,OAAO,EAKN,KAAK,eAAe,EAGpB,MAAM,aAAa,CAAC;AAIrB;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAGxB,CAAC;AAEhC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,iBAAiB,EAAE,MAAM,EACzB,iBAAiB,EAAE,MAAM,GACvB,eAAe,CAoBjB;AA8CD,qDAAqD;AACrD,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,EACjC,UAAU,EAAE,eAAe,GACzB,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,eAAe,GACzB,iBAAiB,CAKnB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,YAAY,EAChE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,eAAe,GACzB,CAAC,CAYH;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,YAAY,EAClE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,eAAe,GACzB,CAAC,CAYH"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { elementCount_ } from "../_array-length.js";
|
|
2
|
+
import { assertParallels_, CONIC_CYLINDRICAL_LIMIT_, CONIC_PAIR_, CONIC_EDGE_TOLERANCE_, conicLongitude_, conicWrite_, } from "./_conic.js";
|
|
3
|
+
const HALF_PI_ = Math.PI / 2;
|
|
4
|
+
/**
|
|
5
|
+
* Albers' equal-area conic projection (Snyder, _Map Projections — A Working
|
|
6
|
+
* Manual_, 1987, §14, spherical form, on the unit sphere): with the standard
|
|
7
|
+
* parallels `φ₁`, `φ₂`, `n = (sin φ₁ + sin φ₂) / 2`, `C = cos²φ₁ + 2n·sin φ₁`,
|
|
8
|
+
* `ρ = √(C − 2n·sin φ) / n`, `ρ₀ = √C / n` (the equator), `x = ρ·sin(nλ)` and
|
|
9
|
+
* `y = ρ₀ − ρ·cos(nλ)`. The formulas are rearranged so that no digits cancel as
|
|
10
|
+
* `n → 0`, where the map becomes Lambert's cylindrical equal-area projection (a
|
|
11
|
+
* cone constant within `1e−12` of `0` is that limit exactly). Inputs are
|
|
12
|
+
* longitude–latitude pairs in radians; a longitude outside `[−π, π]` or a
|
|
13
|
+
* latitude outside `[−π/2, π/2]` gives `NaN`, as does a `NaN` component. The
|
|
14
|
+
* inverses need plane coordinates below `1e150` in magnitude.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The USGS standard parallels of the conterminous United States, `29.5°` and
|
|
18
|
+
* `45.5°`, in radians: `conicEqualAreaCreate(...ALBERS_PARALLELS)` is the
|
|
19
|
+
* projection the `albers` kind names.
|
|
20
|
+
*/
|
|
21
|
+
export const ALBERS_PARALLELS = Object.freeze([
|
|
22
|
+
(29.5 * Math.PI) / 180,
|
|
23
|
+
(45.5 * Math.PI) / 180,
|
|
24
|
+
]);
|
|
25
|
+
/**
|
|
26
|
+
* Makes the record for the standard parallels `standardParallel1` and
|
|
27
|
+
* `standardParallel2`, in radians, once; it is reused by every call.
|
|
28
|
+
*
|
|
29
|
+
* @throws {RangeError} Unless both parallels are within `[−π/2, π/2]`, or when
|
|
30
|
+
* the pair is degenerate (opposite poles).
|
|
31
|
+
*/
|
|
32
|
+
export function conicEqualAreaCreate(standardParallel1, standardParallel2) {
|
|
33
|
+
assertParallels_("conicEqualAreaCreate", standardParallel1, standardParallel2);
|
|
34
|
+
const sine1 = Math.sin(standardParallel1);
|
|
35
|
+
const cosine1 = Math.cos(standardParallel1);
|
|
36
|
+
let n = (sine1 + Math.sin(standardParallel2)) / 2;
|
|
37
|
+
const constant = cosine1 * cosine1 + 2 * n * sine1;
|
|
38
|
+
if (Math.abs(n) < CONIC_CYLINDRICAL_LIMIT_) {
|
|
39
|
+
n = 0;
|
|
40
|
+
}
|
|
41
|
+
const a = Math.sqrt(Math.max(0, constant));
|
|
42
|
+
if (!(a > 1e-9)) {
|
|
43
|
+
throw new RangeError("conicEqualAreaCreate: the standard parallels are opposite poles, which map to no cone.");
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze({ kind: "conic-equal-area", n, a });
|
|
46
|
+
}
|
|
47
|
+
function project_(out, offset, longitude, latitude, projection) {
|
|
48
|
+
const n = projection.n;
|
|
49
|
+
const a = projection.a;
|
|
50
|
+
const valid = Math.abs(latitude) <= HALF_PI_ && Math.abs(longitude) <= Math.PI;
|
|
51
|
+
const sine = Math.sin(latitude);
|
|
52
|
+
const radius = Math.sqrt(Math.max(0, a * a - 2 * n * sine));
|
|
53
|
+
const drop = (2 * sine) / (a + radius);
|
|
54
|
+
conicWrite_(out, offset, n, radius, drop, longitude);
|
|
55
|
+
if (!valid) {
|
|
56
|
+
out[offset] = Number.NaN;
|
|
57
|
+
out[offset + 1] = Number.NaN;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function unproject_(out, offset, x, y, projection) {
|
|
61
|
+
const n = projection.n;
|
|
62
|
+
const a = projection.a;
|
|
63
|
+
// sin φ = (C − (nρ)²) / 2n, with ρ₀ − ρ·cos θ = y substituted.
|
|
64
|
+
const sine = a * y - (n * (x * x + y * y)) / 2;
|
|
65
|
+
const longitude = conicLongitude_(n, a, x, y);
|
|
66
|
+
const valid = Math.abs(sine) <= 1 + CONIC_EDGE_TOLERANCE_ &&
|
|
67
|
+
Math.abs(longitude) <= Math.PI * (1 + CONIC_EDGE_TOLERANCE_);
|
|
68
|
+
out[offset] = valid
|
|
69
|
+
? Math.max(-Math.PI, Math.min(Math.PI, longitude))
|
|
70
|
+
: Number.NaN;
|
|
71
|
+
out[offset + 1] = valid
|
|
72
|
+
? Math.asin(Math.max(-1, Math.min(1, sine)))
|
|
73
|
+
: Number.NaN;
|
|
74
|
+
}
|
|
75
|
+
/** Writes the plane point of `coords` into `out`. */
|
|
76
|
+
export function conicEqualAreaProject(out, coords, projection) {
|
|
77
|
+
project_(CONIC_PAIR_, 0, coords[0], coords[1], projection);
|
|
78
|
+
out[0] = CONIC_PAIR_[0];
|
|
79
|
+
out[1] = CONIC_PAIR_[1];
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
84
|
+
* point outside the map gives `NaN`.
|
|
85
|
+
*/
|
|
86
|
+
export function conicEqualAreaUnproject(out, point, projection) {
|
|
87
|
+
unproject_(CONIC_PAIR_, 0, point[0], point[1], projection);
|
|
88
|
+
out[0] = CONIC_PAIR_[0];
|
|
89
|
+
out[1] = CONIC_PAIR_[1];
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
94
|
+
* (as many numbers), as {@link conicEqualAreaProject} does for one. `out` may be
|
|
95
|
+
* `input`. O(n).
|
|
96
|
+
*
|
|
97
|
+
* @returns `out`.
|
|
98
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
99
|
+
*/
|
|
100
|
+
export function conicEqualAreaProjectArray(out, input, projection) {
|
|
101
|
+
const count = elementCount_("conicEqualAreaProjectArray", out, input, 2, 2);
|
|
102
|
+
for (let index = 0; index < count; index++) {
|
|
103
|
+
project_(out, 2 * index, input[2 * index], input[2 * index + 1], projection);
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
109
|
+
* (as many numbers), as {@link conicEqualAreaUnproject} does for one. `out` may
|
|
110
|
+
* be `input`. O(n).
|
|
111
|
+
*
|
|
112
|
+
* @returns `out`.
|
|
113
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
114
|
+
*/
|
|
115
|
+
export function conicEqualAreaUnprojectArray(out, input, projection) {
|
|
116
|
+
const count = elementCount_("conicEqualAreaUnprojectArray", out, input, 2, 2);
|
|
117
|
+
for (let index = 0; index < count; index++) {
|
|
118
|
+
unproject_(out, 2 * index, input[2 * index], input[2 * index + 1], projection);
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=conic-equal-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conic-equal-area.js","sourceRoot":"","sources":["../../src/conic/conic-equal-area.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,qBAAqB,EAErB,eAAe,EACf,WAAW,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACxE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG;IACtB,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG;CACtB,CAA8B,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,iBAAyB,EACzB,iBAAyB;IAEzB,gBAAgB,CACf,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,CACjB,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,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,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC3C,GAAM,EACN,KAAmB,EACnB,UAA2B;IAE3B,MAAM,KAAK,GAAG,aAAa,CAAC,8BAA8B,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5C,UAAU,CACT,GAAG,EACH,CAAC,GAAG,KAAK,EACT,KAAK,CAAC,CAAC,GAAG,KAAK,CAAE,EACjB,KAAK,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAE,EACrB,UAAU,CACV,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { LongitudeLatitude, ReadonlyLongitudeLatitude } from "@ac-kit/math-geometry";
|
|
2
|
+
import type { ReadonlyVec2, Vec2 } from "@ac-kit/math-linear";
|
|
3
|
+
import { type ConicProjection } from "./_conic.js";
|
|
4
|
+
/**
|
|
5
|
+
* The equidistant conic projection (Snyder, _Map Projections — A Working
|
|
6
|
+
* Manual_, 1987, §16, spherical form, on the unit sphere): the meridians are
|
|
7
|
+
* true to scale. With the standard parallels `φ₁`, `φ₂`, `n = (cos φ₁ − cos φ₂)
|
|
8
|
+
* / (φ₂ − φ₁)` (`sin φ₁` when the parallels are equal), `G = cos φ₁ / n + φ₁`,
|
|
9
|
+
* `ρ = G − φ`, `ρ₀ = G` (the equator), `x = ρ·sin(nλ)` and `y = ρ₀ −
|
|
10
|
+
* ρ·cos(nλ)`. The formulas are rearranged (with `K = n·G`) so that no digits
|
|
11
|
+
* cancel as `n → 0`, where the map becomes the equirectangular projection
|
|
12
|
+
* scaled by `cos φ₁` (a cone constant within `1e−12` of `0` is that limit
|
|
13
|
+
* exactly). Inputs are longitude–latitude pairs in radians; a longitude outside
|
|
14
|
+
* `[−π, π]` or a latitude outside `[−π/2, π/2]` gives `NaN`, as does a `NaN`
|
|
15
|
+
* component. The inverses need plane coordinates below `1e150` in magnitude.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Makes the record for the standard parallels `standardParallel1` and
|
|
19
|
+
* `standardParallel2`, in radians, once; it is reused by every call.
|
|
20
|
+
*
|
|
21
|
+
* @throws {RangeError} Unless both parallels are within `[−π/2, π/2]`, or when
|
|
22
|
+
* the pair is degenerate (opposite poles).
|
|
23
|
+
*/
|
|
24
|
+
export declare function conicEquidistantCreate(standardParallel1: number, standardParallel2: number): ConicProjection;
|
|
25
|
+
/** Writes the plane point of `coords` into `out`. */
|
|
26
|
+
export declare function conicEquidistantProject(out: Vec2, coords: ReadonlyLongitudeLatitude, projection: ConicProjection): Vec2;
|
|
27
|
+
/**
|
|
28
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
29
|
+
* point outside the map gives `NaN`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function conicEquidistantUnproject(out: LongitudeLatitude, point: ReadonlyVec2, projection: ConicProjection): LongitudeLatitude;
|
|
32
|
+
/**
|
|
33
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
34
|
+
* (as many numbers), as {@link conicEquidistantProject} does for one. `out` may
|
|
35
|
+
* be `input`. O(n).
|
|
36
|
+
*
|
|
37
|
+
* @returns `out`.
|
|
38
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
39
|
+
*/
|
|
40
|
+
export declare function conicEquidistantProjectArray<T extends Float64Array>(out: T, input: Float64Array, projection: ConicProjection): T;
|
|
41
|
+
/**
|
|
42
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
43
|
+
* (as many numbers), as {@link conicEquidistantUnproject} does for one. `out`
|
|
44
|
+
* may be `input`. O(n).
|
|
45
|
+
*
|
|
46
|
+
* @returns `out`.
|
|
47
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
48
|
+
*/
|
|
49
|
+
export declare function conicEquidistantUnprojectArray<T extends Float64Array>(out: T, input: Float64Array, projection: ConicProjection): T;
|
|
50
|
+
//# sourceMappingURL=conic-equidistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conic-equidistant.d.ts","sourceRoot":"","sources":["../../src/conic/conic-equidistant.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;AAG9D,OAAO,EAKN,KAAK,eAAe,EAIpB,MAAM,aAAa,CAAC;AAIrB;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,iBAAiB,EAAE,MAAM,EACzB,iBAAiB,EAAE,MAAM,GACvB,eAAe,CAsBjB;AA2CD,qDAAqD;AACrD,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,EACjC,UAAU,EAAE,eAAe,GACzB,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,eAAe,GACzB,iBAAiB,CAKnB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,YAAY,EAClE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,eAAe,GACzB,CAAC,CAYH;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,YAAY,EACpE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,eAAe,GACzB,CAAC,CAkBH"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { elementCount_ } from "../_array-length.js";
|
|
2
|
+
import { assertParallels_, CONIC_CYLINDRICAL_LIMIT_, CONIC_PAIR_, CONIC_EDGE_TOLERANCE_, conicLongitude_, conicRadius_, conicWrite_, } from "./_conic.js";
|
|
3
|
+
const HALF_PI_ = Math.PI / 2;
|
|
4
|
+
/**
|
|
5
|
+
* The equidistant conic projection (Snyder, _Map Projections — A Working
|
|
6
|
+
* Manual_, 1987, §16, spherical form, on the unit sphere): the meridians are
|
|
7
|
+
* true to scale. With the standard parallels `φ₁`, `φ₂`, `n = (cos φ₁ − cos φ₂)
|
|
8
|
+
* / (φ₂ − φ₁)` (`sin φ₁` when the parallels are equal), `G = cos φ₁ / n + φ₁`,
|
|
9
|
+
* `ρ = G − φ`, `ρ₀ = G` (the equator), `x = ρ·sin(nλ)` and `y = ρ₀ −
|
|
10
|
+
* ρ·cos(nλ)`. The formulas are rearranged (with `K = n·G`) so that no digits
|
|
11
|
+
* cancel as `n → 0`, where the map becomes the equirectangular projection
|
|
12
|
+
* scaled by `cos φ₁` (a cone constant within `1e−12` of `0` is that limit
|
|
13
|
+
* exactly). Inputs are longitude–latitude pairs in radians; a longitude outside
|
|
14
|
+
* `[−π, π]` or a latitude outside `[−π/2, π/2]` gives `NaN`, as does a `NaN`
|
|
15
|
+
* component. The inverses need plane coordinates below `1e150` in magnitude.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Makes the record for the standard parallels `standardParallel1` and
|
|
19
|
+
* `standardParallel2`, in radians, once; it is reused by every call.
|
|
20
|
+
*
|
|
21
|
+
* @throws {RangeError} Unless both parallels are within `[−π/2, π/2]`, or when
|
|
22
|
+
* the pair is degenerate (opposite poles).
|
|
23
|
+
*/
|
|
24
|
+
export function conicEquidistantCreate(standardParallel1, standardParallel2) {
|
|
25
|
+
assertParallels_("conicEquidistantCreate", standardParallel1, standardParallel2);
|
|
26
|
+
const cosine1 = Math.cos(standardParallel1);
|
|
27
|
+
// n = (cos φ₁ − cos φ₂) / (φ₂ − φ₁) = sin m · sin h / h, m and h as the mean
|
|
28
|
+
// and half difference: exact for close parallels, sin φ₁ when equal.
|
|
29
|
+
const mean = (standardParallel1 + standardParallel2) / 2;
|
|
30
|
+
const half = (standardParallel2 - standardParallel1) / 2;
|
|
31
|
+
let n = Math.sin(mean) * (half === 0 ? 1 : Math.sin(half) / half);
|
|
32
|
+
if (Math.abs(n) < CONIC_CYLINDRICAL_LIMIT_) {
|
|
33
|
+
n = 0;
|
|
34
|
+
}
|
|
35
|
+
const a = cosine1 + n * standardParallel1;
|
|
36
|
+
if (!(a > 1e-9)) {
|
|
37
|
+
throw new RangeError("conicEquidistantCreate: the standard parallels are opposite poles, which map to no cone.");
|
|
38
|
+
}
|
|
39
|
+
return Object.freeze({ kind: "conic-equidistant", n, a });
|
|
40
|
+
}
|
|
41
|
+
function project_(out, offset, longitude, latitude, projection) {
|
|
42
|
+
const n = projection.n;
|
|
43
|
+
const valid = Math.abs(latitude) <= HALF_PI_ && Math.abs(longitude) <= Math.PI;
|
|
44
|
+
conicWrite_(out, offset, n, projection.a - n * latitude, latitude, longitude);
|
|
45
|
+
if (!valid) {
|
|
46
|
+
out[offset] = Number.NaN;
|
|
47
|
+
out[offset + 1] = Number.NaN;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function unproject_(out, offset, x, y, projection) {
|
|
51
|
+
const n = projection.n;
|
|
52
|
+
const a = projection.a;
|
|
53
|
+
const radius = conicRadius_(n, a, x, y);
|
|
54
|
+
// φ = (K − nρ) / n, rewritten as (2K·y − n·(x² + y²)) / (K + nρ).
|
|
55
|
+
const latitude = (2 * a * y - n * (x * x + y * y)) / (a + radius);
|
|
56
|
+
const longitude = conicLongitude_(n, a, x, y);
|
|
57
|
+
const valid = Math.abs(latitude) <= HALF_PI_ * (1 + CONIC_EDGE_TOLERANCE_) &&
|
|
58
|
+
Math.abs(longitude) <= Math.PI * (1 + CONIC_EDGE_TOLERANCE_);
|
|
59
|
+
out[offset] = valid
|
|
60
|
+
? Math.max(-Math.PI, Math.min(Math.PI, longitude))
|
|
61
|
+
: Number.NaN;
|
|
62
|
+
out[offset + 1] = valid
|
|
63
|
+
? Math.max(-HALF_PI_, Math.min(HALF_PI_, latitude))
|
|
64
|
+
: Number.NaN;
|
|
65
|
+
}
|
|
66
|
+
/** Writes the plane point of `coords` into `out`. */
|
|
67
|
+
export function conicEquidistantProject(out, coords, projection) {
|
|
68
|
+
project_(CONIC_PAIR_, 0, coords[0], coords[1], projection);
|
|
69
|
+
out[0] = CONIC_PAIR_[0];
|
|
70
|
+
out[1] = CONIC_PAIR_[1];
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
75
|
+
* point outside the map gives `NaN`.
|
|
76
|
+
*/
|
|
77
|
+
export function conicEquidistantUnproject(out, point, projection) {
|
|
78
|
+
unproject_(CONIC_PAIR_, 0, point[0], point[1], projection);
|
|
79
|
+
out[0] = CONIC_PAIR_[0];
|
|
80
|
+
out[1] = CONIC_PAIR_[1];
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
85
|
+
* (as many numbers), as {@link conicEquidistantProject} does for one. `out` may
|
|
86
|
+
* be `input`. O(n).
|
|
87
|
+
*
|
|
88
|
+
* @returns `out`.
|
|
89
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
90
|
+
*/
|
|
91
|
+
export function conicEquidistantProjectArray(out, input, projection) {
|
|
92
|
+
const count = elementCount_("conicEquidistantProjectArray", out, input, 2, 2);
|
|
93
|
+
for (let index = 0; index < count; index++) {
|
|
94
|
+
project_(out, 2 * index, input[2 * index], input[2 * index + 1], projection);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
100
|
+
* (as many numbers), as {@link conicEquidistantUnproject} does for one. `out`
|
|
101
|
+
* may be `input`. O(n).
|
|
102
|
+
*
|
|
103
|
+
* @returns `out`.
|
|
104
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
105
|
+
*/
|
|
106
|
+
export function conicEquidistantUnprojectArray(out, input, projection) {
|
|
107
|
+
const count = elementCount_("conicEquidistantUnprojectArray", out, input, 2, 2);
|
|
108
|
+
for (let index = 0; index < count; index++) {
|
|
109
|
+
unproject_(out, 2 * index, input[2 * index], input[2 * index + 1], projection);
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=conic-equidistant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conic-equidistant.js","sourceRoot":"","sources":["../../src/conic/conic-equidistant.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,qBAAqB,EAErB,eAAe,EACf,YAAY,EACZ,WAAW,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACrC,iBAAyB,EACzB,iBAAyB;IAEzB,gBAAgB,CACf,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,CACjB,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC5C,6EAA6E;IAC7E,qEAAqE;IACrE,MAAM,IAAI,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,GAAG,IAAI,CA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,KAAmB,EACnB,UAA2B;IAE3B,MAAM,KAAK,GAAG,aAAa,CAC1B,gCAAgC,EAChC,GAAG,EACH,KAAK,EACL,CAAC,EACD,CAAC,CACD,CAAC;IACF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5C,UAAU,CACT,GAAG,EACH,CAAC,GAAG,KAAK,EACT,KAAK,CAAC,CAAC,GAAG,KAAK,CAAE,EACjB,KAAK,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAE,EACrB,UAAU,CACV,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LongitudeLatitude, ReadonlyLongitudeLatitude } from "@ac-kit/math-geometry";
|
|
2
|
+
import type { ReadonlyVec2, Vec2 } from "@ac-kit/math-linear";
|
|
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 declare function equirectangularProject(out: Vec2, coords: ReadonlyLongitudeLatitude): Vec2;
|
|
14
|
+
/**
|
|
15
|
+
* Writes the longitude and latitude of the plane point `point` into `out`; a
|
|
16
|
+
* point outside the rectangle `[−π, π] × [−π/2, π/2]` gives `NaN`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function equirectangularUnproject(out: LongitudeLatitude, point: ReadonlyVec2): LongitudeLatitude;
|
|
19
|
+
/**
|
|
20
|
+
* Writes the plane point of every longitude–latitude pair of `input` into `out`
|
|
21
|
+
* (as many numbers), as {@link equirectangularProject} does for one. `out` may
|
|
22
|
+
* be `input`. O(n).
|
|
23
|
+
*
|
|
24
|
+
* @returns `out`.
|
|
25
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
26
|
+
*/
|
|
27
|
+
export declare function equirectangularProjectArray<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
28
|
+
/**
|
|
29
|
+
* Writes the longitude–latitude pair of every plane point of `input` into `out`
|
|
30
|
+
* (as many numbers), as {@link equirectangularUnproject} does for one. `out` may
|
|
31
|
+
* be `input`. O(n).
|
|
32
|
+
*
|
|
33
|
+
* @returns `out`.
|
|
34
|
+
* @throws {RangeError} Unless `out` and `input` have the same even length.
|
|
35
|
+
*/
|
|
36
|
+
export declare function equirectangularUnprojectArray<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
37
|
+
//# sourceMappingURL=equirectangular.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equirectangular.d.ts","sourceRoot":"","sources":["../../src/cylindrical/equirectangular.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;AAM9D;;;;;;;;GAQG;AAEH,qDAAqD;AACrD,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,GAC/B,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAOnB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,YAAY,EACjE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAQH;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,YAAY,EACnE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAgBH"}
|