Turfjs / turf-intersect

find the intersection of features
30 stars 9 forks source link

Add support for FeatureCollections and update tests #8

Closed rukku closed 7 years ago

rukku commented 9 years ago

Intersecting featurecollections now result in a multipolygon.

Removed the 'intersect -- geometries' test as it will always fail as it assumes the input are Polygons or geometries. Added a new tests as well for the following inputs:

Just tell me if my tests are messy or something (first code PR, most contribute documentation. )

cc @morganherlocker @lyzidiamond

morganherlocker commented 9 years ago

hitting a dependency error when testing this:

➜  turf-intersect git:(master) ✗ npm t

> turf-intersect@1.4.1 test /Users/morgan/Documents/scratch/turf-intersect
> node test/test.js

module.js:340
    throw err;
          ^
Error: Cannot find module '../bower_components/closure-library/closure/goog/bootstrap/nodejs'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/morgan/Documents/scratch/turf-intersect/node_modules/jsts/node_modules/javascript.util/dist/javascript.util-node.min.js:42:237)
    at Object.<anonymous> (/Users/morgan/Documents/scratch/turf-intersect/node_modules/jsts/node_modules/javascript.util/dist/javascript.util-node.min.js:42:339)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
morganherlocker commented 9 years ago

ok, looks like this is an upstream jsts issue https://github.com/bjornharrtell/javascript.util/issues/10

robludwig commented 9 years ago

@morganherlocker see workaround here if you are interested in a temporary fix. you just need to hack in an earlier version of the broken dep

DenisCarriere commented 7 years ago

@rukku Thanks for the commits 👍

However this type of FeatureCollection support should be do via @turf/meta using featureEach().

FYI: the intersect module is being maintained in the main TurfJS library https://github.com/Turfjs/turf/tree/master/packages/turf-intersect