@nika-js/onlymap 0.2.3 → 0.3.1
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/.vscode/onlymap.code-snippets +13 -0
- package/LICENSE.md +4 -0
- package/README.md +30 -7
- package/THIRD-PARTY-LICENSES.md +7874 -0
- package/dist/{Arrow.dom-7AXne1TU.js → Arrow.dom-BNjbQ9jb.js} +23 -23
- package/dist/LercDecode.es-CVmNpXBp.js +303 -0
- package/dist/assets/LercDecode.es-BJb2dZu5.js +305 -0
- package/dist/assets/__vite-browser-external-DDArsqdc.js +29 -0
- package/dist/assets/lerc-wasm.wasm +0 -0
- package/dist/assets/lzw-BY5a_5nb.js +83 -0
- package/dist/assets/worker-DtIrTJB7.js +305 -0
- package/dist/assets/zstd-QGAv3PMm.js +383 -0
- package/dist/{basemap-BdvB-SHy.js → basemap-BSb-g03Z.js} +5729 -5684
- package/dist/basemap-registry.d.ts +10 -0
- package/dist/basemap.d.ts +23 -0
- package/dist/color.d.ts +9 -0
- package/dist/{convert-arrow-schema-CvZ3cT5m.js → convert-arrow-schema-DrAihRf9.js} +31 -31
- package/dist/ctx.d.ts +3 -0
- package/dist/deck.d.ts +28 -0
- package/dist/deck.js +16 -0
- package/dist/elements/om-map.d.ts +29 -0
- package/dist/html-data.d.ts +2 -2
- package/dist/index-CIEkseeV.js +3108 -0
- package/dist/index-D67FynN5.js +594 -0
- package/dist/{index-CJOMgp8k.js → index-QSkZjzIL.js} +4 -4
- package/dist/index-WeMwLoaQ.js +1446 -0
- package/dist/{index-BxzDKZpu.js → index-lV5eG2Xt.js} +22439 -21347
- package/dist/index.d.ts +13 -0
- package/dist/ir-snapshot.d.ts +2 -0
- package/dist/ir.d.ts +10 -0
- package/dist/layer-registry.d.ts +15 -1
- package/dist/legend-spec.d.ts +66 -0
- package/dist/lerc-DJzRIT6z.js +30 -0
- package/dist/lerc-wasm.wasm +0 -0
- package/dist/lzw-BY5a_5nb.js +83 -0
- package/dist/mgrs-BY9bIvp4.js +799 -0
- package/dist/onlymapjs.css +1 -1
- package/dist/onlymapjs.js +55 -35
- package/dist/programmatic.d.ts +35 -0
- package/dist/raster-BKf1dx54.js +8843 -0
- package/dist/raster.d.ts +61 -0
- package/dist/react/om-layer.d.ts +2 -0
- package/dist/react.js +18 -16
- package/dist/{recordbatch-HRu0SMKp.js → recordbatch-Bpc0uxFn.js} +200 -200
- package/dist/runtime-core.d.ts +73 -1
- package/dist/scene-lighting.d.ts +83 -0
- package/dist/selection.d.ts +1 -1
- package/dist/snapshot.d.ts +14 -0
- package/dist/{table-accessors-DBjWgN0C.js → table-accessors-CYWTzpQI.js} +71 -76
- package/dist/terrain.d.ts +113 -0
- package/dist/version.d.ts +1 -1
- package/dist/zstd-jXobGRcq.js +14 -0
- package/docs/custom-layers.md +99 -0
- package/llms.txt +5 -5
- package/onlymapjs.html-data.json +163 -29
- package/package.json +35 -15
- package/skills/onlymapjs/SKILL.md +3 -1
- package/skills/onlymapjs/references/syntax.md +53 -3
- package/dist/index-BVQ0s1Zh.js +0 -1457
- package/dist/index-CvBHiOGD.js +0 -605
- package/dist/index-Vc8QfNEf.js +0 -3907
- package/dist/onlymapjs.umd.cjs +0 -8634
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
class X {
|
|
2
|
+
static getId(e) {
|
|
3
|
+
const i = e.find((t) => Array.isArray(t) && t[0] === "ID");
|
|
4
|
+
return i && i.length >= 3 ? {
|
|
5
|
+
authority: i[1],
|
|
6
|
+
code: parseInt(i[2], 10)
|
|
7
|
+
} : null;
|
|
8
|
+
}
|
|
9
|
+
static convertUnit(e, i = "unit") {
|
|
10
|
+
if (!e || e.length < 3)
|
|
11
|
+
return { type: i, name: "unknown", conversion_factor: null };
|
|
12
|
+
const t = e[1], n = parseFloat(e[2]) || null, o = e.find((f) => Array.isArray(f) && f[0] === "ID"), s = o ? {
|
|
13
|
+
authority: o[1],
|
|
14
|
+
code: parseInt(o[2], 10)
|
|
15
|
+
} : null;
|
|
16
|
+
return {
|
|
17
|
+
type: i,
|
|
18
|
+
name: t,
|
|
19
|
+
conversion_factor: n,
|
|
20
|
+
id: s
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static convertAxis(e) {
|
|
24
|
+
const i = e[1] || "Unknown";
|
|
25
|
+
let t;
|
|
26
|
+
const n = i.match(/^\((.)\)$/);
|
|
27
|
+
if (n) {
|
|
28
|
+
const c = n[1].toUpperCase();
|
|
29
|
+
if (c === "E") t = "east";
|
|
30
|
+
else if (c === "N") t = "north";
|
|
31
|
+
else if (c === "U") t = "up";
|
|
32
|
+
else if (e[2]) t = e[2];
|
|
33
|
+
else throw new Error(`Unknown axis abbreviation: ${c}`);
|
|
34
|
+
} else
|
|
35
|
+
t = e[2] || "unknown";
|
|
36
|
+
const o = e.find((c) => Array.isArray(c) && c[0] === "ORDER"), s = o ? parseInt(o[1], 10) : null, f = e.find(
|
|
37
|
+
(c) => Array.isArray(c) && (c[0] === "LENGTHUNIT" || c[0] === "ANGLEUNIT" || c[0] === "SCALEUNIT")
|
|
38
|
+
), _ = this.convertUnit(f);
|
|
39
|
+
return {
|
|
40
|
+
name: i,
|
|
41
|
+
direction: t,
|
|
42
|
+
// Use the valid PROJJSON direction value
|
|
43
|
+
unit: _,
|
|
44
|
+
order: s
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
static extractAxes(e) {
|
|
48
|
+
return e.filter((i) => Array.isArray(i) && i[0] === "AXIS").map((i) => this.convertAxis(i)).sort((i, t) => (i.order || 0) - (t.order || 0));
|
|
49
|
+
}
|
|
50
|
+
static convert(e, i = {}) {
|
|
51
|
+
switch (e[0]) {
|
|
52
|
+
case "PROJCRS":
|
|
53
|
+
i.type = "ProjectedCRS", i.name = e[1], i.base_crs = e.find((r) => Array.isArray(r) && r[0] === "BASEGEOGCRS") ? this.convert(e.find((r) => Array.isArray(r) && r[0] === "BASEGEOGCRS")) : null, i.conversion = e.find((r) => Array.isArray(r) && r[0] === "CONVERSION") ? this.convert(e.find((r) => Array.isArray(r) && r[0] === "CONVERSION")) : null;
|
|
54
|
+
const t = e.find((r) => Array.isArray(r) && r[0] === "CS");
|
|
55
|
+
t && (i.coordinate_system = {
|
|
56
|
+
type: t[1],
|
|
57
|
+
axis: this.extractAxes(e)
|
|
58
|
+
});
|
|
59
|
+
const n = e.find((r) => Array.isArray(r) && r[0] === "LENGTHUNIT");
|
|
60
|
+
if (n) {
|
|
61
|
+
const r = this.convertUnit(n);
|
|
62
|
+
i.coordinate_system.unit = r;
|
|
63
|
+
}
|
|
64
|
+
i.id = this.getId(e);
|
|
65
|
+
break;
|
|
66
|
+
case "BASEGEOGCRS":
|
|
67
|
+
case "GEOGCRS":
|
|
68
|
+
case "GEODCRS":
|
|
69
|
+
i.type = e[0] === "GEODCRS" ? "GeodeticCRS" : "GeographicCRS", i.name = e[1];
|
|
70
|
+
const o = e.find(
|
|
71
|
+
(r) => Array.isArray(r) && (r[0] === "DATUM" || r[0] === "ENSEMBLE")
|
|
72
|
+
);
|
|
73
|
+
if (o) {
|
|
74
|
+
const r = this.convert(o);
|
|
75
|
+
o[0] === "ENSEMBLE" ? i.datum_ensemble = r : i.datum = r;
|
|
76
|
+
const h = e.find((l) => Array.isArray(l) && l[0] === "PRIMEM");
|
|
77
|
+
h && h[1] !== "Greenwich" && (r.prime_meridian = {
|
|
78
|
+
name: h[1],
|
|
79
|
+
longitude: parseFloat(h[2])
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
i.coordinate_system = {
|
|
83
|
+
type: "ellipsoidal",
|
|
84
|
+
axis: this.extractAxes(e)
|
|
85
|
+
}, i.id = this.getId(e);
|
|
86
|
+
break;
|
|
87
|
+
case "DATUM":
|
|
88
|
+
i.type = "GeodeticReferenceFrame", i.name = e[1], i.ellipsoid = e.find((r) => Array.isArray(r) && r[0] === "ELLIPSOID") ? this.convert(e.find((r) => Array.isArray(r) && r[0] === "ELLIPSOID")) : null;
|
|
89
|
+
break;
|
|
90
|
+
case "ENSEMBLE":
|
|
91
|
+
i.type = "DatumEnsemble", i.name = e[1], i.members = e.filter((r) => Array.isArray(r) && r[0] === "MEMBER").map((r) => ({
|
|
92
|
+
type: "DatumEnsembleMember",
|
|
93
|
+
name: r[1],
|
|
94
|
+
id: this.getId(r)
|
|
95
|
+
// Extract ID as { authority, code }
|
|
96
|
+
}));
|
|
97
|
+
const s = e.find((r) => Array.isArray(r) && r[0] === "ENSEMBLEACCURACY");
|
|
98
|
+
s && (i.accuracy = parseFloat(s[1]));
|
|
99
|
+
const f = e.find((r) => Array.isArray(r) && r[0] === "ELLIPSOID");
|
|
100
|
+
f && (i.ellipsoid = this.convert(f)), i.id = this.getId(e);
|
|
101
|
+
break;
|
|
102
|
+
case "ELLIPSOID":
|
|
103
|
+
i.type = "Ellipsoid", i.name = e[1], i.semi_major_axis = parseFloat(e[2]), i.inverse_flattening = parseFloat(e[3]), e.find((r) => Array.isArray(r) && r[0] === "LENGTHUNIT") && this.convert(e.find((r) => Array.isArray(r) && r[0] === "LENGTHUNIT"), i);
|
|
104
|
+
break;
|
|
105
|
+
case "CONVERSION":
|
|
106
|
+
i.type = "Conversion", i.name = e[1], i.method = e.find((r) => Array.isArray(r) && r[0] === "METHOD") ? this.convert(e.find((r) => Array.isArray(r) && r[0] === "METHOD")) : null, i.parameters = e.filter((r) => Array.isArray(r) && r[0] === "PARAMETER").map((r) => this.convert(r));
|
|
107
|
+
break;
|
|
108
|
+
case "METHOD":
|
|
109
|
+
i.type = "Method", i.name = e[1], i.id = this.getId(e);
|
|
110
|
+
break;
|
|
111
|
+
case "PARAMETER":
|
|
112
|
+
i.type = "Parameter", i.name = e[1], i.value = parseFloat(e[2]), i.unit = this.convertUnit(
|
|
113
|
+
e.find(
|
|
114
|
+
(r) => Array.isArray(r) && (r[0] === "LENGTHUNIT" || r[0] === "ANGLEUNIT" || r[0] === "SCALEUNIT")
|
|
115
|
+
)
|
|
116
|
+
), i.id = this.getId(e);
|
|
117
|
+
break;
|
|
118
|
+
case "BOUNDCRS":
|
|
119
|
+
i.type = "BoundCRS";
|
|
120
|
+
const _ = e.find((r) => Array.isArray(r) && r[0] === "SOURCECRS");
|
|
121
|
+
if (_) {
|
|
122
|
+
const r = _.find((h) => Array.isArray(h));
|
|
123
|
+
i.source_crs = r ? this.convert(r) : null;
|
|
124
|
+
}
|
|
125
|
+
const c = e.find((r) => Array.isArray(r) && r[0] === "TARGETCRS");
|
|
126
|
+
if (c) {
|
|
127
|
+
const r = c.find((h) => Array.isArray(h));
|
|
128
|
+
i.target_crs = r ? this.convert(r) : null;
|
|
129
|
+
}
|
|
130
|
+
const u = e.find((r) => Array.isArray(r) && r[0] === "ABRIDGEDTRANSFORMATION");
|
|
131
|
+
u ? i.transformation = this.convert(u) : i.transformation = null;
|
|
132
|
+
break;
|
|
133
|
+
case "ABRIDGEDTRANSFORMATION":
|
|
134
|
+
if (i.type = "Transformation", i.name = e[1], i.method = e.find((r) => Array.isArray(r) && r[0] === "METHOD") ? this.convert(e.find((r) => Array.isArray(r) && r[0] === "METHOD")) : null, i.parameters = e.filter((r) => Array.isArray(r) && (r[0] === "PARAMETER" || r[0] === "PARAMETERFILE")).map((r) => {
|
|
135
|
+
if (r[0] === "PARAMETER")
|
|
136
|
+
return this.convert(r);
|
|
137
|
+
if (r[0] === "PARAMETERFILE")
|
|
138
|
+
return {
|
|
139
|
+
name: r[1],
|
|
140
|
+
value: r[2],
|
|
141
|
+
id: {
|
|
142
|
+
authority: "EPSG",
|
|
143
|
+
code: 8656
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}), i.parameters.length === 7) {
|
|
147
|
+
const r = i.parameters[6];
|
|
148
|
+
r.name === "Scale difference" && (r.value = Math.round((r.value - 1) * 1e12) / 1e6);
|
|
149
|
+
}
|
|
150
|
+
i.id = this.getId(e);
|
|
151
|
+
break;
|
|
152
|
+
case "AXIS":
|
|
153
|
+
i.coordinate_system || (i.coordinate_system = { type: "unspecified", axis: [] }), i.coordinate_system.axis.push(this.convertAxis(e));
|
|
154
|
+
break;
|
|
155
|
+
case "LENGTHUNIT":
|
|
156
|
+
const d = this.convertUnit(e, "LinearUnit");
|
|
157
|
+
i.coordinate_system && i.coordinate_system.axis && i.coordinate_system.axis.forEach((r) => {
|
|
158
|
+
r.unit || (r.unit = d);
|
|
159
|
+
}), d.conversion_factor && d.conversion_factor !== 1 && i.semi_major_axis && (i.semi_major_axis = {
|
|
160
|
+
value: i.semi_major_axis,
|
|
161
|
+
unit: d
|
|
162
|
+
});
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
i.keyword = e[0];
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
return i;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
class re extends X {
|
|
172
|
+
static convert(e, i = {}) {
|
|
173
|
+
return super.convert(e, i), i.coordinate_system && i.coordinate_system.subtype === "Cartesian" && delete i.coordinate_system, i.usage && delete i.usage, i;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class te extends X {
|
|
177
|
+
static convert(e, i = {}) {
|
|
178
|
+
super.convert(e, i);
|
|
179
|
+
const t = e.find((o) => Array.isArray(o) && o[0] === "CS");
|
|
180
|
+
t && (i.coordinate_system = {
|
|
181
|
+
subtype: t[1],
|
|
182
|
+
axis: this.extractAxes(e)
|
|
183
|
+
});
|
|
184
|
+
const n = e.find((o) => Array.isArray(o) && o[0] === "USAGE");
|
|
185
|
+
if (n) {
|
|
186
|
+
const o = n.find((_) => Array.isArray(_) && _[0] === "SCOPE"), s = n.find((_) => Array.isArray(_) && _[0] === "AREA"), f = n.find((_) => Array.isArray(_) && _[0] === "BBOX");
|
|
187
|
+
i.usage = {}, o && (i.usage.scope = o[1]), s && (i.usage.area = s[1]), f && (i.usage.bbox = f.slice(1));
|
|
188
|
+
}
|
|
189
|
+
return i;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function ne(a) {
|
|
193
|
+
return a.find((e) => Array.isArray(e) && e[0] === "USAGE") ? "2019" : (a.find((e) => Array.isArray(e) && e[0] === "CS") || a[0] === "BOUNDCRS" || a[0] === "PROJCRS" || a[0] === "GEOGCRS", "2015");
|
|
194
|
+
}
|
|
195
|
+
function oe(a) {
|
|
196
|
+
return (ne(a) === "2019" ? te : re).convert(a);
|
|
197
|
+
}
|
|
198
|
+
function se(a) {
|
|
199
|
+
const e = a.toUpperCase();
|
|
200
|
+
return e.includes("PROJCRS") || e.includes("GEOGCRS") || e.includes("BOUNDCRS") || e.includes("VERTCRS") || e.includes("LENGTHUNIT") || e.includes("ANGLEUNIT") || e.includes("SCALEUNIT") ? "WKT2" : (e.includes("PROJCS") || e.includes("GEOGCS") || e.includes("LOCAL_CS") || e.includes("VERT_CS") || e.includes("UNIT"), "WKT1");
|
|
201
|
+
}
|
|
202
|
+
var O = 1, Z = 2, Y = 3, L = 4, Q = 5, z = -1, fe = /\s/, ce = /[A-Za-z]/, de = /[A-Za-z84_]/, D = /[,\]]/, $ = /[\d\.E\-\+]/;
|
|
203
|
+
function v(a) {
|
|
204
|
+
if (typeof a != "string")
|
|
205
|
+
throw new Error("not a string");
|
|
206
|
+
this.text = a.trim(), this.level = 0, this.place = 0, this.root = null, this.stack = [], this.currentObject = null, this.state = O;
|
|
207
|
+
}
|
|
208
|
+
v.prototype.readCharicter = function() {
|
|
209
|
+
var a = this.text[this.place++];
|
|
210
|
+
if (this.state !== L)
|
|
211
|
+
for (; fe.test(a); ) {
|
|
212
|
+
if (this.place >= this.text.length)
|
|
213
|
+
return;
|
|
214
|
+
a = this.text[this.place++];
|
|
215
|
+
}
|
|
216
|
+
switch (this.state) {
|
|
217
|
+
case O:
|
|
218
|
+
return this.neutral(a);
|
|
219
|
+
case Z:
|
|
220
|
+
return this.keyword(a);
|
|
221
|
+
case L:
|
|
222
|
+
return this.quoted(a);
|
|
223
|
+
case Q:
|
|
224
|
+
return this.afterquote(a);
|
|
225
|
+
case Y:
|
|
226
|
+
return this.number(a);
|
|
227
|
+
case z:
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
v.prototype.afterquote = function(a) {
|
|
232
|
+
if (a === '"') {
|
|
233
|
+
this.word += '"', this.state = L;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (D.test(a)) {
|
|
237
|
+
this.word = this.word.trim(), this.afterItem(a);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
throw new Error(`havn't handled "` + a + '" in afterquote yet, index ' + this.place);
|
|
241
|
+
};
|
|
242
|
+
v.prototype.afterItem = function(a) {
|
|
243
|
+
if (a === ",") {
|
|
244
|
+
this.word !== null && this.currentObject.push(this.word), this.word = null, this.state = O;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (a === "]") {
|
|
248
|
+
this.level--, this.word !== null && (this.currentObject.push(this.word), this.word = null), this.state = O, this.currentObject = this.stack.pop(), this.currentObject || (this.state = z);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
v.prototype.number = function(a) {
|
|
253
|
+
if ($.test(a)) {
|
|
254
|
+
this.word += a;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (D.test(a)) {
|
|
258
|
+
this.word = parseFloat(this.word), this.afterItem(a);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
throw new Error(`havn't handled "` + a + '" in number yet, index ' + this.place);
|
|
262
|
+
};
|
|
263
|
+
v.prototype.quoted = function(a) {
|
|
264
|
+
if (a === '"') {
|
|
265
|
+
this.state = Q;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
this.word += a;
|
|
269
|
+
};
|
|
270
|
+
v.prototype.keyword = function(a) {
|
|
271
|
+
if (de.test(a)) {
|
|
272
|
+
this.word += a;
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (a === "[") {
|
|
276
|
+
var e = [];
|
|
277
|
+
e.push(this.word), this.level++, this.root === null ? this.root = e : this.currentObject.push(e), this.stack.push(this.currentObject), this.currentObject = e, this.state = O;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (D.test(a)) {
|
|
281
|
+
this.afterItem(a);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
throw new Error(`havn't handled "` + a + '" in keyword yet, index ' + this.place);
|
|
285
|
+
};
|
|
286
|
+
v.prototype.neutral = function(a) {
|
|
287
|
+
if (ce.test(a)) {
|
|
288
|
+
this.word = a, this.state = Z;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (a === '"') {
|
|
292
|
+
this.word = "", this.state = L;
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if ($.test(a)) {
|
|
296
|
+
this.word = a, this.state = Y;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (D.test(a)) {
|
|
300
|
+
this.afterItem(a);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
throw new Error(`havn't handled "` + a + '" in neutral yet, index ' + this.place);
|
|
304
|
+
};
|
|
305
|
+
v.prototype.output = function() {
|
|
306
|
+
for (; this.place < this.text.length; )
|
|
307
|
+
this.readCharicter();
|
|
308
|
+
if (this.state === z)
|
|
309
|
+
return this.root;
|
|
310
|
+
throw new Error('unable to parse string "' + this.text + '". State is ' + this.state);
|
|
311
|
+
};
|
|
312
|
+
function _e(a) {
|
|
313
|
+
var e = new v(a);
|
|
314
|
+
return e.output();
|
|
315
|
+
}
|
|
316
|
+
function P(a, e, i) {
|
|
317
|
+
Array.isArray(e) && (i.unshift(e), e = null);
|
|
318
|
+
var t = e ? {} : a, n = i.reduce(function(o, s) {
|
|
319
|
+
return R(s, o), o;
|
|
320
|
+
}, t);
|
|
321
|
+
e && (a[e] = n);
|
|
322
|
+
}
|
|
323
|
+
function R(a, e) {
|
|
324
|
+
if (!Array.isArray(a)) {
|
|
325
|
+
e[a] = !0;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var i = a.shift();
|
|
329
|
+
if (i === "PARAMETER" && (i = a.shift()), a.length === 1) {
|
|
330
|
+
if (Array.isArray(a[0])) {
|
|
331
|
+
e[i] = {}, R(a[0], e[i]);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
e[i] = a[0];
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (!a.length) {
|
|
338
|
+
e[i] = !0;
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (i === "TOWGS84") {
|
|
342
|
+
e[i] = a;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (i === "AXIS") {
|
|
346
|
+
i in e || (e[i] = []), e[i].push(a);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
Array.isArray(i) || (e[i] = {});
|
|
350
|
+
var t;
|
|
351
|
+
switch (i) {
|
|
352
|
+
case "UNIT":
|
|
353
|
+
case "PRIMEM":
|
|
354
|
+
case "VERT_DATUM":
|
|
355
|
+
e[i] = {
|
|
356
|
+
name: a[0].toLowerCase(),
|
|
357
|
+
convert: a[1]
|
|
358
|
+
}, a.length === 3 && R(a[2], e[i]);
|
|
359
|
+
return;
|
|
360
|
+
case "SPHEROID":
|
|
361
|
+
case "ELLIPSOID":
|
|
362
|
+
e[i] = {
|
|
363
|
+
name: a[0],
|
|
364
|
+
a: a[1],
|
|
365
|
+
rf: a[2]
|
|
366
|
+
}, a.length === 4 && R(a[3], e[i]);
|
|
367
|
+
return;
|
|
368
|
+
case "EDATUM":
|
|
369
|
+
case "ENGINEERINGDATUM":
|
|
370
|
+
case "LOCAL_DATUM":
|
|
371
|
+
case "DATUM":
|
|
372
|
+
case "VERT_CS":
|
|
373
|
+
case "VERTCRS":
|
|
374
|
+
case "VERTICALCRS":
|
|
375
|
+
a[0] = ["name", a[0]], P(e, i, a);
|
|
376
|
+
return;
|
|
377
|
+
case "COMPD_CS":
|
|
378
|
+
case "COMPOUNDCRS":
|
|
379
|
+
case "FITTED_CS":
|
|
380
|
+
// the followings are the crs defined in
|
|
381
|
+
// https://github.com/proj4js/proj4js/blob/1da4ed0b865d0fcb51c136090569210cdcc9019e/lib/parseCode.js#L11
|
|
382
|
+
case "PROJECTEDCRS":
|
|
383
|
+
case "PROJCRS":
|
|
384
|
+
case "GEOGCS":
|
|
385
|
+
case "GEOCCS":
|
|
386
|
+
case "PROJCS":
|
|
387
|
+
case "LOCAL_CS":
|
|
388
|
+
case "GEODCRS":
|
|
389
|
+
case "GEODETICCRS":
|
|
390
|
+
case "GEODETICDATUM":
|
|
391
|
+
case "ENGCRS":
|
|
392
|
+
case "ENGINEERINGCRS":
|
|
393
|
+
a[0] = ["name", a[0]], P(e, i, a), e[i].type = i;
|
|
394
|
+
return;
|
|
395
|
+
default:
|
|
396
|
+
for (t = -1; ++t < a.length; )
|
|
397
|
+
if (!Array.isArray(a[t]))
|
|
398
|
+
return R(a, e[i]);
|
|
399
|
+
return P(e, i, a);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
var le = 0.017453292519943295;
|
|
403
|
+
function A(a) {
|
|
404
|
+
return a * le;
|
|
405
|
+
}
|
|
406
|
+
function w(a) {
|
|
407
|
+
const e = (a.projName || "").toLowerCase().replace(/_/g, " ");
|
|
408
|
+
a.long0 === void 0 && a.longc !== void 0 && (a.long0 = a.longc), !a.lat_ts && a.lat1 && (e === "stereographic south pole" || e === "polar stereographic (variant b)") ? (a.lat0 = A(a.lat1 > 0 ? 90 : -90), a.lat_ts = a.lat1, delete a.lat1) : !a.lat_ts && a.lat0 && (e === "polar stereographic" || e === "polar stereographic (variant a)") && (a.lat_ts = a.lat0, a.lat0 = A(a.lat0 > 0 ? 90 : -90), delete a.lat1);
|
|
409
|
+
}
|
|
410
|
+
function H(a) {
|
|
411
|
+
let e = { units: null, to_meter: void 0 };
|
|
412
|
+
return typeof a == "string" ? (e.units = a.toLowerCase(), e.units === "metre" && (e.units = "meter"), e.units === "meter" && (e.to_meter = 1)) : a && a.name && (e.units = a.name.toLowerCase(), e.units === "metre" && (e.units = "meter"), e.to_meter = a.conversion_factor), e;
|
|
413
|
+
}
|
|
414
|
+
function V(a) {
|
|
415
|
+
return typeof a == "object" ? a.value * a.unit.conversion_factor : a;
|
|
416
|
+
}
|
|
417
|
+
function W(a, e) {
|
|
418
|
+
a.ellipsoid.radius ? (e.a = a.ellipsoid.radius, e.rf = 0) : (e.a = V(a.ellipsoid.semi_major_axis), a.ellipsoid.inverse_flattening !== void 0 ? e.rf = a.ellipsoid.inverse_flattening : a.ellipsoid.semi_major_axis !== void 0 && a.ellipsoid.semi_minor_axis !== void 0 && (e.rf = e.a / (e.a - V(a.ellipsoid.semi_minor_axis))));
|
|
419
|
+
}
|
|
420
|
+
function U(a, e = {}) {
|
|
421
|
+
return !a || typeof a != "object" ? a : a.type === "BoundCRS" ? (U(a.source_crs, e), a.transformation && (a.transformation.method && a.transformation.method.name === "NTv2" ? e.nadgrids = a.transformation.parameters[0].value : e.datum_params = a.transformation.parameters.map((i) => i.value)), e) : (Object.keys(a).forEach((i) => {
|
|
422
|
+
const t = a[i];
|
|
423
|
+
if (t !== null)
|
|
424
|
+
switch (i) {
|
|
425
|
+
case "name":
|
|
426
|
+
if (e.srsCode)
|
|
427
|
+
break;
|
|
428
|
+
e.name = t, e.srsCode = t;
|
|
429
|
+
break;
|
|
430
|
+
case "type":
|
|
431
|
+
t === "GeographicCRS" ? e.projName = "longlat" : t === "GeodeticCRS" ? a.coordinate_system && a.coordinate_system.subtype === "Cartesian" ? e.projName = "geocent" : e.projName = "longlat" : t === "ProjectedCRS" && a.conversion && a.conversion.method && (e.projName = a.conversion.method.name);
|
|
432
|
+
break;
|
|
433
|
+
case "datum":
|
|
434
|
+
case "datum_ensemble":
|
|
435
|
+
t.ellipsoid && (e.ellps = t.ellipsoid.name, W(t, e)), t.prime_meridian && (e.from_greenwich = t.prime_meridian.longitude * Math.PI / 180);
|
|
436
|
+
break;
|
|
437
|
+
case "ellipsoid":
|
|
438
|
+
e.ellps = t.name, W(t, e);
|
|
439
|
+
break;
|
|
440
|
+
case "prime_meridian":
|
|
441
|
+
e.long0 = (t.longitude || 0) * Math.PI / 180;
|
|
442
|
+
break;
|
|
443
|
+
case "coordinate_system":
|
|
444
|
+
if (t.axis) {
|
|
445
|
+
const n = {
|
|
446
|
+
east: "e",
|
|
447
|
+
north: "n",
|
|
448
|
+
west: "w",
|
|
449
|
+
south: "s",
|
|
450
|
+
up: "u",
|
|
451
|
+
down: "d",
|
|
452
|
+
geocentricx: "e",
|
|
453
|
+
geocentricy: "n",
|
|
454
|
+
geocentricz: "u"
|
|
455
|
+
}, o = t.axis.map((s) => n[s.direction.toLowerCase()]);
|
|
456
|
+
if (o.every(Boolean) && (e.axis = o.join(""), e.axis.length === 2 && (e.axis += "u")), t.unit) {
|
|
457
|
+
const { units: s, to_meter: f } = H(t.unit);
|
|
458
|
+
e.units = s, e.to_meter = f;
|
|
459
|
+
} else if (t.axis[0] && t.axis[0].unit) {
|
|
460
|
+
const { units: s, to_meter: f } = H(t.axis[0].unit);
|
|
461
|
+
e.units = s, e.to_meter = f;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
break;
|
|
465
|
+
case "id":
|
|
466
|
+
t.authority && t.code && (e.title = t.authority + ":" + t.code);
|
|
467
|
+
break;
|
|
468
|
+
case "conversion":
|
|
469
|
+
t.method && t.method.name && (e.projName = t.method.name), t.parameters && t.parameters.forEach((n) => {
|
|
470
|
+
const o = n.name.toLowerCase().replace(/\s+/g, "_"), s = n.value;
|
|
471
|
+
n.unit && n.unit.conversion_factor ? e[o] = s * n.unit.conversion_factor : n.unit === "degree" ? e[o] = s * Math.PI / 180 : e[o] = s;
|
|
472
|
+
});
|
|
473
|
+
break;
|
|
474
|
+
case "unit":
|
|
475
|
+
t.name && (e.units = t.name.toLowerCase(), e.units === "metre" && (e.units = "meter")), t.conversion_factor && (e.to_meter = t.conversion_factor);
|
|
476
|
+
break;
|
|
477
|
+
case "base_crs":
|
|
478
|
+
U(t, e), e.datumCode = t.id ? t.id.authority + "_" + t.id.code : t.name;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}), e.latitude_of_false_origin !== void 0 && (e.lat0 = e.latitude_of_false_origin), e.longitude_of_false_origin !== void 0 && (e.long0 = e.longitude_of_false_origin), e.latitude_of_standard_parallel !== void 0 && (e.lat0 = e.latitude_of_standard_parallel, e.lat1 = e.latitude_of_standard_parallel), e.latitude_of_1st_standard_parallel !== void 0 && (e.lat1 = e.latitude_of_1st_standard_parallel), e.latitude_of_2nd_standard_parallel !== void 0 && (e.lat2 = e.latitude_of_2nd_standard_parallel), e.latitude_of_projection_centre !== void 0 && (e.lat0 = e.latitude_of_projection_centre), e.longitude_of_projection_centre !== void 0 && (e.longc = e.longitude_of_projection_centre), e.easting_at_false_origin !== void 0 && (e.x0 = e.easting_at_false_origin), e.northing_at_false_origin !== void 0 && (e.y0 = e.northing_at_false_origin), e.latitude_of_natural_origin !== void 0 && (e.lat0 = e.latitude_of_natural_origin), e.longitude_of_natural_origin !== void 0 && (e.long0 = e.longitude_of_natural_origin), e.longitude_of_origin !== void 0 && (e.long0 = e.longitude_of_origin), e.false_easting !== void 0 && (e.x0 = e.false_easting), e.easting_at_projection_centre && (e.x0 = e.easting_at_projection_centre), e.false_northing !== void 0 && (e.y0 = e.false_northing), e.northing_at_projection_centre && (e.y0 = e.northing_at_projection_centre), e.standard_parallel_1 !== void 0 && (e.lat1 = e.standard_parallel_1), e.standard_parallel_2 !== void 0 && (e.lat2 = e.standard_parallel_2), e.scale_factor_at_natural_origin !== void 0 && (e.k0 = e.scale_factor_at_natural_origin), e.scale_factor_at_projection_centre !== void 0 && (e.k0 = e.scale_factor_at_projection_centre), e.scale_factor_on_pseudo_standard_parallel !== void 0 && (e.k0 = e.scale_factor_on_pseudo_standard_parallel), e.azimuth !== void 0 && (e.alpha = e.azimuth), e.azimuth_at_projection_centre !== void 0 && (e.alpha = e.azimuth_at_projection_centre), e.angle_from_rectified_to_skew_grid && (e.rectified_grid_angle = e.angle_from_rectified_to_skew_grid), w(e), e);
|
|
482
|
+
}
|
|
483
|
+
var he = [
|
|
484
|
+
"PROJECTEDCRS",
|
|
485
|
+
"PROJCRS",
|
|
486
|
+
"GEOGCS",
|
|
487
|
+
"GEOCCS",
|
|
488
|
+
"PROJCS",
|
|
489
|
+
"LOCAL_CS",
|
|
490
|
+
"GEODCRS",
|
|
491
|
+
"GEODETICCRS",
|
|
492
|
+
"GEODETICDATUM",
|
|
493
|
+
"ENGCRS",
|
|
494
|
+
"ENGINEERINGCRS"
|
|
495
|
+
];
|
|
496
|
+
function ue(a, e) {
|
|
497
|
+
var i = e[0], t = e[1];
|
|
498
|
+
!(i in a) && t in a && (a[i] = a[t], e.length === 3 && (a[i] = e[2](a[i])));
|
|
499
|
+
}
|
|
500
|
+
function j(a) {
|
|
501
|
+
for (var e = Object.keys(a), i = 0, t = e.length; i < t; ++i) {
|
|
502
|
+
var n = e[i];
|
|
503
|
+
he.indexOf(n) !== -1 && me(a[n]), typeof a[n] == "object" && j(a[n]);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function me(a) {
|
|
507
|
+
if (a.AUTHORITY) {
|
|
508
|
+
var e = Object.keys(a.AUTHORITY)[0];
|
|
509
|
+
e && e in a.AUTHORITY && (a.title = e + ":" + a.AUTHORITY[e]);
|
|
510
|
+
}
|
|
511
|
+
if (a.type === "GEOGCS" ? a.projName = "longlat" : a.type === "LOCAL_CS" ? (a.projName = "identity", a.local = !0) : typeof a.PROJECTION == "object" ? a.projName = Object.keys(a.PROJECTION)[0] : a.projName = a.PROJECTION, a.AXIS) {
|
|
512
|
+
for (var i = "", t = 0, n = a.AXIS.length; t < n; ++t) {
|
|
513
|
+
var o = [a.AXIS[t][0].toLowerCase(), a.AXIS[t][1].toLowerCase()];
|
|
514
|
+
o[0].indexOf("north") !== -1 || (o[0] === "y" || o[0] === "lat") && o[1] === "north" ? i += "n" : o[0].indexOf("south") !== -1 || (o[0] === "y" || o[0] === "lat") && o[1] === "south" ? i += "s" : o[0].indexOf("east") !== -1 || (o[0] === "x" || o[0] === "lon") && o[1] === "east" ? i += "e" : (o[0].indexOf("west") !== -1 || (o[0] === "x" || o[0] === "lon") && o[1] === "west") && (i += "w");
|
|
515
|
+
}
|
|
516
|
+
i.length === 2 && (i += "u"), i.length === 3 && (a.axis = i);
|
|
517
|
+
}
|
|
518
|
+
a.UNIT && (a.units = a.UNIT.name.toLowerCase(), a.units === "metre" && (a.units = "meter"), a.UNIT.convert && (a.type === "GEOGCS" ? a.DATUM && a.DATUM.SPHEROID && (a.to_meter = a.UNIT.convert * a.DATUM.SPHEROID.a) : a.to_meter = a.UNIT.convert));
|
|
519
|
+
var s = a.GEOGCS;
|
|
520
|
+
a.type === "GEOGCS" && (s = a), s && (s.PRIMEM && s.PRIMEM.convert && (a.from_greenwich = A(s.PRIMEM.convert)), s.DATUM ? a.datumCode = s.DATUM.name.toLowerCase() : a.datumCode = s.name.toLowerCase(), a.datumCode.slice(0, 2) === "d_" && (a.datumCode = a.datumCode.slice(2)), a.datumCode === "new_zealand_1949" && (a.datumCode = "nzgd49"), (a.datumCode === "wgs_1984" || a.datumCode === "world_geodetic_system_1984") && (a.PROJECTION === "Mercator_Auxiliary_Sphere" && (a.sphere = !0), a.datumCode = "wgs84"), a.datumCode === "belge_1972" && (a.datumCode = "rnb72"), s.DATUM && s.DATUM.SPHEROID && (a.ellps = s.DATUM.SPHEROID.name.replace("_19", "").replace(/[Cc]larke\_18/, "clrk"), a.ellps.toLowerCase().slice(0, 13) === "international" && (a.ellps = "intl"), a.a = s.DATUM.SPHEROID.a, a.rf = parseFloat(s.DATUM.SPHEROID.rf)), s.DATUM && s.DATUM.TOWGS84 && (a.datum_params = s.DATUM.TOWGS84), ~a.datumCode.indexOf("osgb_1936") && (a.datumCode = "osgb36"), ~a.datumCode.indexOf("osni_1952") && (a.datumCode = "osni52"), (~a.datumCode.indexOf("tm65") || ~a.datumCode.indexOf("geodetic_datum_of_1965")) && (a.datumCode = "ire65"), a.datumCode === "ch1903+" && (a.datumCode = "ch1903"), ~a.datumCode.indexOf("israel") && (a.datumCode = "isr93")), a.b && !isFinite(a.b) && (a.b = a.a), a.rectified_grid_angle && (a.rectified_grid_angle = A(a.rectified_grid_angle));
|
|
521
|
+
function f(u) {
|
|
522
|
+
var d = a.to_meter || 1;
|
|
523
|
+
return u * d;
|
|
524
|
+
}
|
|
525
|
+
var _ = function(u) {
|
|
526
|
+
return ue(a, u);
|
|
527
|
+
}, c = [
|
|
528
|
+
["standard_parallel_1", "Standard_Parallel_1"],
|
|
529
|
+
["standard_parallel_1", "Latitude of 1st standard parallel"],
|
|
530
|
+
["standard_parallel_2", "Standard_Parallel_2"],
|
|
531
|
+
["standard_parallel_2", "Latitude of 2nd standard parallel"],
|
|
532
|
+
["false_easting", "False_Easting"],
|
|
533
|
+
["false_easting", "False easting"],
|
|
534
|
+
["false-easting", "Easting at false origin"],
|
|
535
|
+
["false_northing", "False_Northing"],
|
|
536
|
+
["false_northing", "False northing"],
|
|
537
|
+
["false_northing", "Northing at false origin"],
|
|
538
|
+
["central_meridian", "Central_Meridian"],
|
|
539
|
+
["central_meridian", "Longitude of natural origin"],
|
|
540
|
+
["central_meridian", "Longitude of false origin"],
|
|
541
|
+
["latitude_of_origin", "Latitude_Of_Origin"],
|
|
542
|
+
["latitude_of_origin", "Central_Parallel"],
|
|
543
|
+
["latitude_of_origin", "Latitude of natural origin"],
|
|
544
|
+
["latitude_of_origin", "Latitude of false origin"],
|
|
545
|
+
["scale_factor", "Scale_Factor"],
|
|
546
|
+
["k0", "scale_factor"],
|
|
547
|
+
["latitude_of_center", "Latitude_Of_Center"],
|
|
548
|
+
["latitude_of_center", "Latitude_of_center"],
|
|
549
|
+
["lat0", "latitude_of_center", A],
|
|
550
|
+
["longitude_of_center", "Longitude_Of_Center"],
|
|
551
|
+
["longitude_of_center", "Longitude_of_center"],
|
|
552
|
+
["longc", "longitude_of_center", A],
|
|
553
|
+
["x0", "false_easting", f],
|
|
554
|
+
["y0", "false_northing", f],
|
|
555
|
+
["long0", "central_meridian", A],
|
|
556
|
+
["lat0", "latitude_of_origin", A],
|
|
557
|
+
["lat0", "standard_parallel_1", A],
|
|
558
|
+
["lat1", "standard_parallel_1", A],
|
|
559
|
+
["lat2", "standard_parallel_2", A],
|
|
560
|
+
["azimuth", "Azimuth"],
|
|
561
|
+
["alpha", "azimuth", A],
|
|
562
|
+
["srsCode", "name"]
|
|
563
|
+
];
|
|
564
|
+
c.forEach(_), w(a);
|
|
565
|
+
}
|
|
566
|
+
function Oe(a) {
|
|
567
|
+
if (typeof a == "object")
|
|
568
|
+
return U(a);
|
|
569
|
+
const e = se(a);
|
|
570
|
+
var i = _e(a);
|
|
571
|
+
if (e === "WKT2") {
|
|
572
|
+
const o = oe(i);
|
|
573
|
+
return U(o);
|
|
574
|
+
}
|
|
575
|
+
var t = i[0], n = {};
|
|
576
|
+
return R(i, n), j(n), n[t];
|
|
577
|
+
}
|
|
578
|
+
var q = 6, k = "AJSAJS", ee = "AFAFAF", S = 65, p = 73, E = 79, T = 86, N = 90;
|
|
579
|
+
const Me = {
|
|
580
|
+
forward: ge,
|
|
581
|
+
inverse: pe,
|
|
582
|
+
toPoint: Ae
|
|
583
|
+
};
|
|
584
|
+
function ge(a, e) {
|
|
585
|
+
return e = e || 5, ye(Ee({
|
|
586
|
+
lat: a[1],
|
|
587
|
+
lon: a[0]
|
|
588
|
+
}), e);
|
|
589
|
+
}
|
|
590
|
+
function pe(a) {
|
|
591
|
+
var e = F(ie(a.toUpperCase()));
|
|
592
|
+
return e.lat && e.lon ? [e.lon, e.lat, e.lon, e.lat] : [e.left, e.bottom, e.right, e.top];
|
|
593
|
+
}
|
|
594
|
+
function Ae(a) {
|
|
595
|
+
var e = F(ie(a.toUpperCase()));
|
|
596
|
+
return e.lat && e.lon ? [e.lon, e.lat] : [(e.left + e.right) / 2, (e.top + e.bottom) / 2];
|
|
597
|
+
}
|
|
598
|
+
function x(a) {
|
|
599
|
+
return a * (Math.PI / 180);
|
|
600
|
+
}
|
|
601
|
+
function K(a) {
|
|
602
|
+
return 180 * (a / Math.PI);
|
|
603
|
+
}
|
|
604
|
+
function Ee(a) {
|
|
605
|
+
var e = a.lat, i = a.lon, t = 6378137, n = 669438e-8, o = 0.9996, s, f, _, c, u, d, r, h = x(e), l = x(i), C, g;
|
|
606
|
+
g = Math.floor((i + 180) / 6) + 1, i === 180 && (g = 60), e >= 56 && e < 64 && i >= 3 && i < 12 && (g = 32), e >= 72 && e < 84 && (i >= 0 && i < 9 ? g = 31 : i >= 9 && i < 21 ? g = 33 : i >= 21 && i < 33 ? g = 35 : i >= 33 && i < 42 && (g = 37)), s = (g - 1) * 6 - 180 + 3, C = x(s), f = n / (1 - n), _ = t / Math.sqrt(1 - n * Math.sin(h) * Math.sin(h)), c = Math.tan(h) * Math.tan(h), u = f * Math.cos(h) * Math.cos(h), d = Math.cos(h) * (l - C), r = t * ((1 - n / 4 - 3 * n * n / 64 - 5 * n * n * n / 256) * h - (3 * n / 8 + 3 * n * n / 32 + 45 * n * n * n / 1024) * Math.sin(2 * h) + (15 * n * n / 256 + 45 * n * n * n / 1024) * Math.sin(4 * h) - 35 * n * n * n / 3072 * Math.sin(6 * h));
|
|
607
|
+
var y = o * _ * (d + (1 - c + u) * d * d * d / 6 + (5 - 18 * c + c * c + 72 * u - 58 * f) * d * d * d * d * d / 120) + 5e5, m = o * (r + _ * Math.tan(h) * (d * d / 2 + (5 - c + 9 * u + 4 * u * u) * d * d * d * d / 24 + (61 - 58 * c + c * c + 600 * u - 330 * f) * d * d * d * d * d * d / 720));
|
|
608
|
+
return e < 0 && (m += 1e7), {
|
|
609
|
+
northing: Math.round(m),
|
|
610
|
+
easting: Math.round(y),
|
|
611
|
+
zoneNumber: g,
|
|
612
|
+
zoneLetter: Ce(e)
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function F(a) {
|
|
616
|
+
var e = a.northing, i = a.easting, t = a.zoneLetter, n = a.zoneNumber;
|
|
617
|
+
if (n < 0 || n > 60)
|
|
618
|
+
return null;
|
|
619
|
+
var o = 0.9996, s = 6378137, f = 669438e-8, _, c = (1 - Math.sqrt(1 - f)) / (1 + Math.sqrt(1 - f)), u, d, r, h, l, C, g, y, m, M = i - 5e5, J = e;
|
|
620
|
+
t < "N" && (J -= 1e7), g = (n - 1) * 6 - 180 + 3, _ = f / (1 - f), C = J / o, y = C / (s * (1 - f / 4 - 3 * f * f / 64 - 5 * f * f * f / 256)), m = y + (3 * c / 2 - 27 * c * c * c / 32) * Math.sin(2 * y) + (21 * c * c / 16 - 55 * c * c * c * c / 32) * Math.sin(4 * y) + 151 * c * c * c / 96 * Math.sin(6 * y), u = s / Math.sqrt(1 - f * Math.sin(m) * Math.sin(m)), d = Math.tan(m) * Math.tan(m), r = _ * Math.cos(m) * Math.cos(m), h = s * (1 - f) / Math.pow(1 - f * Math.sin(m) * Math.sin(m), 1.5), l = M / (u * o);
|
|
621
|
+
var I = m - u * Math.tan(m) / h * (l * l / 2 - (5 + 3 * d + 10 * r - 4 * r * r - 9 * _) * l * l * l * l / 24 + (61 + 90 * d + 298 * r + 45 * d * d - 252 * _ - 3 * r * r) * l * l * l * l * l * l / 720);
|
|
622
|
+
I = K(I);
|
|
623
|
+
var b = (l - (1 + 2 * d + r) * l * l * l / 6 + (5 - 2 * r + 28 * d - 3 * r * r + 8 * _ + 24 * d * d) * l * l * l * l * l / 120) / Math.cos(m);
|
|
624
|
+
b = g + K(b);
|
|
625
|
+
var G;
|
|
626
|
+
if (a.accuracy) {
|
|
627
|
+
var B = F({
|
|
628
|
+
northing: a.northing + a.accuracy,
|
|
629
|
+
easting: a.easting + a.accuracy,
|
|
630
|
+
zoneLetter: a.zoneLetter,
|
|
631
|
+
zoneNumber: a.zoneNumber
|
|
632
|
+
});
|
|
633
|
+
G = {
|
|
634
|
+
top: B.lat,
|
|
635
|
+
right: B.lon,
|
|
636
|
+
bottom: I,
|
|
637
|
+
left: b
|
|
638
|
+
};
|
|
639
|
+
} else
|
|
640
|
+
G = {
|
|
641
|
+
lat: I,
|
|
642
|
+
lon: b
|
|
643
|
+
};
|
|
644
|
+
return G;
|
|
645
|
+
}
|
|
646
|
+
function Ce(a) {
|
|
647
|
+
var e = "Z";
|
|
648
|
+
return 84 >= a && a >= 72 ? e = "X" : 72 > a && a >= 64 ? e = "W" : 64 > a && a >= 56 ? e = "V" : 56 > a && a >= 48 ? e = "U" : 48 > a && a >= 40 ? e = "T" : 40 > a && a >= 32 ? e = "S" : 32 > a && a >= 24 ? e = "R" : 24 > a && a >= 16 ? e = "Q" : 16 > a && a >= 8 ? e = "P" : 8 > a && a >= 0 ? e = "N" : 0 > a && a >= -8 ? e = "M" : -8 > a && a >= -16 ? e = "L" : -16 > a && a >= -24 ? e = "K" : -24 > a && a >= -32 ? e = "J" : -32 > a && a >= -40 ? e = "H" : -40 > a && a >= -48 ? e = "G" : -48 > a && a >= -56 ? e = "F" : -56 > a && a >= -64 ? e = "E" : -64 > a && a >= -72 ? e = "D" : -72 > a && a >= -80 && (e = "C"), e;
|
|
649
|
+
}
|
|
650
|
+
function ye(a, e) {
|
|
651
|
+
var i = "00000" + a.easting, t = "00000" + a.northing;
|
|
652
|
+
return a.zoneNumber + a.zoneLetter + ve(a.easting, a.northing, a.zoneNumber) + i.substr(i.length - 5, e) + t.substr(t.length - 5, e);
|
|
653
|
+
}
|
|
654
|
+
function ve(a, e, i) {
|
|
655
|
+
var t = ae(i), n = Math.floor(a / 1e5), o = Math.floor(e / 1e5) % 20;
|
|
656
|
+
return Re(n, o, t);
|
|
657
|
+
}
|
|
658
|
+
function ae(a) {
|
|
659
|
+
var e = a % q;
|
|
660
|
+
return e === 0 && (e = q), e;
|
|
661
|
+
}
|
|
662
|
+
function Re(a, e, i) {
|
|
663
|
+
var t = i - 1, n = k.charCodeAt(t), o = ee.charCodeAt(t), s = n + a - 1, f = o + e, _ = !1;
|
|
664
|
+
s > N && (s = s - N + S - 1, _ = !0), (s === p || n < p && s > p || (s > p || n < p) && _) && s++, (s === E || n < E && s > E || (s > E || n < E) && _) && (s++, s === p && s++), s > N && (s = s - N + S - 1), f > T ? (f = f - T + S - 1, _ = !0) : _ = !1, (f === p || o < p && f > p || (f > p || o < p) && _) && f++, (f === E || o < E && f > E || (f > E || o < E) && _) && (f++, f === p && f++), f > T && (f = f - T + S - 1);
|
|
665
|
+
var c = String.fromCharCode(s) + String.fromCharCode(f);
|
|
666
|
+
return c;
|
|
667
|
+
}
|
|
668
|
+
function ie(a) {
|
|
669
|
+
if (a && a.length === 0)
|
|
670
|
+
throw "MGRSPoint coverting from nothing";
|
|
671
|
+
for (var e = a.length, i = null, t = "", n, o = 0; !/[A-Z]/.test(n = a.charAt(o)); ) {
|
|
672
|
+
if (o >= 2)
|
|
673
|
+
throw "MGRSPoint bad conversion from: " + a;
|
|
674
|
+
t += n, o++;
|
|
675
|
+
}
|
|
676
|
+
var s = parseInt(t, 10);
|
|
677
|
+
if (o === 0 || o + 3 > e)
|
|
678
|
+
throw "MGRSPoint bad conversion from: " + a;
|
|
679
|
+
var f = a.charAt(o++);
|
|
680
|
+
if (f <= "A" || f === "B" || f === "Y" || f >= "Z" || f === "I" || f === "O")
|
|
681
|
+
throw "MGRSPoint zone letter " + f + " not handled: " + a;
|
|
682
|
+
i = a.substring(o, o += 2);
|
|
683
|
+
for (var _ = ae(s), c = Se(i.charAt(0), _), u = Te(i.charAt(1), _); u < Ne(f); )
|
|
684
|
+
u += 2e6;
|
|
685
|
+
var d = e - o;
|
|
686
|
+
if (d % 2 !== 0)
|
|
687
|
+
throw `MGRSPoint has to have an even number
|
|
688
|
+
of digits after the zone letter and two 100km letters - front
|
|
689
|
+
half for easting meters, second half for
|
|
690
|
+
northing meters` + a;
|
|
691
|
+
var r = d / 2, h = 0, l = 0, C, g, y, m, M;
|
|
692
|
+
return r > 0 && (C = 1e5 / Math.pow(10, r), g = a.substring(o, o + r), h = parseFloat(g) * C, y = a.substring(o + r), l = parseFloat(y) * C), m = h + c, M = l + u, {
|
|
693
|
+
easting: m,
|
|
694
|
+
northing: M,
|
|
695
|
+
zoneLetter: f,
|
|
696
|
+
zoneNumber: s,
|
|
697
|
+
accuracy: C
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
function Se(a, e) {
|
|
701
|
+
for (var i = k.charCodeAt(e - 1), t = 1e5, n = !1; i !== a.charCodeAt(0); ) {
|
|
702
|
+
if (i++, i === p && i++, i === E && i++, i > N) {
|
|
703
|
+
if (n)
|
|
704
|
+
throw "Bad character: " + a;
|
|
705
|
+
i = S, n = !0;
|
|
706
|
+
}
|
|
707
|
+
t += 1e5;
|
|
708
|
+
}
|
|
709
|
+
return t;
|
|
710
|
+
}
|
|
711
|
+
function Te(a, e) {
|
|
712
|
+
if (a > "V")
|
|
713
|
+
throw "MGRSPoint given invalid Northing " + a;
|
|
714
|
+
for (var i = ee.charCodeAt(e - 1), t = 0, n = !1; i !== a.charCodeAt(0); ) {
|
|
715
|
+
if (i++, i === p && i++, i === E && i++, i > T) {
|
|
716
|
+
if (n)
|
|
717
|
+
throw "Bad character: " + a;
|
|
718
|
+
i = S, n = !0;
|
|
719
|
+
}
|
|
720
|
+
t += 1e5;
|
|
721
|
+
}
|
|
722
|
+
return t;
|
|
723
|
+
}
|
|
724
|
+
function Ne(a) {
|
|
725
|
+
var e;
|
|
726
|
+
switch (a) {
|
|
727
|
+
case "C":
|
|
728
|
+
e = 11e5;
|
|
729
|
+
break;
|
|
730
|
+
case "D":
|
|
731
|
+
e = 2e6;
|
|
732
|
+
break;
|
|
733
|
+
case "E":
|
|
734
|
+
e = 28e5;
|
|
735
|
+
break;
|
|
736
|
+
case "F":
|
|
737
|
+
e = 37e5;
|
|
738
|
+
break;
|
|
739
|
+
case "G":
|
|
740
|
+
e = 46e5;
|
|
741
|
+
break;
|
|
742
|
+
case "H":
|
|
743
|
+
e = 55e5;
|
|
744
|
+
break;
|
|
745
|
+
case "J":
|
|
746
|
+
e = 64e5;
|
|
747
|
+
break;
|
|
748
|
+
case "K":
|
|
749
|
+
e = 73e5;
|
|
750
|
+
break;
|
|
751
|
+
case "L":
|
|
752
|
+
e = 82e5;
|
|
753
|
+
break;
|
|
754
|
+
case "M":
|
|
755
|
+
e = 91e5;
|
|
756
|
+
break;
|
|
757
|
+
case "N":
|
|
758
|
+
e = 0;
|
|
759
|
+
break;
|
|
760
|
+
case "P":
|
|
761
|
+
e = 8e5;
|
|
762
|
+
break;
|
|
763
|
+
case "Q":
|
|
764
|
+
e = 17e5;
|
|
765
|
+
break;
|
|
766
|
+
case "R":
|
|
767
|
+
e = 26e5;
|
|
768
|
+
break;
|
|
769
|
+
case "S":
|
|
770
|
+
e = 35e5;
|
|
771
|
+
break;
|
|
772
|
+
case "T":
|
|
773
|
+
e = 44e5;
|
|
774
|
+
break;
|
|
775
|
+
case "U":
|
|
776
|
+
e = 53e5;
|
|
777
|
+
break;
|
|
778
|
+
case "V":
|
|
779
|
+
e = 62e5;
|
|
780
|
+
break;
|
|
781
|
+
case "W":
|
|
782
|
+
e = 7e6;
|
|
783
|
+
break;
|
|
784
|
+
case "X":
|
|
785
|
+
e = 79e5;
|
|
786
|
+
break;
|
|
787
|
+
default:
|
|
788
|
+
e = -1;
|
|
789
|
+
}
|
|
790
|
+
if (e >= 0)
|
|
791
|
+
return e;
|
|
792
|
+
throw "Invalid zone letter: " + a;
|
|
793
|
+
}
|
|
794
|
+
export {
|
|
795
|
+
ge as f,
|
|
796
|
+
Me as m,
|
|
797
|
+
Ae as t,
|
|
798
|
+
Oe as w
|
|
799
|
+
};
|