-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit of turf/boolean-within #924
Conversation
I'll try to make the |
* must not intersect the exterior of the secondary (geometry b). | ||
* Boolean-within returns the exact opposite result of the `@turf/boolean-contains`. | ||
* | ||
* @name booleanWith |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
booleanWithin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gees your diligent!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha! lolz..
case 'Polygon': | ||
return inside(geom1, geom2, true); | ||
default: | ||
throw new Error('feature2 ' + type2 + ' geometry not supported'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of throwing an error, it would be better to throw false
if Point cannot be within another Point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm this is the pattern we've followed for all the other boolean modules. I'd suggest if we want to change our approach for one then we should do it for all of them. Perhaps we should do this as a v5
change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, no might be fine... since some of the within
combinations don't actually make sense, this is good for now. 👍
case 'Polygon': | ||
return isMultiPointInPoly(geom1, geom2); | ||
default: | ||
throw new Error('feature2 ' + type2 + ' geometry not supported'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
throw new Error('feature2 ' + type2 + ' geometry not supported'); | ||
} | ||
default: | ||
throw new Error('feature1 ' + type1 + ' geometry not supported'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No support for MultiPolygon or MultiLineString?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet, but there probably should be. The problem is there aren't any picture for it and so I always forget :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HAHA no pictures 🤣 Those pictures are so helpful!
const result = within(feature1, feature2); | ||
if (process.env.JSTS) t.true(booleanJSTS('within', feature1, feature2), '[true] JSTS - ' + name); | ||
|
||
if (process.env.SHAPELY) shapely.within(feature1, feature2).then(result => t.true(result, '[true] shapely - ' + name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to try to make this look like this:
t.true(shapely.within(feature1, feature2), '[true] shapely - ' + name);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nicer :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! I got to get on that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great! Would be nice to know why those shapely boolean tests didn't pass, i'll look into that.
Seems like something crapped out on Mourner's eslint config: 🤔
|
@DenisCarriere that's what happened here!! 😢 |
@stebogit No it's not your fault 😄 Strange things happen with NPM modules, that's why locking them into the version is sometimes the best thing to do... I've locked in TurfJS's |
packages/turf-simplify/test.js
Outdated
@@ -4,7 +4,7 @@ const path = require('path'); | |||
const load = require('load-json-file'); | |||
const write = require('write-json-file'); | |||
const truncate = require('@turf/truncate'); | |||
const {polygon, multiPolygon} = require('@turf/helpers'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rowanwins Don't know why @turf/simplify
was modified in this PR. 🤷♂️
New module
@turf/boolean-within
npm test
at the sub modules where changes have occurred.npm run lint
to ensure code style at the turf module level.Submitting a new TurfJS Module.
./scripts/generate-readmes
to createREADME.md
.package.json
using "Full Name <@github Username>".Initial commit of the boolean-within module.
Tested against
jsts
usingboolean-jsts
with no issues. Tried testing usingboolean-shapely
but for some reason none of the tests resulting intrue
would pass.... probably something silly I did, all the fail tests worked fine...Let me know if you spot anything astray.