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

turf-intersect

Package Overview
Dependencies
Maintainers
2
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 0.0.0 to 1.0.0

test/test.js

33

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')
var jsts = require('jsts');
var featurecollection = require('turf-featurecollection');
module.exports = function(polys1, polys2){
if(polys1.type === 'FeatureCollection') {
polys1 = polys1.features[0];
} else if(polys1.type !== 'Feature') {
polys1 = {
type: 'Feature',
geometry: polys1
};
}
if(polys2.type === 'FeatureCollection') {
polys2 = polys2.features[0];
} else if(polys2.type !== 'Feature') {
polys2 = {
type: 'Feature',
geometry: polys2
};
}
var reader = new jsts.io.GeoJSONReader(),
a = reader.read(JSON.stringify(polys1.features[0].geometry)),
b = reader.read(JSON.stringify(polys2.features[0].geometry)),
a = reader.read(JSON.stringify(polys1.geometry)),
b = reader.read(JSON.stringify(polys2.geometry)),
intersection = a.intersection(b),
parser = new jsts.io.GeoJSONParser()
parser = new jsts.io.GeoJSONParser();
intersection = parser.write(intersection)
intersection = featurecollection([intersection])
intersection = parser.write(intersection);
intersection = featurecollection([intersection]);
return intersection;
}
}
{
"name": "turf-intersect",
"version": "0.0.0",
"version": "1.0.0",
"description": "find the intersection of spatial features",
"main": "index.js",
"scripts": {
"test": "tape test/*.js"
"test": "node test/test.js"
},

@@ -9,0 +9,0 @@ "repository": {

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