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

New module @turf/boolean-equal #869

Merged
merged 9 commits into from
Aug 2, 2017
Merged

New module @turf/boolean-equal #869

merged 9 commits into from
Aug 2, 2017

Conversation

stebogit
Copy link
Collaborator

@stebogit stebogit commented Jul 27, 2017

Imported from turf-equal.
Implements DE-9IM "equal" spatial relation.

TODOs:

  • remove redundant coordinated from input features

Thanks @tmcw and @tcql for the original work! 👍

@stebogit stebogit self-assigned this Jul 27, 2017
@rowanwins
Copy link
Member

rowanwins commented Jul 27, 2017

Hey @stebogit

Unfortunately this module isn't quite this simple.

For example the following lines should pass

[[0, 0], [2, 2]]
and 
[[0, 0] [,1, 1], [2, 2]]

Shapely provides this helpful definition

Returns True if the set-theoretic boundary, interior, and exterior of the object coincide with those of the other.

So points are easy, lines and polygons need a bit more thought.

Me thinks you'll probably need to start from scratch.

@DenisCarriere
Copy link
Member

DenisCarriere commented Jul 27, 2017

@rowanwins 👍 Good catch, added that test in this module.

Shapely successfully passes (True) & this current library tests fail (False) on lines-extra-vertices.geojson.

@stebogit
Copy link
Collaborator Author

stebogit commented Aug 1, 2017

the following lines should pass

[[0, 0], [2, 2]]
and 
[[0, 0] [,1, 1], [2, 2]]

@rowanwins @DenisCarriere the test now would pass if I could install the brand new @turf/clean-coords module; I tested it referencing the local module but I could not figure out how to install it from package.json. I tried yarn, npm and lerna bootstrap, but nothing. Can you please fix that?

BTW I had to fix how @turf/clean-coords handled a single clean segment (like [[0, 0], [2, 2]]) cause it was failing. Hope it's fine.

Please fill free to add more tests with unclean features if you like.

if (!feature2) throw new Error('feature2 is required');
var type1 = getGeomType(feature1);
var type2 = getGeomType(feature2);
if (type1 !== type2) throw new Error('features must be of the same type');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we throwing an error, shouldn't this simply return false?

if (type1 !== type2) return false;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahahah! yes that's right @DenisCarriere! 😅

Copy link
Member

@DenisCarriere DenisCarriere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Published

@DenisCarriere DenisCarriere merged commit d3e024f into master Aug 2, 2017
@DenisCarriere DenisCarriere deleted the equal branch August 2, 2017 02:30
@rowanwins
Copy link
Member

rowanwins commented Aug 2, 2017

From my quick glance at the source and tests this doesn't support polys that have different starting vertices
eg

[[[0,0],[1,1],[1,0],[0,0]]]
// should equal true
[[[1,1],[1,0],[0,0],[1,1]]]

So we might need a bit more thought here.

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

Successfully merging this pull request may close these issues.

3 participants