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

Add Point Linestring Distance #573

Conversation

isVoid
Copy link
Contributor

@isVoid isVoid commented Jun 16, 2022

This PR adds point to linestring distance.

Contributes to #231

@github-actions github-actions bot added cmake Related to CMake code or build configuration libcuspatial Relates to the cuSpatial C++ library labels Jun 16, 2022
@harrism harrism added feature request New feature or request non-breaking Non-breaking change labels Jun 21, 2022
@github-actions
Copy link

This PR has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this PR if it is no longer required. Otherwise, please respond with a comment indicating any updates. This PR will be labeled inactive-90d if there is no activity in the next 60 days.

@harrism
Copy link
Member

harrism commented Jul 28, 2022

Probably should retarget to 22.10?

…into feature/header_only_point_linestring_distance
@isVoid isVoid changed the base branch from branch-22.08 to branch-22.10 August 1, 2022 16:41
@isVoid
Copy link
Contributor Author

isVoid commented Aug 17, 2022

rerun tests

(Seems like the rest of the CI is blocked by the fixes included in this PR)

@isVoid
Copy link
Contributor Author

isVoid commented Aug 17, 2022

The last test failure was results from the incorrect grid-stride loop guard condition. The last point of the last linestring point array should not be accessed since each iteration handles one line-segment. Thus the guard condition should be:

idx < std::distance(linestring_points_first, thrust::prev(linestring_points_last));

The skip condition in the loop is also missing a check on OB iterator. And should skip iteration to next grid-stride instead of just returning. (The length of each linestring does not correlate with grid-stride).

if (offsets_iter != linestring_offsets_last and *offsets_iter - 1 == idx) { continue; }

@isVoid isVoid requested a review from harrism August 17, 2022 18:34
* pair
* @param linestring_points_last end of the range of points of the linestring element of each pair
* @param distances_first beginning the output range of distances
* @param stream The CUDA stream to use for device memory operations and kernel launches.
Copy link
Contributor

Choose a reason for hiding this comment

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

These docs aren't the same as the ones in detail/point_linestring_distance.cuh, but they are close. I slightly prefer the ones in detail. I don't like seeing the duplication, is there a good solution to it? They'll diverge and need constant attention.

Copy link
Contributor Author

@isVoid isVoid Aug 17, 2022

Choose a reason for hiding this comment

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

We can use @copydoc to copy all documentation contents from one to other. But I haven't tested if we can override specifics secions/parameters after doing that. Will try it out.

Copy link
Member

Choose a reason for hiding this comment

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

You can add docs (e.g. additional @param) after @copydoc, but you can't remove.

Copy link
Contributor Author

@isVoid isVoid Aug 17, 2022

Choose a reason for hiding this comment

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

but you can't remove.

Do we want different doc contents for the internal function v.s. the user API? IMO the internal function doc should describe how the function works to help developer understand the logics, and user API docs should focus on usage, parameter constraints, exceptions etc..

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally, having started this conversation, I prefer a single doc. Everything being developed in C++ RAPIDS, detail, experimental, and public namespaces, is targeted at power users aka advanced developers. I don't see much of a distinction between developer and user. Plus maintenance is much more complicated to maintain parallel docsets that are almost the same but differ in obscure ways. I'm not dogmatic about this though, if you think more refined documentation is appropriate I won't stop you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, since the internal function will not be rendered on doxygen website, @copydoc will essentailly have no effect. Eventually the function's docstring goes with the function it decorates. While reducing duplication is a good thing, keeping track of remote referencing could be even a harder task to maintain without the help of doxygen.

@isVoid
Copy link
Contributor Author

isVoid commented Aug 19, 2022

@thomcom I believe I have added the geoarrow point array format and offset array format support per your review above.
The good news is I almost didn't have to touch the kernel at all. To your question:

I'm interested to find out in this if it works without modification.

The answer is positive.

One last thing that's missing from making this fully geoarrow compliant is supporting multi-linestring and multi-point. Since that's a pretty big change to the code, after a second thought, I'm planning to submit it as a separate PR.

Other than this I believe there's an open question for docstrings. If you agree, can we punt the question to later PR and proceed with this one?

@isVoid isVoid requested a review from thomcom August 19, 2022 17:34
@isVoid
Copy link
Contributor Author

isVoid commented Aug 23, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 85c0b61 into rapidsai:branch-22.10 Aug 23, 2022
@isVoid
Copy link
Contributor Author

isVoid commented Aug 23, 2022

Thanks to all reviewers, a draft follow up PR is up as promised: #660

@isVoid isVoid deleted the feature/header_only_point_linestring_distance branch August 23, 2022 03:29
rapids-bot bot pushed a commit that referenced this pull request Sep 13, 2022
…ython bindings (#660)

This PR adds multi-point and multi-linestring support to `point_linestring_distance`. The c++ API **always** supports multi-variant of the geometry type, since any single-geometry type can be wrapped with a `counting_iteartor` for its underlying geometry offset.

The column API accepts a `std::optional` for the geometry offset inputs. If not provided, they are considered single geometry by default. A `multigeom_dispatcher` is used to generalize the runtime to compile optional information.

This PR also builds python bindings for `point_linestring_distance`. First, the cython bindings is created with a backported `optional` module from cython 3.0 to support the above `std::optional` API. The cython APIs also made use of the dynamic typing property of python to allow geometry offsets to be optional arguments. The python API is the first examplar of a computing API accepting GeoSeries as input. For simplicity, we assume `GeoSeries` only contains single type geometry and there is no mixing of `points` and `multipoints`.

Contributes to #231 
Follow up to #573

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

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

URL: #660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team cmake Related to CMake code or build configuration feature request New feature or request libcuspatial Relates to the cuSpatial C++ library non-breaking Non-breaking change
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants