@turf/intersect 7.0.0 → 7.1.0-alpha.70
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 +6 -10
- package/dist/cjs/index.cjs +1 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@ finds their polygonal intersection. If they don't intersect, returns null.
|
|
|
9
9
|
|
|
10
10
|
### Parameters
|
|
11
11
|
|
|
12
|
-
* `features` **[FeatureCollection][3]<([Polygon][
|
|
13
|
-
* `options` **[Object][
|
|
12
|
+
* `features` **[FeatureCollection][3]<([Polygon][1] | [MultiPolygon][2])>** the features to intersect
|
|
13
|
+
* `options` **[Object][4]** Optional Parameters (optional, default `{}`)
|
|
14
14
|
|
|
15
|
-
* `options.properties` **[Object][
|
|
15
|
+
* `options.properties` **[Object][4]** Translate GeoJSON Properties to Feature (optional, default `{}`)
|
|
16
16
|
|
|
17
17
|
### Examples
|
|
18
18
|
|
|
@@ -42,7 +42,7 @@ var intersection = turf.intersect(turf.featureCollection([poly1, poly2]));
|
|
|
42
42
|
var addToMap = [poly1, poly2, intersection];
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Returns **([Feature][
|
|
45
|
+
Returns **([Feature][5] | null)** returns a feature representing the area they share (either a [Polygon][1] or
|
|
46
46
|
[MultiPolygon][2]). If they do not share any area, returns `null`.
|
|
47
47
|
|
|
48
48
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
@@ -51,13 +51,9 @@ Returns **([Feature][7] | null)** returns a feature representing the area they s
|
|
|
51
51
|
|
|
52
52
|
[3]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
53
53
|
|
|
54
|
-
[4]: https://
|
|
54
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
55
55
|
|
|
56
|
-
[5]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
57
|
-
|
|
58
|
-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
59
|
-
|
|
60
|
-
[7]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
56
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
61
57
|
|
|
62
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. -->
|
|
63
59
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// index.ts
|
|
5
2
|
var _helpers = require('@turf/helpers');
|
|
6
3
|
var _meta = require('@turf/meta');
|
|
7
4
|
var _polygonclipping = require('polygon-clipping'); var _polygonclipping2 = _interopRequireDefault(_polygonclipping);
|
|
@@ -23,7 +20,6 @@ function intersect(features, options = {}) {
|
|
|
23
20
|
return _helpers.polygon.call(void 0, intersection[0], options.properties);
|
|
24
21
|
return _helpers.multiPolygon.call(void 0, intersection, options.properties);
|
|
25
22
|
}
|
|
26
|
-
__name(intersect, "intersect");
|
|
27
23
|
var turf_intersect_default = intersect;
|
|
28
24
|
|
|
29
25
|
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AAOA,SAAS,cAAc,eAAe;AACtC,SAAS,gBAAgB;AACzB,OAAO,qBAAqB;AAqC5B,SAAS,UACP,UACA,UAEI,CAAC,GACsC;AAC3C,QAAM,QAAgC,CAAC;AAEvC,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAAmC;AAAA,EACrD,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AACA,QAAM,eAAe,gBAAgB;AAAA,IACnC,MAAM,CAAC;AAAA,IACP,GAAG,MAAM,MAAM,CAAC;AAAA,EAClB;AACA,MAAI,aAAa,WAAW;AAAG,WAAO;AACtC,MAAI,aAAa,WAAW;AAC1B,WAAO,QAAQ,aAAa,CAAC,GAAG,QAAQ,UAAU;AACpD,SAAO,aAAa,cAAc,QAAQ,UAAU;AACtD;AAGA,IAAO,yBAAQ","sourcesContent":["import {\n Feature,\n GeoJsonProperties,\n MultiPolygon,\n Polygon,\n FeatureCollection,\n} from \"geojson\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport polygonClipping from \"polygon-clipping\";\n\n/**\n * Takes {@link Polygon|polygon} or {@link MultiPolygon|multi-polygon} geometries and\n * finds their polygonal intersection. If they don't intersect, returns null.\n *\n * @name intersect\n * @param {FeatureCollection<Polygon | MultiPolygon>} features the features to intersect\n * @param {Object} [options={}] Optional Parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Feature\n * @returns {Feature|null} returns a feature representing the area they share (either a {@link Polygon} or\n * {@link MultiPolygon}). If they do not share any area, returns `null`.\n * @example\n * var poly1 = turf.polygon([[\n * [-122.801742, 45.48565],\n * [-122.801742, 45.60491],\n * [-122.584762, 45.60491],\n * [-122.584762, 45.48565],\n * [-122.801742, 45.48565]\n * ]]);\n *\n * var poly2 = turf.polygon([[\n * [-122.520217, 45.535693],\n * [-122.64038, 45.553967],\n * [-122.720031, 45.526554],\n * [-122.669906, 45.507309],\n * [-122.723464, 45.446643],\n * [-122.532577, 45.408574],\n * [-122.487258, 45.477466],\n * [-122.520217, 45.535693]\n * ]]);\n *\n * var intersection = turf.intersect(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * var addToMap = [poly1, poly2, intersection];\n */\nfunction intersect<P extends GeoJsonProperties = GeoJsonProperties>(\n features: FeatureCollection<Polygon | MultiPolygon>,\n options: {\n properties?: P;\n } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n const geoms: polygonClipping.Geom[] = [];\n\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polygonClipping.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must specify at least 2 geometries\");\n }\n const intersection = polygonClipping.intersection(\n geoms[0],\n ...geoms.slice(1)\n );\n if (intersection.length === 0) return null;\n if (intersection.length === 1)\n return polygon(intersection[0], options.properties);\n return multiPolygon(intersection, options.properties);\n}\n\nexport { intersect };\nexport default intersect;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// index.ts
|
|
5
2
|
import { multiPolygon, polygon } from "@turf/helpers";
|
|
6
3
|
import { geomEach } from "@turf/meta";
|
|
@@ -23,7 +20,6 @@ function intersect(features, options = {}) {
|
|
|
23
20
|
return polygon(intersection[0], options.properties);
|
|
24
21
|
return multiPolygon(intersection, options.properties);
|
|
25
22
|
}
|
|
26
|
-
__name(intersect, "intersect");
|
|
27
23
|
var turf_intersect_default = intersect;
|
|
28
24
|
export {
|
|
29
25
|
turf_intersect_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n Feature,\n GeoJsonProperties,\n MultiPolygon,\n Polygon,\n FeatureCollection,\n} from \"geojson\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport polygonClipping from \"polygon-clipping\";\n\n/**\n * Takes {@link Polygon|polygon} or {@link MultiPolygon|multi-polygon} geometries and\n * finds their polygonal intersection. If they don't intersect, returns null.\n *\n * @name intersect\n * @param {FeatureCollection<Polygon | MultiPolygon>} features the features to intersect\n * @param {Object} [options={}] Optional Parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Feature\n * @returns {Feature|null} returns a feature representing the area they share (either a {@link Polygon} or\n * {@link MultiPolygon}). If they do not share any area, returns `null`.\n * @example\n * var poly1 = turf.polygon([[\n * [-122.801742, 45.48565],\n * [-122.801742, 45.60491],\n * [-122.584762, 45.60491],\n * [-122.584762, 45.48565],\n * [-122.801742, 45.48565]\n * ]]);\n *\n * var poly2 = turf.polygon([[\n * [-122.520217, 45.535693],\n * [-122.64038, 45.553967],\n * [-122.720031, 45.526554],\n * [-122.669906, 45.507309],\n * [-122.723464, 45.446643],\n * [-122.532577, 45.408574],\n * [-122.487258, 45.477466],\n * [-122.520217, 45.535693]\n * ]]);\n *\n * var intersection = turf.intersect(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * var addToMap = [poly1, poly2, intersection];\n */\nfunction intersect<P extends GeoJsonProperties = GeoJsonProperties>(\n features: FeatureCollection<Polygon | MultiPolygon>,\n options: {\n properties?: P;\n } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n const geoms: polygonClipping.Geom[] = [];\n\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polygonClipping.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must specify at least 2 geometries\");\n }\n const intersection = polygonClipping.intersection(\n geoms[0],\n ...geoms.slice(1)\n );\n if (intersection.length === 0) return null;\n if (intersection.length === 1)\n return polygon(intersection[0], options.properties);\n return multiPolygon(intersection, options.properties);\n}\n\nexport { intersect };\nexport default intersect;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n Feature,\n GeoJsonProperties,\n MultiPolygon,\n Polygon,\n FeatureCollection,\n} from \"geojson\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport polygonClipping from \"polygon-clipping\";\n\n/**\n * Takes {@link Polygon|polygon} or {@link MultiPolygon|multi-polygon} geometries and\n * finds their polygonal intersection. If they don't intersect, returns null.\n *\n * @name intersect\n * @param {FeatureCollection<Polygon | MultiPolygon>} features the features to intersect\n * @param {Object} [options={}] Optional Parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Feature\n * @returns {Feature|null} returns a feature representing the area they share (either a {@link Polygon} or\n * {@link MultiPolygon}). If they do not share any area, returns `null`.\n * @example\n * var poly1 = turf.polygon([[\n * [-122.801742, 45.48565],\n * [-122.801742, 45.60491],\n * [-122.584762, 45.60491],\n * [-122.584762, 45.48565],\n * [-122.801742, 45.48565]\n * ]]);\n *\n * var poly2 = turf.polygon([[\n * [-122.520217, 45.535693],\n * [-122.64038, 45.553967],\n * [-122.720031, 45.526554],\n * [-122.669906, 45.507309],\n * [-122.723464, 45.446643],\n * [-122.532577, 45.408574],\n * [-122.487258, 45.477466],\n * [-122.520217, 45.535693]\n * ]]);\n *\n * var intersection = turf.intersect(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * var addToMap = [poly1, poly2, intersection];\n */\nfunction intersect<P extends GeoJsonProperties = GeoJsonProperties>(\n features: FeatureCollection<Polygon | MultiPolygon>,\n options: {\n properties?: P;\n } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n const geoms: polygonClipping.Geom[] = [];\n\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polygonClipping.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must specify at least 2 geometries\");\n }\n const intersection = polygonClipping.intersection(\n geoms[0],\n ...geoms.slice(1)\n );\n if (intersection.length === 0) return null;\n if (intersection.length === 1)\n return polygon(intersection[0], options.properties);\n return multiPolygon(intersection, options.properties);\n}\n\nexport { intersect };\nexport default intersect;\n"],"mappings":";AAOA,SAAS,cAAc,eAAe;AACtC,SAAS,gBAAgB;AACzB,OAAO,qBAAqB;AAqC5B,SAAS,UACP,UACA,UAEI,CAAC,GACsC;AAC3C,QAAM,QAAgC,CAAC;AAEvC,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAAmC;AAAA,EACrD,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AACA,QAAM,eAAe,gBAAgB;AAAA,IACnC,MAAM,CAAC;AAAA,IACP,GAAG,MAAM,MAAM,CAAC;AAAA,EAClB;AACA,MAAI,aAAa,WAAW;AAAG,WAAO;AACtC,MAAI,aAAa,WAAW;AAC1B,WAAO,QAAQ,aAAa,CAAC,GAAG,QAAQ,UAAU;AACpD,SAAO,aAAa,cAAc,QAAQ,UAAU;AACtD;AAGA,IAAO,yBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/intersect",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.70+948cdafaf",
|
|
4
4
|
"description": "turf intersect module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,10 +64,11 @@
|
|
|
64
64
|
"write-json-file": "^5.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@turf/helpers": "^7.0.
|
|
68
|
-
"@turf/meta": "^7.0.
|
|
67
|
+
"@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
|
|
68
|
+
"@turf/meta": "^7.1.0-alpha.70+948cdafaf",
|
|
69
|
+
"@types/geojson": "^7946.0.10",
|
|
69
70
|
"polygon-clipping": "^0.15.3",
|
|
70
71
|
"tslib": "^2.6.2"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
|
|
73
74
|
}
|