proj4 2.15.0 → 2.16.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.
Files changed (127) hide show
  1. package/.github/workflows/build-and-test.yml +45 -7
  2. package/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
  3. package/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
  4. package/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
  5. package/.nyc_output/processinfo/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
  6. package/.nyc_output/processinfo/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
  7. package/.nyc_output/processinfo/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
  8. package/.nyc_output/processinfo/index.json +1 -0
  9. package/Gruntfile.js +20 -84
  10. package/README.md +20 -6
  11. package/bower.json +1 -1
  12. package/component.json +1 -1
  13. package/dist/proj4-src.js +8934 -7083
  14. package/dist/proj4.js +1 -1
  15. package/eslint.config.mjs +41 -0
  16. package/lib/Point.js +4 -4
  17. package/lib/Proj.js +7 -8
  18. package/lib/adjust_axis.js +30 -33
  19. package/lib/common/acosh.js +2 -2
  20. package/lib/common/adjust_lat.js +2 -2
  21. package/lib/common/adjust_lon.js +2 -3
  22. package/lib/common/adjust_zone.js +1 -1
  23. package/lib/common/asinh.js +2 -2
  24. package/lib/common/asinhy.js +1 -1
  25. package/lib/common/asinz.js +2 -2
  26. package/lib/common/atanh.js +2 -2
  27. package/lib/common/clens.js +1 -1
  28. package/lib/common/clens_cmplx.js +1 -1
  29. package/lib/common/cosh.js +2 -2
  30. package/lib/common/e0fn.js +2 -2
  31. package/lib/common/e1fn.js +2 -2
  32. package/lib/common/e2fn.js +2 -2
  33. package/lib/common/e3fn.js +2 -2
  34. package/lib/common/fL.js +2 -2
  35. package/lib/common/gN.js +2 -2
  36. package/lib/common/gatg.js +1 -1
  37. package/lib/common/hypot.js +1 -1
  38. package/lib/common/imlfn.js +3 -3
  39. package/lib/common/invlatiso.js +2 -2
  40. package/lib/common/iqsfnz.js +5 -6
  41. package/lib/common/latiso.js +2 -2
  42. package/lib/common/log1py.js +1 -1
  43. package/lib/common/mlfn.js +2 -2
  44. package/lib/common/msfnz.js +2 -2
  45. package/lib/common/phi2z.js +3 -3
  46. package/lib/common/pj_enfn.js +2 -2
  47. package/lib/common/pj_inv_mlfn.js +6 -6
  48. package/lib/common/pj_mlfn.js +2 -2
  49. package/lib/common/qsfnz.js +3 -4
  50. package/lib/common/sign.js +3 -3
  51. package/lib/common/sinh.js +2 -2
  52. package/lib/common/srat.js +2 -2
  53. package/lib/common/tanh.js +2 -2
  54. package/lib/common/toPoint.js +4 -4
  55. package/lib/common/tsfnz.js +2 -2
  56. package/lib/constants/Datum.js +1228 -46
  57. package/lib/constants/Ellipsoid.js +225 -266
  58. package/lib/constants/PrimeMeridian.js +14 -14
  59. package/lib/constants/units.js +20 -20
  60. package/lib/constants/values.js +4 -4
  61. package/lib/core.js +2 -2
  62. package/lib/datum.js +2 -2
  63. package/lib/datumUtils.js +9 -14
  64. package/lib/datum_transform.js +26 -26
  65. package/lib/defs.js +10 -20
  66. package/lib/deriveConstants.js +4 -2
  67. package/lib/extend.js +1 -1
  68. package/lib/global.js +6 -6
  69. package/lib/includedProjections.js +25 -25
  70. package/lib/index.js +9 -9
  71. package/lib/nadgrid.js +36 -14
  72. package/lib/parseCode.js +10 -11
  73. package/lib/projString.js +41 -44
  74. package/lib/projections/aea.js +7 -12
  75. package/lib/projections/aeqd.js +51 -86
  76. package/lib/projections/bonne.js +11 -13
  77. package/lib/projections/cass.js +8 -15
  78. package/lib/projections/cea.js +7 -9
  79. package/lib/projections/eqc.js +2 -5
  80. package/lib/projections/eqdc.js +10 -16
  81. package/lib/projections/eqearth.js +17 -17
  82. package/lib/projections/equi.js +4 -6
  83. package/lib/projections/etmerc.js +9 -11
  84. package/lib/projections/gauss.js +3 -3
  85. package/lib/projections/geocent.js +13 -14
  86. package/lib/projections/geos.js +136 -137
  87. package/lib/projections/gnom.js +8 -13
  88. package/lib/projections/gstmerc.js +2 -5
  89. package/lib/projections/krovak.js +3 -3
  90. package/lib/projections/laea.js +85 -97
  91. package/lib/projections/lcc.js +28 -33
  92. package/lib/projections/longlat.js +4 -4
  93. package/lib/projections/merc.js +12 -19
  94. package/lib/projections/mill.js +6 -7
  95. package/lib/projections/moll.js +8 -9
  96. package/lib/projections/nzmg.js +2 -2
  97. package/lib/projections/omerc.js +55 -57
  98. package/lib/projections/ortho.js +9 -10
  99. package/lib/projections/poly.js +13 -21
  100. package/lib/projections/qsc.js +19 -21
  101. package/lib/projections/robin.js +118 -118
  102. package/lib/projections/sinu.js +12 -23
  103. package/lib/projections/somerc.js +3 -3
  104. package/lib/projections/stere.js +29 -41
  105. package/lib/projections/sterea.js +3 -4
  106. package/lib/projections/tmerc.js +29 -36
  107. package/lib/projections/tpers.js +14 -15
  108. package/lib/projections/utm.js +3 -4
  109. package/lib/projections/vandg.js +15 -21
  110. package/lib/projections.js +12 -4
  111. package/lib/transform.js +3 -3
  112. package/package.json +29 -22
  113. package/projs.js +2 -2
  114. package/publish.sh +2 -2
  115. package/rollup.config.mjs +29 -0
  116. package/scripts/readme.md +10 -0
  117. package/scripts/updateDatums.mjs +119 -0
  118. package/scripts/updateEllipsoids.mjs +70 -0
  119. package/test/ntv2_0_downsampled_no_error_columns.gsb +0 -0
  120. package/test/opt.html +27 -24
  121. package/test/puppeteer-tests.mjs +110 -0
  122. package/test/test-ci.mjs +10 -0
  123. package/test/test.js +197 -125
  124. package/test/testData.js +1802 -312
  125. package/.jshintrc +0 -12
  126. package/test/amd.html +0 -63
  127. package/test/package.json.js +0 -1
