-
Notifications
You must be signed in to change notification settings - Fork 157
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
Header-only quadtree_point_to_nearest_linestring #1005
Merged
rapids-bot
merged 53 commits into
rapidsai:branch-23.04
from
harrism:fea-header-only-quadtree-point-to-nearest-linestring
Mar 30, 2023
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
3450ecb
Improve parameter documentation in point_quadtree
harrism 1d60510
copyright
harrism 85bc49d
Initial prototype of quadtree_point_in_polygon
harrism d00773d
Remove TODO since this PR is finishing it.
harrism 76bbc8e
Templatize
harrism b59467a
Initial header-only implementation (untested)
harrism e61f33b
Fix stream/mr parameter order
harrism 42ca6de
Working header-only refactor
harrism 411cc35
Merge branch 'branch-23.04' into fea-header-only-quadtree-pip
harrism 8785316
Merge branch 'branch-23.04' into fea-header-only-quadtree-pip
harrism a37eefc
Fix include path.
harrism f31fe78
stream, mr
harrism dd61ed8
stream, mr
harrism 4c7aede
Port small test to header-only API.
harrism 6659278
Port large test to header-only API
harrism 3465ada
Add `point_quadtree_ref` class and use to simplify APIs
harrism 8e2b426
style
harrism a2e2dfb
Replace separate x_min/y_min with vec_2d
harrism 7bb397d
Use c++17 for building tests!
harrism 987c56d
Use multipolygon_range
harrism 1c605d3
Style
harrism d49366d
Merge branch 'branch-23.04' into fea-header-only-quadtree-pip
harrism 61c330e
Fix CUSPATIAL_EXPECTS call
harrism d5455f3
Add missing includes.
harrism d1bc4a8
Merge branch 'branch-23.04' into fea-header-only-quadtree-pip
harrism 17e6223
style
harrism 69381ad
Fix benchmarks build
harrism c819ac0
Review feedback.
harrism c2369be
style
harrism 4531c9c
Passing C++, failing Pytest
harrism 63a39b2
Merge branch 'fea-header-only-quadtree-pip' into fea-header-only-quad…
harrism f02de59
style
harrism f8df520
Make is_vec_2d more generic and update usage.
harrism cab59f3
Use thrust::raw_reference_cast
harrism 57417bf
Refactor test
harrism 71ba3c0
Add and use linestring sizes validation macro(s).
harrism a14586c
[part|ring]_begin --> [part|ring]_offset_begin etc.
harrism db0a3d3
Fix error reason
harrism 17ae8ae
Error tests
harrism 89f02ac
Merge branch 'fea-header-only-quadtree-pip' into fea-header-only-quad…
harrism 281de32
Fix validation
harrism 78445af
Remove old test, add error (column-based) test
harrism 6e89da4
style
harrism baaf578
Spelling
harrism c1467d1
Merge branch 'fea-header-only-quadtree-pip' into fea-header-only-quad…
harrism 9e2e43e
Spelling
harrism 934d841
Merge branch 'branch-23.04' into fea-header-only-quadtree-pip
harrism 7d226ca
Merge branch 'fea-header-only-quadtree-pip' into fea-header-only-quad…
harrism 72be747
Fix polygon/linestring data in pytests
harrism acdd9ab
Re-add protected
harrism 71d69e2
Merge branch 'branch-23.04' of github.com:rapidsai/cuspatial into fea…
harrism 39a0c48
Feedback from @isVoid
harrism 1885ded
"" -> <>
harrism File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
cpp/include/cuspatial/experimental/detail/algorithm/point_linestring_distance.cuh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cuspatial/experimental/geometry/linestring_ref.cuh> | ||
#include <cuspatial/experimental/geometry/segment.cuh> | ||
#include <cuspatial/vec_2d.hpp> | ||
|
||
namespace cuspatial { | ||
namespace detail { | ||
|
||
template <typename T> | ||
__device__ T proj2(segment<T> const& s, vec_2d<T> const& v) | ||
{ | ||
return dot(v - s.v1, s.v2 - s.v1); | ||
} | ||
|
||
template <typename T, typename LinestringRef> | ||
inline __device__ T point_linestring_distance(vec_2d<T> const& point, | ||
LinestringRef const& linestring) | ||
{ | ||
T distance_squared = std::numeric_limits<T>::max(); | ||
|
||
for (auto const& s : linestring) { | ||
auto v1p = point - s.v1; | ||
auto v2p = point - s.v2; | ||
auto d0 = dot(v1p, v1p); | ||
auto d1 = dot(v2p, v2p); | ||
auto d2 = s.length2(); | ||
auto d3 = proj2(s, point); | ||
auto const r = d3 * d3 / d2; | ||
auto const d = (d3 <= 0 || r >= d2) ? min(d0, d1) : d0 - r; | ||
distance_squared = min(distance_squared, d); | ||
} | ||
|
||
return sqrt(distance_squared); | ||
} | ||
|
||
} // namespace detail | ||
} // namespace cuspatial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I wonder if we can simplify
point_to_segment_distance_squared
inlinestring.cuh
with this API?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.
Yeah, I think it can be simplified, or factored in a way to maximize reuse.