1 | function getCodeFromEsriWKT(esri_wkt) {
|
2 | if (!esri_wkt) return;
|
3 | const match = /PROJCS\[\"([^"]+)\"/.exec(esri_wkt);
|
4 | if (!match) return;
|
5 | const name = match[1];
|
6 | if (name.match(/^WGS_1984_UTM_Zone_\d{1,2}(N|S)$/)) {
|
7 | const last_part = name.split("_").pop();
|
8 | const zone = last_part.substring(0, last_part.length - 1);
|
9 | const hemisphere = last_part.substring(last_part.length - 1) == "N" ? 6 : 7;
|
10 | return Number.parseInt("32" + hemisphere + zone);
|
11 | } else if (name.match(/^NAD_1983_UTM_Zone_\d{1,2}N$/)) {
|
12 | const last_part = name.split("_").pop();
|
13 | const zone = last_part.substring(0, last_part.length - 1);
|
14 | return Number.parseInt("269" + zone);
|
15 | }
|
16 | }
|
17 |
|
18 | if (typeof define === "function" && define.amd) {
|
19 | define(function () {
|
20 | return getCodeFromEsriWKT;
|
21 | });
|
22 | }
|
23 |
|
24 | if (typeof module === "object") {
|
25 | module.exports = getCodeFromEsriWKT;
|
26 | module.exports.default = getCodeFromEsriWKT;
|
27 | }
|