-
Notifications
You must be signed in to change notification settings - Fork 154
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 C++ API for point_linestring_nearest_points
#658
Add C++ API for point_linestring_nearest_points
#658
Conversation
…_linestring_distance
This reverts commit a8ec5ff.
This reverts commit 2ed60eb.
…into feature/header_only_point_linestring_distance
Co-authored-by: Mark Harris <mharris@nvidia.com>
…b.com:isVoid/cuspatial into feature/header_only_point_linestring_distance
…into feature/header_only_point_linestring_distance
…into feature/pairwise_point_to_nearest_linestring_point
…into feature/pairwise_point_to_nearest_linestring_point
Hi, I noticed that cython does not yet support |
done. |
rerun tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @isVoid !
cpp/include/cuspatial/experimental/detail/point_linestring_nearest_points.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/point_linestring_nearest_points.cuh
Outdated
Show resolved
Hide resolved
cpp/include/cuspatial/experimental/detail/point_linestring_nearest_points.cuh
Outdated
Show resolved
Hide resolved
thrust::distance(points_geometry_offsets_first, points_geometry_offsets_last) - 1; | ||
auto num_linestring_points = thrust::distance(linestring_points_first, linestring_points_last); | ||
|
||
for (auto idx = threadIdx.x + blockIdx.x * blockDim.x; idx < num_pairs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing this quadruple nested loop, I see now how important it will be to add automatic geometry iterators that know how to do the nested indexing. You want to be able to just iterate over the pairs, and for each pair, just have a for_each over the points and a nested for_each over the points of the multilinestring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, abstracting different level of iteration is direly needed. Perhaps we can continue the discussion in #677 ?
cpp/include/cuspatial/experimental/point_linestring_nearest_points.cuh
Outdated
Show resolved
Hide resolved
* ``` | ||
* | ||
* @param multipoint_geometry_offsets Beginning and ending indices for each multipoint | ||
* @param points_xy Interleaved x, y-coordinate of points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interleaved x and y doesn't match other cuspatial column-based APIs. We have always had the X/Y and Lon/Lat positions in separate columns, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We started making this adaptation for #649. We could keep them separate but on the python side this would always require 2 scatter operations before we can call c++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I was under the impression that if you are using the column-based API you are using dataframes, which tend to have a separate column for each field. What does GeoPandas do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A GeoSeries in geopandas is an array of structures. There's currently a discussion over the format of xy-coordinates going on at geoarrow:
geoarrow/geoarrow#26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We argued successfully to use xy interleaved coordinates for points to improve cache coherency and word size (coalesced memory access) availability for kernels when GeoArrow
was designed. @isVoid has been in the process of converting our existing APIs to support GeoArrow
more directly. I'll be following up in the above conversation today.
* ``` | ||
* | ||
* @param multipoint_geometry_offsets Beginning and ending indices for each multipoint | ||
* @param points_xy Interleaved x, y-coordinate of points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We argued successfully to use xy interleaved coordinates for points to improve cache coherency and word size (coalesced memory access) availability for kernels when GeoArrow
was designed. @isVoid has been in the process of converting our existing APIs to support GeoArrow
more directly. I'll be following up in the above conversation today.
rerun tests |
Upon addressing this comment: #658 (comment), I introduced a bug overwrites for thrust::tuple min repro: https://godbolt.org/z/drTr4dx8z |
Co-authored-by: H. Thomson Comer <thomcom@gmail.com>
I think this is ready to merge @isVoid? Congrats! :) |
@gpucibot merge |
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
This PR adds C++ API of
point_linestring_nearest_points
. The host counterpart of this function isshapely.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