dgeoutils 2.4.41 → 2.4.44
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/package.json +1 -4
- package/dist/cjs/DCircle.d.ts +0 -18
- package/dist/cjs/DCircle.js +0 -102
- package/dist/cjs/DLine.d.ts +0 -39
- package/dist/cjs/DLine.js +0 -343
- package/dist/cjs/DNumbers.d.ts +0 -8
- package/dist/cjs/DNumbers.js +0 -30
- package/dist/cjs/DPlane.d.ts +0 -25
- package/dist/cjs/DPlane.js +0 -132
- package/dist/cjs/DPoint.d.ts +0 -138
- package/dist/cjs/DPoint.js +0 -803
- package/dist/cjs/DPolygon.d.ts +0 -137
- package/dist/cjs/DPolygon.js +0 -1745
- package/dist/cjs/DPolygonLoop.d.ts +0 -60
- package/dist/cjs/DPolygonLoop.js +0 -439
- package/dist/cjs/FastSearch.d.ts +0 -6
- package/dist/cjs/FastSearch.js +0 -53
- package/dist/cjs/InterpolationMatrix.d.ts +0 -24
- package/dist/cjs/InterpolationMatrix.js +0 -173
- package/dist/cjs/TraceMatrix.d.ts +0 -22
- package/dist/cjs/TraceMatrix.js +0 -285
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/utils.d.ts +0 -49
- package/dist/cjs/utils.js +0 -280
- package/dist/es2015/DCircle.js +0 -87
- package/dist/es2015/DLine.js +0 -290
- package/dist/es2015/DNumbers.js +0 -22
- package/dist/es2015/DPlane.js +0 -105
- package/dist/es2015/DPoint.js +0 -676
- package/dist/es2015/DPolygon.js +0 -1193
- package/dist/es2015/DPolygonLoop.js +0 -430
- package/dist/es2015/FastSearch.js +0 -25
- package/dist/es2015/InterpolationMatrix.js +0 -128
- package/dist/es2015/TraceMatrix.js +0 -229
- package/dist/es2015/index.js +0 -11
- package/dist/es2015/utils.js +0 -207
- package/dist/esm/DCircle.js +0 -99
- package/dist/esm/DLine.js +0 -340
- package/dist/esm/DNumbers.js +0 -27
- package/dist/esm/DPlane.js +0 -129
- package/dist/esm/DPoint.js +0 -800
- package/dist/esm/DPolygon.js +0 -1742
- package/dist/esm/DPolygonLoop.js +0 -436
- package/dist/esm/FastSearch.js +0 -50
- package/dist/esm/InterpolationMatrix.js +0 -170
- package/dist/esm/TraceMatrix.js +0 -282
- package/dist/esm/index.js +0 -11
- package/dist/esm/utils.js +0 -265
- package/dist/umd/dgeoutils.js +0 -4347
- package/dist/umd/dgeoutils.min.js +0 -1
- package/dist/umd/dgeoutils.min.js.map +0 -1
package/dist/esm/DPoint.js
DELETED
|
@@ -1,800 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
-
if (!m) return o;
|
|
26
|
-
var i = m.call(o), r, ar = [], e;
|
|
27
|
-
try {
|
|
28
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
-
}
|
|
30
|
-
catch (error) { e = { error: error }; }
|
|
31
|
-
finally {
|
|
32
|
-
try {
|
|
33
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
-
}
|
|
35
|
-
finally { if (e) throw e.error; }
|
|
36
|
-
}
|
|
37
|
-
return ar;
|
|
38
|
-
};
|
|
39
|
-
import { DLine } from './DLine';
|
|
40
|
-
import { DPolygon } from './DPolygon';
|
|
41
|
-
import { checkFunction, createArray, DGeo, div, isDefAndNotNull, toDegreesMinutesSeconds } from './utils';
|
|
42
|
-
var diff = 0;
|
|
43
|
-
var radiansPolygon = new DPolygon();
|
|
44
|
-
var pseudoMercatorPolygon = new DPolygon();
|
|
45
|
-
var worldGeodeticPolygon = new DPolygon();
|
|
46
|
-
export var EARTH_RADIUS_IN_METERS = 6378137;
|
|
47
|
-
var EARTH_IN_METERS = 20037508.34;
|
|
48
|
-
var DEGREES_IN_EARTH = 180;
|
|
49
|
-
var METERS_IN_ONE_DEGREE = EARTH_IN_METERS / DEGREES_IN_EARTH;
|
|
50
|
-
var DEGREES_IN_ONE_METER = DEGREES_IN_EARTH / EARTH_IN_METERS;
|
|
51
|
-
export var HALF_PI_IN_DEGREE = 90;
|
|
52
|
-
export var PI_IN_DEGREE = 180;
|
|
53
|
-
export var DOUBLE_PI_IN_DEGREE = 360;
|
|
54
|
-
export var PI_TO_DEGREE = Math.PI / PI_IN_DEGREE;
|
|
55
|
-
export var DEGREE_TO_PI = PI_IN_DEGREE / Math.PI;
|
|
56
|
-
var DPoint = (function () {
|
|
57
|
-
function DPoint(x, y, z) {
|
|
58
|
-
if (x === void 0) { x = 0; }
|
|
59
|
-
if (y === void 0) { y = x; }
|
|
60
|
-
this.x = x;
|
|
61
|
-
this.y = y;
|
|
62
|
-
this.z = z;
|
|
63
|
-
this.properties = {};
|
|
64
|
-
}
|
|
65
|
-
DPoint.zero = function () {
|
|
66
|
-
return new DPoint();
|
|
67
|
-
};
|
|
68
|
-
DPoint.parse = function (c, format) {
|
|
69
|
-
if (format === void 0) { format = DGeo.parseFormat; }
|
|
70
|
-
var _a = c, lat = _a.lat, lon = _a.lon, _b = _a.lng, lng = _b === void 0 ? lon : _b, alt = _a.alt;
|
|
71
|
-
if (lat && lng) {
|
|
72
|
-
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
73
|
-
}
|
|
74
|
-
var _c = c, x = _c.x, y = _c.y, z = _c.z, properties = __rest(_c, ["x", "y", "z"]);
|
|
75
|
-
if (isDefAndNotNull(x) && isDefAndNotNull(y)) {
|
|
76
|
-
return new DPoint(x, y, z).setProperties(properties);
|
|
77
|
-
}
|
|
78
|
-
var t = c;
|
|
79
|
-
if (c.type === 'Point') {
|
|
80
|
-
t = c.coordinates;
|
|
81
|
-
}
|
|
82
|
-
if (c.type === 'Feature') {
|
|
83
|
-
var f = DPoint.parse(c.geometry, format);
|
|
84
|
-
f.properties = __assign({}, c.properties);
|
|
85
|
-
return f;
|
|
86
|
-
}
|
|
87
|
-
return format.replace(/[^x-z]/gmiu, '')
|
|
88
|
-
.split('')
|
|
89
|
-
.reduce(function (a, k, index) {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
switch (k) {
|
|
92
|
-
case 'x':
|
|
93
|
-
a.x = (_a = t[index]) !== null && _a !== void 0 ? _a : 0;
|
|
94
|
-
break;
|
|
95
|
-
case 'y':
|
|
96
|
-
a.y = (_b = t[index]) !== null && _b !== void 0 ? _b : 0;
|
|
97
|
-
break;
|
|
98
|
-
case 'z':
|
|
99
|
-
a.z = t[index];
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
}
|
|
103
|
-
return a;
|
|
104
|
-
}, new DPoint());
|
|
105
|
-
};
|
|
106
|
-
DPoint.parseFromWKT = function (wkt) {
|
|
107
|
-
var regexp = /POINT \((?<data>(?:(?!\)).)*?)\)$/miu;
|
|
108
|
-
var data = wkt.trim().toUpperCase();
|
|
109
|
-
var res = regexp.exec(data);
|
|
110
|
-
var _a = __read(res.groups.data.split(' ').map(Number), 3), x = _a[0], y = _a[1], z = _a[2];
|
|
111
|
-
return new DPoint(x, y, z);
|
|
112
|
-
};
|
|
113
|
-
DPoint.random = function () {
|
|
114
|
-
return new DPoint(Math.random(), Math.random());
|
|
115
|
-
};
|
|
116
|
-
DPoint.getTileFromQuadKey = function (quadKey) {
|
|
117
|
-
var p = new DPoint(0, 0, quadKey.length);
|
|
118
|
-
for (var i = p.z; i > 0; i--) {
|
|
119
|
-
var mask = 1 << (i - 1);
|
|
120
|
-
switch (quadKey[p.z - i]) {
|
|
121
|
-
case '0':
|
|
122
|
-
break;
|
|
123
|
-
case '1':
|
|
124
|
-
p.x |= mask;
|
|
125
|
-
break;
|
|
126
|
-
case '2':
|
|
127
|
-
p.y |= mask;
|
|
128
|
-
break;
|
|
129
|
-
case '3':
|
|
130
|
-
p.x |= mask;
|
|
131
|
-
p.y |= mask;
|
|
132
|
-
break;
|
|
133
|
-
default:
|
|
134
|
-
throw new Error('Invalid QuadKey digit sequence.');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return p;
|
|
138
|
-
};
|
|
139
|
-
DPoint.prototype.toDegreesMinutesSeconds = function () {
|
|
140
|
-
return {
|
|
141
|
-
x: toDegreesMinutesSeconds(this.x),
|
|
142
|
-
y: toDegreesMinutesSeconds(this.y)
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
DPoint.prototype.getTileFromCoords = function (zoom) {
|
|
146
|
-
if (zoom === void 0) { zoom = this.z; }
|
|
147
|
-
checkFunction('getTileFromCoords')
|
|
148
|
-
.checkArgument('this')
|
|
149
|
-
.shouldBeDegree(this);
|
|
150
|
-
var x = Math.floor((this.x + PI_IN_DEGREE) / DOUBLE_PI_IN_DEGREE * (Math.pow(2, zoom)));
|
|
151
|
-
var y = Math.floor((1 - Math.log(Math.tan(this.y * PI_TO_DEGREE) + 1 / Math.cos(this.y * PI_TO_DEGREE)) / Math.PI) / 2 * (Math.pow(2, zoom)));
|
|
152
|
-
return new DPoint(x, y, zoom);
|
|
153
|
-
};
|
|
154
|
-
DPoint.prototype.getQuadKeyFromTile = function (zoom) {
|
|
155
|
-
if (zoom === void 0) { zoom = this.z; }
|
|
156
|
-
var quadKey = [];
|
|
157
|
-
for (var i = zoom; i > 0; i--) {
|
|
158
|
-
var digit = 0;
|
|
159
|
-
var mask = 1 << (i - 1);
|
|
160
|
-
if ((this.x & mask) !== 0) {
|
|
161
|
-
digit++;
|
|
162
|
-
}
|
|
163
|
-
if ((this.y & mask) !== 0) {
|
|
164
|
-
digit++;
|
|
165
|
-
digit++;
|
|
166
|
-
}
|
|
167
|
-
quadKey.push(digit);
|
|
168
|
-
}
|
|
169
|
-
return quadKey.join('');
|
|
170
|
-
};
|
|
171
|
-
DPoint.prototype.getCoordsFromTile = function (zoom) {
|
|
172
|
-
if (zoom === void 0) { zoom = this.z; }
|
|
173
|
-
checkFunction('getCoordsFromTile')
|
|
174
|
-
.checkArgument('this')
|
|
175
|
-
.shouldBeUInt(this);
|
|
176
|
-
var n = Math.PI - 2 * Math.PI * this.y / (Math.pow(2, zoom));
|
|
177
|
-
var x = this.x / (Math.pow(2, zoom)) * DOUBLE_PI_IN_DEGREE - PI_IN_DEGREE;
|
|
178
|
-
var y = PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
|
|
179
|
-
return new DPoint(x, y, zoom);
|
|
180
|
-
};
|
|
181
|
-
DPoint.prototype.toCoords = function (format) {
|
|
182
|
-
var _this = this;
|
|
183
|
-
if (format === void 0) { format = DGeo.parseFormat; }
|
|
184
|
-
return format.replace(/[^x-z]/gmiu, '').split('')
|
|
185
|
-
.map(function (k) { return ({
|
|
186
|
-
x: _this.x,
|
|
187
|
-
y: _this.y,
|
|
188
|
-
z: _this.z
|
|
189
|
-
})[k]; })
|
|
190
|
-
.filter(function (r) { return r !== undefined; });
|
|
191
|
-
};
|
|
192
|
-
DPoint.prototype.toGeoJSON = function (format) {
|
|
193
|
-
if (format === void 0) { format = DGeo.parseFormat; }
|
|
194
|
-
return {
|
|
195
|
-
type: 'Point',
|
|
196
|
-
coordinates: this.toCoords(format)
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
DPoint.prototype.toGeoJSONFeature = function (format) {
|
|
200
|
-
if (format === void 0) { format = DGeo.parseFormat; }
|
|
201
|
-
return {
|
|
202
|
-
type: 'Feature',
|
|
203
|
-
properties: __assign({}, this.properties),
|
|
204
|
-
geometry: this.toGeoJSON(format)
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
DPoint.prototype.findLine = function (p) {
|
|
208
|
-
checkFunction('findLine')
|
|
209
|
-
.checkArgument('this')
|
|
210
|
-
.shouldBeMeters(this)
|
|
211
|
-
.checkArgument('p')
|
|
212
|
-
.shouldBeMeters(p);
|
|
213
|
-
if (this.equal(p)) {
|
|
214
|
-
return this.findLine(p.clone().move(0, 1));
|
|
215
|
-
}
|
|
216
|
-
var a = this.y - p.y - diff;
|
|
217
|
-
var b = p.x - this.x - diff;
|
|
218
|
-
var c = this.x * p.y - p.x * this.y - diff;
|
|
219
|
-
if (a === 0) {
|
|
220
|
-
return new DLine(0, 1, c / b, this, p);
|
|
221
|
-
}
|
|
222
|
-
if (b === 0) {
|
|
223
|
-
return new DLine(1, 0, c / a, this, p);
|
|
224
|
-
}
|
|
225
|
-
return new DLine(a, b, c, this, p);
|
|
226
|
-
};
|
|
227
|
-
DPoint.prototype.findInnerAngle = function (p1, p3) {
|
|
228
|
-
checkFunction('findInnerAngle')
|
|
229
|
-
.checkArgument('this')
|
|
230
|
-
.shouldBeMeters(this)
|
|
231
|
-
.checkArgument('p1')
|
|
232
|
-
.shouldBeMeters(p1)
|
|
233
|
-
.checkArgument('p3')
|
|
234
|
-
.shouldBeMeters(p3);
|
|
235
|
-
var a1 = this.findLine(p1).getFi();
|
|
236
|
-
var a2 = this.findLine(p3).getFi();
|
|
237
|
-
if (a2 >= a1) {
|
|
238
|
-
return a2 - a1;
|
|
239
|
-
}
|
|
240
|
-
return a2 + Math.PI * 2 - a1;
|
|
241
|
-
};
|
|
242
|
-
DPoint.prototype.toString = function () {
|
|
243
|
-
return "".concat(this.x, " ").concat(this.y);
|
|
244
|
-
};
|
|
245
|
-
DPoint.prototype.getValue = function () {
|
|
246
|
-
return [this.x, this.y];
|
|
247
|
-
};
|
|
248
|
-
DPoint.prototype.height = function (z) {
|
|
249
|
-
this.z = z;
|
|
250
|
-
return this;
|
|
251
|
-
};
|
|
252
|
-
DPoint.prototype.toWKT = function () {
|
|
253
|
-
var _a = this, x = _a.x, y = _a.y;
|
|
254
|
-
return "POINT (".concat(x, " ").concat(y, ")");
|
|
255
|
-
};
|
|
256
|
-
DPoint.prototype.distance = function (p) {
|
|
257
|
-
checkFunction('distance')
|
|
258
|
-
.checkArgument('this')
|
|
259
|
-
.shouldBeMeters(this)
|
|
260
|
-
.checkArgument('p')
|
|
261
|
-
.shouldBeMeters(p);
|
|
262
|
-
var dx = p.x - this.x;
|
|
263
|
-
var dy = p.y - this.y;
|
|
264
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
265
|
-
};
|
|
266
|
-
DPoint.prototype.distance3d = function (p) {
|
|
267
|
-
checkFunction('distance3d')
|
|
268
|
-
.checkArgument('this')
|
|
269
|
-
.shouldBeMeters(this)
|
|
270
|
-
.checkArgument('p')
|
|
271
|
-
.shouldBeMeters(p)
|
|
272
|
-
.checkArgument('this.z')
|
|
273
|
-
.shouldExist(this.z)
|
|
274
|
-
.checkArgument('p.z')
|
|
275
|
-
.shouldExist(p.z);
|
|
276
|
-
var dx = p.x - this.x;
|
|
277
|
-
var dy = p.y - this.y;
|
|
278
|
-
var dz = p.z - this.z;
|
|
279
|
-
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
280
|
-
};
|
|
281
|
-
DPoint.prototype.setX = function (x) {
|
|
282
|
-
this.x = typeof x === 'number' ? x : x(this);
|
|
283
|
-
return this;
|
|
284
|
-
};
|
|
285
|
-
DPoint.prototype.setZ = function (z) {
|
|
286
|
-
this.z = typeof z === 'number' ? z : z(this);
|
|
287
|
-
return this;
|
|
288
|
-
};
|
|
289
|
-
DPoint.prototype.setY = function (y) {
|
|
290
|
-
this.y = typeof y === 'number' ? y : y(this);
|
|
291
|
-
return this;
|
|
292
|
-
};
|
|
293
|
-
DPoint.prototype.setProperties = function (v) {
|
|
294
|
-
this.properties = typeof v === 'object' ? v : v(this);
|
|
295
|
-
return this;
|
|
296
|
-
};
|
|
297
|
-
DPoint.prototype.clone = function () {
|
|
298
|
-
var p = new DPoint(this.x, this.y, this.z);
|
|
299
|
-
p.properties = __assign({}, this.properties);
|
|
300
|
-
return p;
|
|
301
|
-
};
|
|
302
|
-
DPoint.prototype.gt = function (p) {
|
|
303
|
-
return this.x > p.x && this.y > p.y;
|
|
304
|
-
};
|
|
305
|
-
DPoint.prototype.lt = function (p) {
|
|
306
|
-
return this.x < p.x && this.y < p.y;
|
|
307
|
-
};
|
|
308
|
-
DPoint.prototype.gtOrEqual = function (p) {
|
|
309
|
-
return this.gt(p) || this.equal(p);
|
|
310
|
-
};
|
|
311
|
-
DPoint.prototype.ltOrEqual = function (p) {
|
|
312
|
-
return this.lt(p) || this.equal(p);
|
|
313
|
-
};
|
|
314
|
-
DPoint.prototype.rotate = function (a) {
|
|
315
|
-
var x = this.x * Math.cos(a) - this.y * Math.sin(a);
|
|
316
|
-
var y = this.x * Math.sin(a) + this.y * Math.cos(a);
|
|
317
|
-
this.x = x;
|
|
318
|
-
this.y = y;
|
|
319
|
-
return this;
|
|
320
|
-
};
|
|
321
|
-
DPoint.prototype.rotate3dX = function (a) {
|
|
322
|
-
var _a = this, y = _a.y, z = _a.z;
|
|
323
|
-
this.y = y * Math.cos(a) + z * Math.sin(a);
|
|
324
|
-
this.z = -y * Math.sin(a) + z * Math.cos(a);
|
|
325
|
-
return this;
|
|
326
|
-
};
|
|
327
|
-
DPoint.prototype.rotate3dY = function (a) {
|
|
328
|
-
var _a = this, x = _a.x, z = _a.z;
|
|
329
|
-
this.x = x * Math.cos(a) + z * Math.sin(a);
|
|
330
|
-
this.z = -x * Math.sin(a) + z * Math.cos(a);
|
|
331
|
-
return this;
|
|
332
|
-
};
|
|
333
|
-
DPoint.prototype.rotate3dZ = function (a) {
|
|
334
|
-
var _a = this, x = _a.x, y = _a.y;
|
|
335
|
-
this.x = x * Math.cos(a) - y * Math.sin(a);
|
|
336
|
-
this.y = -x * Math.sin(a) + y * Math.cos(a);
|
|
337
|
-
return this;
|
|
338
|
-
};
|
|
339
|
-
DPoint.prototype.move = function (x, y, z) {
|
|
340
|
-
if (y === void 0) { y = x; }
|
|
341
|
-
var xV = 0;
|
|
342
|
-
var yV = 0;
|
|
343
|
-
var zV = undefined;
|
|
344
|
-
if (x instanceof DPoint) {
|
|
345
|
-
xV = this.x + x.x;
|
|
346
|
-
yV = this.y + x.y;
|
|
347
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
|
|
348
|
-
zV = this.z + x.z;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
xV = this.x + x;
|
|
353
|
-
yV = this.y + y;
|
|
354
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
|
|
355
|
-
zV = this.z + z;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
this.x = xV;
|
|
359
|
-
this.y = yV;
|
|
360
|
-
if (isDefAndNotNull(zV)) {
|
|
361
|
-
this.z = zV;
|
|
362
|
-
}
|
|
363
|
-
return this;
|
|
364
|
-
};
|
|
365
|
-
DPoint.prototype.degreeToMeters = function () {
|
|
366
|
-
checkFunction('degreeToMeters')
|
|
367
|
-
.checkArgument('this')
|
|
368
|
-
.shouldBeDegree(this);
|
|
369
|
-
var x = ((this.x + PI_IN_DEGREE) % DOUBLE_PI_IN_DEGREE - PI_IN_DEGREE) * METERS_IN_ONE_DEGREE;
|
|
370
|
-
var y = (Math.log(Math.tan(((this.y + HALF_PI_IN_DEGREE) % PI_IN_DEGREE) *
|
|
371
|
-
(Math.PI / DOUBLE_PI_IN_DEGREE))) / PI_TO_DEGREE) * METERS_IN_ONE_DEGREE;
|
|
372
|
-
this.x = x;
|
|
373
|
-
this.y = y;
|
|
374
|
-
return this;
|
|
375
|
-
};
|
|
376
|
-
DPoint.prototype.metersToDegree = function () {
|
|
377
|
-
checkFunction('metersToDegree')
|
|
378
|
-
.checkArgument('this')
|
|
379
|
-
.shouldBeMeters(this);
|
|
380
|
-
var lon = this.x * DEGREES_IN_ONE_METER;
|
|
381
|
-
var lat = Math.atan(Math.pow(Math.E, ((this.y / METERS_IN_ONE_DEGREE) * PI_TO_DEGREE))) *
|
|
382
|
-
(DOUBLE_PI_IN_DEGREE / Math.PI) - HALF_PI_IN_DEGREE;
|
|
383
|
-
this.x = lon;
|
|
384
|
-
this.y = lat;
|
|
385
|
-
return this;
|
|
386
|
-
};
|
|
387
|
-
DPoint.prototype.degreeToRadians = function () {
|
|
388
|
-
checkFunction('degreeToRadians')
|
|
389
|
-
.checkArgument('this')
|
|
390
|
-
.shouldBeDegree(this);
|
|
391
|
-
return this.scale(PI_TO_DEGREE);
|
|
392
|
-
};
|
|
393
|
-
DPoint.prototype.radiansToDegrees = function () {
|
|
394
|
-
checkFunction('radiansToDegrees')
|
|
395
|
-
.checkArgument('this')
|
|
396
|
-
.shouldBeRadians(this);
|
|
397
|
-
return this.scale(DEGREE_TO_PI);
|
|
398
|
-
};
|
|
399
|
-
DPoint.prototype.radiansToMeters = function () {
|
|
400
|
-
checkFunction('radiansToMeters')
|
|
401
|
-
.checkArgument('this')
|
|
402
|
-
.shouldBeRadians(this);
|
|
403
|
-
return this.radiansToDegrees().degreeToMeters();
|
|
404
|
-
};
|
|
405
|
-
DPoint.prototype.metersToRadians = function () {
|
|
406
|
-
checkFunction('metersToRadians')
|
|
407
|
-
.checkArgument('this')
|
|
408
|
-
.shouldBeMeters(this);
|
|
409
|
-
return this.metersToDegree().degreeToRadians();
|
|
410
|
-
};
|
|
411
|
-
DPoint.prototype.round = function () {
|
|
412
|
-
this.x = Math.round(this.x);
|
|
413
|
-
this.y = Math.round(this.y);
|
|
414
|
-
return this;
|
|
415
|
-
};
|
|
416
|
-
DPoint.prototype.ceil = function () {
|
|
417
|
-
this.x = Math.ceil(this.x);
|
|
418
|
-
this.y = Math.ceil(this.y);
|
|
419
|
-
return this;
|
|
420
|
-
};
|
|
421
|
-
DPoint.prototype.floor = function () {
|
|
422
|
-
this.x = Math.floor(this.x);
|
|
423
|
-
this.y = Math.floor(this.y);
|
|
424
|
-
return this;
|
|
425
|
-
};
|
|
426
|
-
DPoint.prototype.toFixed = function (n) {
|
|
427
|
-
if (n === void 0) { n = 2; }
|
|
428
|
-
this.x = parseFloat(this.x.toFixed(n));
|
|
429
|
-
this.y = parseFloat(this.y.toFixed(n));
|
|
430
|
-
return this;
|
|
431
|
-
};
|
|
432
|
-
DPoint.prototype.abs = function () {
|
|
433
|
-
this.x = Math.abs(this.x);
|
|
434
|
-
this.y = Math.abs(this.y);
|
|
435
|
-
return this;
|
|
436
|
-
};
|
|
437
|
-
DPoint.prototype.scale = function (x, y, z) {
|
|
438
|
-
if (y === void 0) { y = x; }
|
|
439
|
-
var xV = 0;
|
|
440
|
-
var yV = 0;
|
|
441
|
-
var zV = undefined;
|
|
442
|
-
if (x instanceof DPoint) {
|
|
443
|
-
xV = this.x * x.x;
|
|
444
|
-
yV = this.y * x.y;
|
|
445
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
|
|
446
|
-
zV = this.z * x.z;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
else {
|
|
450
|
-
xV = this.x * x;
|
|
451
|
-
yV = this.y * y;
|
|
452
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
|
|
453
|
-
zV = this.z * z;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
this.x = xV;
|
|
457
|
-
this.y = yV;
|
|
458
|
-
if (isDefAndNotNull(zV)) {
|
|
459
|
-
this.z = zV;
|
|
460
|
-
}
|
|
461
|
-
return this;
|
|
462
|
-
};
|
|
463
|
-
DPoint.prototype.divide = function (x, y, z) {
|
|
464
|
-
if (y === void 0) { y = x; }
|
|
465
|
-
var xV = 0;
|
|
466
|
-
var yV = 0;
|
|
467
|
-
var zV = undefined;
|
|
468
|
-
if (x instanceof DPoint) {
|
|
469
|
-
xV = this.x / x.x;
|
|
470
|
-
yV = this.y / x.y;
|
|
471
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
|
|
472
|
-
zV = this.z / x.z;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
xV = this.x / x;
|
|
477
|
-
yV = this.y / y;
|
|
478
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
|
|
479
|
-
zV = this.z / z;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
this.x = xV;
|
|
483
|
-
this.y = yV;
|
|
484
|
-
if (isDefAndNotNull(zV)) {
|
|
485
|
-
this.z = zV;
|
|
486
|
-
}
|
|
487
|
-
return this;
|
|
488
|
-
};
|
|
489
|
-
DPoint.prototype.mod = function (x, y, z) {
|
|
490
|
-
if (y === void 0) { y = x; }
|
|
491
|
-
var xV = 0;
|
|
492
|
-
var yV = 0;
|
|
493
|
-
var zV = undefined;
|
|
494
|
-
if (x instanceof DPoint) {
|
|
495
|
-
xV = this.x % x.x;
|
|
496
|
-
yV = this.y % x.y;
|
|
497
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
|
|
498
|
-
zV = this.z % x.z;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
xV = this.x % x;
|
|
503
|
-
yV = this.y % y;
|
|
504
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
|
|
505
|
-
zV = this.z % z;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
this.x = xV;
|
|
509
|
-
this.y = yV;
|
|
510
|
-
if (isDefAndNotNull(zV)) {
|
|
511
|
-
this.z = zV;
|
|
512
|
-
}
|
|
513
|
-
return this;
|
|
514
|
-
};
|
|
515
|
-
DPoint.prototype.div = function (x, y, z) {
|
|
516
|
-
if (y === void 0) { y = x; }
|
|
517
|
-
var xV = 0;
|
|
518
|
-
var yV = 0;
|
|
519
|
-
var zV = undefined;
|
|
520
|
-
if (x instanceof DPoint) {
|
|
521
|
-
xV = div(this.x, x.x);
|
|
522
|
-
yV = div(this.y, x.y);
|
|
523
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
|
|
524
|
-
zV = div(this.z, x.z);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
xV = div(this.x, x);
|
|
529
|
-
yV = div(this.y, y);
|
|
530
|
-
if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
|
|
531
|
-
zV = div(this.z, z);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
this.x = xV;
|
|
535
|
-
this.y = yV;
|
|
536
|
-
if (isDefAndNotNull(zV)) {
|
|
537
|
-
this.z = zV;
|
|
538
|
-
}
|
|
539
|
-
return this;
|
|
540
|
-
};
|
|
541
|
-
DPoint.prototype.equal = function (p) {
|
|
542
|
-
return this.x === p.x && this.y === p.y && this.z === p.z;
|
|
543
|
-
};
|
|
544
|
-
DPoint.prototype.like = function (p, d) {
|
|
545
|
-
var _a, _b, _c, _d;
|
|
546
|
-
if (d === void 0) { d = 0.001; }
|
|
547
|
-
if (this.equal(p)) {
|
|
548
|
-
return true;
|
|
549
|
-
}
|
|
550
|
-
var likeX = Math.abs(this.x - p.x) < d;
|
|
551
|
-
var likeY = Math.abs(this.y - p.y) < d;
|
|
552
|
-
var likeZ = Math.abs(((_b = (_a = this.z) !== null && _a !== void 0 ? _a : p.z) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = p.z) !== null && _c !== void 0 ? _c : this.z) !== null && _d !== void 0 ? _d : 0)) < d;
|
|
553
|
-
return likeX && likeY && likeZ;
|
|
554
|
-
};
|
|
555
|
-
DPoint.prototype.flipVertically = function (size) {
|
|
556
|
-
var v = size;
|
|
557
|
-
if (size instanceof DPoint) {
|
|
558
|
-
v = size.y;
|
|
559
|
-
}
|
|
560
|
-
this.y = v - this.y;
|
|
561
|
-
return this;
|
|
562
|
-
};
|
|
563
|
-
Object.defineProperty(DPoint.prototype, "likeRadians", {
|
|
564
|
-
get: function () {
|
|
565
|
-
if (radiansPolygon.length === 0) {
|
|
566
|
-
radiansPolygon.push(new DPoint(-Math.PI, -Math.PI / 2), new DPoint(Math.PI, Math.PI / 2));
|
|
567
|
-
}
|
|
568
|
-
return radiansPolygon.simpleInclude(this);
|
|
569
|
-
},
|
|
570
|
-
enumerable: false,
|
|
571
|
-
configurable: true
|
|
572
|
-
});
|
|
573
|
-
Object.defineProperty(DPoint.prototype, "likeWorldGeodeticSystem", {
|
|
574
|
-
get: function () {
|
|
575
|
-
if (worldGeodeticPolygon.length === 0) {
|
|
576
|
-
worldGeodeticPolygon.push(new DPoint(-180, -90), new DPoint(180, 90));
|
|
577
|
-
}
|
|
578
|
-
return !this.likeRadians && worldGeodeticPolygon.simpleInclude(this);
|
|
579
|
-
},
|
|
580
|
-
enumerable: false,
|
|
581
|
-
configurable: true
|
|
582
|
-
});
|
|
583
|
-
Object.defineProperty(DPoint.prototype, "likePseudoMercator", {
|
|
584
|
-
get: function () {
|
|
585
|
-
if (pseudoMercatorPolygon.length === 0) {
|
|
586
|
-
pseudoMercatorPolygon.push(new DPoint(-20026376.39, -20048966.10), new DPoint(20026376.39, 20048966.10));
|
|
587
|
-
}
|
|
588
|
-
return !this.likeRadians && !this.likeWorldGeodeticSystem && pseudoMercatorPolygon.simpleInclude(this);
|
|
589
|
-
},
|
|
590
|
-
enumerable: false,
|
|
591
|
-
configurable: true
|
|
592
|
-
});
|
|
593
|
-
Object.defineProperty(DPoint.prototype, "w", {
|
|
594
|
-
get: function () {
|
|
595
|
-
return this.x;
|
|
596
|
-
},
|
|
597
|
-
set: function (x) {
|
|
598
|
-
this.x = x;
|
|
599
|
-
},
|
|
600
|
-
enumerable: false,
|
|
601
|
-
configurable: true
|
|
602
|
-
});
|
|
603
|
-
Object.defineProperty(DPoint.prototype, "h", {
|
|
604
|
-
get: function () {
|
|
605
|
-
return this.y;
|
|
606
|
-
},
|
|
607
|
-
set: function (y) {
|
|
608
|
-
this.y = y;
|
|
609
|
-
},
|
|
610
|
-
enumerable: false,
|
|
611
|
-
configurable: true
|
|
612
|
-
});
|
|
613
|
-
Object.defineProperty(DPoint.prototype, "area", {
|
|
614
|
-
get: function () {
|
|
615
|
-
checkFunction('area')
|
|
616
|
-
.checkArgument('this')
|
|
617
|
-
.shouldBeMeters(this);
|
|
618
|
-
return this.w * this.h;
|
|
619
|
-
},
|
|
620
|
-
enumerable: false,
|
|
621
|
-
configurable: true
|
|
622
|
-
});
|
|
623
|
-
Object.defineProperty(DPoint.prototype, "hip", {
|
|
624
|
-
get: function () {
|
|
625
|
-
checkFunction('hip')
|
|
626
|
-
.checkArgument('this')
|
|
627
|
-
.shouldBeMeters(this);
|
|
628
|
-
return Math.sqrt(this.w * this.w + this.h * this.h);
|
|
629
|
-
},
|
|
630
|
-
enumerable: false,
|
|
631
|
-
configurable: true
|
|
632
|
-
});
|
|
633
|
-
Object.defineProperty(DPoint.prototype, "min", {
|
|
634
|
-
get: function () {
|
|
635
|
-
return Math.min(this.x, this.y);
|
|
636
|
-
},
|
|
637
|
-
enumerable: false,
|
|
638
|
-
configurable: true
|
|
639
|
-
});
|
|
640
|
-
Object.defineProperty(DPoint.prototype, "max", {
|
|
641
|
-
get: function () {
|
|
642
|
-
return Math.max(this.x, this.y);
|
|
643
|
-
},
|
|
644
|
-
enumerable: false,
|
|
645
|
-
configurable: true
|
|
646
|
-
});
|
|
647
|
-
Object.defineProperty(DPoint.prototype, "hipPoint", {
|
|
648
|
-
get: function () {
|
|
649
|
-
var hip = this.hip;
|
|
650
|
-
return new DPoint(hip, hip);
|
|
651
|
-
},
|
|
652
|
-
enumerable: false,
|
|
653
|
-
configurable: true
|
|
654
|
-
});
|
|
655
|
-
Object.defineProperty(DPoint.prototype, "xPoint", {
|
|
656
|
-
get: function () {
|
|
657
|
-
var x = this.x;
|
|
658
|
-
return new DPoint(x, x);
|
|
659
|
-
},
|
|
660
|
-
enumerable: false,
|
|
661
|
-
configurable: true
|
|
662
|
-
});
|
|
663
|
-
Object.defineProperty(DPoint.prototype, "yPoint", {
|
|
664
|
-
get: function () {
|
|
665
|
-
var y = this.y;
|
|
666
|
-
return new DPoint(y, y);
|
|
667
|
-
},
|
|
668
|
-
enumerable: false,
|
|
669
|
-
configurable: true
|
|
670
|
-
});
|
|
671
|
-
Object.defineProperty(DPoint.prototype, "wPoint", {
|
|
672
|
-
get: function () {
|
|
673
|
-
return this.xPoint;
|
|
674
|
-
},
|
|
675
|
-
enumerable: false,
|
|
676
|
-
configurable: true
|
|
677
|
-
});
|
|
678
|
-
Object.defineProperty(DPoint.prototype, "hPoint", {
|
|
679
|
-
get: function () {
|
|
680
|
-
return this.yPoint;
|
|
681
|
-
},
|
|
682
|
-
enumerable: false,
|
|
683
|
-
configurable: true
|
|
684
|
-
});
|
|
685
|
-
Object.defineProperty(DPoint.prototype, "lat", {
|
|
686
|
-
get: function () {
|
|
687
|
-
return this.y;
|
|
688
|
-
},
|
|
689
|
-
set: function (v) {
|
|
690
|
-
this.y = v;
|
|
691
|
-
},
|
|
692
|
-
enumerable: false,
|
|
693
|
-
configurable: true
|
|
694
|
-
});
|
|
695
|
-
Object.defineProperty(DPoint.prototype, "lng", {
|
|
696
|
-
get: function () {
|
|
697
|
-
return this.x;
|
|
698
|
-
},
|
|
699
|
-
set: function (v) {
|
|
700
|
-
this.x = v;
|
|
701
|
-
},
|
|
702
|
-
enumerable: false,
|
|
703
|
-
configurable: true
|
|
704
|
-
});
|
|
705
|
-
Object.defineProperty(DPoint.prototype, "lon", {
|
|
706
|
-
get: function () {
|
|
707
|
-
return this.x;
|
|
708
|
-
},
|
|
709
|
-
set: function (v) {
|
|
710
|
-
this.x = v;
|
|
711
|
-
},
|
|
712
|
-
enumerable: false,
|
|
713
|
-
configurable: true
|
|
714
|
-
});
|
|
715
|
-
Object.defineProperty(DPoint.prototype, "alt", {
|
|
716
|
-
get: function () {
|
|
717
|
-
return this.z;
|
|
718
|
-
},
|
|
719
|
-
set: function (v) {
|
|
720
|
-
this.z = v;
|
|
721
|
-
},
|
|
722
|
-
enumerable: false,
|
|
723
|
-
configurable: true
|
|
724
|
-
});
|
|
725
|
-
DPoint.prototype.simple = function (xKey, yKey, zKey) {
|
|
726
|
-
var _a, _b;
|
|
727
|
-
if (xKey === void 0) { xKey = 'x'; }
|
|
728
|
-
if (yKey === void 0) { yKey = 'y'; }
|
|
729
|
-
if (zKey === void 0) { zKey = 'z'; }
|
|
730
|
-
return __assign((_a = {}, _a[xKey] = this.x, _a[yKey] = this.y, _a), (isDefAndNotNull(this.z) ? (_b = {},
|
|
731
|
-
_b[zKey] = this.z,
|
|
732
|
-
_b) : {}));
|
|
733
|
-
};
|
|
734
|
-
DPoint.prototype.setIfLessThan = function (p) {
|
|
735
|
-
this.x = Math.max(this.x, p.x);
|
|
736
|
-
this.y = Math.max(this.y, p.y);
|
|
737
|
-
return this;
|
|
738
|
-
};
|
|
739
|
-
DPoint.prototype.setIfMoreThan = function (p) {
|
|
740
|
-
this.x = Math.min(this.x, p.x);
|
|
741
|
-
this.y = Math.min(this.y, p.y);
|
|
742
|
-
return this;
|
|
743
|
-
};
|
|
744
|
-
DPoint.prototype.minus = function () {
|
|
745
|
-
return this.scale(-1);
|
|
746
|
-
};
|
|
747
|
-
DPoint.prototype.orthodromicPath = function (point, pointsCount) {
|
|
748
|
-
if (pointsCount === void 0) { pointsCount = 360; }
|
|
749
|
-
checkFunction('orthodromicPath')
|
|
750
|
-
.checkArgument('this')
|
|
751
|
-
.shouldBeDegree(this)
|
|
752
|
-
.checkArgument('point')
|
|
753
|
-
.shouldBeDegree(point);
|
|
754
|
-
var t = this.clone().degreeToRadians();
|
|
755
|
-
var p = point.clone().degreeToRadians();
|
|
756
|
-
var d = Math.sin(p.x - t.x);
|
|
757
|
-
var step = (p.x - t.x) / (pointsCount - 1);
|
|
758
|
-
return new DPolygon(createArray(pointsCount)
|
|
759
|
-
.map(function (v, i) {
|
|
760
|
-
var x = t.x + step * i;
|
|
761
|
-
var y = Math.atan((Math.tan(t.y) * Math.sin(p.x - x)) / d +
|
|
762
|
-
(Math.tan(p.y) * Math.sin(x - t.x)) / d);
|
|
763
|
-
return new DPoint(x, y).radiansToDegrees();
|
|
764
|
-
}));
|
|
765
|
-
};
|
|
766
|
-
DPoint.prototype.sortByDistance = function (p) {
|
|
767
|
-
var _this = this;
|
|
768
|
-
return p
|
|
769
|
-
.clone()
|
|
770
|
-
.map(function (d, index) {
|
|
771
|
-
d.properties.distance = d.distance(_this);
|
|
772
|
-
d.properties.index = index;
|
|
773
|
-
return d;
|
|
774
|
-
})
|
|
775
|
-
.sort(function (a, b) { return a.properties.distance - b.properties.distance; });
|
|
776
|
-
};
|
|
777
|
-
DPoint.prototype.calculateAltitudeByDistanceBetweenPoints = function (p1, p2) {
|
|
778
|
-
var _a, _b, _c, _d, _e;
|
|
779
|
-
if (p1.alt === p2.alt) {
|
|
780
|
-
this.alt = p1.alt;
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
783
|
-
var minAlt = Math.min((_a = p1.alt) !== null && _a !== void 0 ? _a : 0, (_b = p2.alt) !== null && _b !== void 0 ? _b : 0);
|
|
784
|
-
var maxAlt = Math.max((_c = p1.alt) !== null && _c !== void 0 ? _c : 0, (_d = p2.alt) !== null && _d !== void 0 ? _d : 0);
|
|
785
|
-
var dAlt = maxAlt - minAlt;
|
|
786
|
-
var distance1 = this.distance(p1);
|
|
787
|
-
var distance2 = this.distance(p2);
|
|
788
|
-
var totalDistance = distance1 + distance2;
|
|
789
|
-
if (((_e = p1.alt) !== null && _e !== void 0 ? _e : 0) === minAlt) {
|
|
790
|
-
this.alt = minAlt + distance1 / totalDistance * dAlt;
|
|
791
|
-
}
|
|
792
|
-
else {
|
|
793
|
-
this.alt = minAlt + distance2 / totalDistance * dAlt;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
return this;
|
|
797
|
-
};
|
|
798
|
-
return DPoint;
|
|
799
|
-
}());
|
|
800
|
-
export { DPoint };
|