Skip to content
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

Improve booleanOverlap docs #1333

Closed
Stophface opened this issue Mar 26, 2018 · 6 comments
Closed

Improve booleanOverlap docs #1333

Stophface opened this issue Mar 26, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@Stophface
Copy link

Stophface commented Mar 26, 2018

I am having this polygon:

const polygon = JSON.parse('{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[6.26950853,50.72473626],[6.26953794,50.72468996],[6.2695546,50.7246512],[6.26949169,50.72468741],[6.26948194,50.72469389],[6.26946154,50.72470787],[6.26949172,50.72474162],[6.26950853,50.72473626]]]}}');

and this bounding box:

const bbox = JSON.parse('{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[6.511887823915231,50.950514414615334],[6.512896634823051,50.53594214902105],[5.98503728350704,50.53594214902105],[5.98604609441486,50.950514414615334],[6.511887823915231,50.950514414615334]]]}}');

I want to know if the polygon is intesecting the bounding box

I use booleanOverlap

turf.booleanOverlap(polygon, bbox);

It returns false.

Why is that? That definetly is within the bounding box. As far as I understand it should return true?

@Stophface
Copy link
Author

Ah, Ive got it.
The documentation says

"Compares two geometries of the same dimension and returns true if their intersection set results in a geometry different from both but of the same dimension. [...]"

My polygon is completely withing the bounding box. As far as I know an intersection (as the documentation says) encompasses a polygon that is within another polygon. What booleanOverlap does is only checking whether it overlaps or not. I think documentation is a little missleading here because it lets users think that booleanOverlap includes a within.

@rowanwins
Copy link
Member

Hi @Stophface

Yeah I think we could improve the docs for some of the boolean modules are understanding their definitions can be a bit finicky.

The following taken from the postgis docs is quite helpful

Returns TRUE if the Geometries "spatially overlap". By that we mean they intersect, but one does not completely contain another.

Cheers
Rowan

@rowanwins rowanwins added the docs label Mar 27, 2018
@Stophface
Copy link
Author

Stophface commented Mar 27, 2018

@rowanwins Yes. As far as I understand, an intersection is:

 return ((booleanWithin(polygon, bbox) || booleanOverlap(poylgon, bbox))

@rowanwins
Copy link
Member

booleanIntersects does now also exists, it's only a recent addition and hasn't made it's way into the docs, but it is available via npm, that said it just returns the opposite of booleanDisjoint.

@rowanwins rowanwins changed the title booleanOverlap gives unexpected result Improve booleanOverlap docs Mar 28, 2018
@rowanwins rowanwins added this to the v7.0.0 milestone Aug 13, 2018
@rowanwins rowanwins self-assigned this Aug 13, 2018
@andrewharvey
Copy link
Contributor

I just ran into this issue, I was thinking that booleanOverlap was an intersection, I can see here it's not. I think that once booleanIntersects makes it to the docs, this would clear up the issue as most people looking for intersects would use it rather than falsly trying to use overlap.

@rowanwins
Copy link
Member

Documentation updated via #2133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants