@turf/intersect 7.0.0 → 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/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 +4 -4
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.7+0ce6ecca0",
|
|
4
4
|
"description": "turf intersect module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,10 +64,10 @@
|
|
|
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.7+0ce6ecca0",
|
|
68
|
+
"@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
|
|
69
69
|
"polygon-clipping": "^0.15.3",
|
|
70
70
|
"tslib": "^2.6.2"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
|
|
73
73
|
}
|