@turf/polygonize 6.4.0 → 7.0.0-alpha.0

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.
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var Node_1 = __importDefault(require("./Node"));
7
- var Edge_1 = __importDefault(require("./Edge"));
8
- var EdgeRing_1 = __importDefault(require("./EdgeRing"));
9
- var meta_1 = require("@turf/meta");
10
- var invariant_1 = require("@turf/invariant");
3
+ const tslib_1 = require("tslib");
4
+ const Node_1 = tslib_1.__importDefault(require("./Node"));
5
+ const Edge_1 = tslib_1.__importDefault(require("./Edge"));
6
+ const EdgeRing_1 = tslib_1.__importDefault(require("./EdgeRing"));
7
+ const meta_1 = require("@turf/meta");
8
+ const invariant_1 = require("@turf/invariant");
11
9
  /**
12
10
  * Validates the geoJson.
13
11
  *
@@ -22,7 +20,7 @@ function validateGeoJson(geoJson) {
22
20
  geoJson.type !== "MultiLineString" &&
23
21
  geoJson.type !== "LineString" &&
24
22
  geoJson.type !== "Feature")
25
- throw new Error("Invalid input type '" + geoJson.type + "'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature");
23
+ throw new Error(`Invalid input type '${geoJson.type}'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature`);
26
24
  }
27
25
  /**
28
26
  * Represents a planar graph of edges and nodes that can be used to compute a polygonization.
@@ -33,8 +31,8 @@ function validateGeoJson(geoJson) {
33
31
  *
34
32
  * This graph is directed (both directions are created)
35
33
  */
