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

Sort the mergeable segments before computing merged segments #1207

Merged
merged 22 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
applied review comments
  • Loading branch information
isVoid committed Jul 14, 2023
commit bac1a362f40579af4e0065d885386722364d92a8
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ __device__ inline bool is_point_in_polygon(vec_2d<T> const& test_point, PolygonR
T run_to_point = test_point.x - a.x;

// point-on-edge test
bool is_colinear = float_equal(run * rise_to_point, run_to_point * rise);
if (is_colinear) {
bool is_collinear = float_equal(run * rise_to_point, run_to_point * rise);
if (is_collinear) {
T minx = a.x;
T maxx = b.x;
if (minx > maxx) thrust::swap(minx, maxx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void __global__ simple_find_and_combine_segments_kernel(OffsetRange offsets,
/**
* @brief Comparator for sorting the segment range.
*
* This comparator makes sure that the segment range are sorted by the following keys:
* This comparator makes sure that the segment range is sorted such that:
* 1. Segments with the same space id are grouped together.
* 2. Segments within the same space are grouped by their slope.
* 3. Within each slope group, segments are sorted by their lower left point.
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/cuspatial/detail/utility/linestring.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ __forceinline__ T __device__ point_to_segment_distance_squared(vec_2d<T> const&
* @brief Computes shortest distance between two segments (ab and cd) that don't intersect.
*/
template <typename T>
__forceinline__ T __device__ segment_distance_no_intersect_or_colinear(vec_2d<T> const& a,
vec_2d<T> const& b,
vec_2d<T> const& c,
vec_2d<T> const& d)
__forceinline__ T __device__ segment_distance_no_intersect_or_collinear(vec_2d<T> const& a,
vec_2d<T> const& b,
vec_2d<T> const& c,
vec_2d<T> const& d)
{
auto dist_sqr = min(
min(point_to_segment_distance_squared(a, c, d), point_to_segment_distance_squared(b, c, d)),
Expand All @@ -123,7 +123,7 @@ __forceinline__ T __device__ squared_segment_distance(vec_2d<T> const& a,

if (float_equal(denom, T{0})) {
// Segments parallel or collinear
return segment_distance_no_intersect_or_colinear(a, b, c, d);
return segment_distance_no_intersect_or_collinear(a, b, c, d);
}

auto ac = c - a;
Expand All @@ -132,7 +132,7 @@ __forceinline__ T __device__ squared_segment_distance(vec_2d<T> const& a,
auto r = r_numer * denom_reciprocal;
auto s = det(ac, ab) * denom_reciprocal;
if (r >= 0 and r <= 1 and s >= 0 and s <= 1) { return 0.0; }
return segment_distance_no_intersect_or_colinear(a, b, c, d);
return segment_distance_no_intersect_or_collinear(a, b, c, d);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_float_precision_limits(point, polygon, expects):
Unique success cases identified by @mharris. These go in a pair
with test_float_precision_limits_failures because these are
inconsistent results, where 0.6 fails above (as True, within the
polygon) and 0.66 below succeeds, though they are colinear.
polygon) and 0.66 below succeeds, though they are collinear.
"""
gpdpoint = gpd.GeoSeries(point)
gpdpolygon = gpd.GeoSeries(polygon)
Expand Down