dgeoutils 2.4.14 → 2.4.15
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 +2 -6
- package/dist/cjs/DPoint.js +9 -9
- package/dist/cjs/DPolygon.d.ts +2 -2
- package/dist/cjs/DPolygon.js +13 -6
- package/dist/cjs/utils.d.ts +8 -4
- package/dist/cjs/utils.js +11 -4
- package/dist/es2015/DPoint.js +8 -9
- package/dist/es2015/DPolygon.js +14 -7
- package/dist/es2015/utils.js +17 -4
- package/dist/esm/DPoint.js +10 -10
- package/dist/esm/DPolygon.js +14 -7
- package/dist/esm/utils.js +11 -4
- package/dist/umd/dgeoutils.js +34 -20
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/DPoint.d.ts
CHANGED
|
@@ -19,9 +19,7 @@ export declare class DPoint {
|
|
|
19
19
|
x: number;
|
|
20
20
|
y: number;
|
|
21
21
|
z?: number | undefined;
|
|
22
|
-
properties:
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
};
|
|
22
|
+
properties: Record<string, any>;
|
|
25
23
|
constructor();
|
|
26
24
|
constructor(xy: number);
|
|
27
25
|
constructor(x: number, y: number);
|
|
@@ -119,9 +117,7 @@ export declare class DPoint {
|
|
|
119
117
|
set lon(v: number);
|
|
120
118
|
get alt(): number | undefined;
|
|
121
119
|
set alt(v: number | undefined);
|
|
122
|
-
simple(xKey?: string, yKey?: string):
|
|
123
|
-
[key: string]: number;
|
|
124
|
-
};
|
|
120
|
+
simple<T extends Record<string, number>>(xKey?: string, yKey?: string, zKey?: string): T;
|
|
125
121
|
setIfLessThan(p: DPoint): DPoint;
|
|
126
122
|
minus(): DPoint;
|
|
127
123
|
orthodromicPath(point: DPoint, pointsCount?: number): DPolygon;
|
package/dist/cjs/DPoint.js
CHANGED
|
@@ -58,7 +58,7 @@ var DPoint = (function () {
|
|
|
58
58
|
return new DPoint();
|
|
59
59
|
};
|
|
60
60
|
DPoint.parse = function (c, format) {
|
|
61
|
-
if (format === void 0) { format =
|
|
61
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
62
62
|
var _a = c, lat = _a.lat, lon = _a.lon, _b = _a.lng, lng = _b === void 0 ? lon : _b, alt = _a.alt;
|
|
63
63
|
if (lat && lng) {
|
|
64
64
|
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
@@ -157,7 +157,7 @@ var DPoint = (function () {
|
|
|
157
157
|
};
|
|
158
158
|
DPoint.prototype.toCoords = function (format) {
|
|
159
159
|
var _this = this;
|
|
160
|
-
if (format === void 0) { format =
|
|
160
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
161
161
|
return format.replace(/[^x-z]/gmiu, '').split('')
|
|
162
162
|
.map(function (k) { return ({
|
|
163
163
|
x: _this.x,
|
|
@@ -167,7 +167,7 @@ var DPoint = (function () {
|
|
|
167
167
|
.filter(function (r) { return r !== undefined; });
|
|
168
168
|
};
|
|
169
169
|
DPoint.prototype.toGeoJSON = function (format) {
|
|
170
|
-
if (format === void 0) { format =
|
|
170
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
171
171
|
return {
|
|
172
172
|
type: 'Point',
|
|
173
173
|
coordinates: this.toCoords(format)
|
|
@@ -691,14 +691,14 @@ var DPoint = (function () {
|
|
|
691
691
|
enumerable: false,
|
|
692
692
|
configurable: true
|
|
693
693
|
});
|
|
694
|
-
DPoint.prototype.simple = function (xKey, yKey) {
|
|
695
|
-
var _a;
|
|
694
|
+
DPoint.prototype.simple = function (xKey, yKey, zKey) {
|
|
695
|
+
var _a, _b;
|
|
696
696
|
if (xKey === void 0) { xKey = 'x'; }
|
|
697
697
|
if (yKey === void 0) { yKey = 'y'; }
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
698
|
+
if (zKey === void 0) { zKey = 'z'; }
|
|
699
|
+
return __assign((_a = {}, _a[xKey] = this.x, _a[yKey] = this.y, _a), ((0, utils_1.isDefAndNotNull)(this.z) ? (_b = {},
|
|
700
|
+
_b[zKey] = this.z,
|
|
701
|
+
_b) : {}));
|
|
702
702
|
};
|
|
703
703
|
DPoint.prototype.setIfLessThan = function (p) {
|
|
704
704
|
this.x = Math.max(this.x, p.x);
|
package/dist/cjs/DPolygon.d.ts
CHANGED
|
@@ -94,13 +94,13 @@ export declare class DPolygon {
|
|
|
94
94
|
onBorder(p: DPoint): boolean;
|
|
95
95
|
nextStart(): DPolygon;
|
|
96
96
|
removeDuplicates(): DPolygon;
|
|
97
|
-
static toGeoJSONFeatureCollection(polygons: DPolygon[], format?: string): FeatureCollection<LineString | Polygon
|
|
97
|
+
static toGeoJSONFeatureCollection(polygons: DPolygon[], format?: string): FeatureCollection<LineString | Polygon>;
|
|
98
98
|
static parse(a: LatLng[], format?: string): DPolygon;
|
|
99
99
|
static parse(a: number[][], format?: string): DPolygon;
|
|
100
100
|
static parse(a: DCoord[], format?: string): DPolygon;
|
|
101
101
|
static parse(a: GeoJsonGeometry | Feature | FeatureCollection<LineString | Polygon>, format?: string): DPolygon | DeepArray<DPolygon>;
|
|
102
102
|
toArrayOfCoords(format?: string): DCoord[];
|
|
103
|
-
toGeoJSONFeature(format?: string): Feature<LineString | Polygon
|
|
103
|
+
toGeoJSONFeature(format?: string): Feature<LineString | Polygon>;
|
|
104
104
|
toGeoJSON(format?: string): LineString | Polygon;
|
|
105
105
|
divideToPieces(piecesCount: number, withAltitude?: boolean): DPolygon;
|
|
106
106
|
prepareToFastSearch(): void;
|
package/dist/cjs/DPolygon.js
CHANGED
|
@@ -967,14 +967,14 @@ var DPolygon = (function () {
|
|
|
967
967
|
return this;
|
|
968
968
|
};
|
|
969
969
|
DPolygon.toGeoJSONFeatureCollection = function (polygons, format) {
|
|
970
|
-
if (format === void 0) { format =
|
|
970
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
971
971
|
return {
|
|
972
972
|
type: 'FeatureCollection',
|
|
973
973
|
features: polygons.map(function (polygon) { return polygon.toGeoJSONFeature(format); })
|
|
974
974
|
};
|
|
975
975
|
};
|
|
976
976
|
DPolygon.parse = function (a, format) {
|
|
977
|
-
if (format === void 0) { format =
|
|
977
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
978
978
|
if (a.type) {
|
|
979
979
|
switch (a.type) {
|
|
980
980
|
case 'FeatureCollection':
|
|
@@ -990,7 +990,14 @@ var DPolygon = (function () {
|
|
|
990
990
|
}, []);
|
|
991
991
|
case 'Feature': {
|
|
992
992
|
var t = DPolygon.parse(a.geometry, format);
|
|
993
|
-
|
|
993
|
+
if (Array.isArray(t)) {
|
|
994
|
+
t.forEach(function (record) {
|
|
995
|
+
record.properties = __assign(__assign({}, a.properties), { id: a.id });
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
t.properties = __assign(__assign({}, a.properties), { id: a.id });
|
|
1000
|
+
}
|
|
994
1001
|
return t;
|
|
995
1002
|
}
|
|
996
1003
|
case 'LineString':
|
|
@@ -1031,11 +1038,11 @@ var DPolygon = (function () {
|
|
|
1031
1038
|
.map(function (r) { return DPoint_1.DPoint.parse(r, format); }));
|
|
1032
1039
|
};
|
|
1033
1040
|
DPolygon.prototype.toArrayOfCoords = function (format) {
|
|
1034
|
-
if (format === void 0) { format =
|
|
1041
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
1035
1042
|
return this.mapArray(function (r) { return r.toCoords(format); });
|
|
1036
1043
|
};
|
|
1037
1044
|
DPolygon.prototype.toGeoJSONFeature = function (format) {
|
|
1038
|
-
if (format === void 0) { format =
|
|
1045
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
1039
1046
|
return {
|
|
1040
1047
|
type: 'Feature',
|
|
1041
1048
|
properties: __assign({}, this.properties),
|
|
@@ -1043,7 +1050,7 @@ var DPolygon = (function () {
|
|
|
1043
1050
|
};
|
|
1044
1051
|
};
|
|
1045
1052
|
DPolygon.prototype.toGeoJSON = function (format) {
|
|
1046
|
-
if (format === void 0) { format =
|
|
1053
|
+
if (format === void 0) { format = utils_1.DGeo.parseFormat; }
|
|
1047
1054
|
if (this.closed) {
|
|
1048
1055
|
return {
|
|
1049
1056
|
type: 'Polygon',
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="offscreencanvas" />
|
|
2
2
|
import { DPoint } from './DPoint';
|
|
3
|
-
|
|
3
|
+
interface DGeoInterface {
|
|
4
4
|
DEBUG: boolean;
|
|
5
|
-
|
|
5
|
+
parseFormat: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DGeo: DGeoInterface;
|
|
6
8
|
export declare const warn: (...args: any[]) => void;
|
|
7
9
|
export declare const isDefAndNotNull: (a: any) => boolean;
|
|
8
10
|
declare type CheckFunc = (p: DPoint) => CheckFunction;
|
|
@@ -19,8 +21,10 @@ interface CheckFunction {
|
|
|
19
21
|
checkArgument: (argName: string) => CheckArgument;
|
|
20
22
|
}
|
|
21
23
|
export declare const checkFunction: (funcName: string) => CheckFunction;
|
|
22
|
-
|
|
23
|
-
export declare const
|
|
24
|
+
declare type ArrayFillFunction<T> = (index: number) => T;
|
|
25
|
+
export declare const createArray: <T = number>(v: number, fillSymbol?: T | ArrayFillFunction<T> | undefined) => T[];
|
|
26
|
+
declare type MatrixFillFunction<T> = (x: number, y: number) => T;
|
|
27
|
+
export declare const createMatrix: <T>({ h, w }: DPoint, fillSymbol?: T | MatrixFillFunction<T> | undefined) => T[][];
|
|
24
28
|
export declare const gaussianElimination: {
|
|
25
29
|
(matrix: number[][]): number[];
|
|
26
30
|
MIN: number;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -28,7 +28,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
exports.div = exports.getCombinations = exports.cartesianProduct = exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
|
|
29
29
|
var DPoint_1 = require("./DPoint");
|
|
30
30
|
exports.DGeo = {
|
|
31
|
-
DEBUG: false
|
|
31
|
+
DEBUG: false,
|
|
32
|
+
parseFormat: 'xyz'
|
|
32
33
|
};
|
|
33
34
|
var warn = function () {
|
|
34
35
|
var args = [];
|
|
@@ -105,13 +106,19 @@ var checkFunction = function (funcName) { return ({
|
|
|
105
106
|
}); };
|
|
106
107
|
exports.checkFunction = checkFunction;
|
|
107
108
|
var createArray = function (v, fillSymbol) {
|
|
108
|
-
if (fillSymbol ===
|
|
109
|
-
|
|
109
|
+
if (typeof fillSymbol === 'function') {
|
|
110
|
+
return new Array(v).fill(false)
|
|
111
|
+
.map(function (_, i) { return fillSymbol(i); });
|
|
112
|
+
}
|
|
113
|
+
return new Array(v).fill(fillSymbol !== null && fillSymbol !== void 0 ? fillSymbol : 0);
|
|
110
114
|
};
|
|
111
115
|
exports.createArray = createArray;
|
|
112
116
|
var createMatrix = function (_a, fillSymbol) {
|
|
113
117
|
var h = _a.h, w = _a.w;
|
|
114
|
-
if (fillSymbol ===
|
|
118
|
+
if (typeof fillSymbol === 'function') {
|
|
119
|
+
return (0, exports.createArray)(h)
|
|
120
|
+
.map(function (_, y) { return (0, exports.createArray)(w, function (x) { return fillSymbol(x, y); }); });
|
|
121
|
+
}
|
|
115
122
|
return (0, exports.createArray)(h)
|
|
116
123
|
.map(function () { return (0, exports.createArray)(w, fillSymbol); });
|
|
117
124
|
};
|
package/dist/es2015/DPoint.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DLine } from './DLine';
|
|
2
2
|
import { DPolygon } from './DPolygon';
|
|
3
|
-
import { checkFunction, createArray, div, isDefAndNotNull } from './utils';
|
|
3
|
+
import { checkFunction, createArray, DGeo, div, isDefAndNotNull } from './utils';
|
|
4
4
|
const diff = 0;
|
|
5
5
|
const radiansPolygon = new DPolygon();
|
|
6
6
|
const pseudoMercatorPolygon = new DPolygon();
|
|
@@ -25,7 +25,7 @@ export class DPoint {
|
|
|
25
25
|
static zero() {
|
|
26
26
|
return new DPoint();
|
|
27
27
|
}
|
|
28
|
-
static parse(c, format =
|
|
28
|
+
static parse(c, format = DGeo.parseFormat) {
|
|
29
29
|
const { lat, lon, lng = lon, alt } = c;
|
|
30
30
|
if (lat && lng) {
|
|
31
31
|
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
@@ -119,7 +119,7 @@ export class DPoint {
|
|
|
119
119
|
const y = PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
|
|
120
120
|
return new DPoint(x, y, zoom);
|
|
121
121
|
}
|
|
122
|
-
toCoords(format =
|
|
122
|
+
toCoords(format = DGeo.parseFormat) {
|
|
123
123
|
return format.replace(/[^x-z]/gmiu, '').split('')
|
|
124
124
|
.map((k) => ({
|
|
125
125
|
x: this.x,
|
|
@@ -128,7 +128,7 @@ export class DPoint {
|
|
|
128
128
|
})[k])
|
|
129
129
|
.filter((r) => r !== undefined);
|
|
130
130
|
}
|
|
131
|
-
toGeoJSON(format =
|
|
131
|
+
toGeoJSON(format = DGeo.parseFormat) {
|
|
132
132
|
return {
|
|
133
133
|
type: 'Point',
|
|
134
134
|
coordinates: this.toCoords(format)
|
|
@@ -573,11 +573,10 @@ export class DPoint {
|
|
|
573
573
|
set alt(v) {
|
|
574
574
|
this.z = v;
|
|
575
575
|
}
|
|
576
|
-
simple(xKey = 'x', yKey = 'y') {
|
|
577
|
-
return {
|
|
578
|
-
[
|
|
579
|
-
|
|
580
|
-
};
|
|
576
|
+
simple(xKey = 'x', yKey = 'y', zKey = 'z') {
|
|
577
|
+
return Object.assign({ [xKey]: this.x, [yKey]: this.y }, (isDefAndNotNull(this.z) ? {
|
|
578
|
+
[zKey]: this.z
|
|
579
|
+
} : {}));
|
|
581
580
|
}
|
|
582
581
|
setIfLessThan(p) {
|
|
583
582
|
this.x = Math.max(this.x, p.x);
|
package/dist/es2015/DPolygon.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DCircle } from './DCircle';
|
|
|
4
4
|
import { DNumbers } from './DNumbers';
|
|
5
5
|
import { io as jstsIo, operation } from 'jsts';
|
|
6
6
|
import { DPolygonLoop } from './DPolygonLoop';
|
|
7
|
-
import { isDefAndNotNull } from './utils';
|
|
7
|
+
import { DGeo, isDefAndNotNull } from './utils';
|
|
8
8
|
const { buffer: { BufferParameters: { CAP_ROUND, CAP_FLAT, CAP_SQUARE } } } = operation;
|
|
9
9
|
export const MIN_POINTS_IN_VALID_POLYGON = 3;
|
|
10
10
|
const APPROXIMATION_VALUE = 0.1;
|
|
@@ -618,13 +618,13 @@ export class DPolygon {
|
|
|
618
618
|
}
|
|
619
619
|
return this;
|
|
620
620
|
}
|
|
621
|
-
static toGeoJSONFeatureCollection(polygons, format =
|
|
621
|
+
static toGeoJSONFeatureCollection(polygons, format = DGeo.parseFormat) {
|
|
622
622
|
return {
|
|
623
623
|
type: 'FeatureCollection',
|
|
624
624
|
features: polygons.map((polygon) => polygon.toGeoJSONFeature(format))
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
|
-
static parse(a, format =
|
|
627
|
+
static parse(a, format = DGeo.parseFormat) {
|
|
628
628
|
if (a.type) {
|
|
629
629
|
switch (a.type) {
|
|
630
630
|
case 'FeatureCollection':
|
|
@@ -640,7 +640,14 @@ export class DPolygon {
|
|
|
640
640
|
}, []);
|
|
641
641
|
case 'Feature': {
|
|
642
642
|
const t = DPolygon.parse(a.geometry, format);
|
|
643
|
-
|
|
643
|
+
if (Array.isArray(t)) {
|
|
644
|
+
t.forEach((record) => {
|
|
645
|
+
record.properties = Object.assign(Object.assign({}, a.properties), { id: a.id });
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
t.properties = Object.assign(Object.assign({}, a.properties), { id: a.id });
|
|
650
|
+
}
|
|
644
651
|
return t;
|
|
645
652
|
}
|
|
646
653
|
case 'LineString':
|
|
@@ -680,17 +687,17 @@ export class DPolygon {
|
|
|
680
687
|
return new DPolygon(a
|
|
681
688
|
.map((r) => DPoint.parse(r, format)));
|
|
682
689
|
}
|
|
683
|
-
toArrayOfCoords(format =
|
|
690
|
+
toArrayOfCoords(format = DGeo.parseFormat) {
|
|
684
691
|
return this.mapArray((r) => r.toCoords(format));
|
|
685
692
|
}
|
|
686
|
-
toGeoJSONFeature(format =
|
|
693
|
+
toGeoJSONFeature(format = DGeo.parseFormat) {
|
|
687
694
|
return {
|
|
688
695
|
type: 'Feature',
|
|
689
696
|
properties: Object.assign({}, this.properties),
|
|
690
697
|
geometry: this.toGeoJSON(format)
|
|
691
698
|
};
|
|
692
699
|
}
|
|
693
|
-
toGeoJSON(format =
|
|
700
|
+
toGeoJSON(format = DGeo.parseFormat) {
|
|
694
701
|
if (this.closed) {
|
|
695
702
|
return {
|
|
696
703
|
type: 'Polygon',
|
package/dist/es2015/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DPoint } from './DPoint';
|
|
2
2
|
export const DGeo = {
|
|
3
|
-
DEBUG: false
|
|
3
|
+
DEBUG: false,
|
|
4
|
+
parseFormat: 'xyz'
|
|
4
5
|
};
|
|
5
6
|
export const warn = (...args) => {
|
|
6
7
|
if (DGeo.DEBUG) {
|
|
@@ -69,9 +70,21 @@ export const checkFunction = (funcName) => ({
|
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
|
-
export const createArray = (v, fillSymbol
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
export const createArray = (v, fillSymbol) => {
|
|
74
|
+
if (typeof fillSymbol === 'function') {
|
|
75
|
+
return new Array(v).fill(false)
|
|
76
|
+
.map((_, i) => fillSymbol(i));
|
|
77
|
+
}
|
|
78
|
+
return new Array(v).fill(fillSymbol !== null && fillSymbol !== void 0 ? fillSymbol : 0);
|
|
79
|
+
};
|
|
80
|
+
export const createMatrix = ({ h, w }, fillSymbol) => {
|
|
81
|
+
if (typeof fillSymbol === 'function') {
|
|
82
|
+
return createArray(h)
|
|
83
|
+
.map((_, y) => createArray(w, (x) => fillSymbol(x, y)));
|
|
84
|
+
}
|
|
85
|
+
return createArray(h)
|
|
86
|
+
.map(() => createArray(w, fillSymbol));
|
|
87
|
+
};
|
|
75
88
|
export const gaussianElimination = (matrix) => {
|
|
76
89
|
const n = matrix.length;
|
|
77
90
|
const matrixClone = createMatrix(new DPoint(n + 1, n));
|
package/dist/esm/DPoint.js
CHANGED
|
@@ -27,7 +27,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
27
27
|
};
|
|
28
28
|
import { DLine } from './DLine';
|
|
29
29
|
import { DPolygon } from './DPolygon';
|
|
30
|
-
import { checkFunction, createArray, div, isDefAndNotNull } from './utils';
|
|
30
|
+
import { checkFunction, createArray, DGeo, div, isDefAndNotNull } from './utils';
|
|
31
31
|
var diff = 0;
|
|
32
32
|
var radiansPolygon = new DPolygon();
|
|
33
33
|
var pseudoMercatorPolygon = new DPolygon();
|
|
@@ -55,7 +55,7 @@ var DPoint = (function () {
|
|
|
55
55
|
return new DPoint();
|
|
56
56
|
};
|
|
57
57
|
DPoint.parse = function (c, format) {
|
|
58
|
-
if (format === void 0) { format =
|
|
58
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
59
59
|
var _a = c, lat = _a.lat, lon = _a.lon, _b = _a.lng, lng = _b === void 0 ? lon : _b, alt = _a.alt;
|
|
60
60
|
if (lat && lng) {
|
|
61
61
|
return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
|
|
@@ -154,7 +154,7 @@ var DPoint = (function () {
|
|
|
154
154
|
};
|
|
155
155
|
DPoint.prototype.toCoords = function (format) {
|
|
156
156
|
var _this = this;
|
|
157
|
-
if (format === void 0) { format =
|
|
157
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
158
158
|
return format.replace(/[^x-z]/gmiu, '').split('')
|
|
159
159
|
.map(function (k) { return ({
|
|
160
160
|
x: _this.x,
|
|
@@ -164,7 +164,7 @@ var DPoint = (function () {
|
|
|
164
164
|
.filter(function (r) { return r !== undefined; });
|
|
165
165
|
};
|
|
166
166
|
DPoint.prototype.toGeoJSON = function (format) {
|
|
167
|
-
if (format === void 0) { format =
|
|
167
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
168
168
|
return {
|
|
169
169
|
type: 'Point',
|
|
170
170
|
coordinates: this.toCoords(format)
|
|
@@ -688,14 +688,14 @@ var DPoint = (function () {
|
|
|
688
688
|
enumerable: false,
|
|
689
689
|
configurable: true
|
|
690
690
|
});
|
|
691
|
-
DPoint.prototype.simple = function (xKey, yKey) {
|
|
692
|
-
var _a;
|
|
691
|
+
DPoint.prototype.simple = function (xKey, yKey, zKey) {
|
|
692
|
+
var _a, _b;
|
|
693
693
|
if (xKey === void 0) { xKey = 'x'; }
|
|
694
694
|
if (yKey === void 0) { yKey = 'y'; }
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
695
|
+
if (zKey === void 0) { zKey = 'z'; }
|
|
696
|
+
return __assign((_a = {}, _a[xKey] = this.x, _a[yKey] = this.y, _a), (isDefAndNotNull(this.z) ? (_b = {},
|
|
697
|
+
_b[zKey] = this.z,
|
|
698
|
+
_b) : {}));
|
|
699
699
|
};
|
|
700
700
|
DPoint.prototype.setIfLessThan = function (p) {
|
|
701
701
|
this.x = Math.max(this.x, p.x);
|
package/dist/esm/DPolygon.js
CHANGED
|
@@ -78,7 +78,7 @@ import { DCircle } from './DCircle';
|
|
|
78
78
|
import { DNumbers } from './DNumbers';
|
|
79
79
|
import { io as jstsIo, operation } from 'jsts';
|
|
80
80
|
import { DPolygonLoop } from './DPolygonLoop';
|
|
81
|
-
import { isDefAndNotNull } from './utils';
|
|
81
|
+
import { DGeo, isDefAndNotNull } from './utils';
|
|
82
82
|
var _a = operation.buffer.BufferParameters, CAP_ROUND = _a.CAP_ROUND, CAP_FLAT = _a.CAP_FLAT, CAP_SQUARE = _a.CAP_SQUARE;
|
|
83
83
|
export var MIN_POINTS_IN_VALID_POLYGON = 3;
|
|
84
84
|
var APPROXIMATION_VALUE = 0.1;
|
|
@@ -964,14 +964,14 @@ var DPolygon = (function () {
|
|
|
964
964
|
return this;
|
|
965
965
|
};
|
|
966
966
|
DPolygon.toGeoJSONFeatureCollection = function (polygons, format) {
|
|
967
|
-
if (format === void 0) { format =
|
|
967
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
968
968
|
return {
|
|
969
969
|
type: 'FeatureCollection',
|
|
970
970
|
features: polygons.map(function (polygon) { return polygon.toGeoJSONFeature(format); })
|
|
971
971
|
};
|
|
972
972
|
};
|
|
973
973
|
DPolygon.parse = function (a, format) {
|
|
974
|
-
if (format === void 0) { format =
|
|
974
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
975
975
|
if (a.type) {
|
|
976
976
|
switch (a.type) {
|
|
977
977
|
case 'FeatureCollection':
|
|
@@ -987,7 +987,14 @@ var DPolygon = (function () {
|
|
|
987
987
|
}, []);
|
|
988
988
|
case 'Feature': {
|
|
989
989
|
var t = DPolygon.parse(a.geometry, format);
|
|
990
|
-
|
|
990
|
+
if (Array.isArray(t)) {
|
|
991
|
+
t.forEach(function (record) {
|
|
992
|
+
record.properties = __assign(__assign({}, a.properties), { id: a.id });
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
else {
|
|
996
|
+
t.properties = __assign(__assign({}, a.properties), { id: a.id });
|
|
997
|
+
}
|
|
991
998
|
return t;
|
|
992
999
|
}
|
|
993
1000
|
case 'LineString':
|
|
@@ -1028,11 +1035,11 @@ var DPolygon = (function () {
|
|
|
1028
1035
|
.map(function (r) { return DPoint.parse(r, format); }));
|
|
1029
1036
|
};
|
|
1030
1037
|
DPolygon.prototype.toArrayOfCoords = function (format) {
|
|
1031
|
-
if (format === void 0) { format =
|
|
1038
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
1032
1039
|
return this.mapArray(function (r) { return r.toCoords(format); });
|
|
1033
1040
|
};
|
|
1034
1041
|
DPolygon.prototype.toGeoJSONFeature = function (format) {
|
|
1035
|
-
if (format === void 0) { format =
|
|
1042
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
1036
1043
|
return {
|
|
1037
1044
|
type: 'Feature',
|
|
1038
1045
|
properties: __assign({}, this.properties),
|
|
@@ -1040,7 +1047,7 @@ var DPolygon = (function () {
|
|
|
1040
1047
|
};
|
|
1041
1048
|
};
|
|
1042
1049
|
DPolygon.prototype.toGeoJSON = function (format) {
|
|
1043
|
-
if (format === void 0) { format =
|
|
1050
|
+
if (format === void 0) { format = DGeo.parseFormat; }
|
|
1044
1051
|
if (this.closed) {
|
|
1045
1052
|
return {
|
|
1046
1053
|
type: 'Polygon',
|
package/dist/esm/utils.js
CHANGED
|
@@ -25,7 +25,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
25
25
|
};
|
|
26
26
|
import { DPoint } from './DPoint';
|
|
27
27
|
export var DGeo = {
|
|
28
|
-
DEBUG: false
|
|
28
|
+
DEBUG: false,
|
|
29
|
+
parseFormat: 'xyz'
|
|
29
30
|
};
|
|
30
31
|
export var warn = function () {
|
|
31
32
|
var args = [];
|
|
@@ -99,12 +100,18 @@ export var checkFunction = function (funcName) { return ({
|
|
|
99
100
|
}
|
|
100
101
|
}); };
|
|
101
102
|
export var createArray = function (v, fillSymbol) {
|
|
102
|
-
if (fillSymbol ===
|
|
103
|
-
|
|
103
|
+
if (typeof fillSymbol === 'function') {
|
|
104
|
+
return new Array(v).fill(false)
|
|
105
|
+
.map(function (_, i) { return fillSymbol(i); });
|
|
106
|
+
}
|
|
107
|
+
return new Array(v).fill(fillSymbol !== null && fillSymbol !== void 0 ? fillSymbol : 0);
|
|
104
108
|
};
|
|
105
109
|
export var createMatrix = function (_a, fillSymbol) {
|
|
106
110
|
var h = _a.h, w = _a.w;
|
|
107
|
-
if (fillSymbol ===
|
|
111
|
+
if (typeof fillSymbol === 'function') {
|
|
112
|
+
return createArray(h)
|
|
113
|
+
.map(function (_, y) { return createArray(w, function (x) { return fillSymbol(x, y); }); });
|
|
114
|
+
}
|
|
108
115
|
return createArray(h)
|
|
109
116
|
.map(function () { return createArray(w, fillSymbol); });
|
|
110
117
|
};
|