@turf/polygonize 6.5.0 → 7.0.0-alpha.1

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,12 +1,10 @@
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 util_1 = require("./util");
7
- var helpers_1 = require("@turf/helpers");
8
- var envelope_1 = __importDefault(require("@turf/envelope"));
9
- var boolean_point_in_polygon_1 = __importDefault(require("@turf/boolean-point-in-polygon"));
3
+ const tslib_1 = require("tslib");
4
+ const util_1 = require("./util");
5
+ const helpers_1 = require("@turf/helpers");
6
+ const envelope_1 = tslib_1.__importDefault(require("@turf/envelope"));
7
+ const boolean_point_in_polygon_1 = tslib_1.__importDefault(require("@turf/boolean-point-in-polygon"));
10
8
  /**
11
9
  * Ring of edges which form a polygon.
12
10
  *
@@ -14,8 +12,8 @@ var boolean_point_in_polygon_1 = __importDefault(require("@turf/boolean-point-in
14
12
  *
15
13
  * This class is inspired in GEOS's geos::operation::polygonize::EdgeRing
16
14
  */
17
- var EdgeRing = /** @class */ (function () {
18
- function EdgeRing() {
15
+ class EdgeRing {
16
+ constructor() {
19
17
  this.edges = [];
20
18
  this.polygon = undefined; //< Caches Polygon representation
21
19
  this.envelope = undefined; //< Caches Envelope representation
@@ -26,10 +24,10 @@ var EdgeRing = /** @class */ (function () {
26
24
  * @memberof EdgeRing
27
25
  * @param {Edge} edge - Edge to be inserted
28
26
  */
29
- EdgeRing.prototype.push = function (edge) {
27
+ push(edge) {
30
28
  this.edges.push(edge);
31
29
  this.polygon = this.envelope = undefined;
32
- };
30
+ }
33
31
  /**
34
32
  * Get Edge.
35
33
  *
@@ -37,31 +35,27 @@ var EdgeRing = /** @class */ (function () {
37
35
  * @param {number} i - Index
38
36
  * @returns {Edge} - Edge in the i position
39
37
  */
40
- EdgeRing.prototype.get = function (i) {
38
+ get(i) {
41
39
  return this.edges[i];
42
- };
43
- Object.defineProperty(EdgeRing.prototype, "length", {
44
- /**
45
- * Getter of length property.
46
- *
47
- * @memberof EdgeRing
48
- * @returns {number} - Length of the edge ring.
49
- */
50
- get: function () {
51
- return this.edges.length;
52
- },
53
- enumerable: true,
54
- configurable: true
55
- });
40
+ }
41
+ /**
42
+ * Getter of length property.
43
+ *
44
+ * @memberof EdgeRing
45
+ * @returns {number} - Length of the edge ring.
46
+ */
47
+ get length() {
48
+ return this.edges.length;
49
+ }
56
50
  /**
57
51
  * Similar to Array.prototype.forEach for the list of Edges in the EdgeRing.
58
52
  *
59
53
  * @memberof EdgeRing
60
54
  * @param {Function} f - The same function to be passed to Array.prototype.forEach
61
55
  */
62
- EdgeRing.prototype.forEach = function (f) {
56
+ forEach(f) {
63
57
  this.edges.forEach(f);
64
- };
58
+ }
65
59
  /**
66
60
  * Similar to Array.prototype.map for the list of Edges in the EdgeRing.
67
61
  *
@@ -69,9 +63,9 @@ var EdgeRing = /** @class */ (function () {
69
63
  * @param {Function} f - The same function to be passed to Array.prototype.map
70
64
  * @returns {Array} - The mapped values in the function
71
65
  */
72
- EdgeRing.prototype.map = function (f) {
66
+ map(f) {
73
67
  return this.edges.map(f);
74
- };
68
+ }
75
69
  /**
76
70
  * Similar to Array.prototype.some for the list of Edges in the EdgeRing.
77
71
  *
@@ -79,9 +73,9 @@ var EdgeRing = /** @class */ (function () {
79
73
  * @param {Function} f - The same function to be passed to Array.prototype.some
80
74
  * @returns {boolean} - True if an Edge check the condition
81
75
  */
82
- EdgeRing.prototype.some = function (f) {
76
+ some(f) {
83
77
  return this.edges.some(f);
84
- };
78
+ }
85
79
  /**
86
80
  * Check if the ring is valid in geomtry terms.
87
81
  *
@@ -92,10 +86,10 @@ var EdgeRing = /** @class */ (function () {
92
86
  * @memberof EdgeRing
93
87
  * @returns {boolean} - Validity of the EdgeRing
94
88
  */
95
- EdgeRing.prototype.isValid = function () {
89
+ isValid() {
96
90
  // TODO: stub
97
91
  return true;
98
- };
92
+ }
99
93
  /**
100
94
  * Tests whether this ring is a hole.
101
95
  *
@@ -105,12 +99,11 @@ var EdgeRing = /** @class */ (function () {
105
99
  * @memberof EdgeRing
106
100
  * @returns {boolean} - true: if it is a hole
107
101
  */
108
- EdgeRing.prototype.isHole = function () {
109
- var _this = this;
102
+ isHole() {
110
103
  // XXX: Assuming Ring is valid
111
104
  // Find highest point
112
- var hiIndex = this.edges.reduce(function (high, edge, i) {
113
- if (edge.from.coordinates[1] > _this.edges[high].from.coordinates[1])
105
+ const hiIndex = this.edges.reduce((high, edge, i) => {
106
+ if (edge.from.coordinates[1] > this.edges[high].from.coordinates[1])
114
107
  high = i;
115
108
  return high;
116
109
  }, 0), iPrev = (hiIndex === 0 ? this.length : hiIndex) - 1, iNext = (hiIndex + 1) % this.length, disc = util_1.orientationIndex(this.edges[iPrev].from.coordinates, this.edges[hiIndex].from.coordinates, this.edges[iNext].from.coordinates);
@@ -118,40 +111,40 @@ var EdgeRing = /** @class */ (function () {
118
111
  return (this.edges[iPrev].from.coordinates[0] >
119
112
  this.edges[iNext].from.coordinates[0]);
120
113
  return disc > 0;
121
- };
114
+ }
122
115
  /**
123
116
  * Creates a MultiPoint representing the EdgeRing (discarts edges directions).
124
117
  *
125
118
  * @memberof EdgeRing
126
119
  * @returns {Feature<MultiPoint>} - Multipoint representation of the EdgeRing
127
120
  */
128
- EdgeRing.prototype.toMultiPoint = function () {
129
- return helpers_1.multiPoint(this.edges.map(function (edge) { return edge.from.coordinates; }));
130
- };
121
+ toMultiPoint() {
122
+ return helpers_1.multiPoint(this.edges.map((edge) => edge.from.coordinates));
123
+ }
131
124
  /**
132
125
  * Creates a Polygon representing the EdgeRing.
133
126
  *
134
127
  * @memberof EdgeRing
135
128
  * @returns {Feature<Polygon>} - Polygon representation of the Edge Ring
136
129
  */
137
- EdgeRing.prototype.toPolygon = function () {
130
+ toPolygon() {
138
131
  if (this.polygon)
139
132
  return this.polygon;
140
- var coordinates = this.edges.map(function (edge) { return edge.from.coordinates; });
133
+ const coordinates = this.edges.map((edge) => edge.from.coordinates);
141
134
  coordinates.push(this.edges[0].from.coordinates);
142
135
  return (this.polygon = helpers_1.polygon([coordinates]));
143
- };
136
+ }
144
137
  /**
145
138
  * Calculates the envelope of the EdgeRing.
146
139
  *
147
140
  * @memberof EdgeRing
148
141
  * @returns {Feature<Polygon>} - envelope
149
142
  */
150
- EdgeRing.prototype.getEnvelope = function () {
143
+ getEnvelope() {
151
144
  if (this.envelope)
152
145
  return this.envelope;
153
146
  return (this.envelope = envelope_1.default(this.toPolygon()));
154
- };
147
+ }
155
148
  /**
156
149
  * `geos::operation::polygonize::EdgeRing::findEdgeRingContaining`
157
150
  *
@@ -160,27 +153,23 @@ var EdgeRing = /** @class */ (function () {
160
153
  *
161
154
  * @returns {EdgeRing} - EdgeRing which contains the testEdgeRing
162
155
  */
163
- EdgeRing.findEdgeRingContaining = function (testEdgeRing, shellList) {
164
- var testEnvelope = testEdgeRing.getEnvelope();
165
- var minEnvelope, minShell;
166
- shellList.forEach(function (shell) {
167
- var tryEnvelope = shell.getEnvelope();
156
+ static findEdgeRingContaining(testEdgeRing, shellList) {
157
+ const testEnvelope = testEdgeRing.getEnvelope();
158
+ let minEnvelope, minShell;
159
+ shellList.forEach((shell) => {
160
+ const tryEnvelope = shell.getEnvelope();
168
161
  if (minShell)
169
162
  minEnvelope = minShell.getEnvelope();
170
163
  // the hole envelope cannot equal the shell envelope
171
164
  if (util_1.envelopeIsEqual(tryEnvelope, testEnvelope))
172
165
  return;
173
166
  if (util_1.envelopeContains(tryEnvelope, testEnvelope)) {
174
- var testEdgeRingCoordinates = testEdgeRing.map(function (edge) { return edge.from.coordinates; });
175
- var testPoint = void 0;
176
- var _loop_1 = function (pt) {
177
- if (!shell.some(function (edge) { return util_1.coordinatesEqual(pt, edge.from.coordinates); })) {
167
+ const testEdgeRingCoordinates = testEdgeRing.map((edge) => edge.from.coordinates);
168
+ let testPoint;
169
+ for (const pt of testEdgeRingCoordinates) {
170
+ if (!shell.some((edge) => util_1.coordinatesEqual(pt, edge.from.coordinates))) {
178
171
  testPoint = pt;
179
172
  }
180
- };
181
- for (var _i = 0, testEdgeRingCoordinates_1 = testEdgeRingCoordinates; _i < testEdgeRingCoordinates_1.length; _i++) {
182
- var pt = testEdgeRingCoordinates_1[_i];
183
- _loop_1(pt);
184
173
  }
185
174
  if (testPoint && shell.inside(helpers_1.point(testPoint))) {
186
175
  if (!minShell || util_1.envelopeContains(minEnvelope, tryEnvelope))
@@ -189,16 +178,15 @@ var EdgeRing = /** @class */ (function () {
189
178
  }
190
179
  });
191
180
  return minShell;
192
- };
181
+ }
193
182
  /**
194
183
  * Checks if the point is inside the edgeRing
195
184
  *
196
185
  * @param {Feature<Point>} pt - Point to check if it is inside the edgeRing
197
186
  * @returns {boolean} - True if it is inside, False otherwise
198
187
  */
199
- EdgeRing.prototype.inside = function (pt) {
188
+ inside(pt) {
200
189
  return boolean_point_in_polygon_1.default(pt, this.toPolygon());
201
- };
202
- return EdgeRing;
203
- }());
190
+ }
191
+ }
204
192
  exports.default = EdgeRing;
@@ -1,7 +1,7 @@
1
1
  import Node from "./Node";
2
2
  import Edge from "./Edge";
3
3
  import EdgeRing from "./EdgeRing";
4
- import { FeatureCollection, LineString, MultiLineString, Feature } from "@turf/helpers";
4
+ import { FeatureCollection, LineString, MultiLineString, Feature } from "geojson";
5
5
  /**
6
6
  * Represents a planar graph of edges and nodes that can be used to compute a polygonization.
7
7
  *
@@ -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;