@turf/flatten 7.0.0-alpha.0 → 7.0.0-alpha.110
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 +22 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{es/index.js → cjs/index.d.ts} +7 -12
- package/dist/{js/index.js → esm/index.d.mts} +7 -15
- package/dist/esm/index.mjs +22 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +33 -22
- package/dist/es/package.json +0 -1
- package/index.d.ts +0 -27
package/README.md
CHANGED
|
@@ -37,26 +37,21 @@ Returns **[FeatureCollection][5]\<any>** all Multi-Geometries are flattened into
|
|
|
37
37
|
|
|
38
38
|
[5]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
39
39
|
|
|
40
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
41
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
42
|
-
./scripts/generate-readmes in the turf project. -->
|
|
40
|
+
<!-- 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. -->
|
|
43
41
|
|
|
44
42
|
---
|
|
45
43
|
|
|
46
|
-
This module is part of the [Turfjs project](
|
|
47
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
48
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
49
|
-
PRs and issues.
|
|
44
|
+
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.
|
|
50
45
|
|
|
51
46
|
### Installation
|
|
52
47
|
|
|
53
|
-
Install this module individually:
|
|
48
|
+
Install this single module individually:
|
|
54
49
|
|
|
55
50
|
```sh
|
|
56
51
|
$ npm install @turf/flatten
|
|
57
52
|
```
|
|
58
53
|
|
|
59
|
-
Or install the
|
|
54
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
60
55
|
|
|
61
56
|
```sh
|
|
62
57
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,22 @@
|
|
|
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 _meta = require('@turf/meta');
|
|
6
|
+
var _helpers = require('@turf/helpers');
|
|
7
|
+
function flatten(geojson) {
|
|
8
|
+
if (!geojson)
|
|
9
|
+
throw new Error("geojson is required");
|
|
10
|
+
var results = [];
|
|
11
|
+
_meta.flattenEach.call(void 0, geojson, function(feature) {
|
|
12
|
+
results.push(feature);
|
|
13
|
+
});
|
|
14
|
+
return _helpers.featureCollection.call(void 0, results);
|
|
15
|
+
}
|
|
16
|
+
__name(flatten, "flatten");
|
|
17
|
+
var turf_flatten_default = flatten;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.default = turf_flatten_default; exports.flatten = flatten;
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AA6ClC,SAAS,QAAQ,SAAwC;AACvD,MAAI,CAAC;AAAS,UAAM,IAAI,MAAM,qBAAqB;AAEnD,MAAI,UAAqB,CAAC;AAC1B,cAAY,SAAS,SAAU,SAAS;AACtC,YAAQ,KAAK,OAAO;AAAA,EACtB,CAAC;AACD,SAAO,kBAAkB,OAAO;AAClC;AARS;AAWT,IAAO,uBAAQ","sourcesContent":["import { flattenEach } from \"@turf/meta\";\nimport { featureCollection } from \"@turf/helpers\";\nimport type { AllGeoJSON } from \"@turf/helpers\";\nimport type {\n Feature,\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n FeatureCollection,\n Polygon,\n MultiPolygon,\n} from \"geojson\";\n\n/**\n * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).\n *\n * @name flatten\n * @param {GeoJSON} geojson any valid GeoJSON Object\n * @returns {FeatureCollection<any>} all Multi-Geometries are flattened into single Features\n * @example\n * var multiGeometry = turf.multiPolygon([\n * [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],\n * [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],\n * [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]\n * ]);\n *\n * var flatten = turf.flatten(multiGeometry);\n *\n * //addToMap\n * var addToMap = [flatten]\n */\nfunction flatten<T extends Point | MultiPoint>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Point>;\n\nfunction flatten<T extends LineString | MultiLineString>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<LineString>;\n\nfunction flatten<T extends Polygon | MultiPolygon>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Polygon>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection<any>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection {\n if (!geojson) throw new Error(\"geojson is required\");\n\n var results: Feature[] = [];\n flattenEach(geojson, function (feature) {\n results.push(feature);\n });\n return featureCollection(results);\n}\n\nexport { flatten };\nexport default flatten;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AllGeoJSON } from '@turf/helpers';
|
|
2
|
+
import { Point, MultiPoint, Feature, FeatureCollection, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
|
|
@@ -19,14 +19,9 @@ import { featureCollection } from '@turf/helpers';
|
|
|
19
19
|
* //addToMap
|
|
20
20
|
* var addToMap = [flatten]
|
|
21
21
|
*/
|
|
22
|
-
function flatten(geojson)
|
|
23
|
-
|
|
22
|
+
declare function flatten<T extends Point | MultiPoint>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Point>;
|
|
23
|
+
declare function flatten<T extends LineString | MultiLineString>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<LineString>;
|
|
24
|
+
declare function flatten<T extends Polygon | MultiPolygon>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Polygon>;
|
|
25
|
+
declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
flattenEach(geojson, function (feature) {
|
|
27
|
-
results.push(feature);
|
|
28
|
-
});
|
|
29
|
-
return featureCollection(results);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default flatten;
|
|
27
|
+
export { flatten as default, flatten };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var meta = require('@turf/meta');
|
|
4
|
-
var helpers = require('@turf/helpers');
|
|
1
|
+
import { AllGeoJSON } from '@turf/helpers';
|
|
2
|
+
import { Point, MultiPoint, Feature, FeatureCollection, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
|
|
@@ -21,15 +19,9 @@ var helpers = require('@turf/helpers');
|
|
|
21
19
|
* //addToMap
|
|
22
20
|
* var addToMap = [flatten]
|
|
23
21
|
*/
|
|
24
|
-
function flatten(geojson)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
meta.flattenEach(geojson, function (feature) {
|
|
29
|
-
results.push(feature);
|
|
30
|
-
});
|
|
31
|
-
return helpers.featureCollection(results);
|
|
32
|
-
}
|
|
22
|
+
declare function flatten<T extends Point | MultiPoint>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Point>;
|
|
23
|
+
declare function flatten<T extends LineString | MultiLineString>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<LineString>;
|
|
24
|
+
declare function flatten<T extends Polygon | MultiPolygon>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Polygon>;
|
|
25
|
+
declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
module.exports.default = flatten;
|
|
27
|
+
export { flatten as default, flatten };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { flattenEach } from "@turf/meta";
|
|
6
|
+
import { featureCollection } from "@turf/helpers";
|
|
7
|
+
function flatten(geojson) {
|
|
8
|
+
if (!geojson)
|
|
9
|
+
throw new Error("geojson is required");
|
|
10
|
+
var results = [];
|
|
11
|
+
flattenEach(geojson, function(feature) {
|
|
12
|
+
results.push(feature);
|
|
13
|
+
});
|
|
14
|
+
return featureCollection(results);
|
|
15
|
+
}
|
|
16
|
+
__name(flatten, "flatten");
|
|
17
|
+
var turf_flatten_default = flatten;
|
|
18
|
+
export {
|
|
19
|
+
turf_flatten_default as default,
|
|
20
|
+
flatten
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { flattenEach } from \"@turf/meta\";\nimport { featureCollection } from \"@turf/helpers\";\nimport type { AllGeoJSON } from \"@turf/helpers\";\nimport type {\n Feature,\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n FeatureCollection,\n Polygon,\n MultiPolygon,\n} from \"geojson\";\n\n/**\n * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).\n *\n * @name flatten\n * @param {GeoJSON} geojson any valid GeoJSON Object\n * @returns {FeatureCollection<any>} all Multi-Geometries are flattened into single Features\n * @example\n * var multiGeometry = turf.multiPolygon([\n * [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],\n * [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],\n * [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]\n * ]);\n *\n * var flatten = turf.flatten(multiGeometry);\n *\n * //addToMap\n * var addToMap = [flatten]\n */\nfunction flatten<T extends Point | MultiPoint>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Point>;\n\nfunction flatten<T extends LineString | MultiLineString>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<LineString>;\n\nfunction flatten<T extends Polygon | MultiPolygon>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Polygon>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection<any>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection {\n if (!geojson) throw new Error(\"geojson is required\");\n\n var results: Feature[] = [];\n flattenEach(geojson, function (feature) {\n results.push(feature);\n });\n return featureCollection(results);\n}\n\nexport { flatten };\nexport default flatten;\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AA6ClC,SAAS,QAAQ,SAAwC;AACvD,MAAI,CAAC;AAAS,UAAM,IAAI,MAAM,qBAAqB;AAEnD,MAAI,UAAqB,CAAC;AAC1B,cAAY,SAAS,SAAU,SAAS;AACtC,YAAQ,KAAK,OAAO;AAAA,EACtB,CAAC;AACD,SAAO,kBAAkB,OAAO;AAClC;AARS;AAWT,IAAO,uBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/flatten",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.110+1411d63a7",
|
|
4
4
|
"description": "turf flatten module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -27,40 +27,51 @@
|
|
|
27
27
|
"gis",
|
|
28
28
|
"featurecollection"
|
|
29
29
|
],
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"type": "commonjs",
|
|
31
|
+
"main": "dist/cjs/index.cjs",
|
|
32
|
+
"module": "dist/esm/index.mjs",
|
|
33
|
+
"types": "dist/cjs/index.d.ts",
|
|
32
34
|
"exports": {
|
|
33
35
|
"./package.json": "./package.json",
|
|
34
36
|
".": {
|
|
35
|
-
"import":
|
|
36
|
-
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./dist/esm/index.d.mts",
|
|
39
|
+
"default": "./dist/esm/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/cjs/index.d.ts",
|
|
43
|
+
"default": "./dist/cjs/index.cjs"
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
},
|
|
39
|
-
"types": "index.d.ts",
|
|
40
47
|
"sideEffects": false,
|
|
41
48
|
"files": [
|
|
42
|
-
"dist"
|
|
43
|
-
"index.d.ts"
|
|
49
|
+
"dist"
|
|
44
50
|
],
|
|
45
51
|
"scripts": {
|
|
46
|
-
"bench": "
|
|
47
|
-
"build": "
|
|
48
|
-
"docs": "
|
|
49
|
-
"test": "npm-run-all test:*",
|
|
50
|
-
"test:tape": "
|
|
52
|
+
"bench": "tsx bench.ts",
|
|
53
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
54
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
55
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
56
|
+
"test:tape": "tsx test.ts",
|
|
51
57
|
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
52
58
|
},
|
|
53
59
|
"devDependencies": {
|
|
54
|
-
"benchmark": "
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
+
"@types/benchmark": "^2.1.5",
|
|
61
|
+
"@types/tape": "^4.2.32",
|
|
62
|
+
"benchmark": "^2.1.4",
|
|
63
|
+
"load-json-file": "^7.0.1",
|
|
64
|
+
"npm-run-all": "^4.1.5",
|
|
65
|
+
"tape": "^5.7.2",
|
|
66
|
+
"tsup": "^8.0.1",
|
|
67
|
+
"tsx": "^4.6.2",
|
|
68
|
+
"typescript": "^5.2.2",
|
|
69
|
+
"write-json-file": "^5.0.0"
|
|
60
70
|
},
|
|
61
71
|
"dependencies": {
|
|
62
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
63
|
-
"@turf/meta": "^7.0.0-alpha.
|
|
72
|
+
"@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
|
|
73
|
+
"@turf/meta": "^7.0.0-alpha.110+1411d63a7",
|
|
74
|
+
"tslib": "^2.6.2"
|
|
64
75
|
},
|
|
65
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
|
|
66
77
|
}
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Point,
|
|
3
|
-
MultiPoint,
|
|
4
|
-
LineString,
|
|
5
|
-
MultiLineString,
|
|
6
|
-
Polygon,
|
|
7
|
-
MultiPolygon,
|
|
8
|
-
Feature,
|
|
9
|
-
FeatureCollection,
|
|
10
|
-
} from "geojson";
|
|
11
|
-
import { AllGeoJSON } from "@turf/helpers";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* http://turfjs.org/docs/#flatten
|
|
15
|
-
*/
|
|
16
|
-
declare function flatten<T extends Point | MultiPoint>(
|
|
17
|
-
geojson: Feature<T> | FeatureCollection<T> | T
|
|
18
|
-
): FeatureCollection<Point>;
|
|
19
|
-
declare function flatten<T extends LineString | MultiLineString>(
|
|
20
|
-
geojson: Feature<T> | FeatureCollection<T> | T
|
|
21
|
-
): FeatureCollection<LineString>;
|
|
22
|
-
declare function flatten<T extends Polygon | MultiPolygon>(
|
|
23
|
-
geojson: Feature<T> | FeatureCollection<T> | T
|
|
24
|
-
): FeatureCollection<Polygon>;
|
|
25
|
-
declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
|
|
26
|
-
|
|
27
|
-
export default flatten;
|