UNPKG

830 BJavaScriptView Raw
1function getCodeFromProjString(proj) {
2 if (proj.includes("+proj=utm") && proj.includes("+zone=")) {
3 const parts = proj.split(" ");
4 const zone = parts.find(part => part.startsWith("+zone=")).split("=")[1];
5 const south = proj.includes("+south");
6
7 let ellps = parts.find(part => part.startsWith("+ellps="));
8 if (ellps) ellps = ellps.split("=")[1];
9
10 if (ellps === "GRS80" && south === false) {
11 return Number.parseInt("269" + zone);
12 } else {
13 const hemisphere = south ? "7" : "6";
14 return Number.parseInt("32" + hemisphere + zone);
15 }
16 }
17}
18
19if (typeof define === "function" && define.amd) {
20 define(function () {
21 return getCodeFromProjString;
22 });
23}
24
25if (typeof module === "object") {
26 module.exports = getCodeFromProjString;
27 module.exports.default = getCodeFromProjString;
28}