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] Nearest point and segment index of linestring to a point (pairwise) #646

Closed
harrism opened this issue Aug 15, 2022 · 7 comments · Fixed by #681
Closed

[FEA] Nearest point and segment index of linestring to a point (pairwise) #646

harrism opened this issue Aug 15, 2022 · 7 comments · Fixed by #681
Assignees
Labels
feature request New feature or request
Milestone

Comments

@harrism
Copy link
Member

harrism commented Aug 15, 2022

Is your feature request related to a problem? Please describe.

For linestring/point pairs, I would like to calculate not only the distance between points and linestrings, but also the nearest point on the linestring and possibly the index of the segment within the linestring that contains that nearest point.

Describe the solution you'd like

Ingestivate leveraging the functionality in #573 to provide the nearest point and segment index.

@harrism harrism added feature request New feature or request Needs Triage Need team to review and classify labels Aug 15, 2022
@harrism harrism moved this to Todo in cuSpatial Aug 15, 2022
@harrism harrism changed the title [FEA] Nearest point and segment index of linestring to a point [FEA] Nearest point and segment index of linestring to a point (pairwise) Aug 15, 2022
@isVoid isVoid self-assigned this Aug 16, 2022
@isVoid
Copy link
Contributor

isVoid commented Aug 16, 2022

To clarify, if a point is the same as a vertex, what's the result segment idx?

@harrism
Copy link
Member Author

harrism commented Aug 17, 2022

I think that is easily answered by considering the cases where the point is the first point or the last point in the linestring. Based on that, I think this is a good answer:

segment_idx = min(point_idx, num_segments - 1);

Where point_idx is the index of the point within the linestring, and num_segments is the number of segments in the linestring. (Note num_segments == num_points - 1, where num_points is the number of points in the linestring.)

So if we have 5 points and 4 segments in a linestring:

closest point index closest segment index
0 0
1 1
2 2
3 3
4 3

@isVoid
Copy link
Contributor

isVoid commented Aug 19, 2022

Another clarification: should the function handle multi-linestring in this method?

@harrism
Copy link
Member Author

harrism commented Aug 22, 2022

For the current request I haven't heard that this is needed. However for completeness I guess we should. The question is what do you return if so?

@isVoid
Copy link
Contributor

isVoid commented Aug 22, 2022

My prototype returns a third column that provides the "part index" of the linestring in a multi-linestring.

@harrism harrism removed the Needs Triage Need team to review and classify label Aug 24, 2022
@harrism harrism added this to the ST_Distance milestone Aug 24, 2022
@isVoid
Copy link
Contributor

isVoid commented Sep 7, 2022

A third clarification: in case there are multiple segments having equal distance to the point, how do you break the tie?

@harrism
Copy link
Member Author

harrism commented Sep 9, 2022

If we are only returning one, I would suggest to not guarantee any ordering. This gives the most flexibility in a parallel implementation.

@harrism harrism moved this from Todo to In Progress in cuSpatial Sep 12, 2022
rapids-bot bot pushed a commit that referenced this issue Sep 22, 2022
This PR adds C++ API of `point_linestring_nearest_points`. The host counterpart of this function is `shapely.ops.nearest_points`. Multiple fields are written when called on this API, including the geometry and part id indicating the geometry that the nearest point is on. In the header only API, the output iterator accepts a zipped iterator made of 4 output iterators. In the column API, a tuple is returned.

The kernel is parallelized per geometry. Each thread computes the nearest point between a pair of multipoint and multilinestring.

Contribute to #646

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - H. Thomson Comer (https://github.com/thomcom)
  - Mark Harris (https://github.com/harrism)

URL: #658
@rapids-bot rapids-bot bot closed this as completed in #681 Sep 29, 2022
rapids-bot bot pushed a commit that referenced this issue Sep 29, 2022
This PR adds python API for point-linestring nearest points. Closes #646 .
Depend on #658 #686 

This PR also moves `Feature_Enum` from io module to geometa module to make sure the coding is consistent and reused throughout the codebase.

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - Mark Harris (https://github.com/harrism)
  - H. Thomson Comer (https://github.com/thomcom)

URL: #681
Repository owner moved this from In Progress to Done in cuSpatial Sep 29, 2022
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
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants