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.
- package/.github/workflows/build-and-test.yml +45 -7
- package/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
- package/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
- package/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
- package/.nyc_output/processinfo/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
- package/.nyc_output/processinfo/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
- package/.nyc_output/processinfo/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/Gruntfile.js +20 -84
- package/README.md +20 -6
- package/bower.json +1 -1
- package/component.json +1 -1
- package/dist/proj4-src.js +8934 -7083
- package/dist/proj4.js +1 -1
- package/eslint.config.mjs +41 -0
- package/lib/Point.js +4 -4
- package/lib/Proj.js +7 -8
- package/lib/adjust_axis.js +30 -33
- package/lib/common/acosh.js +2 -2
- package/lib/common/adjust_lat.js +2 -2
- package/lib/common/adjust_lon.js +2 -3
- package/lib/common/adjust_zone.js +1 -1
- package/lib/common/asinh.js +2 -2
- package/lib/common/asinhy.js +1 -1
- package/lib/common/asinz.js +2 -2
- package/lib/common/atanh.js +2 -2
- package/lib/common/clens.js +1 -1
- package/lib/common/clens_cmplx.js +1 -1
- package/lib/common/cosh.js +2 -2
- package/lib/common/e0fn.js +2 -2
- package/lib/common/e1fn.js +2 -2
- package/lib/common/e2fn.js +2 -2
- package/lib/common/e3fn.js +2 -2
- package/lib/common/fL.js +2 -2
- package/lib/common/gN.js +2 -2
- package/lib/common/gatg.js +1 -1
- package/lib/common/hypot.js +1 -1
- package/lib/common/imlfn.js +3 -3
- package/lib/common/invlatiso.js +2 -2
- package/lib/common/iqsfnz.js +5 -6
- package/lib/common/latiso.js +2 -2
- package/lib/common/log1py.js +1 -1
- package/lib/common/mlfn.js +2 -2
- package/lib/common/msfnz.js +2 -2
- package/lib/common/phi2z.js +3 -3
- package/lib/common/pj_enfn.js +2 -2
- package/lib/common/pj_inv_mlfn.js +6 -6
- package/lib/common/pj_mlfn.js +2 -2
- package/lib/common/qsfnz.js +3 -4
- package/lib/common/sign.js +3 -3
- package/lib/common/sinh.js +2 -2
- package/lib/common/srat.js +2 -2
- package/lib/common/tanh.js +2 -2
- package/lib/common/toPoint.js +4 -4
- package/lib/common/tsfnz.js +2 -2
- package/lib/constants/Datum.js +1228 -46
- package/lib/constants/Ellipsoid.js +225 -266
- package/lib/constants/PrimeMeridian.js +14 -14
- package/lib/constants/units.js +20 -20
- package/lib/constants/values.js +4 -4
- package/lib/core.js +2 -2
- package/lib/datum.js +2 -2
- package/lib/datumUtils.js +9 -14
- package/lib/datum_transform.js +26 -26
- package/lib/defs.js +10 -20
- package/lib/deriveConstants.js +4 -2
- package/lib/extend.js +1 -1
- package/lib/global.js +6 -6
- package/lib/includedProjections.js +25 -25
- package/lib/index.js +9 -9
- package/lib/nadgrid.js +36 -14
- package/lib/parseCode.js +10 -11
- package/lib/projString.js +41 -44
- package/lib/projections/aea.js +7 -12
- package/lib/projections/aeqd.js +51 -86
- package/lib/projections/bonne.js +11 -13
- package/lib/projections/cass.js +8 -15
- package/lib/projections/cea.js +7 -9
- package/lib/projections/eqc.js +2 -5
- package/lib/projections/eqdc.js +10 -16
- package/lib/projections/eqearth.js +17 -17
- package/lib/projections/equi.js +4 -6
- package/lib/projections/etmerc.js +9 -11
- package/lib/projections/gauss.js +3 -3
- package/lib/projections/geocent.js +13 -14
- package/lib/projections/geos.js +136 -137
- package/lib/projections/gnom.js +8 -13
- package/lib/projections/gstmerc.js +2 -5
- package/lib/projections/krovak.js +3 -3
- package/lib/projections/laea.js +85 -97
- package/lib/projections/lcc.js +28 -33
- package/lib/projections/longlat.js +4 -4
- package/lib/projections/merc.js +12 -19
- package/lib/projections/mill.js +6 -7
- package/lib/projections/moll.js +8 -9
- package/lib/projections/nzmg.js +2 -2
- package/lib/projections/omerc.js +55 -57
- package/lib/projections/ortho.js +9 -10
- package/lib/projections/poly.js +13 -21
- package/lib/projections/qsc.js +19 -21
- package/lib/projections/robin.js +118 -118
- package/lib/projections/sinu.js +12 -23
- package/lib/projections/somerc.js +3 -3
- package/lib/projections/stere.js +29 -41
- package/lib/projections/sterea.js +3 -4
- package/lib/projections/tmerc.js +29 -36
- package/lib/projections/tpers.js +14 -15
- package/lib/projections/utm.js +3 -4
- package/lib/projections/vandg.js +15 -21
- package/lib/projections.js +12 -4
- package/lib/transform.js +3 -3
- package/package.json +29 -22
- package/projs.js +2 -2
- package/publish.sh +2 -2
- package/rollup.config.mjs +29 -0
- package/scripts/readme.md +10 -0
- package/scripts/updateDatums.mjs +119 -0
- package/scripts/updateEllipsoids.mjs +70 -0
- package/test/ntv2_0_downsampled_no_error_columns.gsb +0 -0
- package/test/opt.html +27 -24
- package/test/puppeteer-tests.mjs +110 -0
- package/test/test-ci.mjs +10 -0
- package/test/test.js +197 -125
- package/test/testData.js +1802 -312
- package/.jshintrc +0 -12
- package/test/amd.html +0 -63
- package/test/package.json.js +0 -1
package/test/test.js
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
// You can do this in the grunt config for each mocha task, see the `options` config
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
// Start the main app logic.
|
|
5
4
|
|
|
6
5
|
function startTests(chai, proj4, testPoints) {
|
|
7
|
-
|
|
8
|
-
|
|
9
6
|
var assert = chai.assert;
|
|
10
7
|
proj4.defs([
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
8
|
+
['EPSG:102018', '+proj=gnom +lat_0=90 +lon_0=0 +x_0=6300000 +y_0=6300000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'],
|
|
9
|
+
['testmerc', '+proj=merc +lon_0=5.937 +lat_ts=45.027 +ellps=sphere'],
|
|
10
|
+
['testmerc2', '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +units=m +k=1.0 +nadgrids=@null +no_defs']
|
|
14
11
|
]);
|
|
15
12
|
proj4.defs('esriOnline', 'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]');
|
|
16
13
|
|
|
17
|
-
describe('parse', function() {
|
|
18
|
-
it('should parse units', function() {
|
|
14
|
+
describe('parse', function () {
|
|
15
|
+
it('should parse units', function () {
|
|
19
16
|
assert.equal(proj4.defs('testmerc2').units, 'm');
|
|
20
17
|
});
|
|
21
18
|
});
|
|
22
19
|
|
|
23
|
-
describe('proj2proj', function() {
|
|
24
|
-
it('should work transforming from one projection to another', function() {
|
|
20
|
+
describe('proj2proj', function () {
|
|
21
|
+
it('should work transforming from one projection to another', function () {
|
|
25
22
|
var sweref99tm = '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
|
|
26
23
|
var rt90 = '+lon_0=15.808277777799999 +lat_0=0.0 +k=1.0 +x_0=1500000.0 +y_0=0.0 +proj=tmerc +ellps=bessel +units=m +towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +no_defs';
|
|
27
24
|
var rslt = proj4(sweref99tm, rt90).forward([319180, 6399862]);
|
|
28
25
|
assert.closeTo(rslt[0], 1271137.927561178, 0.000001);
|
|
29
26
|
assert.closeTo(rslt[1], 6404230.291456626, 0.000001);
|
|
30
27
|
});
|
|
31
|
-
it('should work with a proj object', function() {
|
|
28
|
+
it('should work with a proj object', function () {
|
|
32
29
|
var sweref99tm = proj4('+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
|
|
33
30
|
var rt90 = proj4('+lon_0=15.808277777799999 +lat_0=0.0 +k=1.0 +x_0=1500000.0 +y_0=0.0 +proj=tmerc +ellps=bessel +units=m +towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +no_defs');
|
|
34
31
|
var rslt = proj4(sweref99tm, rt90).forward([319180, 6399862]);
|
|
@@ -37,10 +34,10 @@ function startTests(chai, proj4, testPoints) {
|
|
|
37
34
|
});
|
|
38
35
|
});
|
|
39
36
|
|
|
40
|
-
describe('proj4', function() {
|
|
41
|
-
describe('core', function() {
|
|
42
|
-
testPoints.forEach(function(testPoint) {
|
|
43
|
-
describe(testPoint.code, function() {
|
|
37
|
+
describe('proj4', function () {
|
|
38
|
+
describe('core', function () {
|
|
39
|
+
testPoints.forEach(function (testPoint) {
|
|
40
|
+
describe(typeof testPoint.code === 'object' ? testPoint.code.name : testPoint.code, function () {
|
|
44
41
|
var xyAcc = 2,
|
|
45
42
|
llAcc = 6;
|
|
46
43
|
if ('acc' in testPoint) {
|
|
@@ -51,29 +48,29 @@ function startTests(chai, proj4, testPoints) {
|
|
|
51
48
|
llAcc = testPoint.acc.ll;
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
var xyEPSLN = Math.pow(10, -
|
|
55
|
-
var llEPSLN = Math.pow(10, -
|
|
56
|
-
describe('traditional', function() {
|
|
57
|
-
it('should work with forwards', function() {
|
|
51
|
+
var xyEPSLN = Math.pow(10, -1 * xyAcc);
|
|
52
|
+
var llEPSLN = Math.pow(10, -1 * llAcc);
|
|
53
|
+
describe('traditional', function () {
|
|
54
|
+
it('should work with forwards', function () {
|
|
58
55
|
var proj = new proj4.Proj(testPoint.code);
|
|
59
56
|
var xy = proj4.transform(proj4.WGS84, proj, proj4.toPoint(testPoint.ll));
|
|
60
57
|
assert.closeTo(xy.x, testPoint.xy[0], xyEPSLN, 'x is close');
|
|
61
58
|
assert.closeTo(xy.y, testPoint.xy[1], xyEPSLN, 'y is close');
|
|
62
59
|
});
|
|
63
|
-
it('should work with backwards', function() {
|
|
60
|
+
it('should work with backwards', function () {
|
|
64
61
|
var proj = new proj4.Proj(testPoint.code);
|
|
65
62
|
var ll = proj4.transform(proj, proj4.WGS84, proj4.toPoint(testPoint.xy));
|
|
66
63
|
assert.closeTo(ll.x, testPoint.ll[0], llEPSLN, 'lng is close');
|
|
67
64
|
assert.closeTo(ll.y, testPoint.ll[1], llEPSLN, 'lat is close');
|
|
68
65
|
});
|
|
69
66
|
});
|
|
70
|
-
describe('new method 2 param', function() {
|
|
71
|
-
it('shortcut method should work with an array', function() {
|
|
67
|
+
describe('new method 2 param', function () {
|
|
68
|
+
it('shortcut method should work with an array', function () {
|
|
72
69
|
var xy = proj4(testPoint.code, testPoint.ll);
|
|
73
70
|
assert.closeTo(xy[0], testPoint.xy[0], xyEPSLN, 'x is close');
|
|
74
71
|
assert.closeTo(xy[1], testPoint.xy[1], xyEPSLN, 'y is close');
|
|
75
72
|
});
|
|
76
|
-
it('shortcut method should work with an object', function() {
|
|
73
|
+
it('shortcut method should work with an object', function () {
|
|
77
74
|
var pt = {
|
|
78
75
|
x: testPoint.ll[0],
|
|
79
76
|
y: testPoint.ll[1]
|
|
@@ -82,20 +79,20 @@ function startTests(chai, proj4, testPoints) {
|
|
|
82
79
|
assert.closeTo(xy.x, testPoint.xy[0], xyEPSLN, 'x is close');
|
|
83
80
|
assert.closeTo(xy.y, testPoint.xy[1], xyEPSLN, 'y is close');
|
|
84
81
|
});
|
|
85
|
-
it('shortcut method should work with a point object', function() {
|
|
82
|
+
it('shortcut method should work with a point object', function () {
|
|
86
83
|
var pt = proj4.toPoint(testPoint.ll);
|
|
87
84
|
var xy = proj4(testPoint.code, pt);
|
|
88
85
|
assert.closeTo(xy.x, testPoint.xy[0], xyEPSLN, 'x is close');
|
|
89
86
|
assert.closeTo(xy.y, testPoint.xy[1], xyEPSLN, 'y is close');
|
|
90
87
|
});
|
|
91
88
|
});
|
|
92
|
-
describe('new method 3 param', function() {
|
|
93
|
-
it('shortcut method should work with an array', function() {
|
|
89
|
+
describe('new method 3 param', function () {
|
|
90
|
+
it('shortcut method should work with an array', function () {
|
|
94
91
|
var xy = proj4(proj4.WGS84, testPoint.code, testPoint.ll);
|
|
95
92
|
assert.closeTo(xy[0], testPoint.xy[0], xyEPSLN, 'x is close');
|
|
96
93
|
assert.closeTo(xy[1], testPoint.xy[1], xyEPSLN, 'y is close');
|
|
97
94
|
});
|
|
98
|
-
it('shortcut method should work with an object', function() {
|
|
95
|
+
it('shortcut method should work with an object', function () {
|
|
99
96
|
var pt = {
|
|
100
97
|
x: testPoint.ll[0],
|
|
101
98
|
y: testPoint.ll[1]
|
|
@@ -104,96 +101,96 @@ function startTests(chai, proj4, testPoints) {
|
|
|
104
101
|
assert.closeTo(xy.x, testPoint.xy[0], xyEPSLN, 'x is close');
|
|
105
102
|
assert.closeTo(xy.y, testPoint.xy[1], xyEPSLN, 'y is close');
|
|
106
103
|
});
|
|
107
|
-
it('shortcut method should work with a point object', function() {
|
|
104
|
+
it('shortcut method should work with a point object', function () {
|
|
108
105
|
var pt = proj4.toPoint(testPoint.ll);
|
|
109
106
|
var xy = proj4(proj4.WGS84, testPoint.code, pt);
|
|
110
107
|
assert.closeTo(xy.x, testPoint.xy[0], xyEPSLN, 'x is close');
|
|
111
108
|
assert.closeTo(xy.y, testPoint.xy[1], xyEPSLN, 'y is close');
|
|
112
109
|
});
|
|
113
110
|
});
|
|
114
|
-
describe('new method 3 param other way', function() {
|
|
115
|
-
it('shortcut method should work with an array', function() {
|
|
111
|
+
describe('new method 3 param other way', function () {
|
|
112
|
+
it('shortcut method should work with an array', function () {
|
|
116
113
|
var ll = proj4(testPoint.code, proj4.WGS84, testPoint.xy);
|
|
117
114
|
assert.closeTo(ll[0], testPoint.ll[0], llEPSLN, 'x is close');
|
|
118
115
|
assert.closeTo(ll[1], testPoint.ll[1], llEPSLN, 'y is close');
|
|
119
116
|
});
|
|
120
|
-
it('shortcut method should work with an object', function() {
|
|
117
|
+
it('shortcut method should work with an object', function () {
|
|
121
118
|
var pt = {
|
|
122
119
|
x: testPoint.xy[0],
|
|
123
120
|
y: testPoint.xy[1]
|
|
124
121
|
};
|
|
125
122
|
// in case of geocentric proj we need Z value.
|
|
126
123
|
if (typeof testPoint.xy[2] === 'number') {
|
|
127
|
-
pt.z = testPoint.xy[2]
|
|
124
|
+
pt.z = testPoint.xy[2];
|
|
128
125
|
}
|
|
129
126
|
var ll = proj4(testPoint.code, proj4.WGS84, pt);
|
|
130
127
|
assert.closeTo(ll.x, testPoint.ll[0], llEPSLN, 'x is close');
|
|
131
128
|
assert.closeTo(ll.y, testPoint.ll[1], llEPSLN, 'y is close');
|
|
132
129
|
});
|
|
133
|
-
it('shortcut method should work with a point object', function() {
|
|
130
|
+
it('shortcut method should work with a point object', function () {
|
|
134
131
|
var pt = proj4.toPoint(testPoint.xy);
|
|
135
132
|
var ll = proj4(testPoint.code, proj4.WGS84, pt);
|
|
136
133
|
assert.closeTo(ll.x, testPoint.ll[0], llEPSLN, 'x is close');
|
|
137
134
|
assert.closeTo(ll.y, testPoint.ll[1], llEPSLN, 'y is close');
|
|
138
135
|
});
|
|
139
136
|
});
|
|
140
|
-
describe('1 param', function() {
|
|
141
|
-
it('forwards', function() {
|
|
137
|
+
describe('1 param', function () {
|
|
138
|
+
it('forwards', function () {
|
|
142
139
|
var xy = proj4(testPoint.code).forward(testPoint.ll);
|
|
143
140
|
assert.closeTo(xy[0], testPoint.xy[0], xyEPSLN, 'x is close');
|
|
144
141
|
assert.closeTo(xy[1], testPoint.xy[1], xyEPSLN, 'y is close');
|
|
145
142
|
});
|
|
146
|
-
it('inverse', function() {
|
|
143
|
+
it('inverse', function () {
|
|
147
144
|
var ll = proj4(testPoint.code).inverse(testPoint.xy);
|
|
148
145
|
assert.closeTo(ll[0], testPoint.ll[0], llEPSLN, 'x is close');
|
|
149
146
|
assert.closeTo(ll[1], testPoint.ll[1], llEPSLN, 'y is close');
|
|
150
147
|
});
|
|
151
148
|
});
|
|
152
|
-
describe('proj object', function() {
|
|
153
|
-
it('should work with a 2 element array', function() {
|
|
149
|
+
describe('proj object', function () {
|
|
150
|
+
it('should work with a 2 element array', function () {
|
|
154
151
|
const ll = [testPoint.ll[0], testPoint.ll[1]];
|
|
155
152
|
Object.freeze(ll);
|
|
156
153
|
var xy = proj4(new proj4.Proj(testPoint.code), ll);
|
|
157
154
|
assert.closeTo(xy[0], testPoint.xy[0], xyEPSLN, 'x is close');
|
|
158
155
|
assert.closeTo(xy[1], testPoint.xy[1], xyEPSLN, 'y is close');
|
|
159
156
|
});
|
|
160
|
-
it('should work
|
|
157
|
+
it('should work with a 3 element array', function () {
|
|
161
158
|
const llz = [testPoint.ll[0], testPoint.ll[1], 0];
|
|
162
159
|
Object.freeze(llz);
|
|
163
160
|
var xy = proj4(new proj4.Proj(testPoint.code), llz);
|
|
164
161
|
assert.closeTo(xy[0], testPoint.xy[0], xyEPSLN, 'x is close');
|
|
165
162
|
assert.closeTo(xy[1], testPoint.xy[1], xyEPSLN, 'y is close');
|
|
166
163
|
});
|
|
167
|
-
it('should work on element', function() {
|
|
164
|
+
it('should work on element', function () {
|
|
168
165
|
var xy = proj4(new proj4.Proj(testPoint.code)).forward(testPoint.ll);
|
|
169
166
|
assert.closeTo(xy[0], testPoint.xy[0], xyEPSLN, 'x is close');
|
|
170
167
|
assert.closeTo(xy[1], testPoint.xy[1], xyEPSLN, 'y is close');
|
|
171
168
|
});
|
|
172
|
-
it('should work 3 element point object', function() {
|
|
169
|
+
it('should work 3 element point object', function () {
|
|
173
170
|
var pt = proj4.toPoint(testPoint.xy);
|
|
174
171
|
var ll = proj4(new proj4.Proj(testPoint.code), proj4.WGS84, pt);
|
|
175
172
|
assert.closeTo(ll.x, testPoint.ll[0], llEPSLN, 'x is close');
|
|
176
173
|
assert.closeTo(ll.y, testPoint.ll[1], llEPSLN, 'y is close');
|
|
177
174
|
});
|
|
178
175
|
});
|
|
179
|
-
describe('proj coord object', function() {
|
|
180
|
-
it('should not be modified', function() {
|
|
181
|
-
var expected = {x: 100000, y: 100000};
|
|
182
|
-
var inpxy = {x: expected.x, y: expected.y};
|
|
176
|
+
describe('proj coord object', function () {
|
|
177
|
+
it('should not be modified', function () {
|
|
178
|
+
var expected = { x: 100000, y: 100000 };
|
|
179
|
+
var inpxy = { x: expected.x, y: expected.y };
|
|
183
180
|
proj4('EPSG:3857', proj4.WGS84, inpxy);
|
|
184
181
|
|
|
185
|
-
assert.deepEqual(inpxy, expected,
|
|
182
|
+
assert.deepEqual(inpxy, expected, 'input is unmodified');
|
|
186
183
|
});
|
|
187
184
|
});
|
|
188
185
|
});
|
|
189
186
|
});
|
|
190
187
|
});
|
|
191
188
|
describe('points', function () {
|
|
192
|
-
it('should not create a z if none was provided', function() {
|
|
189
|
+
it('should not create a z if none was provided', function () {
|
|
193
190
|
const result = proj4(
|
|
194
191
|
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]',
|
|
195
192
|
'PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB_1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4277"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],AUTHORITY["EPSG","27700"],AXIS["Easting",EAST],AXIS["Northing",NORTH]]',
|
|
196
|
-
{x: -0.12793738, y: 51.507747});
|
|
193
|
+
{ x: -0.12793738, y: 51.507747 });
|
|
197
194
|
assert.closeTo(result.x, 530018.229301635, 1e-6);
|
|
198
195
|
assert.closeTo(result.y, 180418.4380560551, 1e-6);
|
|
199
196
|
assert.equal(result.z, undefined);
|
|
@@ -250,7 +247,7 @@ function startTests(chai, proj4, testPoints) {
|
|
|
250
247
|
319180,
|
|
251
248
|
6399862,
|
|
252
249
|
0,
|
|
253
|
-
1000
|
|
250
|
+
1000
|
|
254
251
|
]);
|
|
255
252
|
assert.closeTo(rslt[0], 1271137.927561178, 0.000001);
|
|
256
253
|
assert.closeTo(rslt[1], 6404230.291456626, 0.000001);
|
|
@@ -272,7 +269,7 @@ function startTests(chai, proj4, testPoints) {
|
|
|
272
269
|
});
|
|
273
270
|
});
|
|
274
271
|
|
|
275
|
-
it('should use [x,y] axis order', function() {
|
|
272
|
+
it('should use [x,y] axis order', function () {
|
|
276
273
|
var enu = 'PROJCS["NAD83 / Massachusetts Mainland", GEOGCS["NAD83", DATUM["North American Datum 1983", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4269"]], PROJECTION["Lambert_Conformal_Conic_2SP", AUTHORITY["EPSG","9802"]], PARAMETER["central_meridian", -71.5], PARAMETER["latitude_of_origin", 41.0], PARAMETER["standard_parallel_1", 42.68333333333334], PARAMETER["false_easting", 200000.0], PARAMETER["false_northing", 750000.0], PARAMETER["scale_factor", 1.0], PARAMETER["standard_parallel_2", 41.71666666666667], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","26986"]]';
|
|
277
274
|
var neu = 'PROJCS["NAD83 / Massachusetts Mainland NE", GEOGCS["NAD83", DATUM["North American Datum 1983", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic latitude", NORTH], AXIS["Geodetic longitude", EAST], AUTHORITY["EPSG","4269"]], PROJECTION["Lambert_Conformal_Conic_2SP", AUTHORITY["EPSG","9802"]], PARAMETER["central_meridian", -71.5], PARAMETER["latitude_of_origin", 41.0], PARAMETER["standard_parallel_1", 42.68333333333334], PARAMETER["false_easting", 200000.0], PARAMETER["false_northing", 750000.0], PARAMETER["scale_factor", 1.0], PARAMETER["standard_parallel_2", 41.71666666666667], UNIT["m", 1.0], AXIS["Northing", NORTH], AXIS["Easting", EAST], AUTHORITY["EPSG","26986"]]';
|
|
278
275
|
var rslt = proj4(enu, neu).forward({
|
|
@@ -283,7 +280,7 @@ function startTests(chai, proj4, testPoints) {
|
|
|
283
280
|
assert.closeTo(rslt.y, 43.4, 0.000001);
|
|
284
281
|
});
|
|
285
282
|
|
|
286
|
-
it('should use correct axis order with proj4.transform()', function() {
|
|
283
|
+
it('should use correct axis order with proj4.transform()', function () {
|
|
287
284
|
var enu = 'PROJCS["NAD83 / Massachusetts Mainland", GEOGCS["NAD83", DATUM["North American Datum 1983", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4269"]], PROJECTION["Lambert_Conformal_Conic_2SP", AUTHORITY["EPSG","9802"]], PARAMETER["central_meridian", -71.5], PARAMETER["latitude_of_origin", 41.0], PARAMETER["standard_parallel_1", 42.68333333333334], PARAMETER["false_easting", 200000.0], PARAMETER["false_northing", 750000.0], PARAMETER["scale_factor", 1.0], PARAMETER["standard_parallel_2", 41.71666666666667], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","26986"]]';
|
|
288
285
|
var neu = 'PROJCS["NAD83 / Massachusetts Mainland NE", GEOGCS["NAD83", DATUM["North American Datum 1983", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic latitude", NORTH], AXIS["Geodetic longitude", EAST], AUTHORITY["EPSG","4269"]], PROJECTION["Lambert_Conformal_Conic_2SP", AUTHORITY["EPSG","9802"]], PARAMETER["central_meridian", -71.5], PARAMETER["latitude_of_origin", 41.0], PARAMETER["standard_parallel_1", 42.68333333333334], PARAMETER["false_easting", 200000.0], PARAMETER["false_northing", 750000.0], PARAMETER["scale_factor", 1.0], PARAMETER["standard_parallel_2", 41.71666666666667], UNIT["m", 1.0], AXIS["Northing", NORTH], AXIS["Easting", EAST], AUTHORITY["EPSG","26986"]]';
|
|
289
286
|
var rslt = proj4(enu, neu).forward({
|
|
@@ -298,10 +295,10 @@ function startTests(chai, proj4, testPoints) {
|
|
|
298
295
|
var enu = '+proj=longlat +axis=enu';
|
|
299
296
|
var esu = '+proj=longlat +axis=esu';
|
|
300
297
|
var wnu = '+proj=longlat +axis=wnu';
|
|
301
|
-
var result = proj4(enu, esu).forward({x: 40, y: 50}, true);
|
|
298
|
+
var result = proj4(enu, esu).forward({ x: 40, y: 50 }, true);
|
|
302
299
|
assert.closeTo(result.x, 40, 0.000001);
|
|
303
300
|
assert.closeTo(result.y, -50, 0.000001);
|
|
304
|
-
var result = proj4(enu, wnu).forward({x: 40, y: 50}, true);
|
|
301
|
+
var result = proj4(enu, wnu).forward({ x: 40, y: 50 }, true);
|
|
305
302
|
assert.closeTo(result.x, -40, 0.000001);
|
|
306
303
|
assert.closeTo(result.y, 50, 0.000001);
|
|
307
304
|
});
|
|
@@ -338,99 +335,99 @@ function startTests(chai, proj4, testPoints) {
|
|
|
338
335
|
});
|
|
339
336
|
});
|
|
340
337
|
});
|
|
341
|
-
describe('errors', function() {
|
|
342
|
-
it('should throw an error for an unknown ref', function() {
|
|
343
|
-
assert.throws(function() {
|
|
338
|
+
describe('errors', function () {
|
|
339
|
+
it('should throw an error for an unknown ref', function () {
|
|
340
|
+
assert.throws(function () {
|
|
344
341
|
new proj4.Proj('fake one');
|
|
345
342
|
}, 'fake one', 'should work');
|
|
346
343
|
});
|
|
347
|
-
it('should throw when passed null', function() {
|
|
348
|
-
assert.throws(function() {
|
|
349
|
-
|
|
344
|
+
it('should throw when passed null', function () {
|
|
345
|
+
assert.throws(function () {
|
|
346
|
+
proj4('+proj=utm +zone=31', [null, 0]);
|
|
350
347
|
}, 'coordinates must be finite numbers', 'should work');
|
|
351
348
|
});
|
|
352
|
-
it('should throw when passed NaN', function() {
|
|
353
|
-
assert.throws(function() {
|
|
354
|
-
|
|
349
|
+
it('should throw when passed NaN', function () {
|
|
350
|
+
assert.throws(function () {
|
|
351
|
+
proj4('+proj=utm +zone=31', [0, NaN]);
|
|
355
352
|
}, 'coordinates must be finite numbers', 'should work');
|
|
356
353
|
});
|
|
357
|
-
it('should throw when passed Infinity', function() {
|
|
358
|
-
assert.throws(function() {
|
|
359
|
-
|
|
354
|
+
it('should throw when passed Infinity', function () {
|
|
355
|
+
assert.throws(function () {
|
|
356
|
+
proj4('+proj=utm +zone=31', [Infinity, 0]);
|
|
360
357
|
}, 'coordinates must be finite numbers', 'should work');
|
|
361
358
|
});
|
|
362
|
-
it('should throw when passed -Infinity', function() {
|
|
363
|
-
assert.throws(function() {
|
|
364
|
-
|
|
359
|
+
it('should throw when passed -Infinity', function () {
|
|
360
|
+
assert.throws(function () {
|
|
361
|
+
proj4('+proj=utm +zone=31', [-Infinity, 0]);
|
|
365
362
|
}, 'coordinates must be finite numbers', 'should work');
|
|
366
363
|
});
|
|
367
364
|
});
|
|
368
|
-
describe('utility', function() {
|
|
369
|
-
it('should have MGRS available in the proj4.util namespace', function() {
|
|
370
|
-
assert.typeOf(proj4.mgrs,
|
|
365
|
+
describe('utility', function () {
|
|
366
|
+
it('should have MGRS available in the proj4.util namespace', function () {
|
|
367
|
+
assert.typeOf(proj4.mgrs, 'object', 'MGRS available in the proj4.util namespace');
|
|
371
368
|
});
|
|
372
|
-
it('should have fromMGRS method added to proj4.Point prototype', function() {
|
|
373
|
-
assert.typeOf(proj4.Point.fromMGRS,
|
|
369
|
+
it('should have fromMGRS method added to proj4.Point prototype', function () {
|
|
370
|
+
assert.typeOf(proj4.Point.fromMGRS, 'function', 'fromMGRS method added to proj4.Point prototype');
|
|
374
371
|
});
|
|
375
|
-
it('should have toMGRS method added to proj4.Point prototype', function() {
|
|
376
|
-
assert.typeOf(proj4.Point.prototype.toMGRS,
|
|
372
|
+
it('should have toMGRS method added to proj4.Point prototype', function () {
|
|
373
|
+
assert.typeOf(proj4.Point.prototype.toMGRS, 'function', 'toMGRS method added to proj4.Point prototype');
|
|
377
374
|
});
|
|
378
375
|
|
|
379
|
-
describe('First MGRS set', function() {
|
|
380
|
-
var mgrs =
|
|
376
|
+
describe('First MGRS set', function () {
|
|
377
|
+
var mgrs = '33UXP04';
|
|
381
378
|
var point = proj4.Point.fromMGRS(mgrs);
|
|
382
|
-
it('Longitude of point from MGRS correct.', function() {
|
|
383
|
-
assert.equal(point.x.toPrecision(7),
|
|
379
|
+
it('Longitude of point from MGRS correct.', function () {
|
|
380
|
+
assert.equal(point.x.toPrecision(7), '16.41450', 'Longitude of point from MGRS correct.');
|
|
384
381
|
});
|
|
385
|
-
it('Latitude of point from MGRS correct.', function() {
|
|
386
|
-
assert.equal(point.y.toPrecision(7),
|
|
382
|
+
it('Latitude of point from MGRS correct.', function () {
|
|
383
|
+
assert.equal(point.y.toPrecision(7), '48.24949', 'Latitude of point from MGRS correct.');
|
|
387
384
|
});
|
|
388
|
-
it('MGRS reference with highest accuracy correct.', function() {
|
|
389
|
-
assert.equal(point.toMGRS(),
|
|
385
|
+
it('MGRS reference with highest accuracy correct.', function () {
|
|
386
|
+
assert.equal(point.toMGRS(), '33UXP0500444998', 'MGRS reference with highest accuracy correct.');
|
|
390
387
|
});
|
|
391
|
-
it('MGRS reference with 1-digit accuracy correct.', function() {
|
|
392
|
-
assert.equal(point.toMGRS(1), mgrs,
|
|
388
|
+
it('MGRS reference with 1-digit accuracy correct.', function () {
|
|
389
|
+
assert.equal(point.toMGRS(1), mgrs, 'MGRS reference with 1-digit accuracy correct.');
|
|
393
390
|
});
|
|
394
391
|
});
|
|
395
|
-
describe('Second MGRS set', function() {
|
|
396
|
-
var mgrs =
|
|
392
|
+
describe('Second MGRS set', function () {
|
|
393
|
+
var mgrs = '24XWT783908'; // near UTM zone border, so there are two ways to reference this
|
|
397
394
|
var point = proj4.Point.fromMGRS(mgrs);
|
|
398
|
-
it(
|
|
399
|
-
assert.equal(point.x.toPrecision(7),
|
|
395
|
+
it('Longitude of point from MGRS correct.', function () {
|
|
396
|
+
assert.equal(point.x.toPrecision(7), '-32.66433', 'Longitude of point from MGRS correct.');
|
|
400
397
|
});
|
|
401
|
-
it(
|
|
402
|
-
assert.equal(point.y.toPrecision(7),
|
|
398
|
+
it('Latitude of point from MGRS correct.', function () {
|
|
399
|
+
assert.equal(point.y.toPrecision(7), '83.62778', 'Latitude of point from MGRS correct.');
|
|
403
400
|
});
|
|
404
|
-
it(
|
|
405
|
-
assert.equal(point.toMGRS(3),
|
|
401
|
+
it('MGRS reference with 3-digit accuracy correct.', function () {
|
|
402
|
+
assert.equal(point.toMGRS(3), '25XEN041865', 'MGRS reference with 3-digit accuracy correct.');
|
|
406
403
|
});
|
|
407
404
|
});
|
|
408
|
-
describe('Defs and Datum definition', function() {
|
|
409
|
-
proj4.defs(
|
|
410
|
-
var point = proj4.transform(proj4.Proj(
|
|
411
|
-
|
|
412
|
-
it(
|
|
413
|
-
assert.equal(point.x.toPrecision(8),
|
|
405
|
+
describe('Defs and Datum definition', function () {
|
|
406
|
+
proj4.defs('EPSG:5514', '+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56');
|
|
407
|
+
var point = proj4.transform(proj4.Proj('WGS84'), proj4.Proj('EPSG:5514'),
|
|
408
|
+
proj4.toPoint([12.806988, 49.452262]));
|
|
409
|
+
it('Longitude of point from WGS84 correct.', function () {
|
|
410
|
+
assert.equal(point.x.toPrecision(8), '-868208.61', 'Longitude of point from WGS84 correct.');
|
|
414
411
|
});
|
|
415
|
-
it(
|
|
416
|
-
assert.equal(point.y.toPrecision(9),
|
|
412
|
+
it('Latitude of point from WGS84 correct.', function () {
|
|
413
|
+
assert.equal(point.y.toPrecision(9), '-1095793.64', 'Latitude of point from WGS84 correct.');
|
|
417
414
|
});
|
|
418
|
-
var point2 = proj4.transform(proj4.Proj(
|
|
419
|
-
|
|
420
|
-
it(
|
|
421
|
-
assert.equal(point2.x.toPrecision(8),
|
|
415
|
+
var point2 = proj4.transform(proj4.Proj('WGS84'), proj4.Proj('EPSG:5514'),
|
|
416
|
+
proj4.toPoint([12.806988, 49.452262]));
|
|
417
|
+
it('Longitude of point from WGS84 with second call for EPSG:5514 correct.', function () {
|
|
418
|
+
assert.equal(point2.x.toPrecision(8), '-868208.61', 'Longitude of point from WGS84 correct.');
|
|
422
419
|
});
|
|
423
|
-
it(
|
|
424
|
-
assert.equal(point2.y.toPrecision(9),
|
|
420
|
+
it('Latitude of point from WGS84 with second call for EPSG:5514 correct.', function () {
|
|
421
|
+
assert.equal(point2.y.toPrecision(9), '-1095793.64', 'Latitude of point from WGS84 correct.');
|
|
425
422
|
});
|
|
426
423
|
});
|
|
427
424
|
});
|
|
428
425
|
|
|
429
|
-
describe('Nadgrids BETA2007', function() {
|
|
426
|
+
describe('Nadgrids BETA2007', function () {
|
|
430
427
|
var tests = [
|
|
431
428
|
['EPSG:31466', 'EPSG:4326', 2559552, 5670982, 6.850861772, 51.170707759, 0.0000001, 0.01],
|
|
432
429
|
['EPSG:31466', 'EPSG:3857', 2559552, 5670982, 762634.443931574, 6651545.680265270, 0.01, 0.01],
|
|
433
|
-
['EPSG:31466', 'EPSG:25832', 2559552, 5670982, 349757.381712518, 5671004.065049540, 0.01, 0.01]
|
|
430
|
+
['EPSG:31466', 'EPSG:25832', 2559552, 5670982, 349757.381712518, 5671004.065049540, 0.01, 0.01]
|
|
434
431
|
];
|
|
435
432
|
|
|
436
433
|
function initializeNadgrid(buffer) {
|
|
@@ -439,12 +436,12 @@ function startTests(chai, proj4, testPoints) {
|
|
|
439
436
|
proj4.defs('EPSG:25832', '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs');
|
|
440
437
|
}
|
|
441
438
|
|
|
442
|
-
before(function(done) {
|
|
439
|
+
before(function (done) {
|
|
443
440
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
444
441
|
const xhr = new XMLHttpRequest();
|
|
445
442
|
xhr.open('GET', 'BETA2007.gsb', true);
|
|
446
443
|
xhr.responseType = 'arraybuffer';
|
|
447
|
-
xhr.addEventListener('load', function() {
|
|
444
|
+
xhr.addEventListener('load', function () {
|
|
448
445
|
initializeNadgrid(xhr.response);
|
|
449
446
|
done();
|
|
450
447
|
});
|
|
@@ -453,18 +450,18 @@ function startTests(chai, proj4, testPoints) {
|
|
|
453
450
|
} else if (typeof require === 'function') {
|
|
454
451
|
const fs = require('fs');
|
|
455
452
|
const path = require('path');
|
|
456
|
-
fs.readFile(path.join(__dirname, 'BETA2007.gsb'), function(err, data) {
|
|
453
|
+
fs.readFile(path.join(__dirname, 'BETA2007.gsb'), function (err, data) {
|
|
457
454
|
if (err) {
|
|
458
455
|
done(err);
|
|
459
456
|
} else {
|
|
460
457
|
initializeNadgrid(data.buffer);
|
|
461
458
|
done();
|
|
462
459
|
}
|
|
463
|
-
})
|
|
460
|
+
});
|
|
464
461
|
}
|
|
465
462
|
});
|
|
466
463
|
|
|
467
|
-
tests.forEach(function(test) {
|
|
464
|
+
tests.forEach(function (test) {
|
|
468
465
|
var fromProj = test[0];
|
|
469
466
|
var toProj = test[1];
|
|
470
467
|
var fromX = test[2];
|
|
@@ -486,7 +483,7 @@ function startTests(chai, proj4, testPoints) {
|
|
|
486
483
|
});
|
|
487
484
|
});
|
|
488
485
|
|
|
489
|
-
describe('Nadgrids ntv2', function() {
|
|
486
|
+
describe('Nadgrids ntv2', function () {
|
|
490
487
|
var tests = [
|
|
491
488
|
[-44.382211538462, 40.3768, -44.380749, 40.377457], // just inside the lower limit
|
|
492
489
|
[-87.617788, 59.623262, -87.617659, 59.623441], // just inside the upper limit
|
|
@@ -504,12 +501,12 @@ function startTests(chai, proj4, testPoints) {
|
|
|
504
501
|
converter = proj4('ntv2_from', 'ntv2_to');
|
|
505
502
|
}
|
|
506
503
|
|
|
507
|
-
before(function(done) {
|
|
504
|
+
before(function (done) {
|
|
508
505
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
509
506
|
const xhr = new XMLHttpRequest();
|
|
510
507
|
xhr.open('GET', 'ntv2_0_downsampled.gsb', true);
|
|
511
508
|
xhr.responseType = 'arraybuffer';
|
|
512
|
-
xhr.addEventListener('load', function() {
|
|
509
|
+
xhr.addEventListener('load', function () {
|
|
513
510
|
initializeNadgrid(xhr.response);
|
|
514
511
|
done();
|
|
515
512
|
});
|
|
@@ -518,18 +515,18 @@ function startTests(chai, proj4, testPoints) {
|
|
|
518
515
|
} else if (typeof require === 'function') {
|
|
519
516
|
const fs = require('fs');
|
|
520
517
|
const path = require('path');
|
|
521
|
-
fs.readFile(path.join(__dirname, 'ntv2_0_downsampled.gsb'), function(err, data) {
|
|
518
|
+
fs.readFile(path.join(__dirname, 'ntv2_0_downsampled.gsb'), function (err, data) {
|
|
522
519
|
if (err) {
|
|
523
520
|
done(err);
|
|
524
521
|
} else {
|
|
525
522
|
initializeNadgrid(data.buffer);
|
|
526
523
|
done();
|
|
527
524
|
}
|
|
528
|
-
})
|
|
525
|
+
});
|
|
529
526
|
}
|
|
530
527
|
});
|
|
531
528
|
|
|
532
|
-
tests.forEach(function(test) {
|
|
529
|
+
tests.forEach(function (test) {
|
|
533
530
|
var fromLng = test[0];
|
|
534
531
|
var fromLat = test[1];
|
|
535
532
|
var toLng = test[2];
|
|
@@ -546,7 +543,80 @@ function startTests(chai, proj4, testPoints) {
|
|
|
546
543
|
[-60, 50, -59.999192, 50.000058]
|
|
547
544
|
];
|
|
548
545
|
|
|
549
|
-
inverseTests.forEach(function(test) {
|
|
546
|
+
inverseTests.forEach(function (test) {
|
|
547
|
+
var fromLng = test[0];
|
|
548
|
+
var fromLat = test[1];
|
|
549
|
+
var toLng = test[2];
|
|
550
|
+
var toLat = test[3];
|
|
551
|
+
it('should inverse interpolate ' + [toLng, toLat] + ' to ' + [fromLng, fromLat], function () {
|
|
552
|
+
var actual = converter.inverse([toLng, toLat]);
|
|
553
|
+
assert.approximately(actual[0], fromLng, 0.000001);
|
|
554
|
+
assert.approximately(actual[1], fromLat, 0.000001);
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
describe('Nadgrids ntv2 no error columns', function () {
|
|
560
|
+
var tests = [
|
|
561
|
+
[-44.382211538462, 40.3768, -44.380749, 40.377457], // just inside the lower limit
|
|
562
|
+
[-87.617788, 59.623262, -87.617659, 59.623441], // just inside the upper limit
|
|
563
|
+
[-44.5, 40.5, -44.498553, 40.500632], // inside the first square
|
|
564
|
+
[-60, 50, -59.999192, 50.000058], // a general point towards the middle of the grid
|
|
565
|
+
[0, 0, 0, 0] // fall back to null
|
|
566
|
+
];
|
|
567
|
+
|
|
568
|
+
var converter;
|
|
569
|
+
|
|
570
|
+
function initializeNadgrid(buffer) {
|
|
571
|
+
proj4.nadgrid('ntv2', buffer, { includeErrorFields: false });
|
|
572
|
+
proj4.defs('ntv2_from', '+proj=longlat +ellps=clrk66 +nadgrids=@ntv2,null');
|
|
573
|
+
proj4.defs('ntv2_to', '+proj=longlat +datum=WGS84 +no_defs');
|
|
574
|
+
converter = proj4('ntv2_from', 'ntv2_to');
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
before(function (done) {
|
|
578
|
+
if (typeof XMLHttpRequest !== 'undefined') {
|
|
579
|
+
const xhr = new XMLHttpRequest();
|
|
580
|
+
xhr.open('GET', 'ntv2_0_downsampled_no_error_columns.gsb', true);
|
|
581
|
+
xhr.responseType = 'arraybuffer';
|
|
582
|
+
xhr.addEventListener('load', function () {
|
|
583
|
+
initializeNadgrid(xhr.response);
|
|
584
|
+
done();
|
|
585
|
+
});
|
|
586
|
+
xhr.addEventListener('error', done);
|
|
587
|
+
xhr.send();
|
|
588
|
+
} else if (typeof require === 'function') {
|
|
589
|
+
const fs = require('fs');
|
|
590
|
+
const path = require('path');
|
|
591
|
+
fs.readFile(path.join(__dirname, 'ntv2_0_downsampled_no_error_columns.gsb'), function (err, data) {
|
|
592
|
+
if (err) {
|
|
593
|
+
done(err);
|
|
594
|
+
} else {
|
|
595
|
+
initializeNadgrid(data.buffer);
|
|
596
|
+
done();
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
tests.forEach(function (test) {
|
|
603
|
+
var fromLng = test[0];
|
|
604
|
+
var fromLat = test[1];
|
|
605
|
+
var toLng = test[2];
|
|
606
|
+
var toLat = test[3];
|
|
607
|
+
it('should interpolate ' + [fromLng, fromLat] + ' to ' + [toLng, toLat], function () {
|
|
608
|
+
var actual = converter.forward([fromLng, fromLat]);
|
|
609
|
+
assert.approximately(actual[0], toLng, 0.000001);
|
|
610
|
+
assert.approximately(actual[1], toLat, 0.000001);
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
var inverseTests = [
|
|
615
|
+
[-44.5, 40.5, -44.498553, 40.500632],
|
|
616
|
+
[-60, 50, -59.999192, 50.000058]
|
|
617
|
+
];
|
|
618
|
+
|
|
619
|
+
inverseTests.forEach(function (test) {
|
|
550
620
|
var fromLng = test[0];
|
|
551
621
|
var fromLat = test[1];
|
|
552
622
|
var toLng = test[2];
|
|
@@ -560,8 +630,10 @@ function startTests(chai, proj4, testPoints) {
|
|
|
560
630
|
});
|
|
561
631
|
});
|
|
562
632
|
}
|
|
563
|
-
if(typeof
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
633
|
+
if (typeof module !== 'undefined') {
|
|
634
|
+
module.exports = startTests;
|
|
635
|
+
} else if (typeof define === 'function') {
|
|
636
|
+
define(function () {
|
|
637
|
+
return startTests;
|
|
638
|
+
});
|
|
567
639
|
}
|