turf-intersect
Advanced tools
| { | ||
| "name": "turf-intersect", | ||
| "version": "1.4.2", | ||
| "dependencies": { | ||
| "jsts": { | ||
| "version": "0.15.0", | ||
| "from": "jsts@>=0.15.0 <0.16.0", | ||
| "resolved": "https://registry.npmjs.org/jsts/-/jsts-0.15.0.tgz", | ||
| "dependencies": { | ||
| "javascript.util": { | ||
| "version": "0.12.5", | ||
| "resolved": "https://registry.npmjs.org/javascript.util/-/javascript.util-0.12.5.tgz" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
+45
-26
| // depend on jsts for now https://github.com/bjornharrtell/jsts/blob/master/examples/overlay.html | ||
| var jsts = require('jsts'); | ||
| var featurecollection = require('turf-featurecollection'); | ||
| /** | ||
| * Takes two {@link Polygon} features and finds their intersection. | ||
| * Takes two {@link Polygon|polygons} and finds their intersection. If they share a border, returns the border; if they don't intersect, returns undefined. | ||
| * | ||
| * @module turf/intersect | ||
| * @category transformation | ||
| * @param {Polygon} poly1 the first Polygon | ||
| * @param {Polygon} poly2 the second Polygon | ||
| * @return {Polygon} a Polygon feature representing the area where `poly1` and `poly2` overlap | ||
| * @param {Feature<Polygon>} poly1 the first polygon | ||
| * @param {Feature<Polygon>} poly2 the second polygon | ||
| * @return {(Feature<Polygon>|undefined|Feature<MultiLineString>)} if `poly1` and `poly2` overlap, returns a Polygon feature representing the area they overlap; if `poly1` and `poly2` do not overlap, returns `undefined`; if `poly1` and `poly2` share a border, a MultiLineString of the locations where their borders are shared | ||
| * @example | ||
| * var poly1 = turf.polygon([[ | ||
| * [-122.801742, 45.48565], | ||
| * [-122.801742, 45.60491], | ||
| * [-122.584762, 45.60491], | ||
| * [-122.584762, 45.48565], | ||
| * [-122.801742, 45.48565] | ||
| * ]]); | ||
| * poly1.properties.fill = '#0f0'; | ||
| * var poly2 = turf.polygon([[ | ||
| * [-122.520217, 45.535693], | ||
| * [-122.64038, 45.553967], | ||
| * [-122.720031, 45.526554], | ||
| * [-122.669906, 45.507309], | ||
| * [-122.723464, 45.446643], | ||
| * [-122.532577, 45.408574], | ||
| * [-122.487258, 45.477466], | ||
| * [-122.520217, 45.535693] | ||
| * ]]); | ||
| * poly2.properties.fill = '#00f'; | ||
| * var polygons = turf.featurecollection([poly1, poly2]); | ||
| * var poly1 = { | ||
| * "type": "Feature", | ||
| * "properties": { | ||
| * "fill": "#0f0" | ||
| * }, | ||
| * "geometry": { | ||
| * "type": "Polygon", | ||
| * "coordinates": [[ | ||
| * [-122.801742, 45.48565], | ||
| * [-122.801742, 45.60491], | ||
| * [-122.584762, 45.60491], | ||
| * [-122.584762, 45.48565], | ||
| * [-122.801742, 45.48565] | ||
| * ]] | ||
| * } | ||
| * } | ||
| * var poly2 = { | ||
| * "type": "Feature", | ||
| * "properties": { | ||
| * "fill": "#00f" | ||
| * }, | ||
| * "geometry": { | ||
| * "type": "Polygon", | ||
| * "coordinates": [[ | ||
| * [-122.520217, 45.535693], | ||
| * [-122.64038, 45.553967], | ||
| * [-122.720031, 45.526554], | ||
| * [-122.669906, 45.507309], | ||
| * [-122.723464, 45.446643], | ||
| * [-122.532577, 45.408574], | ||
| * [-122.487258, 45.477466], | ||
| * [-122.520217, 45.535693] | ||
| * ]] | ||
| * } | ||
| * } | ||
| * | ||
| * var polygons = { | ||
| * "type": "FeatureCollection", | ||
| * "features": [poly1, poly2] | ||
| * }; | ||
| * | ||
| * var intersection = turf.intersect(poly1, poly2); | ||
@@ -42,3 +61,3 @@ * | ||
| module.exports = function(poly1, poly2){ | ||
| var geom1; | ||
| var geom1, geom2; | ||
| if(poly1.type === 'Feature') geom1 = poly1.geometry; | ||
@@ -45,0 +64,0 @@ else geom1 = poly1; |
+2
-3
| { | ||
| "name": "turf-intersect", | ||
| "version": "1.4.1", | ||
| "version": "1.4.2", | ||
| "description": "find the intersection of spatial features", | ||
@@ -33,5 +33,4 @@ "main": "index.js", | ||
| "dependencies": { | ||
| "jsts": "~0.15.0", | ||
| "turf-featurecollection": "^1.0.0" | ||
| "jsts": "~0.15.0" | ||
| } | ||
| } |
+49
-25
@@ -10,3 +10,3 @@ # turf-intersect | ||
| Takes two Polygon features and finds their intersection. | ||
| Takes two Polygon|polygons and finds their intersection. If they share a border, returns the border; if they don't intersect, returns undefined. | ||
@@ -16,6 +16,6 @@ | ||
| | parameter | type | description | | ||
| | --------- | ------- | ------------------ | | ||
| | `poly1` | Polygon | the first Polygon | | ||
| | `poly2` | Polygon | the second Polygon | | ||
| | parameter | type | description | | ||
| | --------- | -------------------- | ------------------ | | ||
| | `poly1` | Feature\.\<Polygon\> | the first polygon | | ||
| | `poly2` | Feature\.\<Polygon\> | the second polygon | | ||
@@ -26,23 +26,43 @@ | ||
| ```js | ||
| var poly1 = turf.polygon([[ | ||
| [-122.801742, 45.48565], | ||
| [-122.801742, 45.60491], | ||
| [-122.584762, 45.60491], | ||
| [-122.584762, 45.48565], | ||
| [-122.801742, 45.48565] | ||
| ]]); | ||
| poly1.properties.fill = '#0f0'; | ||
| var poly2 = turf.polygon([[ | ||
| [-122.520217, 45.535693], | ||
| [-122.64038, 45.553967], | ||
| [-122.720031, 45.526554], | ||
| [-122.669906, 45.507309], | ||
| [-122.723464, 45.446643], | ||
| [-122.532577, 45.408574], | ||
| [-122.487258, 45.477466], | ||
| [-122.520217, 45.535693] | ||
| ]]); | ||
| poly2.properties.fill = '#00f'; | ||
| var polygons = turf.featurecollection([poly1, poly2]); | ||
| var poly1 = { | ||
| "type": "Feature", | ||
| "properties": { | ||
| "fill": "#0f0" | ||
| }, | ||
| "geometry": { | ||
| "type": "Polygon", | ||
| "coordinates": [[ | ||
| [-122.801742, 45.48565], | ||
| [-122.801742, 45.60491], | ||
| [-122.584762, 45.60491], | ||
| [-122.584762, 45.48565], | ||
| [-122.801742, 45.48565] | ||
| ]] | ||
| } | ||
| } | ||
| var poly2 = { | ||
| "type": "Feature", | ||
| "properties": { | ||
| "fill": "#00f" | ||
| }, | ||
| "geometry": { | ||
| "type": "Polygon", | ||
| "coordinates": [[ | ||
| [-122.520217, 45.535693], | ||
| [-122.64038, 45.553967], | ||
| [-122.720031, 45.526554], | ||
| [-122.669906, 45.507309], | ||
| [-122.723464, 45.446643], | ||
| [-122.532577, 45.408574], | ||
| [-122.487258, 45.477466], | ||
| [-122.520217, 45.535693] | ||
| ]] | ||
| } | ||
| } | ||
| var polygons = { | ||
| "type": "FeatureCollection", | ||
| "features": [poly1, poly2] | ||
| }; | ||
| var intersection = turf.intersect(poly1, poly2); | ||
@@ -55,2 +75,5 @@ | ||
| **Returns** `Feature.<Polygon>,Feature.<MultiLineString>`, if `poly1` and `poly2` overlap, returns a Polygon feature representing the area they overlap; if `poly1` and `poly2` do not overlap, returns `undefined`; if `poly1` and `poly2` share a border, a MultiLineString of the locations where their borders are shared | ||
| ## Installation | ||
@@ -70,1 +93,2 @@ | ||
Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
17000
11.29%1
-50%14
7.69%526
7.57%90
36.36%1
Infinity%3
50%- Removed
- Removed