dgeoutils 2.4.15 → 2.4.18
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 +8 -2
- package/dist/cjs/DPoint.js +28 -0
- package/dist/es2015/DPoint.js +27 -0
- package/dist/esm/DPoint.js +28 -0
- package/dist/umd/dgeoutils.js +29 -1
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/DPoint.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DLine } from './DLine';
|
|
2
2
|
import { DPolygon } from './DPolygon';
|
|
3
|
-
import { Point } from 'geojson';
|
|
3
|
+
import { Point, Feature } from 'geojson';
|
|
4
4
|
export declare const EARTH_RADIUS_IN_METERS = 6378137;
|
|
5
5
|
export declare type DCoord = [number, number] | [number, number, number];
|
|
6
6
|
export interface LatLng {
|
|
@@ -9,6 +9,11 @@ export interface LatLng {
|
|
|
9
9
|
lon?: number;
|
|
10
10
|
alt?: number;
|
|
11
11
|
}
|
|
12
|
+
export interface XYZ extends Record<string, any> {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
z?: number;
|
|
16
|
+
}
|
|
12
17
|
export declare const HALF_PI_IN_DEGREE = 90;
|
|
13
18
|
export declare const PI_IN_DEGREE = 180;
|
|
14
19
|
export declare const DOUBLE_PI_IN_DEGREE = 360;
|
|
@@ -25,7 +30,7 @@ export declare class DPoint {
|
|
|
25
30
|
constructor(x: number, y: number);
|
|
26
31
|
constructor(x: number, y: number, z?: number);
|
|
27
32
|
static zero(): DPoint;
|
|
28
|
-
static parse(c: LatLng | number[] | DCoord | Point, format?: string): DPoint;
|
|
33
|
+
static parse(c: LatLng | number[] | DCoord | Point | Feature<Point> | XYZ, format?: string): DPoint;
|
|
29
34
|
static parseFromWKT(wkt: string): DPoint;
|
|
30
35
|
static random(): DPoint;
|
|
31
36
|
static getTileFromQuadKey(quadKey: string): DPoint;
|
|
@@ -34,6 +39,7 @@ export declare class DPoint {
|
|
|
34
39
|
getCoordsFromTile(zoom?: number): DPoint;
|
|
35
40
|
toCoords(format?: string): DCoord;
|
|
36
41
|
toGeoJSON(format?: string): Point;
|
|
42
|
+
toGeoJSONFeature(format?: string): Feature<Point>;
|
|
37
43
|
findLine(p: DPoint): DLine;
|
|
38
44
|
findInnerAngle(p1: DPoint, p3: DPoint): number;
|
|
39
45
|
toString(): string;
|
package/dist/cjs/DPoint.js
CHANGED
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __read = (this && this.__read) || function (o, n) {
|
|
14
25
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
26
|
if (!m) return o;
|
|
@@ -63,10 +74,19 @@ var DPoint = (function () {
|
|
|
63
74
|
if (lat && lng) {
|
|
64
75
|
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
65
76
|
}
|
|
77
|
+
var _c = c, x = _c.x, y = _c.y, z = _c.z, properties = __rest(_c, ["x", "y", "z"]);
|
|
78
|
+
if ((0, utils_1.isDefAndNotNull)(x) && (0, utils_1.isDefAndNotNull)(y)) {
|
|
79
|
+
return new DPoint(x, y, z).setProperties(properties);
|
|
80
|
+
}
|
|
66
81
|
var t = c;
|
|
67
82
|
if (c.type === 'Point') {
|
|
68
83
|
t = c.coordinates;
|
|
69
84
|
}
|
|
85
|
+
if (c.type === 'Feature') {
|
|
86
|
+
var f = DPoint.parse(c.geometry, format);
|
|
87
|
+
f.properties = __assign({}, c.properties);
|
|
88
|
+
return f;
|
|
89
|
+
}
|
|
70
90
|
return format.replace(/[^x-z]/gmiu, '')
|
|
71
91
|
.split('')
|
|
72
92
|
.reduce(function (a, k, index) {
|
|
@@ -173,6 +193,14 @@ var DPoint = (function () {
|
|
|
173
193
|
coordinates: this.toCoords(format)
|
|
174
194
|
};
|
|
175
195
|
};
|
|
196
|
+
DPoint.prototype.toGeoJSONFeature = function (format) {
|
|
197
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
198
|
+
return {
|
|
199
|
+
type: 'Feature',
|
|
200
|
+
properties: __assign({}, this.properties),
|
|
201
|
+
geometry: this.toGeoJSON(format)
|
|
202
|
+
};
|
|
203
|
+
};
|
|
176
204
|
DPoint.prototype.findLine = function (p) {
|
|
177
205
|
(0, utils_1.checkFunction)('findLine')
|
|
178
206
|
.checkArgument('this')
|
package/dist/es2015/DPoint.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { DLine } from './DLine';
|
|
2
13
|
import { DPolygon } from './DPolygon';
|
|
3
14
|
import { checkFunction, createArray, DGeo, div, isDefAndNotNull } from './utils';
|
|
@@ -30,10 +41,19 @@ export class DPoint {
|
|
|
30
41
|
if (lat && lng) {
|
|
31
42
|
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
32
43
|
}
|
|
44
|
+
const _a = c, { x, y, z } = _a, properties = __rest(_a, ["x", "y", "z"]);
|
|
45
|
+
if (isDefAndNotNull(x) && isDefAndNotNull(y)) {
|
|
46
|
+
return new DPoint(x, y, z).setProperties(properties);
|
|
47
|
+
}
|
|
33
48
|
let t = c;
|
|
34
49
|
if (c.type === 'Point') {
|
|
35
50
|
t = c.coordinates;
|
|
36
51
|
}
|
|
52
|
+
if (c.type === 'Feature') {
|
|
53
|
+
const f = DPoint.parse(c.geometry, format);
|
|
54
|
+
f.properties = Object.assign({}, c.properties);
|
|
55
|
+
return f;
|
|
56
|
+
}
|
|
37
57
|
return format.replace(/[^x-z]/gmiu, '')
|
|
38
58
|
.split('')
|
|
39
59
|
.reduce((a, k, index) => {
|
|
@@ -134,6 +154,13 @@ export class DPoint {
|
|
|
134
154
|
coordinates: this.toCoords(format)
|
|
135
155
|
};
|
|
136
156
|
}
|
|
157
|
+
toGeoJSONFeature(format = DGeo.parseFormat) {
|
|
158
|
+
return {
|
|
159
|
+
type: 'Feature',
|
|
160
|
+
properties: Object.assign({}, this.properties),
|
|
161
|
+
geometry: this.toGeoJSON(format)
|
|
162
|
+
};
|
|
163
|
+
}
|
|
137
164
|
findLine(p) {
|
|
138
165
|
checkFunction('findLine')
|
|
139
166
|
.checkArgument('this')
|
package/dist/esm/DPoint.js
CHANGED
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
|
+
};
|
|
12
23
|
var __read = (this && this.__read) || function (o, n) {
|
|
13
24
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
25
|
if (!m) return o;
|
|
@@ -60,10 +71,19 @@ var DPoint = (function () {
|
|
|
60
71
|
if (lat && lng) {
|
|
61
72
|
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
62
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
|
+
}
|
|
63
78
|
var t = c;
|
|
64
79
|
if (c.type === 'Point') {
|
|
65
80
|
t = c.coordinates;
|
|
66
81
|
}
|
|
82
|
+
if (c.type === 'Feature') {
|
|
83
|
+
var f = DPoint.parse(c.geometry, format);
|
|
84
|
+
f.properties = __assign({}, c.properties);
|
|
85
|
+
return f;
|
|
86
|
+
}
|
|
67
87
|
return format.replace(/[^x-z]/gmiu, '')
|
|
68
88
|
.split('')
|
|
69
89
|
.reduce(function (a, k, index) {
|
|
@@ -170,6 +190,14 @@ var DPoint = (function () {
|
|
|
170
190
|
coordinates: this.toCoords(format)
|
|
171
191
|
};
|
|
172
192
|
};
|
|
193
|
+
DPoint.prototype.toGeoJSONFeature = function (format) {
|
|
194
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
195
|
+
return {
|
|
196
|
+
type: 'Feature',
|
|
197
|
+
properties: __assign({}, this.properties),
|
|
198
|
+
geometry: this.toGeoJSON(format)
|
|
199
|
+
};
|
|
200
|
+
};
|
|
173
201
|
DPoint.prototype.findLine = function (p) {
|
|
174
202
|
checkFunction('findLine')
|
|
175
203
|
.checkArgument('this')
|