36
- var Graph = /** @class */ (function () {
37
- function Graph() {
34
+ class Graph {
35
+ constructor() {
38
36
  this.edges = []; //< {Edge[]} dirEdges
39
37
  // The key is the `id` of the Node (ie: coordinates.join(','))
40
38
  this.nodes = {};
@@ -46,35 +44,35 @@ var Graph = /** @class */ (function () {
46
44
  * @returns {Graph} - The newly created graph
47
45
  * @throws {Error} if geoJson is invalid.
48
46
  */
49
- Graph.fromGeoJson = function (geoJson) {
47
+ static fromGeoJson(geoJson) {
50
48
  validateGeoJson(geoJson);
51
- var graph = new Graph();
52
- meta_1.flattenEach(geoJson, function (feature) {
49
+ const graph = new Graph();
50
+ meta_1.flattenEach(geoJson, (feature) => {
53
51
  invariant_1.featureOf(feature, "LineString", "Graph::fromGeoJson");
54
52
  // When a LineString if formed by many segments, split them
55
- meta_1.coordReduce(feature, function (prev, cur) {
53
+ meta_1.coordReduce(feature, (prev, cur) => {
56
54
  if (prev) {
57
- var start = graph.getNode(prev), end = graph.getNode(cur);
55
+ const start = graph.getNode(prev), end = graph.getNode(cur);
58
56
  graph.addEdge(start, end);
59
57
  }
60
58
  return cur;
61
59
  });
62
60
  });
63
61
  return graph;
64
- };
62
+ }
65
63
  /**
66
64
  * Creates or get a Node.
67
65
  *
68
66
  * @param {number[]} coordinates - Coordinates of the node
69
67
  * @returns {Node} - The created or stored node
70
68
  */
71
- Graph.prototype.getNode = function (coordinates) {
72
- var id = Node_1.default.buildId(coordinates);
73
- var node = this.nodes[id];
69
+ getNode(coordinates) {
70
+ const id = Node_1.default.buildId(coordinates);
71
+ let node = this.nodes[id];
74
72
  if (!node)
75
73
  node = this.nodes[id] = new Node_1.default(coordinates);
76
74
  return node;
77
- };
75
+ }
78
76
  /**
79
77
  * Adds an Edge and its symetricall.
80
78
  *
@@ -83,20 +81,19 @@ var Graph = /** @class */ (function () {
83
81
  * @param {Node} from - Node which starts the Edge
84
82
  * @param {Node} to - Node which ends the Edge
85
83
  */
86
- Graph.prototype.addEdge = function (from, to) {
87
- var edge = new Edge_1.default(from, to), symetricEdge = edge.getSymetric();
84
+ addEdge(from, to) {
85
+ const edge = new Edge_1.default(from, to), symetricEdge = edge.getSymetric();
88
86
  this.edges.push(edge);
89
87
  this.edges.push(symetricEdge);
90
- };
88
+ }
91
89
  /**
92
90
  * Removes Dangle Nodes (nodes with grade 1).
93
91
  */
94
- Graph.prototype.deleteDangles = function () {
95
- var _this = this;
92
+ deleteDangles() {
96
93
  Object.keys(this.nodes)
97
- .map(function (id) { return _this.nodes[id]; })
98
- .forEach(function (node) { return _this._removeIfDangle(node); });
99
- };
94
+ .map((id) => this.nodes[id])
95
+ .forEach((node) => this._removeIfDangle(node));
96
+ }
100
97
  /**
101
98
  * Check if node is dangle, if so, remove it.
102
99
  *
@@ -104,15 +101,14 @@ var Graph = /** @class */ (function () {
104
101
  *
105
102
  * @param {Node} node - Node to check if it's a dangle
106
103
  */
107
- Graph.prototype._removeIfDangle = function (node) {
108
- var _this = this;
104
+ _removeIfDangle(node) {
109
105
  // As edges are directed and symetrical, we count only innerEdges
110
106
  if (node.innerEdges.length <= 1) {
111
- var outerNodes = node.getOuterEdges().map(function (e) { return e.to; });
107
+ const outerNodes = node.getOuterEdges().map((e) => e.to);
112
108
  this.removeNode(node);
113
- outerNodes.forEach(function (n) { return _this._removeIfDangle(n); });
109
+ outerNodes.forEach((n) => this._removeIfDangle(n));
114
110
  }
115
- };
111
+ }
116
112
  /**
117
113
  * Delete cut-edges (bridge edges).
118
114
  *
@@ -120,18 +116,17 @@ var Graph = /** @class */ (function () {
120
116
  * in which they are. (The label is a number incremented by 1). Edges with the same
121
117
  * label are cut-edges.
122
118
  */
123
- Graph.prototype.deleteCutEdges = function () {
124
- var _this = this;
119
+ deleteCutEdges() {
125
120
  this._computeNextCWEdges();
126
121
  this._findLabeledEdgeRings();
127
122
  // Cut-edges (bridges) are edges where both edges have the same label
128
- this.edges.forEach(function (edge) {
123
+ this.edges.forEach((edge) => {
129
124
  if (edge.label === edge.symetric.label) {
130
- _this.removeEdge(edge.symetric);
131
- _this.removeEdge(edge);
125
+ this.removeEdge(edge.symetric);
126
+ this.removeEdge(edge);
132
127
  }
133
128
  });
134
- };
129
+ }
135
130
  /**
136
131
  * Set the `next` property of each Edge.
137
132
  *
@@ -140,19 +135,16 @@ var Graph = /** @class */ (function () {
140
135
  *
141
136
  * @param {Node} [node] - If no node is passed, the function calls itself for every node in the Graph
142
137
  */
143
- Graph.prototype._computeNextCWEdges = function (node) {
144
- var _this = this;
138
+ _computeNextCWEdges(node) {
145
139
  if (typeof node === "undefined") {
146
- Object.keys(this.nodes).forEach(function (id) {
147
- return _this._computeNextCWEdges(_this.nodes[id]);
148
- });
140
+ Object.keys(this.nodes).forEach((id) => this._computeNextCWEdges(this.nodes[id]));
149
141
  }
150
142
  else {
151
- node.getOuterEdges().forEach(function (edge, i) {
143
+ node.getOuterEdges().forEach((edge, i) => {
152
144
  node.getOuterEdge((i === 0 ? node.getOuterEdges().length : i) - 1).symetric.next = edge;
153
145
  });
154
146
  }
155
- };
147
+ }
156
148
  /**
157
149
  * Computes the next edge pointers going CCW around the given node, for the given edgering label.
158
150
  *
@@ -164,11 +156,11 @@ var Graph = /** @class */ (function () {
164
156
  * @param {Node} node - Node
165
157
  * @param {number} label - Ring's label
166
158
  */
167
- Graph.prototype._computeNextCCWEdges = function (node, label) {
168
- var edges = node.getOuterEdges();
169
- var firstOutDE, prevInDE;
170
- for (var i = edges.length - 1; i >= 0; --i) {
171
- var de = edges[i], sym = de.symetric, outDE = void 0, inDE = void 0;
159
+ _computeNextCCWEdges(node, label) {
160
+ const edges = node.getOuterEdges();
161
+ let firstOutDE, prevInDE;
162
+ for (let i = edges.length - 1; i >= 0; --i) {
163
+ let de = edges[i], sym = de.symetric, outDE, inDE;
172
164
  if (de.label === label)
173
165
  outDE = de;
174
166
  if (sym.label === label)
@@ -189,7 +181,7 @@ var Graph = /** @class */ (function () {
189
181
  }
190
182
  if (prevInDE)
191
183
  prevInDE.next = firstOutDE;
192
- };
184
+ }
193
185
  /**
194
186
  * Finds rings and labels edges according to which rings are.
195
187
  *
@@ -197,14 +189,14 @@ var Graph = /** @class */ (function () {
197
189
  *
198
190
  * @returns {Edge[]} edges that start rings
199
191
  */
200
- Graph.prototype._findLabeledEdgeRings = function () {
201
- var edgeRingStarts = [];
202
- var label = 0;
203
- this.edges.forEach(function (edge) {
192
+ _findLabeledEdgeRings() {
193
+ const edgeRingStarts = [];
194
+ let label = 0;
195
+ this.edges.forEach((edge) => {
204
196
  if (edge.label >= 0)
205
197
  return;
206
198
  edgeRingStarts.push(edge);
207
- var e = edge;
199
+ let e = edge;
208
200
  do {
209
201
  e.label = label;
210
202
  e = e.next;
@@ -212,96 +204,90 @@ var Graph = /** @class */ (function () {
212
204
  label++;
213
205
  });
214
206
  return edgeRingStarts;
215
- };
207
+ }
216
208
  /**
217
209
  * Computes the EdgeRings formed by the edges in this graph.
218
210
  *
219
211
  * @returns {EdgeRing[]} - A list of all the EdgeRings in the graph.
220
212
  */
221
- Graph.prototype.getEdgeRings = function () {
222
- var _this = this;
213
+ getEdgeRings() {
223
214
  this._computeNextCWEdges();
224
215
  // Clear labels
225
- this.edges.forEach(function (edge) {
216
+ this.edges.forEach((edge) => {
226
217
  edge.label = undefined;
227
218
  });
228
- this._findLabeledEdgeRings().forEach(function (edge) {
219
+ this._findLabeledEdgeRings().forEach((edge) => {
229
220
  // convertMaximalToMinimalEdgeRings
230
- _this._findIntersectionNodes(edge).forEach(function (node) {
231
- _this._computeNextCCWEdges(node, edge.label);
221
+ this._findIntersectionNodes(edge).forEach((node) => {
222
+ this._computeNextCCWEdges(node, edge.label);
232
223
  });
233
224
  });
234
- var edgeRingList = [];
225
+ const edgeRingList = [];
235
226
  // find all edgerings
236
- this.edges.forEach(function (edge) {
227
+ this.edges.forEach((edge) => {
237
228
  if (edge.ring)
238
229
  return;
239
- edgeRingList.push(_this._findEdgeRing(edge));
230
+ edgeRingList.push(this._findEdgeRing(edge));
240
231
  });
241
232
  return edgeRingList;
242
- };
233
+ }
243
234
  /**
244
235
  * Find all nodes in a Maxima EdgeRing which are self-intersection nodes.
245
236
  *
246
237
  * @param {Node} startEdge - Start Edge of the Ring
247
238
  * @returns {Node[]} - intersection nodes
248
239
  */
249
- Graph.prototype._findIntersectionNodes = function (startEdge) {
250
- var intersectionNodes = [];
251
- var edge = startEdge;
252
- var _loop_1 = function () {
240
+ _findIntersectionNodes(startEdge) {
241
+ const intersectionNodes = [];
242
+ let edge = startEdge;
243
+ do {
253
244
  // getDegree
254
- var degree = 0;
255
- edge.from.getOuterEdges().forEach(function (e) {
245
+ let degree = 0;
246
+ edge.from.getOuterEdges().forEach((e) => {
256
247
  if (e.label === startEdge.label)
257
248
  ++degree;
258
249
  });
259
250
  if (degree > 1)
260
251
  intersectionNodes.push(edge.from);
261
252
  edge = edge.next;
262
- };
263
- do {
264
- _loop_1();
265
253
  } while (!startEdge.isEqual(edge));
266
254
  return intersectionNodes;
267
- };
255
+ }
268
256
  /**
269
257
  * Get the edge-ring which starts from the provided Edge.
270
258
  *
271
259
  * @param {Edge} startEdge - starting edge of the edge ring
272
260
  * @returns {EdgeRing} - EdgeRing which start Edge is the provided one.
273
261
  */
274
- Graph.prototype._findEdgeRing = function (startEdge) {
275
- var edge = startEdge;
276
- var edgeRing = new EdgeRing_1.default();
262
+ _findEdgeRing(startEdge) {
263
+ let edge = startEdge;
264
+ const edgeRing = new EdgeRing_1.default();
277
265
  do {
278
266
  edgeRing.push(edge);
279
267
  edge.ring = edgeRing;
280
268
  edge = edge.next;
281
269
  } while (!startEdge.isEqual(edge));
282
270
  return edgeRing;
283
- };
271
+ }
284
272
  /**
285
273
  * Removes a node from the Graph.
286
274
  *
287
275
  * It also removes edges asociated to that node
288
276
  * @param {Node} node - Node to be removed
289
277
  */
290
- Graph.prototype.removeNode = function (node) {
291
- var _this = this;
292
- node.getOuterEdges().forEach(function (edge) { return _this.removeEdge(edge); });
293
- node.innerEdges.forEach(function (edge) { return _this.removeEdge(edge); });
278
+ removeNode(node) {
279
+ node.getOuterEdges().forEach((edge) => this.removeEdge(edge));
280
+ node.innerEdges.forEach((edge) => this.removeEdge(edge));
294
281
  delete this.nodes[node.id];
295
- };
282
+ }
296
283
  /**
297
284
  * Remove edge from the graph and deletes the edge.
298
285
  *
299
286
  * @param {Edge} edge - Edge to be removed
300
287
  */
301
- Graph.prototype.removeEdge = function (edge) {
302
- this.edges = this.edges.filter(function (e) { return !e.isEqual(edge); });
288
+ removeEdge(edge) {
289
+ this.edges = this.edges.filter((e) => !e.isEqual(edge));
303
290
  edge.deleteEdge();
304
- };
305
- return Graph;
306
- }());
291
+ }
292
+ }
307
293
  exports.default = Graph;
@@ -10,15 +10,15 @@ export default class Node {
10
10
  private outerEdges;
11
11
  private outerEdgesSorted;
12
12
  constructor(coordinates: number[]);
13
- removeInnerEdge(edge: any): void;
14
- removeOuterEdge(edge: any): void;
13
+ removeInnerEdge(edge: Edge): void;
14
+ removeOuterEdge(edge: Edge): void;
15
15
  /**
16
16
  * Outer edges are stored CCW order.
17
17
  *
18
18
  * @memberof Node
19
19
  * @param {Edge} edge - Edge to add as an outerEdge.
20
20
  */
21
- addOuterEdge(edge: any): void;
21
+ addOuterEdge(edge: Edge): void;
22
22
  /**
23
23
  * Sorts outer edges in CCW way.
24
24
  *
@@ -35,6 +35,6 @@ export default class Node {
35
35
  * @returns {Edge[]} - List of outer edges sorted in a CCW order.
36
36
  */
37
37
  getOuterEdges(): Edge[];
38
- getOuterEdge(i: any): Edge;
39
- addInnerEdge(edge: any): void;
38
+ getOuterEdge(i: number): Edge;
39
+ addInnerEdge(edge: Edge): void;
40
40
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var util_1 = require("./util");
3
+ const util_1 = require("./util");
4
4
  /**
5
5
  * Node
6
6
  */
7
- var Node = /** @class */ (function () {
8
- function Node(coordinates) {
7
+ class Node {
8
+ constructor(coordinates) {
9
9
  this.id = Node.buildId(coordinates);
10
10
  this.coordinates = coordinates; //< {Number[]}
11
11
  this.innerEdges = []; //< {Edge[]}
@@ -13,64 +13,63 @@ var Node = /** @class */ (function () {
13
13
  this.outerEdges = []; //< {Edge[]}
14
14
  this.outerEdgesSorted = false; //< {Boolean} flag that stores if the outer Edges had been sorted
15
15
  }
16
- Node.buildId = function (coordinates) {
16
+ static buildId(coordinates) {
17
17
  return coordinates.join(",");
18
- };
19
- Node.prototype.removeInnerEdge = function (edge) {
20
- this.innerEdges = this.innerEdges.filter(function (e) { return e.from.id !== edge.from.id; });
21
- };
22
- Node.prototype.removeOuterEdge = function (edge) {
23
- this.outerEdges = this.outerEdges.filter(function (e) { return e.to.id !== edge.to.id; });
24
- };
18
+ }
19
+ removeInnerEdge(edge) {
20
+ this.innerEdges = this.innerEdges.filter((e) => e.from.id !== edge.from.id);
21
+ }
22
+ removeOuterEdge(edge) {
23
+ this.outerEdges = this.outerEdges.filter((e) => e.to.id !== edge.to.id);
24
+ }
25
25
  /**
26
26
  * Outer edges are stored CCW order.
27
27
  *
28
28
  * @memberof Node
29
29
  * @param {Edge} edge - Edge to add as an outerEdge.
30
30
  */
31
- Node.prototype.addOuterEdge = function (edge) {
31
+ addOuterEdge(edge) {
32
32
  this.outerEdges.push(edge);
33
33
  this.outerEdgesSorted = false;
34
- };
34
+ }
35
35
  /**
36
36
  * Sorts outer edges in CCW way.
37
37
  *
38
38
  * @memberof Node
39
39
  * @private
40
40
  */
41
- Node.prototype.sortOuterEdges = function () {
42
- var _this = this;
41
+ sortOuterEdges() {
43
42
  if (!this.outerEdgesSorted) {
44
43
  //this.outerEdges.sort((a, b) => a.compareTo(b));
45
44
  // Using this comparator in order to be deterministic
46
- this.outerEdges.sort(function (a, b) {
47
- var aNode = a.to, bNode = b.to;
48
- if (aNode.coordinates[0] - _this.coordinates[0] >= 0 &&
49
- bNode.coordinates[0] - _this.coordinates[0] < 0)
45
+ this.outerEdges.sort((a, b) => {
46
+ const aNode = a.to, bNode = b.to;
47
+ if (aNode.coordinates[0] - this.coordinates[0] >= 0 &&
48
+ bNode.coordinates[0] - this.coordinates[0] < 0)
50
49
  return 1;
51
- if (aNode.coordinates[0] - _this.coordinates[0] < 0 &&
52
- bNode.coordinates[0] - _this.coordinates[0] >= 0)
50
+ if (aNode.coordinates[0] - this.coordinates[0] < 0 &&
51
+ bNode.coordinates[0] - this.coordinates[0] >= 0)
53
52
  return -1;
54
- if (aNode.coordinates[0] - _this.coordinates[0] === 0 &&
55
- bNode.coordinates[0] - _this.coordinates[0] === 0) {
56
- if (aNode.coordinates[1] - _this.coordinates[1] >= 0 ||
57
- bNode.coordinates[1] - _this.coordinates[1] >= 0)
53
+ if (aNode.coordinates[0] - this.coordinates[0] === 0 &&
54
+ bNode.coordinates[0] - this.coordinates[0] === 0) {
55
+ if (aNode.coordinates[1] - this.coordinates[1] >= 0 ||
56
+ bNode.coordinates[1] - this.coordinates[1] >= 0)
58
57
  return aNode.coordinates[1] - bNode.coordinates[1];
59
58
  return bNode.coordinates[1] - aNode.coordinates[1];
60
59
  }
61
- var det = util_1.orientationIndex(_this.coordinates, aNode.coordinates, bNode.coordinates);
60
+ const det = util_1.orientationIndex(this.coordinates, aNode.coordinates, bNode.coordinates);
62
61
  if (det < 0)
63
62
  return 1;
64
63
  if (det > 0)
65
64
  return -1;
66
- var d1 = Math.pow(aNode.coordinates[0] - _this.coordinates[0], 2) +
67
- Math.pow(aNode.coordinates[1] - _this.coordinates[1], 2), d2 = Math.pow(bNode.coordinates[0] - _this.coordinates[0], 2) +
68
- Math.pow(bNode.coordinates[1] - _this.coordinates[1], 2);
65
+ const d1 = Math.pow(aNode.coordinates[0] - this.coordinates[0], 2) +
66
+ Math.pow(aNode.coordinates[1] - this.coordinates[1], 2), d2 = Math.pow(bNode.coordinates[0] - this.coordinates[0], 2) +
67
+ Math.pow(bNode.coordinates[1] - this.coordinates[1], 2);
69
68
  return d1 - d2;
70
69
  });
71
70
  this.outerEdgesSorted = true;
72
71
  }
73
- };
72
+ }
74
73
  /**
75
74
  * Retrieves outer edges.
76
75
  *
@@ -79,17 +78,16 @@ var Node = /** @class */ (function () {
79
78
  * @memberof Node
80
79
  * @returns {Edge[]} - List of outer edges sorted in a CCW order.
81
80
  */
82
- Node.prototype.getOuterEdges = function () {
81
+ getOuterEdges() {
83
82
  this.sortOuterEdges();
84
83
  return this.outerEdges;
85
- };
86
- Node.prototype.getOuterEdge = function (i) {
84
+ }
85
+ getOuterEdge(i) {
87
86
  this.sortOuterEdges();
88
87
  return this.outerEdges[i];
89
- };
90
- Node.prototype.addInnerEdge = function (edge) {
88
+ }
89
+ addInnerEdge(edge) {
91
90
  this.innerEdges.push(edge);
92
- };
93
- return Node;
94
- }());
91
+ }
92
+ }
95
93
  exports.default = Node;
@@ -1,3 +1,4 @@
1
+ import { Feature, Polygon } from "geojson";
1
2
  /**
2
3
  * Returns the direction of the point q relative to the vector p1 -> p2.
3
4
  *
@@ -12,7 +13,7 @@
12
13
  * -1 if q is cw (right) from p1->p2,
13
14
  * 0 if q is colinear with p1->p2
14
15
  */
15
- declare function orientationIndex(p1: any, p2: any, q: any): number;
16
+ export declare function orientationIndex(p1: number[], p2: number[], q: number[]): number;
16
17
  /**
17
18
  * Checks if two envelopes are equal.
18
19
  *
@@ -22,7 +23,7 @@ declare function orientationIndex(p1: any, p2: any, q: any): number;
22
23
  * @param {Feature<Polygon>} env2 - Envelope
23
24
  * @returns {boolean} - True if the envelopes are equal
24
25
  */
25
- declare function envelopeIsEqual(env1: any, env2: any): boolean;
26
+ export declare function envelopeIsEqual(env1: Feature<Polygon>, env2: Feature<Polygon>): boolean;
26
27
  /**
27
28
  * Check if a envelope is contained in other one.
28
29
  *
@@ -34,7 +35,7 @@ declare function envelopeIsEqual(env1: any, env2: any): boolean;
34
35
  * @param {Feature<Polygon>} env - Envelope
35
36
  * @returns {boolean} - True if env is contained in self
36
37
  */
37
- declare function envelopeContains(self: any, env: any): any;
38
+ export declare function envelopeContains(self: Feature<Polygon>, env: Feature<Polygon>): boolean;
38
39
  /**
39
40
  * Checks if two coordinates are equal.
40
41
  *
@@ -42,5 +43,4 @@ declare function envelopeContains(self: any, env: any): any;
42
43
  * @param {number[]} coord2 - Second coordinate
43
44
  * @returns {boolean} - True if coordinates are equal
44
45
  */
45
- declare function coordinatesEqual(coord1: any, coord2: any): boolean;
46
- export { orientationIndex, envelopeIsEqual, envelopeContains, coordinatesEqual, };
46
+ export declare function coordinatesEqual(coord1: number[], coord2: number[]): boolean;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var boolean_point_in_polygon_1 = __importDefault(require("@turf/boolean-point-in-polygon"));
7
- var helpers_1 = require("@turf/helpers");
3
+ const tslib_1 = require("tslib");
4
+ const boolean_point_in_polygon_1 = tslib_1.__importDefault(require("@turf/boolean-point-in-polygon"));
5
+ const helpers_1 = require("@turf/helpers");
8
6
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign#Polyfill
9
7
  function mathSign(x) {
10
8
  return ((x > 0) - (x < 0) || +x);
@@ -24,7 +22,7 @@ function mathSign(x) {
24
22
  * 0 if q is colinear with p1->p2
25
23
  */
26
24
  function orientationIndex(p1, p2, q) {
27
- var dx1 = p2[0] - p1[0], dy1 = p2[1] - p1[1], dx2 = q[0] - p2[0], dy2 = q[1] - p2[1];
25
+ const dx1 = p2[0] - p1[0], dy1 = p2[1] - p1[1], dx2 = q[0] - p2[0], dy2 = q[1] - p2[1];
28
26
  return mathSign(dx1 * dy2 - dx2 * dy1);
29
27
  }
30
28
  exports.orientationIndex = orientationIndex;
@@ -38,11 +36,11 @@ exports.orientationIndex = orientationIndex;
38
36
  * @returns {boolean} - True if the envelopes are equal
39
37
  */
40
38
  function envelopeIsEqual(env1, env2) {
41
- var envX1 = env1.geometry.coordinates.map(function (c) { return c[0]; }), envY1 = env1.geometry.coordinates.map(function (c) { return c[1]; }), envX2 = env2.geometry.coordinates.map(function (c) { return c[0]; }), envY2 = env2.geometry.coordinates.map(function (c) { return c[1]; });
42
- return (Math.max(null, envX1) === Math.max(null, envX2) &&
43
- Math.max(null, envY1) === Math.max(null, envY2) &&
44
- Math.min(null, envX1) === Math.min(null, envX2) &&
45
- Math.min(null, envY1) === Math.min(null, envY2));
39
+ const envX1 = env1.geometry.coordinates[0].map((c) => c[0]), envY1 = env1.geometry.coordinates[0].map((c) => c[1]), envX2 = env2.geometry.coordinates[0].map((c) => c[0]), envY2 = env2.geometry.coordinates[0].map((c) => c[1]);
40
+ return (Math.max.apply(null, envX1) === Math.max.apply(null, envX2) &&
41
+ Math.max.apply(null, envY1) === Math.max.apply(null, envY2) &&
42
+ Math.min.apply(null, envX1) === Math.min.apply(null, envX2) &&
43
+ Math.min.apply(null, envY1) === Math.min.apply(null, envY2));
46
44
  }
47
45
  exports.envelopeIsEqual = envelopeIsEqual;
48
46
  /**
@@ -57,9 +55,7 @@ exports.envelopeIsEqual = envelopeIsEqual;
57
55
  * @returns {boolean} - True if env is contained in self
58
56
  */
59
57
  function envelopeContains(self, env) {
60
- return env.geometry.coordinates[0].every(function (c) {
61
- return boolean_point_in_polygon_1.default(helpers_1.point(c), self);
62
- });
58
+ return env.geometry.coordinates[0].every((c) => boolean_point_in_polygon_1.default(helpers_1.point(c), self));
63
59
  }
64
60
  exports.envelopeContains = envelopeContains;
65
61
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/polygonize",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf polygonize module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -16,6 +16,7 @@
16
16
  "type": "git",
17
17
  "url": "git://github.com/Turfjs/turf.git"
18
18
  },
19
+ "funding": "https://opencollective.com/turf",
19
20
  "publishConfig": {
20
21
  "access": "public"
21
22
  },
@@ -47,7 +48,7 @@
47
48
  "docs": "node ../../scripts/generate-readmes",
48
49
  "test": "npm-run-all test:*",
49
50
  "test:tape": "ts-node -r esm test.js",
50
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
51
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
51
52
  },
52
53
  "devDependencies": {
53
54
  "benchmark": "*",
@@ -60,11 +61,12 @@
60
61
  "write-json-file": "*"
61
62
  },
62
63
  "dependencies": {
63
- "@turf/boolean-point-in-polygon": "^6.4.0",
64
- "@turf/envelope": "^6.4.0",
65
- "@turf/helpers": "^6.4.0",
66
- "@turf/invariant": "^6.4.0",
67
- "@turf/meta": "^6.4.0"
64
+ "@turf/boolean-point-in-polygon": "^7.0.0-alpha.0",
65
+ "@turf/envelope": "^7.0.0-alpha.0",
66
+ "@turf/helpers": "^7.0.0-alpha.0",
67
+ "@turf/invariant": "^7.0.0-alpha.0",
68
+ "@turf/meta": "^7.0.0-alpha.0",
69
+ "tslib": "^2.3.0"
68
70
  },
69
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
71
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
70
72
  }