@turf/concave 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.
package/README.md CHANGED
@@ -7,14 +7,16 @@
7
7
  Takes a set of [points][1] and returns a concave hull Polygon or MultiPolygon.
8
8
  Internally, this uses [turf-tin][2] to generate geometries.
9
9
 
10
- **Parameters**
10
+ ### Parameters
11
11
 
12
- - `points` **[FeatureCollection][3]<[Point][4]>** input points
13
- - `options` **[Object][5]** Optional parameters (optional, default `{}`)
14
- - `options.maxEdge` **[number][6]** the length (in 'units') of an edge necessary for part of the hull to become concave. (optional, default `Infinity`)
15
- - `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
12
+ * `points` **[FeatureCollection][3]<[Point][4]>** input points
13
+ * `options` **[Object][5]** Optional parameters (optional, default `{}`)
16
14
 
17
- **Examples**
15
+ * `options.maxEdge` **[number][6]** the length (in 'units') of an edge necessary for part of the
16
+ hull to become concave. (optional, default `Infinity`)
17
+ * `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
18
+
19
+ ### Examples
18
20
 
19
21
  ```javascript
20
22
  var points = turf.featureCollection([
@@ -33,7 +35,7 @@ var hull = turf.concave(points, options);
33
35
  var addToMap = [points, hull]
34
36
  ```
35
37
 
36
- Returns **([Feature][8]&lt;([Polygon][9] \| [MultiPolygon][10])> | null)** a concave hull (null value is returned if unable to compute hull)
38
+ Returns **([Feature][8]<([Polygon][9] | [MultiPolygon][10])> | null)** a concave hull (null value is returned if unable to compute hull)
37
39
 
38
40
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
39
41
 
package/dist/es/index.js CHANGED
@@ -30,27 +30,26 @@ import dissolve from "./lib/turf-dissolve.js";
30
30
  * //addToMap
31
31
  * var addToMap = [points, hull]
32
32
  */
