proj4 2.20.2 → 2.20.3

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/lib/parseCode.js CHANGED
@@ -13,6 +13,9 @@ function testWKT(code) {
13
13
  }
14
14
  var codes = ['3857', '900913', '3785', '102113'];
15
15
  function checkMercator(item) {
16
+ if (item.title) {
17
+ return item.title.toLowerCase().indexOf('epsg:') === 0 && codes.indexOf(item.title.substr(5)) > -1;
18
+ }
16
19
  var auth = match(item, 'authority');
17
20
  if (!auth) {
18
21
  return;
@@ -14,8 +14,8 @@ export function init() {
14
14
 
15
15
  /* Place parameters in static storage for common use
16
16
  ------------------------------------------------- */
17
- this.sin_p14 = Math.sin(this.lat0);
18
- this.cos_p14 = Math.cos(this.lat0);
17
+ this.sin_p14 = Math.sin(this.lat0 || 0);
18
+ this.cos_p14 = Math.cos(this.lat0 || 0);
19
19
  }
20
20
 
21
21
  /* Orthographic forward equations--mapping lat,long to x,y
@@ -30,7 +30,7 @@ export function forward(p) {
30
30
  var lat = p.y;
31
31
  /* Forward equations
32
32
  ----------------- */
33
- dlon = adjust_lon(lon - this.long0, this.over);
33
+ dlon = adjust_lon(lon - (this.long0 || 0), this.over);
34
34
 
35
35
  sinphi = Math.sin(lat);
36
36
  cosphi = Math.cos(lat);
@@ -40,7 +40,7 @@ export function forward(p) {
40
40
  ksp = 1;
41
41
  if ((g > 0) || (Math.abs(g) <= EPSLN)) {
42
42
  x = this.a * ksp * cosphi * Math.sin(dlon);
43
- y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
43
+ y = (this.y0 || 0) + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
44
44
  }
45
45
  p.x = x;
46
46
  p.y = y;
@@ -53,36 +53,39 @@ export function inverse(p) {
53
53
  var sinz, cosz; /* sin of z and cos of z */
54
54
  var con;
55
55
  var lon, lat;
56
+ var long0, lat0;
56
57
  /* Inverse equations
57
58
  ----------------- */
58
- p.x -= this.x0;
59
- p.y -= this.y0;
59
+ p.x -= this.x0 || 0;
60
+ p.y -= this.y0 || 0;
60
61
  rh = Math.sqrt(p.x * p.x + p.y * p.y);
61
62
  z = asinz(rh / this.a);
62
63
 
63
64
  sinz = Math.sin(z);
64
65
  cosz = Math.cos(z);
65
66
 
66
- lon = this.long0;
67
+ long0 = this.long0 || 0;
68
+ lat0 = this.lat0 || 0;
69
+ lon = long0;
67
70
  if (Math.abs(rh) <= EPSLN) {
68
- lat = this.lat0;
71
+ lat = lat0;
69
72
  p.x = lon;
70
73
  p.y = lat;
71
74
  return p;
72
75
  }
73
76
  lat = asinz(cosz * this.sin_p14 + (p.y * sinz * this.cos_p14) / rh);
74
- con = Math.abs(this.lat0) - HALF_PI;
77
+ con = Math.abs(lat0) - HALF_PI;
75
78
  if (Math.abs(con) <= EPSLN) {
76
- if (this.lat0 >= 0) {
77
- lon = adjust_lon(this.long0 + Math.atan2(p.x, -p.y), this.over);
79
+ if (lat0 >= 0) {
80
+ lon = adjust_lon(long0 + Math.atan2(p.x, -p.y), this.over);
78
81
  } else {
79
- lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y), this.over);
82
+ lon = adjust_lon(long0 - Math.atan2(-p.x, p.y), this.over);
80
83
  }
81
84
  p.x = lon;
82
85
  p.y = lat;
83
86
  return p;
84
87
  }
85
- lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz), this.over);
88
+ lon = adjust_lon(long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz), this.over);
86
89
  p.x = lon;
87
90
  p.y = lat;
88
91
  return p;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proj4",
3
- "version": "2.20.2",
3
+ "version": "2.20.3",
4
4
  "description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
5
5
  "homepage": "https://proj4js.github.io/proj4js/",
6
6
  "main": "dist/proj4-src.js",
@@ -48,6 +48,6 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "mgrs": "1.0.0",
51
- "wkt-parser": "^1.5.1"
51
+ "wkt-parser": "^1.5.3"
52
52
  }
53
53
  }