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

Allow for duplicate coordinates #4

Closed
codeandcats opened this issue Nov 25, 2015 · 3 comments
Closed

Allow for duplicate coordinates #4

codeandcats opened this issue Nov 25, 2015 · 3 comments

Comments

@codeandcats
Copy link
Owner

Currently the tree will not allow you to add multiple data points with the same coordinates.
Though, I don't think there's any technical requirement for not allowing duplicate coordinates.

@codeandcats codeandcats changed the title Add ability to have multiple data points in same location Multiple data points in same location Nov 25, 2015
@codeandcats codeandcats changed the title Multiple data points in same location Allow for duplicate coordinates Nov 25, 2015
@ForNeVeR
Copy link

ForNeVeR commented Mar 6, 2016

+1

@codeandcats
Copy link
Owner Author

I'm thinking of adding a DuplicateBehavior property that is an enum with the following possible values:

  • Skip (Silently ignores requests to add a duplicate coord and returns False)
  • Error (Throws an exception if requested to add a duplicate coord)
  • Allow (Allows adding duplicate coordinates)
  • Update (Updates the existing node at coord with new value)

This would be added in a minor update with a default behavior of Skip for backwards compatibility.

Then in a major update I would update the default behavior to be Allow since I believe most cases would not care about multiple points at the same coordinate.

@codeandcats
Copy link
Owner Author

I've decided not to allow duplicates for now.

However, as of version 1.2.0 I've added an overloaded constructor for the KdTree which takes an AddDuplicateBehavior enum which specifies how to handle attempts to add nodes with coordinates that already exist. There are three options:

  • Skip (Current and Default behavior. Silently ignores request to add duplicate node and returns false)
  • Error (Throws a DuplicateNodeError exception when attempting to add duplicate node)
  • Update (Updates the existing node at coord with value of new node you're trying to add)

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

No branches or pull requests

2 participants