proj4 2.19.10 → 2.20.1-alpha
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/Gruntfile.js +2 -1
- package/README.md +2 -0
- package/bower.json +1 -1
- package/changelog.md +2 -0
- package/component.json +1 -1
- package/dist/lib/common/adjust_lon.d.ts +1 -1
- package/dist/lib/defs.d.ts +2 -0
- package/dist/lib/projections/eqearth.d.ts +2 -0
- package/dist/lib/projections/moll.d.ts +7 -1
- package/dist/lib/projections/ob_tran.d.ts +78 -0
- package/dist/proj4-src.js +708 -338
- package/dist/proj4.js +1 -1
- package/lib/common/adjust_lon.js +4 -1
- package/lib/defs.js +8 -0
- package/lib/global.js +2 -0
- package/lib/includedProjections.js +3 -1
- package/lib/projString.js +4 -0
- package/lib/projections/aea.js +2 -2
- package/lib/projections/aeqd.js +6 -6
- package/lib/projections/bonne.js +4 -4
- package/lib/projections/cass.js +2 -2
- package/lib/projections/cea.js +3 -3
- package/lib/projections/eqc.js +2 -2
- package/lib/projections/eqdc.js +3 -3
- package/lib/projections/eqearth.js +4 -2
- package/lib/projections/equi.js +2 -2
- package/lib/projections/etmerc.js +2 -2
- package/lib/projections/gnom.js +2 -2
- package/lib/projections/krovak.js +1 -1
- package/lib/projections/laea.js +2 -2
- package/lib/projections/lcc.js +2 -2
- package/lib/projections/merc.js +3 -3
- package/lib/projections/mill.js +2 -2
- package/lib/projections/moll.js +10 -3
- package/lib/projections/ob_tran.js +347 -0
- package/lib/projections/omerc.js +2 -2
- package/lib/projections/ortho.js +4 -4
- package/lib/projections/poly.js +5 -5
- package/lib/projections/robin.js +2 -2
- package/lib/projections/sinu.js +3 -3
- package/lib/projections/stere.js +6 -6
- package/lib/projections/sterea.js +2 -2
- package/lib/projections/tmerc.js +3 -3
- package/lib/projections/vandg.js +2 -2
- package/package.json +1 -1
- package/projs.js +2 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import adjust_lon from '../common/adjust_lon';
|
|
2
|
+
import { D2R, HALF_PI, EPSLN } from '../constants/values';
|
|
3
|
+
import Proj from '../Proj';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Original projection implementation:
|
|
7
|
+
https://github.com/OSGeo/PROJ/blob/46c47e9adf6376ae06afabe5d24a0016a05ced82/src/projections/ob_tran.cpp
|
|
8
|
+
|
|
9
|
+
Documentation:
|
|
10
|
+
https://proj.org/operations/projections/ob_tran.html
|
|
11
|
+
|
|
12
|
+
References/Formulas:
|
|
13
|
+
https://pubs.usgs.gov/pp/1395/report.pdf
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
+proj=ob_tran +o_proj=moll +o_lat_p=45 +o_lon_p=-90
|
|
17
|
+
+proj=ob_tran +o_proj=moll +o_lat_p=45 +o_lon_p=-90 +lon_0=60
|
|
18
|
+
+proj=ob_tran +o_proj=moll +o_lat_p=45 +o_lon_p=-90 +lon_0=-90
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const projectionType = {
|
|
22
|
+
OBLIQUE: {
|
|
23
|
+
forward: forwardOblique,
|
|
24
|
+
inverse: inverseOblique
|
|
25
|
+
},
|
|
26
|
+
TRANSVERSE: {
|
|
27
|
+
forward: forwardTransverse,
|
|
28
|
+
inverse: inverseTransverse
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {Object} LocalThis
|
|
34
|
+
* @property {number} lamp
|
|
35
|
+
* @property {number} cphip
|
|
36
|
+
* @property {number} sphip
|
|
37
|
+
* @property {Object} projectionType
|
|
38
|
+
* @property {string | undefined} o_proj
|
|
39
|
+
* @property {string | undefined} o_lon_p
|
|
40
|
+
* @property {string | undefined} o_lat_p
|
|
41
|
+
* @property {string | undefined} o_alpha
|
|
42
|
+
* @property {string | undefined} o_lon_c
|
|
43
|
+
* @property {string | undefined} o_lat_c
|
|
44
|
+
* @property {string | undefined} o_lon_1
|
|
45
|
+
* @property {string | undefined} o_lat_1
|
|
46
|
+
* @property {string | undefined} o_lon_2
|
|
47
|
+
* @property {string | undefined} o_lat_2
|
|
48
|
+
* @property {number | undefined} oLongP
|
|
49
|
+
* @property {number | undefined} oLatP
|
|
50
|
+
* @property {number | undefined} oAlpha
|
|
51
|
+
* @property {number | undefined} oLongC
|
|
52
|
+
* @property {number | undefined} oLatC
|
|
53
|
+
* @property {number | undefined} oLong1
|
|
54
|
+
* @property {number | undefined} oLat1
|
|
55
|
+
* @property {number | undefined} oLong2
|
|
56
|
+
* @property {number | undefined} oLat2
|
|
57
|
+
* @property {import('..').Converter} obliqueProjection
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Parameters can be from the following sets:
|
|
63
|
+
* New pole --> o_lat_p, o_lon_p
|
|
64
|
+
* Rotate about point --> o_alpha, o_lon_c, o_lat_c
|
|
65
|
+
* New equator points --> lon_1, lat_1, lon_2, lat_2
|
|
66
|
+
*
|
|
67
|
+
* Per the original source code, the parameter sets are
|
|
68
|
+
* checked in the order of the object below.
|
|
69
|
+
*/
|
|
70
|
+
const paramSets = {
|
|
71
|
+
ROTATE: {
|
|
72
|
+
o_alpha: 'oAlpha',
|
|
73
|
+
o_lon_c: 'oLongC',
|
|
74
|
+
o_lat_c: 'oLatC'
|
|
75
|
+
},
|
|
76
|
+
NEW_POLE: {
|
|
77
|
+
o_lat_p: 'oLatP',
|
|
78
|
+
o_lon_p: 'oLongP'
|
|
79
|
+
},
|
|
80
|
+
NEW_EQUATOR: {
|
|
81
|
+
o_lon_1: 'oLong1',
|
|
82
|
+
o_lat_1: 'oLat1',
|
|
83
|
+
o_lon_2: 'oLong2',
|
|
84
|
+
o_lat_2: 'oLat2'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
89
|
+
export function init() {
|
|
90
|
+
this.x0 = this.x0 || 0;
|
|
91
|
+
this.y0 = this.y0 || 0;
|
|
92
|
+
this.long0 = this.long0 || 0;
|
|
93
|
+
this.title = this.title || 'General Oblique Transformation';
|
|
94
|
+
|
|
95
|
+
/** Verify required parameters exist */
|
|
96
|
+
if (!this.o_proj) {
|
|
97
|
+
throw new Error('Missing parameter: o_proj');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (this.o_proj === `ob_tran`) {
|
|
101
|
+
throw new Error('Invalid value for o_proj: ' + this.o_proj);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const newProjStr = this.projStr.replace('+proj=ob_tran', '').replace('+o_proj=', '+proj=').trim();
|
|
105
|
+
|
|
106
|
+
/** @type {import('../defs.js').ProjectionDefinition} */
|
|
107
|
+
const oProj = Proj(newProjStr);
|
|
108
|
+
if (!oProj) {
|
|
109
|
+
throw new Error('Invalid parameter: o_proj. Unknown projection ' + this.o_proj);
|
|
110
|
+
}
|
|
111
|
+
oProj.long0 = 0; // we handle long0 before/after forward/inverse
|
|
112
|
+
this.obliqueProjection = oProj;
|
|
113
|
+
|
|
114
|
+
let matchedSet;
|
|
115
|
+
const paramSetsKeys = Object.keys(paramSets);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* parse strings, convert to radians, throw on NaN
|
|
119
|
+
* @param {string} name
|
|
120
|
+
* @returns {number | undefined}
|
|
121
|
+
*/
|
|
122
|
+
const parseParam = (name) => {
|
|
123
|
+
if (typeof this[name] === `undefined`) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const val = parseFloat(this[name]) * D2R;
|
|
127
|
+
if (isNaN(val)) {
|
|
128
|
+
throw new Error('Invalid value for ' + name + ': ' + this[name]);
|
|
129
|
+
}
|
|
130
|
+
return val;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
for (let i = 0; i < paramSetsKeys.length; i++) {
|
|
134
|
+
const setKey = paramSetsKeys[i];
|
|
135
|
+
const set = paramSets[setKey];
|
|
136
|
+
const params = Object.entries(set);
|
|
137
|
+
const setHasParams = params.some(
|
|
138
|
+
([p]) => typeof this[p] !== 'undefined'
|
|
139
|
+
);
|
|
140
|
+
if (!setHasParams) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
matchedSet = set;
|
|
144
|
+
for (let ii = 0; ii < params.length; ii++) {
|
|
145
|
+
const [inputParam, param] = params[ii];
|
|
146
|
+
const val = parseParam(inputParam);
|
|
147
|
+
if (typeof val === 'undefined') {
|
|
148
|
+
throw new Error('Missing parameter: ' + inputParam + '.');
|
|
149
|
+
}
|
|
150
|
+
this[param] = val;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!matchedSet) {
|
|
156
|
+
throw new Error('No valid parameters provided for ob_tran projection.');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const { lamp, phip } = createRotation(this, matchedSet);
|
|
160
|
+
this.lamp = lamp;
|
|
161
|
+
|
|
162
|
+
if (Math.abs(phip) > EPSLN) {
|
|
163
|
+
this.cphip = Math.cos(phip);
|
|
164
|
+
this.sphip = Math.sin(phip);
|
|
165
|
+
this.projectionType = projectionType.OBLIQUE;
|
|
166
|
+
} else {
|
|
167
|
+
this.projectionType = projectionType.TRANSVERSE;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ob_tran forward equations--mapping (lat,long) to (x,y)
|
|
172
|
+
// transverse (90 degrees from normal orientation) - forwardTransverse
|
|
173
|
+
// or oblique (arbitrary angle) used based on parameters - forwardOblique
|
|
174
|
+
// -----------------------------------------------------------------
|
|
175
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
176
|
+
export function forward(p) {
|
|
177
|
+
return this.projectionType.forward(this, p);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// inverse equations--mapping (x,y) to (lat,long)
|
|
181
|
+
// transverse: inverseTransverse
|
|
182
|
+
// oblique: inverseOblique
|
|
183
|
+
// -----------------------------------------------------------------
|
|
184
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
185
|
+
export function inverse(p) {
|
|
186
|
+
return this.projectionType.inverse(this, p);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @param {import('../defs.js').ProjectionDefinition & LocalThis} params - Initialized projection definition
|
|
191
|
+
* @param {Object} how - Transformation method
|
|
192
|
+
* @returns {{phip: number, lamp: number}}
|
|
193
|
+
*/
|
|
194
|
+
function createRotation(params, how) {
|
|
195
|
+
let phip, lamp;
|
|
196
|
+
if (how === paramSets.ROTATE) {
|
|
197
|
+
let lamc = params.oLongC;
|
|
198
|
+
let phic = params.oLatC;
|
|
199
|
+
let alpha = params.oAlpha;
|
|
200
|
+
if (Math.abs(Math.abs(phic) - HALF_PI) <= EPSLN) {
|
|
201
|
+
throw new Error('Invalid value for o_lat_c: ' + params.o_lat_c + ' should be < 90°');
|
|
202
|
+
}
|
|
203
|
+
lamp = lamc + Math.atan2(-1 * Math.cos(alpha), -1 * Math.sin(alpha) * Math.sin(phic));
|
|
204
|
+
phip = Math.asin(Math.cos(phic) * Math.sin(alpha));
|
|
205
|
+
} else if (how === paramSets.NEW_POLE) {
|
|
206
|
+
lamp = params.oLongP;
|
|
207
|
+
phip = params.oLatP;
|
|
208
|
+
} else {
|
|
209
|
+
let lam1 = params.oLong1;
|
|
210
|
+
let phi1 = params.oLat1;
|
|
211
|
+
let lam2 = params.oLong2;
|
|
212
|
+
let phi2 = params.oLat2;
|
|
213
|
+
let con = Math.abs(phi1);
|
|
214
|
+
|
|
215
|
+
if (Math.abs(phi1) > HALF_PI - EPSLN) {
|
|
216
|
+
throw new Error('Invalid value for o_lat_1: ' + params.o_lat_1 + ' should be < 90°');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (Math.abs(phi2) > HALF_PI - EPSLN) {
|
|
220
|
+
throw new Error('Invalid value for o_lat_2: ' + params.o_lat_2 + ' should be < 90°');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (Math.abs(phi1 - phi2) < EPSLN) {
|
|
224
|
+
throw new Error('Invalid value for o_lat_1 and o_lat_2: o_lat_1 should be different from o_lat_2');
|
|
225
|
+
}
|
|
226
|
+
if (con < EPSLN) {
|
|
227
|
+
throw new Error('Invalid value for o_lat_1: o_lat_1 should be different from zero');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
lamp = Math.atan2(
|
|
231
|
+
(Math.cos(phi1) * Math.sin(phi2) * Math.cos(lam1))
|
|
232
|
+
- (Math.sin(phi1) * Math.cos(phi2) * Math.cos(lam2)),
|
|
233
|
+
(Math.sin(phi1) * Math.cos(phi2) * Math.sin(lam2))
|
|
234
|
+
- (Math.cos(phi1) * Math.sin(phi2) * Math.sin(lam1))
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
phip = Math.atan(-1 * Math.cos(lamp - lam1) / Math.tan(phi1));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return { lamp, phip };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Forward (lng, lat) to (x, y) for oblique case
|
|
245
|
+
* @param {import('../defs.js').ProjectionDefinition & LocalThis} self
|
|
246
|
+
* @param {{x: number, y: number}} lp - lambda, phi
|
|
247
|
+
*/
|
|
248
|
+
function forwardOblique(self, lp) {
|
|
249
|
+
let { x: lam, y: phi } = lp;
|
|
250
|
+
lam += self.long0;
|
|
251
|
+
const coslam = Math.cos(lam);
|
|
252
|
+
const sinphi = Math.sin(phi);
|
|
253
|
+
const cosphi = Math.cos(phi);
|
|
254
|
+
|
|
255
|
+
lp.x = adjust_lon(
|
|
256
|
+
Math.atan2(
|
|
257
|
+
cosphi * Math.sin(lam),
|
|
258
|
+
(self.sphip * cosphi * coslam) + (self.cphip * sinphi)
|
|
259
|
+
) + self.lamp
|
|
260
|
+
);
|
|
261
|
+
lp.y = Math.asin(
|
|
262
|
+
(self.sphip * sinphi) - (self.cphip * cosphi * coslam)
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
return self.obliqueProjection.forward(lp);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Forward (lng, lat) to (x, y) for transverse case
|
|
270
|
+
* @param {import('../defs.js').ProjectionDefinition & LocalThis} self
|
|
271
|
+
* @param {{x: number, y: number}} lp - lambda, phi
|
|
272
|
+
*/
|
|
273
|
+
function forwardTransverse(self, lp) {
|
|
274
|
+
let { x: lam, y: phi } = lp;
|
|
275
|
+
lam += self.long0;
|
|
276
|
+
const cosphi = Math.cos(phi);
|
|
277
|
+
const coslam = Math.cos(lam);
|
|
278
|
+
lp.x = adjust_lon(
|
|
279
|
+
Math.atan2(
|
|
280
|
+
cosphi * Math.sin(lam),
|
|
281
|
+
Math.sin(phi)
|
|
282
|
+
) + self.lamp
|
|
283
|
+
);
|
|
284
|
+
lp.y = Math.asin(-1 * cosphi * coslam);
|
|
285
|
+
|
|
286
|
+
return self.obliqueProjection.forward(lp);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Inverse (x, y) to (lng, lat) for oblique case
|
|
291
|
+
* @param {import('../defs.js').ProjectionDefinition & LocalThis} self
|
|
292
|
+
* @param {{x: number, y: number}} lp - lambda, phi
|
|
293
|
+
*/
|
|
294
|
+
function inverseOblique(self, lp) {
|
|
295
|
+
const innerLp = self.obliqueProjection.inverse(lp);
|
|
296
|
+
let { x: lam, y: phi } = innerLp;
|
|
297
|
+
|
|
298
|
+
if (lam < Number.MAX_VALUE) {
|
|
299
|
+
lam -= self.lamp;
|
|
300
|
+
const coslam = Math.cos(lam);
|
|
301
|
+
const sinphi = Math.sin(phi);
|
|
302
|
+
const cosphi = Math.cos(phi);
|
|
303
|
+
lp.x = Math.atan2(
|
|
304
|
+
cosphi * Math.sin(lam),
|
|
305
|
+
(self.sphip * cosphi * coslam) - (self.cphip * sinphi)
|
|
306
|
+
);
|
|
307
|
+
lp.y = Math.asin(
|
|
308
|
+
(self.sphip * sinphi) + (self.cphip * cosphi * coslam)
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
lp.x = adjust_lon(lp.x + self.long0);
|
|
313
|
+
return lp;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Inverse (x, y) to (lng, lat) for transverse case
|
|
318
|
+
* @param {import('../defs.js').ProjectionDefinition & LocalThis} self
|
|
319
|
+
* @param {{x: number, y: number}} lp - lambda, phi
|
|
320
|
+
*/
|
|
321
|
+
function inverseTransverse(self, lp) {
|
|
322
|
+
const innerLp = self.obliqueProjection.inverse(lp);
|
|
323
|
+
let { x: lam, y: phi } = innerLp;
|
|
324
|
+
|
|
325
|
+
if (lam < Number.MAX_VALUE) {
|
|
326
|
+
const cosphi = Math.cos(phi);
|
|
327
|
+
lam -= self.lamp;
|
|
328
|
+
lp.x = Math.atan2(
|
|
329
|
+
cosphi * Math.sin(lam),
|
|
330
|
+
-1 * Math.sin(phi)
|
|
331
|
+
);
|
|
332
|
+
lp.y = Math.asin(
|
|
333
|
+
cosphi * Math.cos(lam)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
lp.x = adjust_lon(lp.x + self.long0);
|
|
338
|
+
return lp;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export var names = ['General Oblique Transformation', 'General_Oblique_Transformation', 'ob_tran'];
|
|
342
|
+
export default {
|
|
343
|
+
init: init,
|
|
344
|
+
forward: forward,
|
|
345
|
+
inverse: inverse,
|
|
346
|
+
names: names
|
|
347
|
+
};
|
package/lib/projections/omerc.js
CHANGED
|
@@ -138,8 +138,8 @@ export function init() {
|
|
|
138
138
|
lam2 += TWO_PI;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
this.lam0 = adjust_lon(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B);
|
|
142
|
-
gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon(lam1 - this.lam0)) / (F - 1 / F));
|
|
141
|
+
this.lam0 = adjust_lon(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B, this.over);
|
|
142
|
+
gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon(lam1 - this.lam0, this.over)) / (F - 1 / F));
|
|
143
143
|
gamma = alpha_c = Math.asin(D * Math.sin(gamma0));
|
|
144
144
|
}
|
|
145
145
|
|
package/lib/projections/ortho.js
CHANGED
|
@@ -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);
|
|
33
|
+
dlon = adjust_lon(lon - this.long0, this.over);
|
|
34
34
|
|
|
35
35
|
sinphi = Math.sin(lat);
|
|
36
36
|
cosphi = Math.cos(lat);
|
|
@@ -74,15 +74,15 @@ export function inverse(p) {
|
|
|
74
74
|
con = Math.abs(this.lat0) - HALF_PI;
|
|
75
75
|
if (Math.abs(con) <= EPSLN) {
|
|
76
76
|
if (this.lat0 >= 0) {
|
|
77
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x, -p.y));
|
|
77
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x, -p.y), this.over);
|
|
78
78
|
} else {
|
|
79
|
-
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
|
|
79
|
+
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y), this.over);
|
|
80
80
|
}
|
|
81
81
|
p.x = lon;
|
|
82
82
|
p.y = lat;
|
|
83
83
|
return p;
|
|
84
84
|
}
|
|
85
|
-
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz));
|
|
85
|
+
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz), this.over);
|
|
86
86
|
p.x = lon;
|
|
87
87
|
p.y = lat;
|
|
88
88
|
return p;
|
package/lib/projections/poly.js
CHANGED
|
@@ -43,7 +43,7 @@ export function forward(p) {
|
|
|
43
43
|
var lon = p.x;
|
|
44
44
|
var lat = p.y;
|
|
45
45
|
var x, y, el;
|
|
46
|
-
var dlon = adjust_lon(lon - this.long0);
|
|
46
|
+
var dlon = adjust_lon(lon - this.long0, this.over);
|
|
47
47
|
el = dlon * Math.sin(lat);
|
|
48
48
|
if (this.sphere) {
|
|
49
49
|
if (Math.abs(lat) <= EPSLN) {
|
|
@@ -79,7 +79,7 @@ export function inverse(p) {
|
|
|
79
79
|
|
|
80
80
|
if (this.sphere) {
|
|
81
81
|
if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
|
|
82
|
-
lon = adjust_lon(x / this.a + this.long0);
|
|
82
|
+
lon = adjust_lon(x / this.a + this.long0, this.over);
|
|
83
83
|
lat = 0;
|
|
84
84
|
} else {
|
|
85
85
|
al = this.lat0 + y / this.a;
|
|
@@ -95,12 +95,12 @@ export function inverse(p) {
|
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));
|
|
98
|
+
lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat), this.over);
|
|
99
99
|
}
|
|
100
100
|
} else {
|
|
101
101
|
if (Math.abs(y + this.ml0) <= EPSLN) {
|
|
102
102
|
lat = 0;
|
|
103
|
-
lon = adjust_lon(this.long0 + x / this.a);
|
|
103
|
+
lon = adjust_lon(this.long0 + x / this.a, this.over);
|
|
104
104
|
} else {
|
|
105
105
|
al = (this.ml0 + y) / this.a;
|
|
106
106
|
bl = x * x / this.a / this.a + al * al;
|
|
@@ -123,7 +123,7 @@ export function inverse(p) {
|
|
|
123
123
|
|
|
124
124
|
// lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
|
|
125
125
|
cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
|
|
126
|
-
lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
|
|
126
|
+
lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat), this.over);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
package/lib/projections/robin.js
CHANGED
|
@@ -84,7 +84,7 @@ export function init() {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export function forward(ll) {
|
|
87
|
-
var lon = adjust_lon(ll.x - this.long0);
|
|
87
|
+
var lon = adjust_lon(ll.x - this.long0, this.over);
|
|
88
88
|
|
|
89
89
|
var dphi = Math.abs(ll.y);
|
|
90
90
|
var i = Math.floor(dphi * C1);
|
|
@@ -148,7 +148,7 @@ export function inverse(xy) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
ll.x = adjust_lon(ll.x + this.long0);
|
|
151
|
+
ll.x = adjust_lon(ll.x + this.long0, this.over);
|
|
152
152
|
return ll;
|
|
153
153
|
}
|
|
154
154
|
|
package/lib/projections/sinu.js
CHANGED
|
@@ -42,7 +42,7 @@ export function forward(p) {
|
|
|
42
42
|
var lat = p.y;
|
|
43
43
|
/* Forward equations
|
|
44
44
|
----------------- */
|
|
45
|
-
lon = adjust_lon(lon - this.long0);
|
|
45
|
+
lon = adjust_lon(lon - this.long0, this.over);
|
|
46
46
|
|
|
47
47
|
if (this.sphere) {
|
|
48
48
|
if (!this.m) {
|
|
@@ -87,7 +87,7 @@ export function inverse(p) {
|
|
|
87
87
|
} else if (this.n !== 1) {
|
|
88
88
|
lat = asinz(Math.sin(lat) / this.n);
|
|
89
89
|
}
|
|
90
|
-
lon = adjust_lon(lon + this.long0);
|
|
90
|
+
lon = adjust_lon(lon + this.long0, this.over);
|
|
91
91
|
lat = adjust_lat(lat);
|
|
92
92
|
} else {
|
|
93
93
|
lat = pj_inv_mlfn(p.y / this.a, this.es, this.en);
|
|
@@ -96,7 +96,7 @@ export function inverse(p) {
|
|
|
96
96
|
s = Math.sin(lat);
|
|
97
97
|
temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));
|
|
98
98
|
// temp = this.long0 + p.x / (this.a * Math.cos(lat));
|
|
99
|
-
lon = adjust_lon(temp);
|
|
99
|
+
lon = adjust_lon(temp, this.over);
|
|
100
100
|
} else if ((s - EPSLN) < HALF_PI) {
|
|
101
101
|
lon = this.long0;
|
|
102
102
|
}
|
package/lib/projections/stere.js
CHANGED
|
@@ -70,7 +70,7 @@ export function forward(p) {
|
|
|
70
70
|
var sinlat = Math.sin(lat);
|
|
71
71
|
var coslat = Math.cos(lat);
|
|
72
72
|
var A, X, sinX, cosX, ts, rh;
|
|
73
|
-
var dlon = adjust_lon(lon - this.long0);
|
|
73
|
+
var dlon = adjust_lon(lon - this.long0, this.over);
|
|
74
74
|
|
|
75
75
|
if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) {
|
|
76
76
|
// case of the origine point
|
|
@@ -131,12 +131,12 @@ export function inverse(p) {
|
|
|
131
131
|
lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh);
|
|
132
132
|
if (Math.abs(this.coslat0) < EPSLN) {
|
|
133
133
|
if (this.lat0 > 0) {
|
|
134
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x, -1 * p.y));
|
|
134
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x, -1 * p.y), this.over);
|
|
135
135
|
} else {
|
|
136
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
|
|
136
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y), this.over);
|
|
137
137
|
}
|
|
138
138
|
} else {
|
|
139
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)));
|
|
139
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)), this.over);
|
|
140
140
|
}
|
|
141
141
|
p.x = lon;
|
|
142
142
|
p.y = lat;
|
|
@@ -155,7 +155,7 @@ export function inverse(p) {
|
|
|
155
155
|
p.y *= this.con;
|
|
156
156
|
ts = rh * this.cons / (2 * this.a * this.k0);
|
|
157
157
|
lat = this.con * phi2z(this.e, ts);
|
|
158
|
-
lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, -1 * p.y));
|
|
158
|
+
lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, -1 * p.y), this.over);
|
|
159
159
|
} else {
|
|
160
160
|
ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1));
|
|
161
161
|
lon = this.long0;
|
|
@@ -163,7 +163,7 @@ export function inverse(p) {
|
|
|
163
163
|
Chi = this.X0;
|
|
164
164
|
} else {
|
|
165
165
|
Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh);
|
|
166
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)));
|
|
166
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)), this.over);
|
|
167
167
|
}
|
|
168
168
|
lat = -1 * phi2z(this.e, Math.tan(0.5 * (HALF_PI + Chi)));
|
|
169
169
|
}
|
|
@@ -27,7 +27,7 @@ export function init() {
|
|
|
27
27
|
|
|
28
28
|
export function forward(p) {
|
|
29
29
|
var sinc, cosc, cosl, k;
|
|
30
|
-
p.x = adjust_lon(p.x - this.long0);
|
|
30
|
+
p.x = adjust_lon(p.x - this.long0, this.over);
|
|
31
31
|
gauss.forward.apply(this, [p]);
|
|
32
32
|
sinc = Math.sin(p.y);
|
|
33
33
|
cosc = Math.cos(p.y);
|
|
@@ -61,7 +61,7 @@ export function inverse(p) {
|
|
|
61
61
|
p.x = lon;
|
|
62
62
|
p.y = lat;
|
|
63
63
|
gauss.inverse.apply(this, [p]);
|
|
64
|
-
p.x = adjust_lon(p.x + this.long0);
|
|
64
|
+
p.x = adjust_lon(p.x + this.long0, this.over);
|
|
65
65
|
return p;
|
|
66
66
|
}
|
|
67
67
|
|
package/lib/projections/tmerc.js
CHANGED
|
@@ -37,7 +37,7 @@ export function forward(p) {
|
|
|
37
37
|
var lon = p.x;
|
|
38
38
|
var lat = p.y;
|
|
39
39
|
|
|
40
|
-
var delta_lon = adjust_lon(lon - this.long0);
|
|
40
|
+
var delta_lon = adjust_lon(lon - this.long0, this.over);
|
|
41
41
|
var con;
|
|
42
42
|
var x, y;
|
|
43
43
|
var sin_phi = Math.sin(lat);
|
|
@@ -125,7 +125,7 @@ export function inverse(p) {
|
|
|
125
125
|
if ((g === 0) && (h === 0)) {
|
|
126
126
|
lon = 0;
|
|
127
127
|
} else {
|
|
128
|
-
lon = adjust_lon(Math.atan2(g, h) + this.long0);
|
|
128
|
+
lon = adjust_lon(Math.atan2(g, h) + this.long0, this.over);
|
|
129
129
|
}
|
|
130
130
|
} else { // ellipsoidal form
|
|
131
131
|
con = this.ml0 + y / this.k0;
|
|
@@ -152,7 +152,7 @@ export function inverse(p) {
|
|
|
152
152
|
lon = adjust_lon(this.long0 + (d * (1
|
|
153
153
|
- ds / 6 * (1 + 2 * t + c
|
|
154
154
|
- ds / 20 * (5 + 28 * t + 24 * ts + 8 * c * t + 6 * c
|
|
155
|
-
- ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi));
|
|
155
|
+
- ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi), this.over);
|
|
156
156
|
} else {
|
|
157
157
|
lat = HALF_PI * sign(y);
|
|
158
158
|
lon = 0;
|
package/lib/projections/vandg.js
CHANGED
|
@@ -24,7 +24,7 @@ export function forward(p) {
|
|
|
24
24
|
|
|
25
25
|
/* Forward equations
|
|
26
26
|
----------------- */
|
|
27
|
-
var dlon = adjust_lon(lon - this.long0);
|
|
27
|
+
var dlon = adjust_lon(lon - this.long0, this.over);
|
|
28
28
|
var x, y;
|
|
29
29
|
|
|
30
30
|
if (Math.abs(lat) <= EPSLN) {
|
|
@@ -113,7 +113,7 @@ export function inverse(p) {
|
|
|
113
113
|
if (Math.abs(xx) < EPSLN) {
|
|
114
114
|
lon = this.long0;
|
|
115
115
|
} else {
|
|
116
|
-
lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx);
|
|
116
|
+
lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx, this.over);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
p.x = lon;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proj4",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.1-alpha",
|
|
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",
|
package/projs.js
CHANGED
|
@@ -29,6 +29,7 @@ import tpers from './lib/projections/tpers';
|
|
|
29
29
|
import geos from './lib/projections/geos';
|
|
30
30
|
import eqearth from './lib/projections/eqearth';
|
|
31
31
|
import bonne from './lib/projections/bonne';
|
|
32
|
+
import ob_tran from './lib/projections/ob_tran';
|
|
32
33
|
export default function (proj4) {
|
|
33
34
|
proj4.Proj.projections.add(tmerc);
|
|
34
35
|
proj4.Proj.projections.add(etmerc);
|
|
@@ -61,4 +62,5 @@ export default function (proj4) {
|
|
|
61
62
|
proj4.Proj.projections.add(geos);
|
|
62
63
|
proj4.Proj.projections.add(eqearth);
|
|
63
64
|
proj4.Proj.projections.add(bonne);
|
|
65
|
+
proj4.Proj.projections.add(ob_tran);
|
|
64
66
|
}
|