dgeoutils 2.4.3 → 2.4.6
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/dist/cjs/DPoint.d.ts +4 -1
- package/dist/cjs/DPoint.js +42 -2
- package/dist/cjs/DPolygon.js +4 -4
- package/dist/es2015/DPoint.js +40 -1
- package/dist/es2015/DPolygon.js +1 -1
- package/dist/esm/DPoint.js +42 -2
- package/dist/esm/DPolygon.js +1 -1
- package/dist/umd/dgeoutils.js +50 -10
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +3 -2
package/dist/cjs/DPoint.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export declare const EARTH_RADIUS_IN_METERS = 6371008.8;
|
|
|
4
4
|
export declare type DCoord = [number, number] | [number, number, number];
|
|
5
5
|
export interface LatLng {
|
|
6
6
|
lat: number;
|
|
7
|
-
lng
|
|
7
|
+
lng?: number;
|
|
8
|
+
lon?: number;
|
|
8
9
|
}
|
|
9
10
|
export declare const HALF_PI_IN_DEGREE = 90;
|
|
10
11
|
export declare const PI_IN_DEGREE = 180;
|
|
@@ -27,7 +28,9 @@ export declare class DPoint {
|
|
|
27
28
|
static parse(c: LatLng | number[] | DCoord): DPoint;
|
|
28
29
|
static parseFromWKT(wkt: string): DPoint;
|
|
29
30
|
static random(): DPoint;
|
|
31
|
+
static getTileFromQuadKey(quadKey: string): DPoint;
|
|
30
32
|
getTileFromCoords(zoom?: number): DPoint;
|
|
33
|
+
getQuadKeyFromTile(zoom?: number): string;
|
|
31
34
|
getCoordsFromTile(zoom?: number): DPoint;
|
|
32
35
|
toCoords(): DCoord;
|
|
33
36
|
findLine(p: DPoint): DLine;
|
package/dist/cjs/DPoint.js
CHANGED
|
@@ -58,11 +58,11 @@ var DPoint = (function () {
|
|
|
58
58
|
return new DPoint();
|
|
59
59
|
};
|
|
60
60
|
DPoint.parse = function (c) {
|
|
61
|
-
var _a = c, lat = _a.lat,
|
|
61
|
+
var _a = c, lat = _a.lat, lon = _a.lon, _b = _a.lng, lng = _b === void 0 ? lon : _b;
|
|
62
62
|
if (lat && lng) {
|
|
63
63
|
return new DPoint(lat, lng, 0);
|
|
64
64
|
}
|
|
65
|
-
var
|
|
65
|
+
var _c = __read(c, 3), x = _c[0], y = _c[1], z = _c[2];
|
|
66
66
|
return new DPoint(x, y, z);
|
|
67
67
|
};
|
|
68
68
|
DPoint.parseFromWKT = function (wkt) {
|
|
@@ -75,6 +75,29 @@ var DPoint = (function () {
|
|
|
75
75
|
DPoint.random = function () {
|
|
76
76
|
return new DPoint(Math.random(), Math.random());
|
|
77
77
|
};
|
|
78
|
+
DPoint.getTileFromQuadKey = function (quadKey) {
|
|
79
|
+
var p = new DPoint(0, 0, quadKey.length);
|
|
80
|
+
for (var i = p.z; i > 0; i--) {
|
|
81
|
+
var mask = 1 << (i - 1);
|
|
82
|
+
switch (quadKey[p.z - i]) {
|
|
83
|
+
case '0':
|
|
84
|
+
break;
|
|
85
|
+
case '1':
|
|
86
|
+
p.x |= mask;
|
|
87
|
+
break;
|
|
88
|
+
case '2':
|
|
89
|
+
p.y |= mask;
|
|
90
|
+
break;
|
|
91
|
+
case '3':
|
|
92
|
+
p.x |= mask;
|
|
93
|
+
p.y |= mask;
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
throw new Error('Invalid QuadKey digit sequence.');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return p;
|
|
100
|
+
};
|
|
78
101
|
DPoint.prototype.getTileFromCoords = function (zoom) {
|
|
79
102
|
if (zoom === void 0) { zoom = this.z; }
|
|
80
103
|
(0, utils_1.checkFunction)('getTileFromCoords')
|
|
@@ -84,6 +107,23 @@ var DPoint = (function () {
|
|
|
84
107
|
var y = Math.floor((1 - Math.log(Math.tan(this.y * exports.PI_TO_DEGREE) + 1 / Math.cos(this.y * exports.PI_TO_DEGREE)) / Math.PI) / 2 * (Math.pow(2, zoom)));
|
|
85
108
|
return new DPoint(x, y, zoom);
|
|
86
109
|
};
|
|
110
|
+
DPoint.prototype.getQuadKeyFromTile = function (zoom) {
|
|
111
|
+
if (zoom === void 0) { zoom = this.z; }
|
|
112
|
+
var quadKey = [];
|
|
113
|
+
for (var i = zoom; i > 0; i--) {
|
|
114
|
+
var digit = 0;
|
|
115
|
+
var mask = 1 << (i - 1);
|
|
116
|
+
if ((this.x & mask) !== 0) {
|
|
117
|
+
digit++;
|
|
118
|
+
}
|
|
119
|
+
if ((this.y & mask) !== 0) {
|
|
120
|
+
digit++;
|
|
121
|
+
digit++;
|
|
122
|
+
}
|
|
123
|
+
quadKey.push(digit);
|
|
124
|
+
}
|
|
125
|
+
return quadKey.join('');
|
|
126
|
+
};
|
|
87
127
|
DPoint.prototype.getCoordsFromTile = function (zoom) {
|
|
88
128
|
if (zoom === void 0) { zoom = this.z; }
|
|
89
129
|
(0, utils_1.checkFunction)('getCoordsFromTile')
|
package/dist/cjs/DPolygon.js
CHANGED
|
@@ -68,10 +68,10 @@ var DPoint_1 = require("./DPoint");
|
|
|
68
68
|
var DLine_1 = require("./DLine");
|
|
69
69
|
var DCircle_1 = require("./DCircle");
|
|
70
70
|
var DNumbers_1 = require("./DNumbers");
|
|
71
|
-
var
|
|
71
|
+
var jsts_1 = require("jsts");
|
|
72
72
|
var DPolygonLoop_1 = require("./DPolygonLoop");
|
|
73
73
|
var utils_1 = require("./utils");
|
|
74
|
-
var _a =
|
|
74
|
+
var _a = jsts_1.operation.buffer.BufferParameters, CAP_ROUND = _a.CAP_ROUND, CAP_FLAT = _a.CAP_FLAT, CAP_SQUARE = _a.CAP_SQUARE;
|
|
75
75
|
exports.MIN_POINTS_IN_VALID_POLYGON = 3;
|
|
76
76
|
var APPROXIMATION_VALUE = 0.1;
|
|
77
77
|
var MAX_CONVEX_ITERATIONS = 100;
|
|
@@ -1283,7 +1283,7 @@ var DPolygon = (function () {
|
|
|
1283
1283
|
DPolygon.prototype.buffer = function (v, quadrantSegments, type) {
|
|
1284
1284
|
if (quadrantSegments === void 0) { quadrantSegments = 64; }
|
|
1285
1285
|
if (type === void 0) { type = DPolygon.CAP_ROUND; }
|
|
1286
|
-
var reader = new
|
|
1286
|
+
var reader = new jsts_1.io.WKTReader();
|
|
1287
1287
|
var _a = this, noHoles = _a.noHoles, closed = _a.closed;
|
|
1288
1288
|
var points = reader
|
|
1289
1289
|
.read(noHoles.toWKT(closed ? DPolygon.WKT_POLYGON : DPolygon.WKT_LINESTRING))
|
|
@@ -1415,7 +1415,7 @@ var DPolygon = (function () {
|
|
|
1415
1415
|
};
|
|
1416
1416
|
DPolygon.prototype.getJSTSGeometry = function (p, unionThis, unionThat) {
|
|
1417
1417
|
var unionOrIntersection = unionThat === unionThis;
|
|
1418
|
-
var reader = new
|
|
1418
|
+
var reader = new jsts_1.io.WKTReader();
|
|
1419
1419
|
var a = reader.read(this.noHoles.toWKT());
|
|
1420
1420
|
var b = reader.read(p.noHoles.toWKT());
|
|
1421
1421
|
if (!unionOrIntersection) {
|
package/dist/es2015/DPoint.js
CHANGED
|
@@ -26,7 +26,7 @@ export class DPoint {
|
|
|
26
26
|
return new DPoint();
|
|
27
27
|
}
|
|
28
28
|
static parse(c) {
|
|
29
|
-
const { lat, lng } = c;
|
|
29
|
+
const { lat, lon, lng = lon } = c;
|
|
30
30
|
if (lat && lng) {
|
|
31
31
|
return new DPoint(lat, lng, 0);
|
|
32
32
|
}
|
|
@@ -43,6 +43,29 @@ export class DPoint {
|
|
|
43
43
|
static random() {
|
|
44
44
|
return new DPoint(Math.random(), Math.random());
|
|
45
45
|
}
|
|
46
|
+
static getTileFromQuadKey(quadKey) {
|
|
47
|
+
const p = new DPoint(0, 0, quadKey.length);
|
|
48
|
+
for (let i = p.z; i > 0; i--) {
|
|
49
|
+
const mask = 1 << (i - 1);
|
|
50
|
+
switch (quadKey[p.z - i]) {
|
|
51
|
+
case '0':
|
|
52
|
+
break;
|
|
53
|
+
case '1':
|
|
54
|
+
p.x |= mask;
|
|
55
|
+
break;
|
|
56
|
+
case '2':
|
|
57
|
+
p.y |= mask;
|
|
58
|
+
break;
|
|
59
|
+
case '3':
|
|
60
|
+
p.x |= mask;
|
|
61
|
+
p.y |= mask;
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
throw new Error('Invalid QuadKey digit sequence.');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return p;
|
|
68
|
+
}
|
|
46
69
|
getTileFromCoords(zoom = this.z) {
|
|
47
70
|
checkFunction('getTileFromCoords')
|
|
48
71
|
.checkArgument('this')
|
|
@@ -51,6 +74,22 @@ export class DPoint {
|
|
|
51
74
|
const 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)));
|
|
52
75
|
return new DPoint(x, y, zoom);
|
|
53
76
|
}
|
|
77
|
+
getQuadKeyFromTile(zoom = this.z) {
|
|
78
|
+
const quadKey = [];
|
|
79
|
+
for (let i = zoom; i > 0; i--) {
|
|
80
|
+
let digit = 0;
|
|
81
|
+
const mask = 1 << (i - 1);
|
|
82
|
+
if ((this.x & mask) !== 0) {
|
|
83
|
+
digit++;
|
|
84
|
+
}
|
|
85
|
+
if ((this.y & mask) !== 0) {
|
|
86
|
+
digit++;
|
|
87
|
+
digit++;
|
|
88
|
+
}
|
|
89
|
+
quadKey.push(digit);
|
|
90
|
+
}
|
|
91
|
+
return quadKey.join('');
|
|
92
|
+
}
|
|
54
93
|
getCoordsFromTile(zoom = this.z) {
|
|
55
94
|
checkFunction('getCoordsFromTile')
|
|
56
95
|
.checkArgument('this')
|
package/dist/es2015/DPolygon.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DPoint } from './DPoint';
|
|
|
2
2
|
import { DLine } from './DLine';
|
|
3
3
|
import { DCircle } from './DCircle';
|
|
4
4
|
import { DNumbers } from './DNumbers';
|
|
5
|
-
import { io as jstsIo, operation } from 'jsts
|
|
5
|
+
import { io as jstsIo, operation } from 'jsts';
|
|
6
6
|
import { DPolygonLoop } from './DPolygonLoop';
|
|
7
7
|
import { isDefAndNotNull } from './utils';
|
|
8
8
|
const { buffer: { BufferParameters: { CAP_ROUND, CAP_FLAT, CAP_SQUARE } } } = operation;
|
package/dist/esm/DPoint.js
CHANGED
|
@@ -55,11 +55,11 @@ var DPoint = (function () {
|
|
|
55
55
|
return new DPoint();
|
|
56
56
|
};
|
|
57
57
|
DPoint.parse = function (c) {
|
|
58
|
-
var _a = c, lat = _a.lat,
|
|
58
|
+
var _a = c, lat = _a.lat, lon = _a.lon, _b = _a.lng, lng = _b === void 0 ? lon : _b;
|
|
59
59
|
if (lat && lng) {
|
|
60
60
|
return new DPoint(lat, lng, 0);
|
|
61
61
|
}
|
|
62
|
-
var
|
|
62
|
+
var _c = __read(c, 3), x = _c[0], y = _c[1], z = _c[2];
|
|
63
63
|
return new DPoint(x, y, z);
|
|
64
64
|
};
|
|
65
65
|
DPoint.parseFromWKT = function (wkt) {
|
|
@@ -72,6 +72,29 @@ var DPoint = (function () {
|
|
|
72
72
|
DPoint.random = function () {
|
|
73
73
|
return new DPoint(Math.random(), Math.random());
|
|
74
74
|
};
|
|
75
|
+
DPoint.getTileFromQuadKey = function (quadKey) {
|
|
76
|
+
var p = new DPoint(0, 0, quadKey.length);
|
|
77
|
+
for (var i = p.z; i > 0; i--) {
|
|
78
|
+
var mask = 1 << (i - 1);
|
|
79
|
+
switch (quadKey[p.z - i]) {
|
|
80
|
+
case '0':
|
|
81
|
+
break;
|
|
82
|
+
case '1':
|
|
83
|
+
p.x |= mask;
|
|
84
|
+
break;
|
|
85
|
+
case '2':
|
|
86
|
+
p.y |= mask;
|
|
87
|
+
break;
|
|
88
|
+
case '3':
|
|
89
|
+
p.x |= mask;
|
|
90
|
+
p.y |= mask;
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
throw new Error('Invalid QuadKey digit sequence.');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return p;
|
|
97
|
+
};
|
|
75
98
|
DPoint.prototype.getTileFromCoords = function (zoom) {
|
|
76
99
|
if (zoom === void 0) { zoom = this.z; }
|
|
77
100
|
checkFunction('getTileFromCoords')
|
|
@@ -81,6 +104,23 @@ var DPoint = (function () {
|
|
|
81
104
|
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)));
|
|
82
105
|
return new DPoint(x, y, zoom);
|
|
83
106
|
};
|
|
107
|
+
DPoint.prototype.getQuadKeyFromTile = function (zoom) {
|
|
108
|
+
if (zoom === void 0) { zoom = this.z; }
|
|
109
|
+
var quadKey = [];
|
|
110
|
+
for (var i = zoom; i > 0; i--) {
|
|
111
|
+
var digit = 0;
|
|
112
|
+
var mask = 1 << (i - 1);
|
|
113
|
+
if ((this.x & mask) !== 0) {
|
|
114
|
+
digit++;
|
|
115
|
+
}
|
|
116
|
+
if ((this.y & mask) !== 0) {
|
|
117
|
+
digit++;
|
|
118
|
+
digit++;
|
|
119
|
+
}
|
|
120
|
+
quadKey.push(digit);
|
|
121
|
+
}
|
|
122
|
+
return quadKey.join('');
|
|
123
|
+
};
|
|
84
124
|
DPoint.prototype.getCoordsFromTile = function (zoom) {
|
|
85
125
|
if (zoom === void 0) { zoom = this.z; }
|
|
86
126
|
checkFunction('getCoordsFromTile')
|
package/dist/esm/DPolygon.js
CHANGED
|
@@ -65,7 +65,7 @@ import { DPoint } from './DPoint';
|
|
|
65
65
|
import { DLine } from './DLine';
|
|
66
66
|
import { DCircle } from './DCircle';
|
|
67
67
|
import { DNumbers } from './DNumbers';
|
|
68
|
-
import { io as jstsIo, operation } from 'jsts
|
|
68
|
+
import { io as jstsIo, operation } from 'jsts';
|
|
69
69
|
import { DPolygonLoop } from './DPolygonLoop';
|
|
70
70
|
import { isDefAndNotNull } from './utils';
|
|
71
71
|
var _a = operation.buffer.BufferParameters, CAP_ROUND = _a.CAP_ROUND, CAP_FLAT = _a.CAP_FLAT, CAP_SQUARE = _a.CAP_SQUARE;
|