@turf/intersect
Advanced tools
Comparing version 7.1.0 to 7.2.0
@@ -7,3 +7,3 @@ import { GeoJsonProperties, FeatureCollection, Polygon, MultiPolygon, Feature } from 'geojson'; | ||
* | ||
* @name intersect | ||
* @function | ||
* @param {FeatureCollection<Polygon | MultiPolygon>} features the features to intersect | ||
@@ -10,0 +10,0 @@ * @param {Object} [options={}] Optional Parameters |
// index.ts | ||
import { multiPolygon, polygon } from "@turf/helpers"; | ||
import { geomEach } from "@turf/meta"; | ||
import polygonClipping from "polygon-clipping"; | ||
import * as polyclip from "polyclip-ts"; | ||
function intersect(features, options = {}) { | ||
@@ -13,11 +13,7 @@ const geoms = []; | ||
} | ||
const intersection = polygonClipping.intersection( | ||
geoms[0], | ||
...geoms.slice(1) | ||
); | ||
if (intersection.length === 0) | ||
return null; | ||
if (intersection.length === 1) | ||
return polygon(intersection[0], options.properties); | ||
return multiPolygon(intersection, options.properties); | ||
const intersection2 = polyclip.intersection(geoms[0], ...geoms.slice(1)); | ||
if (intersection2.length === 0) return null; | ||
if (intersection2.length === 1) | ||
return polygon(intersection2[0], options.properties); | ||
return multiPolygon(intersection2, options.properties); | ||
} | ||
@@ -24,0 +20,0 @@ var turf_intersect_default = intersect; |
{ | ||
"name": "@turf/intersect", | ||
"version": "7.1.0", | ||
"version": "7.2.0", | ||
"description": "turf intersect module", | ||
@@ -55,3 +55,3 @@ "author": "Turf Authors", | ||
"@types/benchmark": "^2.1.5", | ||
"@types/tape": "^4.2.32", | ||
"@types/tape": "^4.13.4", | ||
"benchmark": "^2.1.4", | ||
@@ -61,16 +61,16 @@ "glob": "^10.3.10", | ||
"npm-run-all": "^4.1.5", | ||
"tape": "^5.7.2", | ||
"tsup": "^8.0.1", | ||
"tsx": "^4.6.2", | ||
"typescript": "^5.2.2", | ||
"tape": "^5.9.0", | ||
"tsup": "^8.3.5", | ||
"tsx": "^4.19.2", | ||
"typescript": "^5.5.4", | ||
"write-json-file": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@turf/helpers": "^7.1.0", | ||
"@turf/meta": "^7.1.0", | ||
"@turf/helpers": "^7.2.0", | ||
"@turf/meta": "^7.2.0", | ||
"@types/geojson": "^7946.0.10", | ||
"polygon-clipping": "^0.15.3", | ||
"tslib": "^2.6.2" | ||
"polyclip-ts": "^0.16.8", | ||
"tslib": "^2.8.1" | ||
}, | ||
"gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef" | ||
"gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16690
84
+ Addedpolyclip-ts@^0.16.8
+ Addedbignumber.js@9.1.2(transitive)
+ Addedpolyclip-ts@0.16.8(transitive)
+ Addedsplaytree-ts@1.0.2(transitive)
- Removedpolygon-clipping@^0.15.3
- Removedpolygon-clipping@0.15.7(transitive)
- Removedrobust-predicates@3.0.2(transitive)
- Removedsplaytree@3.1.2(transitive)
Updated@turf/helpers@^7.2.0
Updated@turf/meta@^7.2.0
Updatedtslib@^2.8.1