@turf/combine 7.0.0-alpha.2 → 7.0.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 +4 -9
- package/dist/cjs/index.cjs +71 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +25 -0
- package/dist/{js → esm}/index.d.ts +4 -2
- package/dist/esm/index.js +71 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +30 -25
- package/dist/es/index.js +0 -78
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -80
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](
|
|
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
|
|
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,71 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
var _helpers = require('@turf/helpers');
|
|
6
|
+
var _meta = require('@turf/meta');
|
|
7
|
+
function combine(fc) {
|
|
8
|
+
var groups = {
|
|
9
|
+
MultiPoint: {
|
|
10
|
+
coordinates: [],
|
|
11
|
+
properties: []
|
|
12
|
+
},
|
|
13
|
+
MultiLineString: {
|
|
14
|
+
coordinates: [],
|
|
15
|
+
properties: []
|
|
16
|
+
},
|
|
17
|
+
MultiPolygon: {
|
|
18
|
+
coordinates: [],
|
|
19
|
+
properties: []
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
_meta.featureEach.call(void 0, fc, (feature2) => {
|
|
23
|
+
var _a;
|
|
24
|
+
switch ((_a = feature2.geometry) == null ? void 0 : _a.type) {
|
|
25
|
+
case "Point":
|
|
26
|
+
groups.MultiPoint.coordinates.push(feature2.geometry.coordinates);
|
|
27
|
+
groups.MultiPoint.properties.push(feature2.properties);
|
|
28
|
+
break;
|
|
29
|
+
case "MultiPoint":
|
|
30
|
+
groups.MultiPoint.coordinates.push(...feature2.geometry.coordinates);
|
|
31
|
+
groups.MultiPoint.properties.push(feature2.properties);
|
|
32
|
+
break;
|
|
33
|
+
case "LineString":
|
|
34
|
+
groups.MultiLineString.coordinates.push(feature2.geometry.coordinates);
|
|
35
|
+
groups.MultiLineString.properties.push(feature2.properties);
|
|
36
|
+
break;
|
|
37
|
+
case "MultiLineString":
|
|
38
|
+
groups.MultiLineString.coordinates.push(
|
|
39
|
+
...feature2.geometry.coordinates
|
|
40
|
+
);
|
|
41
|
+
groups.MultiLineString.properties.push(feature2.properties);
|
|
42
|
+
break;
|
|
43
|
+
case "Polygon":
|
|
44
|
+
groups.MultiPolygon.coordinates.push(feature2.geometry.coordinates);
|
|
45
|
+
groups.MultiPolygon.properties.push(feature2.properties);
|
|
46
|
+
break;
|
|
47
|
+
case "MultiPolygon":
|
|
48
|
+
groups.MultiPolygon.coordinates.push(...feature2.geometry.coordinates);
|
|
49
|
+
groups.MultiPolygon.properties.push(feature2.properties);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return _helpers.featureCollection.call(void 0,
|
|
56
|
+
Object.keys(groups).filter(function(key) {
|
|
57
|
+
return groups[key].coordinates.length;
|
|
58
|
+
}).sort().map(function(key) {
|
|
59
|
+
var geometry = { type: key, coordinates: groups[key].coordinates };
|
|
60
|
+
var properties = { collectedProperties: groups[key].properties };
|
|
61
|
+
return _helpers.feature.call(void 0, geometry, properties);
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
__name(combine, "combine");
|
|
66
|
+
var turf_combine_default = combine;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
exports.combine = combine; exports.default = turf_combine_default;
|
|
71
|
+
//# 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,MACd,YAAY,CAAC;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,aAAa,CAAC;AAAA,MACd,YAAY,CAAC;AAAA,IACf;AAAA,IACA,cAAc;AAAA,MACZ,aAAa,CAAC;AAAA,MACd,YAAY,CAAC;AAAA,IACf;AAAA,EACF;AAEA,cAAY,IAAI,CAACA,aAAY;AAnD/B;AAoDI,aAAQ,KAAAA,SAAQ,aAAR,mBAAkB,MAAM;AAAA,MAC9B,KAAK;AACH,eAAO,WAAW,YAAY,KAAKA,SAAQ,SAAS,WAAW;AAC/D,eAAO,WAAW,WAAW,KAAKA,SAAQ,UAAU;AACpD;AAAA,MACF,KAAK;AACH,eAAO,WAAW,YAAY,KAAK,GAAGA,SAAQ,SAAS,WAAW;AAClE,eAAO,WAAW,WAAW,KAAKA,SAAQ,UAAU;AACpD;AAAA,MACF,KAAK;AACH,eAAO,gBAAgB,YAAY,KAAKA,SAAQ,SAAS,WAAW;AACpE,eAAO,gBAAgB,WAAW,KAAKA,SAAQ,UAAU;AACzD;AAAA,MACF,KAAK;AACH,eAAO,gBAAgB,YAAY;AAAA,UACjC,GAAGA,SAAQ,SAAS;AAAA,QACtB;AACA,eAAO,gBAAgB,WAAW,KAAKA,SAAQ,UAAU;AACzD;AAAA,MACF,KAAK;AACH,eAAO,aAAa,YAAY,KAAKA,SAAQ,SAAS,WAAW;AACjE,eAAO,aAAa,WAAW,KAAKA,SAAQ,UAAU;AACtD;AAAA,MACF,KAAK;AACH,eAAO,aAAa,YAAY,KAAK,GAAGA,SAAQ,SAAS,WAAW;AACpE,eAAO,aAAa,WAAW,KAAKA,SAAQ,UAAU;AACtD;AAAA,MACF;AACE;AAAA,IACJ;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACJ,OAAO,KAAK,MAAM,EAChB,OAAO,SAAU,KAAK;AACrB,aAAO,OAAO,GAAG,EAAE,YAAY;AAAA,IACjC,CAAC,EACA,KAAK,EACL,IAAI,SAAU,KAAK;AAClB,UAAI,WAAW,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;AApES;AAuET,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 {
|
|
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
|
-
|
|
24
|
+
|
|
25
|
+
export { combine, combine as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { feature, featureCollection } from "@turf/helpers";
|
|
6
|
+
import { featureEach } from "@turf/meta";
|
|
7
|
+
function combine(fc) {
|
|
8
|
+
var groups = {
|
|
9
|
+
MultiPoint: {
|
|
10
|
+
coordinates: [],
|
|
11
|
+
properties: []
|
|
12
|
+
},
|
|
13
|
+
MultiLineString: {
|
|
14
|
+
coordinates: [],
|
|
15
|
+
properties: []
|
|
16
|
+
},
|
|
17
|
+
MultiPolygon: {
|
|
18
|
+
coordinates: [],
|
|
19
|
+
properties: []
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
featureEach(fc, (feature2) => {
|
|
23
|
+
var _a;
|
|
24
|
+
switch ((_a = feature2.geometry) == null ? void 0 : _a.type) {
|
|
25
|
+
case "Point":
|
|
26
|
+
groups.MultiPoint.coordinates.push(feature2.geometry.coordinates);
|
|
27
|
+
groups.MultiPoint.properties.push(feature2.properties);
|
|
28
|
+
break;
|
|
29
|
+
case "MultiPoint":
|
|
30
|
+
groups.MultiPoint.coordinates.push(...feature2.geometry.coordinates);
|
|
31
|
+
groups.MultiPoint.properties.push(feature2.properties);
|
|
32
|
+
break;
|
|
33
|
+
case "LineString":
|
|
34
|
+
groups.MultiLineString.coordinates.push(feature2.geometry.coordinates);
|
|
35
|
+
groups.MultiLineString.properties.push(feature2.properties);
|
|
36
|
+
break;
|
|
37
|
+
case "MultiLineString":
|
|
38
|
+
groups.MultiLineString.coordinates.push(
|
|
39
|
+
...feature2.geometry.coordinates
|
|
40
|
+
);
|
|
41
|
+
groups.MultiLineString.properties.push(feature2.properties);
|
|
42
|
+
break;
|
|
43
|
+
case "Polygon":
|
|
44
|
+
groups.MultiPolygon.coordinates.push(feature2.geometry.coordinates);
|
|
45
|
+
groups.MultiPolygon.properties.push(feature2.properties);
|
|
46
|
+
break;
|
|
47
|
+
case "MultiPolygon":
|
|
48
|
+
groups.MultiPolygon.coordinates.push(...feature2.geometry.coordinates);
|
|
49
|
+
groups.MultiPolygon.properties.push(feature2.properties);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return featureCollection(
|
|
56
|
+
Object.keys(groups).filter(function(key) {
|
|
57
|
+
return groups[key].coordinates.length;
|
|
58
|
+
}).sort().map(function(key) {
|
|
59
|
+
var geometry = { type: key, coordinates: groups[key].coordinates };
|
|
60
|
+
var properties = { collectedProperties: groups[key].properties };
|
|
61
|
+
return feature(geometry, properties);
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
__name(combine, "combine");
|
|
66
|
+
var turf_combine_default = combine;
|
|
67
|
+
export {
|
|
68
|
+
combine,
|
|
69
|
+
turf_combine_default as default
|
|
70
|
+
};
|
|
71
|
+
//# 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,iBAAiB;AAAA,MACf,aAAa,CAAC;AAAA,MACd,YAAY,CAAC;AAAA,IACf;AAAA,IACA,cAAc;AAAA,MACZ,aAAa,CAAC;AAAA,MACd,YAAY,CAAC;AAAA,IACf;AAAA,EACF;AAEA,cAAY,IAAI,CAACA,aAAY;AAnD/B;AAoDI,aAAQ,KAAAA,SAAQ,aAAR,mBAAkB,MAAM;AAAA,MAC9B,KAAK;AACH,eAAO,WAAW,YAAY,KAAKA,SAAQ,SAAS,WAAW;AAC/D,eAAO,WAAW,WAAW,KAAKA,SAAQ,UAAU;AACpD;AAAA,MACF,KAAK;AACH,eAAO,WAAW,YAAY,KAAK,GAAGA,SAAQ,SAAS,WAAW;AAClE,eAAO,WAAW,WAAW,KAAKA,SAAQ,UAAU;AACpD;AAAA,MACF,KAAK;AACH,eAAO,gBAAgB,YAAY,KAAKA,SAAQ,SAAS,WAAW;AACpE,eAAO,gBAAgB,WAAW,KAAKA,SAAQ,UAAU;AACzD;AAAA,MACF,KAAK;AACH,eAAO,gBAAgB,YAAY;AAAA,UACjC,GAAGA,SAAQ,SAAS;AAAA,QACtB;AACA,eAAO,gBAAgB,WAAW,KAAKA,SAAQ,UAAU;AACzD;AAAA,MACF,KAAK;AACH,eAAO,aAAa,YAAY,KAAKA,SAAQ,SAAS,WAAW;AACjE,eAAO,aAAa,WAAW,KAAKA,SAAQ,UAAU;AACtD;AAAA,MACF,KAAK;AACH,eAAO,aAAa,YAAY,KAAK,GAAGA,SAAQ,SAAS,WAAW;AACpE,eAAO,aAAa,WAAW,KAAKA,SAAQ,UAAU;AACtD;AAAA,MACF;AACE;AAAA,IACJ;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACJ,OAAO,KAAK,MAAM,EAChB,OAAO,SAAU,KAAK;AACrB,aAAO,OAAO,GAAG,EAAE,YAAY;AAAA,IACjC,CAAC,EACA,KAAK,EACL,IAAI,SAAU,KAAK;AAClB,UAAI,WAAW,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;AApES;AAuET,IAAO,uBAAQ;","names":["feature"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/combine",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
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
|
-
"
|
|
27
|
-
"
|
|
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
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
43
|
-
"build": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
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/
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
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
|
|
61
|
-
"@turf/meta": "^7.0.0
|
|
62
|
-
"tslib": "^2.
|
|
65
|
+
"@turf/helpers": "^7.0.0",
|
|
66
|
+
"@turf/meta": "^7.0.0",
|
|
67
|
+
"tslib": "^2.6.2"
|
|
63
68
|
},
|
|
64
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
|
|
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;
|
package/dist/es/package.json
DELETED
|
@@ -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;
|