Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-intersect

Package Overview
Dependencies
Maintainers
8
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-intersect - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

npm-shrinkwrap.json

71

index.js
// 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;

{
"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"
}
}

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc