@turf/combine 7.0.0-alpha.2 → 7.1.0-alpha.7

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
@@ -55,26 +55,21 @@ Returns **[FeatureCollection][8]<([MultiPoint][12] | [MultiLineString][13] | [Mu
55
55
 
56
56
  [14]: https://tools.ietf.org/html/rfc7946#section-3.1.7
57
57
 
58
- <!-- This file is automatically generated. Please don't edit it directly:
59
- if you find an error, edit the source file (likely index.js), and re-run
60
- ./scripts/generate-readmes in the turf project. -->
58
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
61
59
 
62
60
  ---
63
61
 
64
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
65
- module collection dedicated to geographic algorithms. It is maintained in the
66
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
67
- PRs and issues.
62
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
68
63
 
69
64
  ### Installation
70
65
 
71
- Install this module individually:
66
+ Install this single module individually:
72
67
 
73
68
  ```sh
74
69
  $ npm install @turf/combine
75
70
  ```
76
71
 
77
- Or install the Turf module that includes it as a function:
72
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
78
73
 
79
74
  ```sh
80
75
  $ npm install @turf/turf
@@ -0,0 +1,67 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
2
+ var _helpers = require('@turf/helpers');
3
+ var _meta = require('@turf/meta');
4
+ function combine(fc) {
5
+ var groups = {
6
+ MultiPoint: {
7
+ coordinates: [],
8
+ properties: []
9
+ },
10
+ MultiLineString: {
11
+ coordinates: [],
12
+ properties: []
13
+ },
14
+ MultiPolygon: {
15
+ coordinates: [],
16
+ properties: []
17
+ }
18
+ };
19
+ _meta.featureEach.call(void 0, fc, (feature2) => {
20
+ var _a;
21
+ switch ((_a = feature2.geometry) == null ? void 0 : _a.type) {
22
+ case "Point":
23
+ groups.MultiPoint.coordinates.push(feature2.geometry.coordinates);
24
+ groups.MultiPoint.properties.push(feature2.properties);
25
+ break;
26
+ case "MultiPoint":
27
+ groups.MultiPoint.coordinates.push(...feature2.geometry.coordinates);
28
+ groups.MultiPoint.properties.push(feature2.properties);
29
+ break;
30
+ case "LineString":
31
+ groups.MultiLineString.coordinates.push(feature2.geometry.coordinates);
32
+ groups.MultiLineString.properties.push(feature2.properties);
33
+ break;
34
+ case "MultiLineString":
35
+ groups.MultiLineString.coordinates.push(
36
+ ...feature2.geometry.coordinates
37
+ );
38
+ groups.MultiLineString.properties.push(feature2.properties);
39
+ break;
40
+ case "Polygon":
41
+ groups.MultiPolygon.coordinates.push(feature2.geometry.coordinates);
42
+ groups.MultiPolygon.properties.push(feature2.properties);
43
+ break;
44
+ case "MultiPolygon":
45
+ groups.MultiPolygon.coordinates.push(...feature2.geometry.coordinates);
46
+ groups.MultiPolygon.properties.push(feature2.properties);
47
+ break;
48
+ default:
49
+ break;
50
+ }
51
+ });
52
+ return _helpers.featureCollection.call(void 0,
53
+ Object.keys(groups).filter(function(key) {
54
+ return groups[key].coordinates.length;
55
+ }).sort().map(function(key) {
56
+ var geometry = { type: key, coordinates: groups[key].coordinates };
57
+ var properties = { collectedProperties: groups[key].properties };
58
+ return _helpers.feature.call(void 0, geometry, properties);
59
+ })
60
+ );
61
+ }
62
+ var turf_combine_default = combine;
63
+
64
+
65
+
66
+ exports.combine = combine; exports.default = turf_combine_default;
67
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":["feature"],"mappings":";AAUA,SAAS,SAAS,yBAAyB;AAC3C,SAAS,mBAAmB;AAoB5B,SAAS,QACP,IAGA;AACA,MAAI,SAAS;AAAA,IACX,YAAY;AAAA,MACV,aAAa,CAAC;AAAA,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W,EAAE,MAAM,KAAK,aAAa,OAAO,GAAG,EAAE,YAAY;AAIjE,UAAI,aAAa,EAAE,qBAAqB,OAAO,GAAG,EAAE,WAAW;AAC/D,aAAO,QAAQ,UAAU,UAAU;AAAA,IACrC,CAAC;AAAA,EACL;AACF;AAGA,IAAO,uBAAQ","sourcesContent":["import {\n GeoJsonProperties,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { feature, featureCollection } from \"@turf/helpers\";\nimport { featureEach } from \"@turf/meta\";\n\n/**\n * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features\n * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.\n *\n * @name combine\n * @param {FeatureCollection<Point|LineString|Polygon>} fc a FeatureCollection of any type\n * @returns {FeatureCollection<MultiPoint|MultiLineString|MultiPolygon>} a FeatureCollection of corresponding type to input\n * @example\n * var fc = turf.featureCollection([\n * turf.point([19.026432, 47.49134]),\n * turf.point([19.074497, 47.509548])\n * ]);\n *\n * var combined = turf.combine(fc);\n *\n * //addToMap\n * var addToMap = [combined]\n */\nfunction combine(\n fc: FeatureCollection<\n Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon\n >\n) {\n var groups = {\n MultiPoint: {\n coordinates: [] as number[][],\n properties: [] as GeoJsonProperties[],\n },\n MultiLineString: {\n coordinates: [] as number[][][],\n properties: [] as GeoJsonProperties[],\n },\n MultiPolygon: {\n coordinates: [] as number[][][][],\n properties: [] as GeoJsonProperties[],\n },\n };\n\n featureEach(fc, (feature) => {\n switch (feature.geometry?.type) {\n case \"Point\":\n groups.MultiPoint.coordinates.push(feature.geometry.coordinates);\n groups.MultiPoint.properties.push(feature.properties);\n break;\n case \"MultiPoint\":\n groups.MultiPoint.coordinates.push(...feature.geometry.coordinates);\n groups.MultiPoint.properties.push(feature.properties);\n break;\n case \"LineString\":\n groups.MultiLineString.coordinates.push(feature.geometry.coordinates);\n groups.MultiLineString.properties.push(feature.properties);\n break;\n case \"MultiLineString\":\n groups.MultiLineString.coordinates.push(\n ...feature.geometry.coordinates\n );\n groups.MultiLineString.properties.push(feature.properties);\n break;\n case \"Polygon\":\n groups.MultiPolygon.coordinates.push(feature.geometry.coordinates);\n groups.MultiPolygon.properties.push(feature.properties);\n break;\n case \"MultiPolygon\":\n groups.MultiPolygon.coordinates.push(...feature.geometry.coordinates);\n groups.MultiPolygon.properties.push(feature.properties);\n break;\n default:\n break;\n }\n });\n\n return featureCollection(\n (Object.keys(groups) as (keyof typeof groups)[])\n .filter(function (key) {\n return groups[key].coordinates.length;\n })\n .sort()\n .map(function (key) {\n var geometry = { type: key, coordinates: groups[key].coordinates } as\n | MultiPoint\n | MultiLineString\n | MultiPolygon;\n var properties = { collectedProperties: groups[key].properties };\n return feature(geometry, properties);\n })\n );\n}\n\nexport { combine };\nexport default combine;\n"]}
@@ -0,0 +1,25 @@
1
+ import { FeatureCollection, Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeoJsonProperties } from 'geojson';
2
+
3
+ /**
4
+ * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features
5
+ * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.
6
+ *
7
+ * @name combine
8
+ * @param {FeatureCollection<Point|LineString|Polygon>} fc a FeatureCollection of any type
9
+ * @returns {FeatureCollection<MultiPoint|MultiLineString|MultiPolygon>} a FeatureCollection of corresponding type to input
10
+ * @example
11
+ * var fc = turf.featureCollection([
12
+ * turf.point([19.026432, 47.49134]),
13
+ * turf.point([19.074497, 47.509548])
14
+ * ]);
15
+ *
16
+ * var combined = turf.combine(fc);
17
+ *
18
+ * //addToMap
19
+ * var addToMap = [combined]
20
+ */
21
+ declare function combine(fc: FeatureCollection<Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon>): FeatureCollection<MultiPoint | MultiLineString | MultiPolygon, {
22
+ collectedProperties: GeoJsonProperties[];
23
+ }>;
24
+
25
+ export { combine, combine as default };
@@ -1,4 +1,5 @@
1
- import { GeoJsonProperties, FeatureCollection, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon } from "geojson";
1
+ import { FeatureCollection, Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeoJsonProperties } from 'geojson';
2
+
2
3
  /**
3
4
  * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features
4
5
  * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.
@@ -20,4 +21,5 @@ import { GeoJsonProperties, FeatureCollection, LineString, MultiLineString, Mult
20
21
  declare function combine(fc: FeatureCollection<Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon>): FeatureCollection<MultiPoint | MultiLineString | MultiPolygon, {
21
22
  collectedProperties: GeoJsonProperties[];
22
23
  }>;
23
- export default combine;
24
+
25
+ export { combine, combine as default };
@@ -0,0 +1,67 @@
1
+ // index.ts
2
+ import { feature, featureCollection } from "@turf/helpers";
3
+ import { featureEach } from "@turf/meta";
4
+ function combine(fc) {
5
+ var groups = {
6
+ MultiPoint: {
7
+ coordinates: [],
8
+ properties: []
9
+ },
10
+ MultiLineString: {
11
+ coordinates: [],
12
+ properties: []
13
+ },
14
+ MultiPolygon: {
15
+ coordinates: [],
16
+ properties: []
17
+ }
18
+ };
19
+ featureEach(fc, (feature2) => {
20
+ var _a;
21
+ switch ((_a = feature2.geometry) == null ? void 0 : _a.type) {
22
+ case "Point":
23
+ groups.MultiPoint.coordinates.push(feature2.geometry.coordinates);
24
+ groups.MultiPoint.properties.push(feature2.properties);
25
+ break;
26
+ case "MultiPoint":
27
+ groups.MultiPoint.coordinates.push(...feature2.geometry.coordinates);
28
+ groups.MultiPoint.properties.push(feature2.properties);
29
+ break;
30
+ case "LineString":
31
+ groups.MultiLineString.coordinates.push(feature2.geometry.coordinates);
32
+ groups.MultiLineString.properties.push(feature2.properties);
33
+ break;
34
+ case "MultiLineString":
35
+ groups.MultiLineString.coordinates.push(
36
+ ...feature2.geometry.coordinates
37
+ );
38
+ groups.MultiLineString.properties.push(feature2.properties);
39
+ break;
40
+ case "Polygon":
41
+ groups.MultiPolygon.coordinates.push(feature2.geometry.coordinates);
42
+ groups.MultiPolygon.properties.push(feature2.properties);
43
+ break;
44
+ case "MultiPolygon":
45
+ groups.MultiPolygon.coordinates.push(...feature2.geometry.coordinates);
46
+ groups.MultiPolygon.properties.push(feature2.properties);
47
+ break;
48
+ default:
49
+ break;
50
+ }
51
+ });
52
+ return featureCollection(
53
+ Object.keys(groups).filter(function(key) {
54
+ return groups[key].coordinates.length;
55
+ }).sort().map(function(key) {
56
+ var geometry = { type: key, coordinates: groups[key].coordinates };
57
+ var properties = { collectedProperties: groups[key].properties };
58
+ return feature(geometry, properties);
59
+ })
60
+ );
61
+ }
62
+ var turf_combine_default = combine;
63
+ export {
64
+ combine,
65
+ turf_combine_default as default
66
+ };
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n GeoJsonProperties,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { feature, featureCollection } from \"@turf/helpers\";\nimport { featureEach } from \"@turf/meta\";\n\n/**\n * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features\n * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.\n *\n * @name combine\n * @param {FeatureCollection<Point|LineString|Polygon>} fc a FeatureCollection of any type\n * @returns {FeatureCollection<MultiPoint|MultiLineString|MultiPolygon>} a FeatureCollection of corresponding type to input\n * @example\n * var fc = turf.featureCollection([\n * turf.point([19.026432, 47.49134]),\n * turf.point([19.074497, 47.509548])\n * ]);\n *\n * var combined = turf.combine(fc);\n *\n * //addToMap\n * var addToMap = [combined]\n */\nfunction combine(\n fc: FeatureCollection<\n Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon\n >\n) {\n var groups = {\n MultiPoint: {\n coordinates: [] as number[][],\n properties: [] as GeoJsonProperties[],\n },\n MultiLineString: {\n coordinates: [] as number[][][],\n properties: [] as GeoJsonProperties[],\n },\n MultiPolygon: {\n coordinates: [] as number[][][][],\n properties: [] as GeoJsonProperties[],\n },\n };\n\n featureEach(fc, (feature) => {\n switch (feature.geometry?.type) {\n case \"Point\":\n groups.MultiPoint.coordinates.push(feature.geometry.coordinates);\n groups.MultiPoint.properties.push(feature.properties);\n break;\n case \"MultiPoint\":\n groups.MultiPoint.coordinates.push(...feature.geometry.coordinates);\n groups.MultiPoint.properties.push(feature.properties);\n break;\n case \"LineString\":\n groups.MultiLineString.coordinates.push(feature.geometry.coordinates);\n groups.MultiLineString.properties.push(feature.properties);\n break;\n case \"MultiLineString\":\n groups.MultiLineString.coordinates.push(\n ...feature.geometry.coordinates\n );\n groups.MultiLineString.properties.push(feature.properties);\n break;\n case \"Polygon\":\n groups.MultiPolygon.coordinates.push(feature.geometry.coordinates);\n groups.MultiPolygon.properties.push(feature.properties);\n break;\n case \"MultiPolygon\":\n groups.MultiPolygon.coordinates.push(...feature.geometry.coordinates);\n groups.MultiPolygon.properties.push(feature.properties);\n break;\n default:\n break;\n }\n });\n\n return featureCollection(\n (Object.keys(groups) as (keyof typeof groups)[])\n .filter(function (key) {\n return groups[key].coordinates.length;\n })\n .sort()\n .map(function (key) {\n var geometry = { type: key, coordinates: groups[key].coordinates } as\n | MultiPoint\n | MultiLineString\n | MultiPolygon;\n var properties = { collectedProperties: groups[key].properties };\n return feature(geometry, properties);\n })\n );\n}\n\nexport { combine };\nexport default combine;\n"],"mappings":";AAUA,SAAS,SAAS,yBAAyB;AAC3C,SAAS,mBAAmB;AAoB5B,SAAS,QACP,IAGA;AACA,MAAI,SAAS;AAAA,IACX,YAAY;AAAA,MACV,aAAa,CAAC;AAAA,MACd,YAAY,CAAC;AAAA,IACf;AAAA,IACA,iBAA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,YAAY;AAIjE,UAAI,aAAa,EAAE,qBAAqB,OAAO,GAAG,EAAE,WAAW;AAC/D,aAAO,QAAQ,UAAU,UAAU;AAAA,IACrC,CAAC;AAAA,EACL;AACF;AAGA,IAAO,uBAAQ;","names":["feature"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/combine",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.1.0-alpha.7+0ce6ecca0",
4
4
  "description": "turf combine module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -23,43 +23,48 @@
23
23
  "multipolygon",
24
24
  "combine"
25
25
  ],
26
- "main": "dist/js/index.js",
27
- "module": "dist/es/index.js",
26
+ "type": "module",
27
+ "main": "dist/cjs/index.cjs",
28
+ "module": "dist/esm/index.js",
29
+ "types": "dist/esm/index.d.ts",
28
30
  "exports": {
29
31
  "./package.json": "./package.json",
30
32
  ".": {
31
- "types": "./dist/js/index.d.ts",
32
- "import": "./dist/es/index.js",
33
- "require": "./dist/js/index.js"
33
+ "import": {
34
+ "types": "./dist/esm/index.d.ts",
35
+ "default": "./dist/esm/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/cjs/index.d.cts",
39
+ "default": "./dist/cjs/index.cjs"
40
+ }
34
41
  }
35
42
  },
36
- "types": "dist/js/index.d.ts",
37
43
  "sideEffects": false,
38
44
  "files": [
39
45
  "dist"
40
46
  ],
41
47
  "scripts": {
42
- "bench": "tsx bench.js",
43
- "build": "npm-run-all build:*",
44
- "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
45
- "build:js": "tsc",
46
- "docs": "tsx ../../scripts/generate-readmes",
47
- "test": "npm-run-all test:*",
48
- "test:tape": "tsx test.js"
48
+ "bench": "tsx bench.ts",
49
+ "build": "tsup --config ../../tsup.config.ts",
50
+ "docs": "tsx ../../scripts/generate-readmes.ts",
51
+ "test": "npm-run-all --npm-path npm test:*",
52
+ "test:tape": "tsx test.ts"
49
53
  },
50
54
  "devDependencies": {
51
- "@types/tape": "*",
52
- "benchmark": "*",
53
- "npm-run-all": "*",
54
- "tape": "*",
55
- "tslint": "*",
56
- "tsx": "*",
57
- "typescript": "*"
55
+ "@types/benchmark": "^2.1.5",
56
+ "@types/tape": "^4.2.32",
57
+ "benchmark": "^2.1.4",
58
+ "npm-run-all": "^4.1.5",
59
+ "tape": "^5.7.2",
60
+ "tsup": "^8.0.1",
61
+ "tsx": "^4.6.2",
62
+ "typescript": "^5.2.2"
58
63
  },
59
64
  "dependencies": {
60
- "@turf/helpers": "^7.0.0-alpha.2",
61
- "@turf/meta": "^7.0.0-alpha.2",
62
- "tslib": "^2.3.0"
65
+ "@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
66
+ "@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
67
+ "tslib": "^2.6.2"
63
68
  },
64
- "gitHead": "dd35b52725945b4fa29a98d9a550733e06cc222e"
69
+ "gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
65
70
  }
package/dist/es/index.js DELETED
@@ -1,78 +0,0 @@
1
- import { feature, featureCollection } from "@turf/helpers";
2
- import { featureEach } from "@turf/meta";
3
- /**
4
- * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features
5
- * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.
6
- *
7
- * @name combine
8
- * @param {FeatureCollection<Point|LineString|Polygon>} fc a FeatureCollection of any type
9
- * @returns {FeatureCollection<MultiPoint|MultiLineString|MultiPolygon>} a FeatureCollection of corresponding type to input
10
- * @example
11
- * var fc = turf.featureCollection([
12
- * turf.point([19.026432, 47.49134]),
13
- * turf.point([19.074497, 47.509548])
14
- * ]);
15
- *
16
- * var combined = turf.combine(fc);
17
- *
18
- * //addToMap
19
- * var addToMap = [combined]
20
- */
21
- function combine(fc) {
22
- var groups = {
23
- MultiPoint: {
24
- coordinates: [],
25
- properties: [],
26
- },
27
- MultiLineString: {
28
- coordinates: [],
29
- properties: [],
30
- },
31
- MultiPolygon: {
32
- coordinates: [],
33
- properties: [],
34
- },
35
- };
36
- featureEach(fc, (feature) => {
37
- var _a;
38
- switch ((_a = feature.geometry) === null || _a === void 0 ? void 0 : _a.type) {
39
- case "Point":
40
- groups.MultiPoint.coordinates.push(feature.geometry.coordinates);
41
- groups.MultiPoint.properties.push(feature.properties);
42
- break;
43
- case "MultiPoint":
44
- groups.MultiPoint.coordinates.push(...feature.geometry.coordinates);
45
- groups.MultiPoint.properties.push(feature.properties);
46
- break;
47
- case "LineString":
48
- groups.MultiLineString.coordinates.push(feature.geometry.coordinates);
49
- groups.MultiLineString.properties.push(feature.properties);
50
- break;
51
- case "MultiLineString":
52
- groups.MultiLineString.coordinates.push(...feature.geometry.coordinates);
53
- groups.MultiLineString.properties.push(feature.properties);
54
- break;
55
- case "Polygon":
56
- groups.MultiPolygon.coordinates.push(feature.geometry.coordinates);
57
- groups.MultiPolygon.properties.push(feature.properties);
58
- break;
59
- case "MultiPolygon":
60
- groups.MultiPolygon.coordinates.push(...feature.geometry.coordinates);
61
- groups.MultiPolygon.properties.push(feature.properties);
62
- break;
63
- default:
64
- break;
65
- }
66
- });
67
- return featureCollection(Object.keys(groups)
68
- .filter(function (key) {
69
- return groups[key].coordinates.length;
70
- })
71
- .sort()
72
- .map(function (key) {
73
- var geometry = { type: key, coordinates: groups[key].coordinates };
74
- var properties = { collectedProperties: groups[key].properties };
75
- return feature(geometry, properties);
76
- }));
77
- }
78
- export default combine;
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const helpers_1 = require("@turf/helpers");
4
- const meta_1 = require("@turf/meta");
5
- /**
6
- * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features
7
- * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.
8
- *
9
- * @name combine
10
- * @param {FeatureCollection<Point|LineString|Polygon>} fc a FeatureCollection of any type
11
- * @returns {FeatureCollection<MultiPoint|MultiLineString|MultiPolygon>} a FeatureCollection of corresponding type to input
12
- * @example
13
- * var fc = turf.featureCollection([
14
- * turf.point([19.026432, 47.49134]),
15
- * turf.point([19.074497, 47.509548])
16
- * ]);
17
- *
18
- * var combined = turf.combine(fc);
19
- *
20
- * //addToMap
21
- * var addToMap = [combined]
22
- */
23
- function combine(fc) {
24
- var groups = {
25
- MultiPoint: {
26
- coordinates: [],
27
- properties: [],
28
- },
29
- MultiLineString: {
30
- coordinates: [],
31
- properties: [],
32
- },
33
- MultiPolygon: {
34
- coordinates: [],
35
- properties: [],
36
- },
37
- };
38
- meta_1.featureEach(fc, (feature) => {
39
- var _a;
40
- switch ((_a = feature.geometry) === null || _a === void 0 ? void 0 : _a.type) {
41
- case "Point":
42
- groups.MultiPoint.coordinates.push(feature.geometry.coordinates);
43
- groups.MultiPoint.properties.push(feature.properties);
44
- break;
45
- case "MultiPoint":
46
- groups.MultiPoint.coordinates.push(...feature.geometry.coordinates);
47
- groups.MultiPoint.properties.push(feature.properties);
48
- break;
49
- case "LineString":
50
- groups.MultiLineString.coordinates.push(feature.geometry.coordinates);
51
- groups.MultiLineString.properties.push(feature.properties);
52
- break;
53
- case "MultiLineString":
54
- groups.MultiLineString.coordinates.push(...feature.geometry.coordinates);
55
- groups.MultiLineString.properties.push(feature.properties);
56
- break;
57
- case "Polygon":
58
- groups.MultiPolygon.coordinates.push(feature.geometry.coordinates);
59
- groups.MultiPolygon.properties.push(feature.properties);
60
- break;
61
- case "MultiPolygon":
62
- groups.MultiPolygon.coordinates.push(...feature.geometry.coordinates);
63
- groups.MultiPolygon.properties.push(feature.properties);
64
- break;
65
- default:
66
- break;
67
- }
68
- });
69
- return helpers_1.featureCollection(Object.keys(groups)
70
- .filter(function (key) {
71
- return groups[key].coordinates.length;
72
- })
73
- .sort()
74
- .map(function (key) {
75
- var geometry = { type: key, coordinates: groups[key].coordinates };
76
- var properties = { collectedProperties: groups[key].properties };
77
- return helpers_1.feature(geometry, properties);
78
- }));
79
- }
80
- exports.default = combine;