33
- function concave(points, options) {
34
- if (options === void 0) { options = {}; }
35
- var maxEdge = options.maxEdge || Infinity;
36
- var cleaned = removeDuplicates(points);
37
- var tinPolys = tin(cleaned);
33
+ function concave(points, options = {}) {
34
+ const maxEdge = options.maxEdge || Infinity;
35
+ const cleaned = removeDuplicates(points);
36
+ const tinPolys = tin(cleaned);
38
37
  // calculate length of all edges and area of all triangles
39
38
  // and remove triangles that fail the max length test
40
- tinPolys.features = tinPolys.features.filter(function (triangle) {
41
- var pt1 = triangle.geometry.coordinates[0][0];
42
- var pt2 = triangle.geometry.coordinates[0][1];
43
- var pt3 = triangle.geometry.coordinates[0][2];
44
- var dist1 = distance(pt1, pt2, options);
45
- var dist2 = distance(pt2, pt3, options);
46
- var dist3 = distance(pt1, pt3, options);
39
+ tinPolys.features = tinPolys.features.filter((triangle) => {
40
+ const pt1 = triangle.geometry.coordinates[0][0];
41
+ const pt2 = triangle.geometry.coordinates[0][1];
42
+ const pt3 = triangle.geometry.coordinates[0][2];
43
+ const dist1 = distance(pt1, pt2, options);
44
+ const dist2 = distance(pt2, pt3, options);
45
+ const dist3 = distance(pt1, pt3, options);
47
46
  return dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge;
48
47
  });
49
48
  if (tinPolys.features.length < 1) {
50
49
  return null;
51
50
  }
52
51
  // merge the adjacent triangles
53
- var dissolved = dissolve(tinPolys);
52
+ const dissolved = dissolve(tinPolys);
54
53
  // geojson-dissolve always returns a MultiPolygon
55
54
  if (dissolved.coordinates.length === 1) {
56
55
  dissolved.coordinates = dissolved.coordinates[0];
@@ -66,14 +65,14 @@ function concave(points, options) {
66
65
  * @returns {FeatureCollection<Point>} cleaned set of points
67
66
  */
68
67
  function removeDuplicates(points) {
69
- var cleaned = [];
70
- var existing = {};
71
- featureEach(points, function (pt) {
68
+ const cleaned = [];
69
+ const existing = {};
70
+ featureEach(points, (pt) => {
72
71
  if (!pt.geometry) {
73
72
  return;
74
73
  }
75
- var key = pt.geometry.coordinates.join("-");
76
- if (!existing.hasOwnProperty(key)) {
74
+ const key = pt.geometry.coordinates.join("-");
75
+ if (!Object.prototype.hasOwnProperty.call(existing, key)) {
77
76
  cleaned.push(pt);
78
77
  existing[key] = true;
79
78
  }
@@ -14,14 +14,13 @@ import polygonDissolve from "./turf-polygon-dissolve.js";
14
14
  * @param {boolean} [options.mutate=false] Prevent input mutation
15
15
  * @returns {Feature<MultiLineString|MultiPolygon>} Dissolved Features
16
16
  */
17
- function dissolve(geojson, options) {
18
- if (options === void 0) { options = {}; }
17
+ function dissolve(geojson, options = {}) {
19
18
  // Optional parameters
20
19
  options = options || {};
21
20
  if (!isObject(options)) {
22
21
  throw new Error("options is invalid");
23
22
  }
24
- var mutate = options.mutate;
23
+ const mutate = options.mutate;
25
24
  // Validation
26
25
  if (getType(geojson) !== "FeatureCollection") {
27
26
  throw new Error("geojson must be a FeatureCollection");
@@ -35,12 +34,12 @@ function dissolve(geojson, options) {
35
34
  geojson = clone(geojson);
36
35
  }
37
36
  // Assert homogenity
38
- var type = getHomogenousType(geojson);
37
+ const type = getHomogenousType(geojson);
39
38
  if (!type) {
40
39
  throw new Error("geojson must be homogenous");
41
40
  }
42
41
  // Data => Typescript hack
43
- var data = geojson;
42
+ const data = geojson;
44
43
  switch (type) {
45
44
  case "LineString":
46
45
  return lineDissolve(data, options);
@@ -58,11 +57,11 @@ function dissolve(geojson, options) {
58
57
  * @returns {string|null} Homogenous type or null if multiple types
59
58
  */
60
59
  function getHomogenousType(geojson) {
61
- var types = {};
62
- flattenEach(geojson, function (feature) {
60
+ const types = {};
61
+ flattenEach(geojson, (feature) => {
63
62
  types[feature.geometry.type] = true;
64
63
  });
65
- var keys = Object.keys(types);
64
+ const keys = Object.keys(types);
66
65
  if (keys.length === 1) {
67
66
  return keys[0];
68
67
  }
@@ -11,14 +11,13 @@ import { lineReduce } from "@turf/meta";
11
11
  * @param {boolean} [options.mutate=false] Prevent input mutation
12
12
  * @returns {Feature<LineString|MultiLineString>} Dissolved lines
13
13
  */
14
- function lineDissolve(geojson, options) {
15
- if (options === void 0) { options = {}; }
14
+ function lineDissolve(geojson, options = {}) {
16
15
  // Optional parameters
17
16
  options = options || {};
18
17
  if (!isObject(options)) {
19
18
  throw new Error("options is invalid");
20
19
  }
21
- var mutate = options.mutate;
20
+ const mutate = options.mutate;
22
21
  // Validation
23
22
  if (getType(geojson) !== "FeatureCollection") {
24
23
  throw new Error("geojson must be a FeatureCollection");
@@ -30,11 +29,11 @@ function lineDissolve(geojson, options) {
30
29
  if (mutate === false || mutate === undefined) {
31
30
  geojson = clone(geojson);
32
31
  }
33
- var result = [];
34
- var lastLine = lineReduce(geojson, function (previousLine, currentLine) {
32
+ const result = [];
33
+ const lastLine = lineReduce(geojson, (previousLine, currentLine) => {
35
34
  // Attempt to merge this LineString with the other LineStrings, updating
36
35
  // the reference as it is merged with others and grows.
37
- var merged = mergeLineStrings(previousLine, currentLine);
36
+ const merged = mergeLineStrings(previousLine, currentLine);
38
37
  // Accumulate the merged LineString
39
38
  if (merged) {
40
39
  return merged;
@@ -59,7 +58,7 @@ function lineDissolve(geojson, options) {
59
58
  // Return MultiLineString if multiple lines were dissolved with gaps
60
59
  }
61
60
  else {
62
- return multiLineString(result.map(function (line) {
61
+ return multiLineString(result.map((line) => {
63
62
  return line.coordinates;
64
63
  }));
65
64
  }
@@ -77,14 +76,14 @@ function coordId(coord) {
77
76
  * @returns {Feature<LineString>|null} Merged LineString
78
77
  */
79
78
  function mergeLineStrings(a, b) {
80
- var coords1 = a.geometry.coordinates;
81
- var coords2 = b.geometry.coordinates;
82
- var s1 = coordId(coords1[0]);
83
- var e1 = coordId(coords1[coords1.length - 1]);
84
- var s2 = coordId(coords2[0]);
85
- var e2 = coordId(coords2[coords2.length - 1]);
79
+ const coords1 = a.geometry.coordinates;
80
+ const coords2 = b.geometry.coordinates;
81
+ const s1 = coordId(coords1[0]);
82
+ const e1 = coordId(coords1[coords1.length - 1]);
83
+ const s2 = coordId(coords2[0]);
84
+ const e2 = coordId(coords2[coords2.length - 1]);
86
85
  // TODO: handle case where more than one of these is true!
87
- var coords;
86
+ let coords;
88
87
  if (s1 === e2) {
89
88
  coords = coords2.concat(coords1.slice(1));
90
89
  }
@@ -12,8 +12,7 @@ import { topology } from "topojson-server";
12
12
  * @param {boolean} [options.mutate=false] Prevent input mutation
13
13
  * @returns {Feature<Polygon|MultiPolygon>} Dissolved Polygons
14
14
  */
15
- export default function polygonDissolve(geojson, options) {
16
- if (options === void 0) { options = {}; }
15
+ export default function polygonDissolve(geojson, options = {}) {
17
16
  // Validation
18
17
  if (getType(geojson) !== "FeatureCollection") {
19
18
  throw new Error("geojson must be a FeatureCollection");
@@ -26,11 +25,11 @@ export default function polygonDissolve(geojson, options) {
26
25
  if (options.mutate === false || options.mutate === undefined) {
27
26
  geojson = clone(geojson);
28
27
  }
29
- var geoms = [];
30
- flattenEach(geojson, function (feature) {
28
+ const geoms = [];
29
+ flattenEach(geojson, (feature) => {
31
30
  geoms.push(feature.geometry);
32
31
  });
33
- var topo = topology({ geoms: geometryCollection(geoms).geometry });
34
- var merged = merge(topo, topo.objects.geoms.geometries);
32
+ const topo = topology({ geoms: geometryCollection(geoms).geometry });
33
+ const merged = merge(topo, topo.objects.geoms.geometries);
35
34
  return merged;
36
35
  }
@@ -1,4 +1,5 @@
1
- import { Feature, FeatureCollection, MultiPolygon, Point, Polygon, Units } from "@turf/helpers";
1
+ import { Feature, FeatureCollection, MultiPolygon, Point, Polygon } from "geojson";
2
+ import { Units } from "@turf/helpers";
2
3
  /**
3
4
  * Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon.
4
5
  * Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.
package/dist/js/index.js CHANGED
@@ -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 distance_1 = __importDefault(require("@turf/distance"));
7
- var helpers_1 = require("@turf/helpers");
8
- var meta_1 = require("@turf/meta");
9
- var tin_1 = __importDefault(require("@turf/tin"));
10
- var turf_dissolve_1 = __importDefault(require("./lib/turf-dissolve"));
3
+ const tslib_1 = require("tslib");
4
+ const distance_1 = tslib_1.__importDefault(require("@turf/distance"));
5
+ const helpers_1 = require("@turf/helpers");
6
+ const meta_1 = require("@turf/meta");
7
+ const tin_1 = tslib_1.__importDefault(require("@turf/tin"));
8
+ const turf_dissolve_1 = tslib_1.__importDefault(require("./lib/turf-dissolve"));
11
9
  /**
12
10
  * Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon.
13
11
  * Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.
@@ -35,27 +33,26 @@ var turf_dissolve_1 = __importDefault(require("./lib/turf-dissolve"));
35
33
  * //addToMap
36
34
  * var addToMap = [points, hull]
37
35
  */
38
- function concave(points, options) {
39
- if (options === void 0) { options = {}; }
40
- var maxEdge = options.maxEdge || Infinity;
41
- var cleaned = removeDuplicates(points);
42
- var tinPolys = tin_1.default(cleaned);
36
+ function concave(points, options = {}) {
37
+ const maxEdge = options.maxEdge || Infinity;
38
+ const cleaned = removeDuplicates(points);
39
+ const tinPolys = tin_1.default(cleaned);
43
40
  // calculate length of all edges and area of all triangles
44
41
  // and remove triangles that fail the max length test
45
- tinPolys.features = tinPolys.features.filter(function (triangle) {
46
- var pt1 = triangle.geometry.coordinates[0][0];
47
- var pt2 = triangle.geometry.coordinates[0][1];
48
- var pt3 = triangle.geometry.coordinates[0][2];
49
- var dist1 = distance_1.default(pt1, pt2, options);
50
- var dist2 = distance_1.default(pt2, pt3, options);
51
- var dist3 = distance_1.default(pt1, pt3, options);
42
+ tinPolys.features = tinPolys.features.filter((triangle) => {
43
+ const pt1 = triangle.geometry.coordinates[0][0];
44
+ const pt2 = triangle.geometry.coordinates[0][1];
45
+ const pt3 = triangle.geometry.coordinates[0][2];
46
+ const dist1 = distance_1.default(pt1, pt2, options);
47
+ const dist2 = distance_1.default(pt2, pt3, options);
48
+ const dist3 = distance_1.default(pt1, pt3, options);
52
49
  return dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge;
53
50
  });
54
51
  if (tinPolys.features.length < 1) {
55
52
  return null;
56
53
  }
57
54
  // merge the adjacent triangles
58
- var dissolved = turf_dissolve_1.default(tinPolys);
55
+ const dissolved = turf_dissolve_1.default(tinPolys);
59
56
  // geojson-dissolve always returns a MultiPolygon
60
57
  if (dissolved.coordinates.length === 1) {
61
58
  dissolved.coordinates = dissolved.coordinates[0];
@@ -71,14 +68,14 @@ function concave(points, options) {
71
68
  * @returns {FeatureCollection<Point>} cleaned set of points
72
69
  */
73
70
  function removeDuplicates(points) {
74
- var cleaned = [];
75
- var existing = {};
76
- meta_1.featureEach(points, function (pt) {
71
+ const cleaned = [];
72
+ const existing = {};
73
+ meta_1.featureEach(points, (pt) => {
77
74
  if (!pt.geometry) {
78
75
  return;
79
76
  }
80
- var key = pt.geometry.coordinates.join("-");
81
- if (!existing.hasOwnProperty(key)) {
77
+ const key = pt.geometry.coordinates.join("-");
78
+ if (!Object.prototype.hasOwnProperty.call(existing, key)) {
82
79
  cleaned.push(pt);
83
80
  existing[key] = true;
84
81
  }
@@ -1,4 +1,4 @@
1
- import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon } from "@turf/helpers";
1
+ import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon } from "geojson";
2
2
  /**
3
3
  * Transform function: attempts to dissolve geojson objects where possible
4
4
  * [GeoJSON] -> GeoJSON geometry
@@ -1,14 +1,12 @@
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 clone_1 = __importDefault(require("@turf/clone"));
7
- var helpers_1 = require("@turf/helpers");
8
- var invariant_1 = require("@turf/invariant");
9
- var meta_1 = require("@turf/meta");
10
- var turf_line_dissolve_1 = __importDefault(require("./turf-line-dissolve"));
11
- var turf_polygon_dissolve_1 = __importDefault(require("./turf-polygon-dissolve"));
3
+ const tslib_1 = require("tslib");
4
+ const clone_1 = tslib_1.__importDefault(require("@turf/clone"));
5
+ const helpers_1 = require("@turf/helpers");
6
+ const invariant_1 = require("@turf/invariant");
7
+ const meta_1 = require("@turf/meta");
8
+ const turf_line_dissolve_1 = tslib_1.__importDefault(require("./turf-line-dissolve"));
9
+ const turf_polygon_dissolve_1 = tslib_1.__importDefault(require("./turf-polygon-dissolve"));
12
10
  /**
13
11
  * Transform function: attempts to dissolve geojson objects where possible
14
12
  * [GeoJSON] -> GeoJSON geometry
@@ -19,14 +17,13 @@ var turf_polygon_dissolve_1 = __importDefault(require("./turf-polygon-dissolve")
19
17
  * @param {boolean} [options.mutate=false] Prevent input mutation
20
18
  * @returns {Feature<MultiLineString|MultiPolygon>} Dissolved Features
21
19
  */
22
- function dissolve(geojson, options) {
23
- if (options === void 0) { options = {}; }
20
+ function dissolve(geojson, options = {}) {
24
21
  // Optional parameters
25
22
  options = options || {};
26
23
  if (!helpers_1.isObject(options)) {
27
24
  throw new Error("options is invalid");
28
25
  }
29
- var mutate = options.mutate;
26
+ const mutate = options.mutate;
30
27
  // Validation
31
28
  if (invariant_1.getType(geojson) !== "FeatureCollection") {
32
29
  throw new Error("geojson must be a FeatureCollection");
@@ -40,12 +37,12 @@ function dissolve(geojson, options) {
40
37
  geojson = clone_1.default(geojson);
41
38
  }
42
39
  // Assert homogenity
43
- var type = getHomogenousType(geojson);
40
+ const type = getHomogenousType(geojson);
44
41
  if (!type) {
45
42
  throw new Error("geojson must be homogenous");
46
43
  }
47
44
  // Data => Typescript hack
48
- var data = geojson;
45
+ const data = geojson;
49
46
  switch (type) {
50
47
  case "LineString":
51
48
  return turf_line_dissolve_1.default(data, options);
@@ -63,11 +60,11 @@ function dissolve(geojson, options) {
63
60
  * @returns {string|null} Homogenous type or null if multiple types
64
61
  */
65
62
  function getHomogenousType(geojson) {
66
- var types = {};
67
- meta_1.flattenEach(geojson, function (feature) {
63
+ const types = {};
64
+ meta_1.flattenEach(geojson, (feature) => {
68
65
  types[feature.geometry.type] = true;
69
66
  });
70
- var keys = Object.keys(types);
67
+ const keys = Object.keys(types);
71
68
  if (keys.length === 1) {
72
69
  return keys[0];
73
70
  }
@@ -1,4 +1,4 @@
1
- import { Feature, FeatureCollection, LineString, MultiLineString } from "@turf/helpers";
1
+ import { Feature, FeatureCollection, LineString, MultiLineString } from "geojson";
2
2
  /**
3
3
  * Merges all connected (non-forking, non-junctioning) line strings into single lineStrings.
4
4
  * [LineString] -> LineString|MultiLineString
@@ -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 clone_1 = __importDefault(require("@turf/clone"));
7
- var helpers_1 = require("@turf/helpers");
8
- var invariant_1 = require("@turf/invariant");
9
- var meta_1 = require("@turf/meta");
3
+ const tslib_1 = require("tslib");
4
+ const clone_1 = tslib_1.__importDefault(require("@turf/clone"));
5
+ const helpers_1 = require("@turf/helpers");
6
+ const invariant_1 = require("@turf/invariant");
7
+ const meta_1 = require("@turf/meta");
10
8
  /**
11
9
  * Merges all connected (non-forking, non-junctioning) line strings into single lineStrings.
12
10
  * [LineString] -> LineString|MultiLineString
@@ -16,14 +14,13 @@ var meta_1 = require("@turf/meta");
16
14
  * @param {boolean} [options.mutate=false] Prevent input mutation
17
15
  * @returns {Feature<LineString|MultiLineString>} Dissolved lines
18
16
  */
19
- function lineDissolve(geojson, options) {
20
- if (options === void 0) { options = {}; }
17
+ function lineDissolve(geojson, options = {}) {
21
18
  // Optional parameters
22
19
  options = options || {};
23
20
  if (!helpers_1.isObject(options)) {
24
21
  throw new Error("options is invalid");
25
22
  }
26
- var mutate = options.mutate;
23
+ const mutate = options.mutate;
27
24
  // Validation
28
25
  if (invariant_1.getType(geojson) !== "FeatureCollection") {
29
26
  throw new Error("geojson must be a FeatureCollection");
@@ -35,11 +32,11 @@ function lineDissolve(geojson, options) {
35
32
  if (mutate === false || mutate === undefined) {
36
33
  geojson = clone_1.default(geojson);
37
34
  }
38
- var result = [];
39
- var lastLine = meta_1.lineReduce(geojson, function (previousLine, currentLine) {
35
+ const result = [];
36
+ const lastLine = meta_1.lineReduce(geojson, (previousLine, currentLine) => {
40
37
  // Attempt to merge this LineString with the other LineStrings, updating
41
38
  // the reference as it is merged with others and grows.
42
- var merged = mergeLineStrings(previousLine, currentLine);
39
+ const merged = mergeLineStrings(previousLine, currentLine);
43
40
  // Accumulate the merged LineString
44
41
  if (merged) {
45
42
  return merged;
@@ -64,7 +61,7 @@ function lineDissolve(geojson, options) {
64
61
  // Return MultiLineString if multiple lines were dissolved with gaps
65
62
  }
66
63
  else {
67
- return helpers_1.multiLineString(result.map(function (line) {
64
+ return helpers_1.multiLineString(result.map((line) => {
68
65
  return line.coordinates;
69
66
  }));
70
67
  }
@@ -82,14 +79,14 @@ function coordId(coord) {
82
79
  * @returns {Feature<LineString>|null} Merged LineString
83
80
  */
84
81
  function mergeLineStrings(a, b) {
85
- var coords1 = a.geometry.coordinates;
86
- var coords2 = b.geometry.coordinates;
87
- var s1 = coordId(coords1[0]);
88
- var e1 = coordId(coords1[coords1.length - 1]);
89
- var s2 = coordId(coords2[0]);
90
- var e2 = coordId(coords2[coords2.length - 1]);
82
+ const coords1 = a.geometry.coordinates;
83
+ const coords2 = b.geometry.coordinates;
84
+ const s1 = coordId(coords1[0]);
85
+ const e1 = coordId(coords1[coords1.length - 1]);
86
+ const s2 = coordId(coords2[0]);
87
+ const e2 = coordId(coords2[coords2.length - 1]);
91
88
  // TODO: handle case where more than one of these is true!
92
- var coords;
89
+ let coords;
93
90
  if (s1 === e2) {
94
91
  coords = coords2.concat(coords1.slice(1));
95
92
  }
@@ -1,4 +1,4 @@
1
- import { Feature, FeatureCollection, MultiPolygon, Polygon } from "@turf/helpers";
1
+ import { Feature, FeatureCollection, MultiPolygon, Polygon } from "geojson";
2
2
  /**
3
3
  * Dissolves all overlapping (Multi)Polygon
4
4
  *
@@ -1,14 +1,12 @@
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 clone_1 = __importDefault(require("@turf/clone"));
7
- var helpers_1 = require("@turf/helpers");
8
- var invariant_1 = require("@turf/invariant");
9
- var meta_1 = require("@turf/meta");
10
- var topojson_client_1 = require("topojson-client");
11
- var topojson_server_1 = require("topojson-server");
3
+ const tslib_1 = require("tslib");
4
+ const clone_1 = tslib_1.__importDefault(require("@turf/clone"));
5
+ const helpers_1 = require("@turf/helpers");
6
+ const invariant_1 = require("@turf/invariant");
7
+ const meta_1 = require("@turf/meta");
8
+ const topojson_client_1 = require("topojson-client");
9
+ const topojson_server_1 = require("topojson-server");
12
10
  /**
13
11
  * Dissolves all overlapping (Multi)Polygon
14
12
  *
@@ -17,8 +15,7 @@ var topojson_server_1 = require("topojson-server");
17
15
  * @param {boolean} [options.mutate=false] Prevent input mutation
18
16
  * @returns {Feature<Polygon|MultiPolygon>} Dissolved Polygons
19
17
  */
20
- function polygonDissolve(geojson, options) {
21
- if (options === void 0) { options = {}; }
18
+ function polygonDissolve(geojson, options = {}) {
22
19
  // Validation
23
20
  if (invariant_1.getType(geojson) !== "FeatureCollection") {
24
21
  throw new Error("geojson must be a FeatureCollection");
@@ -31,12 +28,12 @@ function polygonDissolve(geojson, options) {
31
28
  if (options.mutate === false || options.mutate === undefined) {
32
29
  geojson = clone_1.default(geojson);
33
30
  }
34
- var geoms = [];
35
- meta_1.flattenEach(geojson, function (feature) {
31
+ const geoms = [];
32
+ meta_1.flattenEach(geojson, (feature) => {
36
33
  geoms.push(feature.geometry);
37
34
  });
38
- var topo = topojson_server_1.topology({ geoms: helpers_1.geometryCollection(geoms).geometry });
39
- var merged = topojson_client_1.merge(topo, topo.objects.geoms.geometries);
35
+ const topo = topojson_server_1.topology({ geoms: helpers_1.geometryCollection(geoms).geometry });
36
+ const merged = topojson_client_1.merge(topo, topo.objects.geoms.geometries);
40
37
  return merged;
41
38
  }
42
39
  exports.default = polygonDissolve;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/concave",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf concave module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -23,6 +23,7 @@
23
23
  "type": "git",
24
24
  "url": "git://github.com/Turfjs/turf.git"
25
25
  },
26
+ "funding": "https://opencollective.com/turf",
26
27
  "publishConfig": {
27
28
  "access": "public"
28
29
  },
@@ -69,14 +70,15 @@
69
70
  "write-json-file": "*"
70
71
  },
71
72
  "dependencies": {
72
- "@turf/clone": "^6.4.0",
73
- "@turf/distance": "^6.4.0",
74
- "@turf/helpers": "^6.4.0",
75
- "@turf/invariant": "^6.4.0",
76
- "@turf/meta": "^6.4.0",
77
- "@turf/tin": "^6.4.0",
73
+ "@turf/clone": "^7.0.0-alpha.0",
74
+ "@turf/distance": "^7.0.0-alpha.0",
75
+ "@turf/helpers": "^7.0.0-alpha.0",
76
+ "@turf/invariant": "^7.0.0-alpha.0",
77
+ "@turf/meta": "^7.0.0-alpha.0",
78
+ "@turf/tin": "^7.0.0-alpha.0",
78
79
  "topojson-client": "3.x",
79
- "topojson-server": "3.x"
80
+ "topojson-server": "3.x",
81
+ "tslib": "^2.3.0"
80
82
  },
81
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
83
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
82
84
  }