package/lib/datumUtils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
- import {PJD_3PARAM, PJD_7PARAM, HALF_PI} from './constants/values';
2
+ import { PJD_3PARAM, PJD_7PARAM, HALF_PI } from './constants/values';
3
3
  export function compareDatums(source, dest) {
4
4
  if (source.datum_type !== dest.datum_type) {
5
5
  return false; // false, datums are not equal
@@ -32,7 +32,7 @@ export function compareDatums(source, dest) {
32
32
  export function geodeticToGeocentric(p, es, a) {
33
33
  var Longitude = p.x;
34
34
  var Latitude = p.y;
35
- var Height = p.z ? p.z : 0; //Z value not always supplied
35
+ var Height = p.z ? p.z : 0; // Z value not always supplied
36
36
 
37
37
  var Rn; /* Earth radius at location */
38
38
  var Sin_Lat; /* Math.sin(Latitude) */
@@ -50,7 +50,7 @@ export function geodeticToGeocentric(p, es, a) {
50
50
  Latitude = HALF_PI;
51
51
  } else if (Latitude < -HALF_PI) {
52
52
  /* Latitude out of range */
53
- //..reportError('geocent:lat out of range:' + Latitude);
53
+ // ..reportError('geocent:lat out of range:' + Latitude);
54
54
  return { x: -Infinity, y: -Infinity, z: p.z };
55
55
  } else if (Latitude > HALF_PI) {
56
56
  /* Latitude out of range */
@@ -94,7 +94,7 @@ export function geocentricToGeodetic(p, es, a, b) {
94
94
 
95
95
  var X = p.x;
96
96
  var Y = p.y;
97
- var Z = p.z ? p.z : 0.0; //Z value not always supplied
97
+ var Z = p.z ? p.z : 0.0; // Z value not always supplied
98
98
  var Longitude;
99
99
  var Latitude;
100
100
  var Height;
@@ -104,7 +104,6 @@ export function geocentricToGeodetic(p, es, a, b) {
104
104
 
105
105
  /* special cases for latitude and longitude */
106
106
  if (P / a < genau) {
107
-
108
107
  /* special case, if P=0. (X=0., Y=0.) */
109
108
  Longitude = 0.0;
110
109
 
@@ -173,21 +172,19 @@ export function geocentricToGeodetic(p, es, a, b) {
173
172
  // pj_geocentic_to_wgs84( p )
174
173
  // p = point to transform in geocentric coordinates (x,y,z)
175
174
 
176
-
177
175
  /** point object, nothing fancy, just allows values to be
178
176
  passed back and forth by reference rather than by value.
179
177
  Other point classes may be used as long as they have
180
178
  x and y properties, which will get modified in the transform method.
181
179
  */
182
180
  export function geocentricToWgs84(p, datum_type, datum_params) {
183
-
184
181
  if (datum_type === PJD_3PARAM) {
185
182
  // if( x[io] === HUGE_VAL )
186
183
  // continue;
187
184
  return {
188
185
  x: p.x + datum_params[0],
189
186
  y: p.y + datum_params[1],
190
- z: p.z + datum_params[2],
187
+ z: p.z + datum_params[2]
191
188
  };
192
189
  } else if (datum_type === PJD_7PARAM) {
193
190
  var Dx_BF = datum_params[0];
@@ -212,16 +209,14 @@ export function geocentricToWgs84(p, datum_type, datum_params) {
212
209
  // coordinate system definition,
213
210
  // point to transform in geocentric coordinates (x,y,z)
214
211
  export function geocentricFromWgs84(p, datum_type, datum_params) {
215
-
216
212
  if (datum_type === PJD_3PARAM) {
217
- //if( x[io] === HUGE_VAL )
213
+ // if( x[io] === HUGE_VAL )
218
214
  // continue;
219
215
  return {
220
216
  x: p.x - datum_params[0],
221
217
  y: p.y - datum_params[1],
222
- z: p.z - datum_params[2],
218
+ z: p.z - datum_params[2]
223
219
  };
224
-
225
220
  } else if (datum_type === PJD_7PARAM) {
226
221
  var Dx_BF = datum_params[0];
227
222
  var Dy_BF = datum_params[1];
@@ -233,7 +228,7 @@ export function geocentricFromWgs84(p, datum_type, datum_params) {
233
228
  var x_tmp = (p.x - Dx_BF) / M_BF;
234
229
  var y_tmp = (p.y - Dy_BF) / M_BF;
235
230
  var z_tmp = (p.z - Dz_BF) / M_BF;
236
- //if( x[io] === HUGE_VAL )
231
+ // if( x[io] === HUGE_VAL )
237
232
  // continue;
238
233
 
239
234
  return {
@@ -241,5 +236,5 @@ export function geocentricFromWgs84(p, datum_type, datum_params) {
241
236
  y: -Rz_BF * x_tmp + y_tmp + Rx_BF * z_tmp,
242
237
  z: Ry_BF * x_tmp - Rx_BF * y_tmp + z_tmp
243
238
  };
244
- } //cs_geocentric_from_wgs84()
239
+ } // cs_geocentric_from_wgs84()
245
240
  }
@@ -8,13 +8,13 @@ import {
8
8
  SRS_WGS84_SEMIMAJOR, SRS_WGS84_SEMIMINOR
9
9
  } from './constants/values';
10
10
 
11
- import {geodeticToGeocentric, geocentricToGeodetic, geocentricToWgs84, geocentricFromWgs84, compareDatums} from './datumUtils';
12
- import adjust_lon from "./common/adjust_lon";
11
+ import { geodeticToGeocentric, geocentricToGeodetic, geocentricToWgs84, geocentricFromWgs84, compareDatums } from './datumUtils';
12
+ import adjust_lon from './common/adjust_lon';
13
13
  function checkParams(type) {
14
14
  return (type === PJD_3PARAM || type === PJD_7PARAM);
15
15
  }
16
16
 
17
- export default function(source, dest, point) {
17
+ export default function (source, dest, point) {
18
18
  // Short cut if the datums are identical.
19
19
  if (compareDatums(source, dest)) {
20
20
  return point; // in this case, zero is sucess,
@@ -49,7 +49,7 @@ export default function(source, dest, point) {
49
49
  }
50
50
 
51
51
  // Do we need to go through geocentric coordinates?
52
- if (source_es === dest_es && source_a === dest_a && !checkParams(source.datum_type) && !checkParams(dest.datum_type)) {
52
+ if (source_es === dest_es && source_a === dest_a && !checkParams(source.datum_type) && !checkParams(dest.datum_type)) {
53
53
  return point;
54
54
  }
55
55
 
@@ -79,9 +79,8 @@ export function applyGridShift(source, inverse, point) {
79
79
  console.log('Grid shift grids not found');
80
80
  return -1;
81
81
  }
82
- var input = {x: -point.x, y: point.y};
83
- var output = {x: Number.NaN, y: Number.NaN};
84
- var onlyMandatoryGrids = false;
82
+ var input = { x: -point.x, y: point.y };
83
+ var output = { x: Number.NaN, y: Number.NaN };
85
84
  var attemptedGrids = [];
86
85
  outer:
87
86
  for (var i = 0; i < source.grids.length; i++) {
@@ -91,10 +90,9 @@ export function applyGridShift(source, inverse, point) {
91
90
  output = input;
92
91
  break;
93
92
  }
94
- onlyMandatoryGrids = grid.mandatory;
95
93
  if (grid.grid === null) {
96
94
  if (grid.mandatory) {
97
- console.log("Unable to find mandatory grid '" + grid.name + "'");
95
+ console.log('Unable to find mandatory grid \'' + grid.name + '\'');
98
96
  return -1;
99
97
  }
100
98
  continue;
@@ -108,7 +106,7 @@ export function applyGridShift(source, inverse, point) {
108
106
  var minY = subgrid.ll[1] - epsilon;
109
107
  var maxX = subgrid.ll[0] + (subgrid.lim[0] - 1) * subgrid.del[0] + epsilon;
110
108
  var maxY = subgrid.ll[1] + (subgrid.lim[1] - 1) * subgrid.del[1] + epsilon;
111
- if (minY > input.y || minX > input.x || maxY < input.y || maxX < input.x ) {
109
+ if (minY > input.y || minX > input.x || maxY < input.y || maxX < input.x) {
112
110
  continue;
113
111
  }
114
112
  output = applySubgridShift(input, inverse, subgrid);
@@ -118,8 +116,8 @@ export function applyGridShift(source, inverse, point) {
118
116
  }
119
117
  }
120
118
  if (isNaN(output.x)) {
121
- console.log("Failed to find a grid shift table for location '"+
122
- -input.x * R2D + " " + input.y * R2D + " tried: '" + attemptedGrids + "'");
119
+ console.log('Failed to find a grid shift table for location \''
120
+ + -input.x * R2D + ' ' + input.y * R2D + ' tried: \'' + attemptedGrids + '\'');
123
121
  return -1;
124
122
  }
125
123
  point.x = -output.x;
@@ -128,9 +126,11 @@ export function applyGridShift(source, inverse, point) {
128
126
  }
129
127
 
130
128
  function applySubgridShift(pin, inverse, ct) {
131
- var val = {x: Number.NaN, y: Number.NaN};
132
- if (isNaN(pin.x)) { return val; }
133
- var tb = {x: pin.x, y: pin.y};
129
+ var val = { x: Number.NaN, y: Number.NaN };
130
+ if (isNaN(pin.x)) {
131
+ return val;
132
+ }
133
+ var tb = { x: pin.x, y: pin.y };
134
134
  tb.x -= ct.ll[0];
135
135
  tb.y -= ct.ll[1];
136
136
  tb.x = adjust_lon(tb.x - Math.PI) + Math.PI;
@@ -146,15 +146,15 @@ function applySubgridShift(pin, inverse, ct) {
146
146
  do {
147
147
  del = nadInterpolate(t, ct);
148
148
  if (isNaN(del.x)) {
149
- console.log("Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.");
149
+ console.log('Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.');
150
150
  break;
151
151
  }
152
- dif = {x: tb.x - (del.x + t.x), y: tb.y - (del.y + t.y)};
152
+ dif = { x: tb.x - (del.x + t.x), y: tb.y - (del.y + t.y) };
153
153
  t.x += dif.x;
154
154
  t.y += dif.y;
155
155
  } while (i-- && Math.abs(dif.x) > tol && Math.abs(dif.y) > tol);
156
156
  if (i < 0) {
157
- console.log("Inverse grid shift iterator failed to converge.");
157
+ console.log('Inverse grid shift iterator failed to converge.');
158
158
  return val;
159
159
  }
160
160
  val.x = adjust_lon(t.x + ct.ll[0]);
@@ -169,10 +169,10 @@ function applySubgridShift(pin, inverse, ct) {
169
169
  }
170
170
 
171
171
  function nadInterpolate(pin, ct) {
172
- var t = {x: pin.x / ct.del[0], y: pin.y / ct.del[1]};
173
- var indx = {x: Math.floor(t.x), y: Math.floor(t.y)};
174
- var frct = {x: t.x - 1.0 * indx.x, y: t.y - 1.0 * indx.y};
175
- var val= {x: Number.NaN, y: Number.NaN};
172
+ var t = { x: pin.x / ct.del[0], y: pin.y / ct.del[1] };
173
+ var indx = { x: Math.floor(t.x), y: Math.floor(t.y) };
174
+ var frct = { x: t.x - 1.0 * indx.x, y: t.y - 1.0 * indx.y };
175
+ var val = { x: Number.NaN, y: Number.NaN };
176
176
  var inx;
177
177
  if (indx.x < 0 || indx.x >= ct.lim[0]) {
178
178
  return val;
@@ -181,13 +181,13 @@ function nadInterpolate(pin, ct) {
181
181
  return val;
182
182
  }
183
183
  inx = (indx.y * ct.lim[0]) + indx.x;
184
- var f00 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
184
+ var f00 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] };
185
185
  inx++;
186
- var f10= {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
186
+ var f10 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] };
187
187
  inx += ct.lim[0];
188
- var f11 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
188
+ var f11 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] };
189
189
  inx--;
190
- var f01 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
190
+ var f01 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] };
191
191
  var m11 = frct.x * frct.y, m10 = frct.x * (1.0 - frct.y),
192
192
  m00 = (1.0 - frct.x) * (1.0 - frct.y), m01 = (1.0 - frct.x) * frct.y;
193
193
  val.x = (m00 * f00.x + m10 * f10.x + m01 * f01.x + m11 * f11.x);
package/lib/defs.js CHANGED
@@ -3,53 +3,43 @@ import parseProj from './projString';
3
3
  import wkt from 'wkt-parser';
4
4
 
5
5
  function defs(name) {
6
- /*global console*/
6
+ /* global console */
7
7
  var that = this;
8
8
  if (arguments.length === 2) {
9
9
  var def = arguments[1];
10
10
  if (typeof def === 'string') {
11
11
  if (def.charAt(0) === '+') {
12
12
  defs[name] = parseProj(arguments[1]);
13
- }
14
- else {
13
+ } else {
15
14
  defs[name] = wkt(arguments[1]);
16
15
  }
17
16
  } else {
18
17
  defs[name] = def;
19
18
  }
20
- }
21
- else if (arguments.length === 1) {
19
+ } else if (arguments.length === 1) {
22
20
  if (Array.isArray(name)) {
23
- return name.map(function(v) {
21
+ return name.map(function (v) {
24
22
  if (Array.isArray(v)) {
25
23
  defs.apply(that, v);
26
- }
27
- else {
24
+ } else {
28
25
  defs(v);
29
26
  }
30
27
  });
31
- }
32
- else if (typeof name === 'string') {
28
+ } else if (typeof name === 'string') {
33
29
  if (name in defs) {
34
30
  return defs[name];
35
31
  }
36
- }
37
- else if ('EPSG' in name) {
32
+ } else if ('EPSG' in name) {
38
33
  defs['EPSG:' + name.EPSG] = name;
39
- }
40
- else if ('ESRI' in name) {
34
+ } else if ('ESRI' in name) {
41
35
  defs['ESRI:' + name.ESRI] = name;
42
- }
43
- else if ('IAU2000' in name) {
36
+ } else if ('IAU2000' in name) {
44
37
  defs['IAU2000:' + name.IAU2000] = name;
45
- }
46
- else {
38
+ } else {
47
39
  console.log(name);
48
40
  }
49
41
  return;
50
42
  }
51
-
52
-
53
43
  }
54
44
  globals(defs);
55
45
  export default defs;
@@ -1,7 +1,9 @@
1
- import {SIXTH, RA4, RA6, EPSLN} from './constants/values';
2
- import {default as Ellipsoid, WGS84} from './constants/Ellipsoid';
1
+ import { SIXTH, RA4, RA6, EPSLN } from './constants/values';
2
+ import { default as Ellipsoid } from './constants/Ellipsoid';
3
3
  import match from './match';
4
4
 
5
+ const WGS84 = Ellipsoid.WGS84; // default ellipsoid
6
+
5
7
  export function eccentricity(a, b, rf, R_A) {
6
8
  var a2 = a * a; // used in geocentric
7
9
  var b2 = b * b; // used in geocentric
package/lib/extend.js CHANGED
@@ -1,4 +1,4 @@
1
- export default function(destination, source) {
1
+ export default function (destination, source) {
2
2
  destination = destination || {};
3
3
  var value, property;
4
4
  if (!source) {
package/lib/global.js CHANGED
@@ -1,11 +1,11 @@
1
- export default function(defs) {
2
- defs('EPSG:4326', "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
3
- defs('EPSG:4269', "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees");
4
- defs('EPSG:3857', "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
1
+ export default function (defs) {
2
+ defs('EPSG:4326', '+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees');
3
+ defs('EPSG:4269', '+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees');
4
+ defs('EPSG:3857', '+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs');
5
5
  // UTM WGS84
6
6
  for (var i = 1; i <= 60; ++i) {
7
- defs('EPSG:' + (32600 + i), "+proj=utm +zone=" + i + " +datum=WGS84 +units=m");
8
- defs('EPSG:' + (32700 + i), "+proj=utm +zone=" + i + " +south +datum=WGS84 +units=m");
7
+ defs('EPSG:' + (32600 + i), '+proj=utm +zone=' + i + ' +datum=WGS84 +units=m');
8
+ defs('EPSG:' + (32700 + i), '+proj=utm +zone=' + i + ' +south +datum=WGS84 +units=m');
9
9
  }
10
10
 
11
11
  defs.WGS84 = defs['EPSG:4326'];
@@ -1,33 +1,33 @@
1
- import tmerc from "./projections/tmerc";
2
- import utm from "./projections/utm";
3
- import sterea from "./projections/sterea";
4
- import stere from "./projections/stere";
5
- import somerc from "./projections/somerc";
6
- import omerc from "./projections/omerc";
7
- import lcc from "./projections/lcc";
8
- import krovak from "./projections/krovak";
9
- import cass from "./projections/cass";
10
- import laea from "./projections/laea";
11
- import aea from "./projections/aea";
12
- import gnom from "./projections/gnom";
13
- import cea from "./projections/cea";
14
- import eqc from "./projections/eqc";
15
- import poly from "./projections/poly";
16
- import nzmg from "./projections/nzmg";
17
- import mill from "./projections/mill";
18
- import sinu from "./projections/sinu";
19
- import moll from "./projections/moll";
20
- import eqdc from "./projections/eqdc";
21
- import vandg from "./projections/vandg";
22
- import aegd from "./projections/aeqd";
1
+ import tmerc from './projections/tmerc';
2
+ import utm from './projections/utm';
3
+ import sterea from './projections/sterea';
4
+ import stere from './projections/stere';
5
+ import somerc from './projections/somerc';
6
+ import omerc from './projections/omerc';
7
+ import lcc from './projections/lcc';
8
+ import krovak from './projections/krovak';
9
+ import cass from './projections/cass';
10
+ import laea from './projections/laea';
11
+ import aea from './projections/aea';
12
+ import gnom from './projections/gnom';
13
+ import cea from './projections/cea';
14
+ import eqc from './projections/eqc';
15
+ import poly from './projections/poly';
16
+ import nzmg from './projections/nzmg';
17
+ import mill from './projections/mill';
18
+ import sinu from './projections/sinu';
19
+ import moll from './projections/moll';
20
+ import eqdc from './projections/eqdc';
21
+ import vandg from './projections/vandg';
22
+ import aegd from './projections/aeqd';
23
23
  import etmerc from './projections/etmerc';
24
24
  import qsc from './projections/qsc';
25
25
  import robin from './projections/robin';
26
26
  import geocent from './projections/geocent';
27
27
  import tpers from './projections/tpers';
28
28
  import geos from './projections/geos';
29
- import eqearth from "./projections/eqearth";
30
- import bonne from "./projections/bonne";
29
+ import eqearth from './projections/eqearth';
30
+ import bonne from './projections/bonne';
31
31
 
32
32
  var projs = [
33
33
  tmerc,
@@ -66,4 +66,4 @@ export default function (proj4) {
66
66
  projs.forEach(function (proj) {
67
67
  proj4.Proj.projections.add(proj);
68
68
  });
69
- }
69
+ }
package/lib/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import proj4 from './core';
2
- import Proj from "./Proj";
3
- import Point from "./Point";
4
- import common from "./common/toPoint";
5
- import defs from "./defs";
6
- import nadgrid from "./nadgrid";
7
- import transform from "./transform";
8
- import mgrs from "mgrs";
9
- import includedProjections from "../projs";
2
+ import Proj from './Proj';
3
+ import Point from './Point';
4
+ import common from './common/toPoint';
5
+ import defs from './defs';
6
+ import nadgrid from './nadgrid';
7
+ import transform from './transform';
8
+ import mgrs from 'mgrs';
9
+ import includedProjections from '../projs';
10
10
 
11
- proj4.defaultDatum = 'WGS84'; //default datum
11
+ proj4.defaultDatum = 'WGS84'; // default datum
12
12
  proj4.Proj = Proj;
13
13
  proj4.WGS84 = new proj4.Proj('WGS84');
14
14
  proj4.Point = Point;
package/lib/nadgrid.js CHANGED
@@ -10,12 +10,16 @@ var loadedNadgrids = {};
10
10
  * Load a binary NTv2 file (.gsb) to a key that can be used in a proj string like +nadgrids=<key>. Pass the NTv2 file
11
11
  * as an ArrayBuffer.
12
12
  */
13
- export default function nadgrid(key, data) {
13
+ export default function nadgrid(key, data, options) {
14
+ var includeErrorFields = true;
15
+ if (options !== undefined && options.includeErrorFields === false) {
16
+ includeErrorFields = false;
17
+ }
14
18
  var view = new DataView(data);
15
19
  var isLittleEndian = detectLittleEndian(view);
16
20
  var header = readHeader(view, isLittleEndian);
17
- var subgrids = readSubgrids(view, header, isLittleEndian);
18
- var nadgrid = {header: header, subgrids: subgrids};
21
+ var subgrids = readSubgrids(view, header, isLittleEndian, includeErrorFields);
22
+ var nadgrid = { header: header, subgrids: subgrids };
19
23
  loadedNadgrids[key] = nadgrid;
20
24
  return nadgrid;
21
25
  }
@@ -25,7 +29,9 @@ export default function nadgrid(key, data) {
25
29
  */
26
30
  export function getNadgrids(nadgrids) {
27
31
  // Format details: http://proj.maptools.org/gen_parms.html
28
- if (nadgrids === undefined) { return null; }
32
+ if (nadgrids === undefined) {
33
+ return null;
34
+ }
29
35
  var grids = nadgrids.split(',');
30
36
  return grids.map(parseNadgridString);
31
37
  }
@@ -39,7 +45,7 @@ function parseNadgridString(value) {
39
45
  value = value.slice(1);
40
46
  }
41
47
  if (value === 'null') {
42
- return {name: 'null', mandatory: !optional, grid: null, isNull: true};
48
+ return { name: 'null', mandatory: !optional, grid: null, isNull: true };
43
49
  }
44
50
  return {
45
51
  name: value,
@@ -74,7 +80,7 @@ function readHeader(view, isLittleEndian) {
74
80
  fromSemiMajorAxis: view.getFloat64(120, isLittleEndian),
75
81
  fromSemiMinorAxis: view.getFloat64(136, isLittleEndian),
76
82
  toSemiMajorAxis: view.getFloat64(152, isLittleEndian),
77
- toSemiMinorAxis: view.getFloat64(168, isLittleEndian),
83
+ toSemiMinorAxis: view.getFloat64(168, isLittleEndian)
78
84
  };
79
85
  }
80
86
 
@@ -82,12 +88,12 @@ function decodeString(view, start, end) {
82
88
  return String.fromCharCode.apply(null, new Uint8Array(view.buffer.slice(start, end)));
83
89
  }
84
90
 
85
- function readSubgrids(view, header, isLittleEndian) {
91
+ function readSubgrids(view, header, isLittleEndian, includeErrorFields) {
86
92
  var gridOffset = 176;
87
93
  var grids = [];
88
94
  for (var i = 0; i < header.nSubgrids; i++) {
89
95
  var subHeader = readGridHeader(view, gridOffset, isLittleEndian);
90
- var nodes = readGridNodes(view, gridOffset, subHeader, isLittleEndian);
96
+ var nodes = readGridNodes(view, gridOffset, subHeader, isLittleEndian, includeErrorFields);
91
97
  var lngColumnCount = Math.round(
92
98
  1 + (subHeader.upperLongitude - subHeader.lowerLongitude) / subHeader.longitudeInterval);
93
99
  var latColumnCount = Math.round(
@@ -100,13 +106,19 @@ function readSubgrids(view, header, isLittleEndian) {
100
106
  count: subHeader.gridNodeCount,
101
107
  cvs: mapNodes(nodes)
102
108
  });
103
- gridOffset += 176 + subHeader.gridNodeCount * 16;
109
+ var rowSize = 16;
110
+ if (includeErrorFields === false) {
111
+ rowSize = 8;
112
+ }
113
+ gridOffset += 176 + subHeader.gridNodeCount * rowSize;
104
114
  }
105
115
  return grids;
106
116
  }
107
117
 
108
118
  function mapNodes(nodes) {
109
- return nodes.map(function (r) {return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)];});
119
+ return nodes.map(function (r) {
120
+ return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)];
121
+ });
110
122
  }
111
123
 
112
124
  function readGridHeader(view, offset, isLittleEndian) {
@@ -123,17 +135,27 @@ function readGridHeader(view, offset, isLittleEndian) {
123
135
  };
124
136
  }
125
137
 
126
- function readGridNodes(view, offset, gridHeader, isLittleEndian) {
138
+ function readGridNodes(view, offset, gridHeader, isLittleEndian, includeErrorFields) {
127
139
  var nodesOffset = offset + 176;
128
140
  var gridRecordLength = 16;
141
+
142
+ if (includeErrorFields === false) {
143
+ gridRecordLength = 8;
144
+ }
145
+
129
146
  var gridShiftRecords = [];
130
147
  for (var i = 0; i < gridHeader.gridNodeCount; i++) {
131
148
  var record = {
132
149
  latitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength, isLittleEndian),
133
- longitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength + 4, isLittleEndian),
134
- latitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 8, isLittleEndian),
135
- longitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 12, isLittleEndian),
150
+ longitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength + 4, isLittleEndian)
151
+
136
152
  };
153
+
154
+ if (includeErrorFields !== false) {
155
+ record.latitudeAccuracy = view.getFloat32(nodesOffset + i * gridRecordLength + 8, isLittleEndian);
156
+ record.longitudeAccuracy = view.getFloat32(nodesOffset + i * gridRecordLength + 12, isLittleEndian);
157
+ }
158
+
137
159
  gridShiftRecords.push(record);
138
160
  }
139
161
  return gridShiftRecords;
package/lib/parseCode.js CHANGED
@@ -2,17 +2,14 @@ import defs from './defs';
2
2
  import wkt from 'wkt-parser';
3
3
  import projStr from './projString';
4
4
  import match from './match';
5
- function testObj(code){
5
+ function testObj(code) {
6
6
  return typeof code === 'string';
7
7
  }
8
- function testDef(code){
8
+ function testDef(code) {
9
9
  return code in defs;
10
10
  }
11
- var codeWords = ['PROJECTEDCRS', 'PROJCRS', 'GEOGCS','GEOCCS','PROJCS','LOCAL_CS', 'GEODCRS', 'GEODETICCRS', 'GEODETICDATUM', 'ENGCRS', 'ENGINEERINGCRS'];
12
- function testWKT(code){
13
- return codeWords.some(function (word) {
14
- return code.indexOf(word) > -1;
15
- });
11
+ function testWKT(code) {
12
+ return (code.indexOf('+') !== 0 && code.indexOf('[') !== -1) || (typeof code === 'object' && !('srsCode' in code));
16
13
  }
17
14
  var codes = ['3857', '900913', '3785', '102113'];
18
15
  function checkMercator(item) {
@@ -30,12 +27,12 @@ function checkProjStr(item) {
30
27
  }
31
28
  return match(ext, 'proj4');
32
29
  }
33
- function testProj(code){
30
+ function testProj(code) {
34
31
  return code[0] === '+';
35
32
  }
36
- function parse(code){
33
+ function parse(code) {
37
34
  if (testObj(code)) {
38
- //check to see if this is a WKT string
35
+ // check to see if this is a WKT string
39
36
  if (testDef(code)) {
40
37
  return defs[code];
41
38
  }
@@ -54,7 +51,9 @@ function parse(code){
54
51
  if (testProj(code)) {
55
52
  return projStr(code);
56
53
  }
57
- }else{
54
+ } else if (!code.projName) {
55
+ return wkt(code);
56
+ } else {
58
57
  return code;
59
58
  }
60
59
  }