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

[FEA]: Need a libcuspatial count_equal_points(lhs, rhs) function. #1020

Closed
thomcom opened this issue Mar 29, 2023 · 10 comments · Fixed by #1022
Closed

[FEA]: Need a libcuspatial count_equal_points(lhs, rhs) function. #1020

thomcom opened this issue Mar 29, 2023 · 10 comments · Fixed by #1022
Assignees
Labels
feature request New feature or request improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Comments

@thomcom
Copy link
Contributor

thomcom commented Mar 29, 2023

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request

Critical (currently preventing usage)

Please provide a clear description of problem you would like to solve.

As I've been implementing binary predicates I've discovered that there are plentiful cases wherein I need the ability to count the number of points in one buffer that are equal to the number of points in another buffer. While numerous equality comparisons are possible and fast in python, I can't without iteration compare a series of points, pairwise,with all other points in a buffer for equality.

For example,

mp1 = [0, 1, 3, 2, 4, 5, 7, 6]
mp2 = [0, 1, 2, 3, 4, 5, 6, 7, 4, 5]
result = count_equal_points(mp1, mp2)
print(result)
1
0
2
0

This feature is useful for many binary predicates, and can't be trivially implemented in python.

Describe any alternatives you have considered

No response

Additional context

No response

@thomcom thomcom added feature request New feature or request Needs Triage Need team to review and classify labels Mar 29, 2023
@isVoid
Copy link
Contributor

isVoid commented Mar 29, 2023

Not sure if I understand the input.

x = [0, 1, 3, 2, 4, 5, 7, 6]
y = [0, 1, 2, 3, 4, 5, 6, 7, 4, 5]
result = count_equal_points(x, y)
print(result)
1
0
2
0
  • x and y doesn't have the same number of input. Is this x/y coordinate?
  • Can you explain what does 1 0 2 0 stand for?

@thomcom
Copy link
Contributor Author

thomcom commented Mar 30, 2023

The output is an allpairs count equals result:

1 = x[0:2] == y[0:2]
0 = x[2:4] != any in y
2 = x[4:6] == y[4:6] and y[8:10]
0 = x[7:8] != any in y

One implementation pseudocode might be:

for each even number in len(x) as i:
    for each even number in len(y) as j:
        if x[i] == y[i] and x[i+1] == y[i+1]:
            result[i % 2]++

@thomcom
Copy link
Contributor Author

thomcom commented Mar 30, 2023

These are interleaved xy buffers.

@isVoid
Copy link
Contributor

isVoid commented Mar 30, 2023

So this looks like an all pairs equals count for two point arrays, or two multipoints. Do you just need this for single point array or multipoint array as well?

@thomcom
Copy link
Contributor Author

thomcom commented Mar 30, 2023

I only need it for single point array, I can convert any other geometry type into that as needed.

@harrism
Copy link
Member

harrism commented Mar 30, 2023

So the X and y arrays are not x- and y-coordinates? Can you make the original request example less confusing by not naming them X and y?

@harrism
Copy link
Member

harrism commented Mar 30, 2023

Do you want the count of matches of each point in the LHS to points of the RHS? Or do you just want true/false if each point in the LHS exists in the RHS? Two different algorithms with different costs...

@thomcom
Copy link
Contributor Author

thomcom commented Mar 31, 2023

No, I can see how that is confusing. mp1 and mp2 are multipoint arrays with interleaved xy coordinates.

I'm not sure yet if I need the count of matches or if I just need to know if any point in mp1 exists in mp2. I think I need both, but I'm working through implementations and haven't covered them all yet. One example is

mp1.touches(mp2), where I only need to know if any point in mp1 is equal to any point in mp2.

Another example is

mp1.equals(mp2), where I need to know if every point in mp1 is equal to every point in mp2.

The second example can be implemented easily in python, but the former example can't be implemented without pythonic iteration.

@isVoid
Copy link
Contributor

isVoid commented Mar 31, 2023

mp1.touches(mp2), where I only need to know if any point in mp1 is equal to any point in mp2.

For this I think you only need a True and False test? You don't need to create a counting function.

@harrism
Copy link
Member

harrism commented Mar 31, 2023

I would think Thrust set operations would be useful for these.

@thomcom thomcom self-assigned this Apr 5, 2023
@thomcom thomcom added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change and removed Needs Triage Need team to review and classify labels Apr 5, 2023
@thomcom thomcom moved this from Todo to In Progress in cuSpatial Apr 5, 2023
@thomcom thomcom moved this from In Progress to Review in cuSpatial Apr 7, 2023
@github-project-automation github-project-automation bot moved this from Review to Done in cuSpatial Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants