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

Header-only polygon_bounding_boxes and linestring_bounding_boxes, make_geometry_id_iterator utility, and box<T> class. #820

Merged
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a23f06a
Add failing tests and empty header-only implementation
harrism Nov 23, 2022
dcc0f7f
Working header-only API
harrism Nov 23, 2022
df8d8f9
Port column-based API to call header-only API
harrism Nov 23, 2022
fe7bf68
Merge branch 'branch-23.02' into fea-header-only-polygon-bboxes
harrism Nov 24, 2022
44e2bd2
Fix tests, add expansion_radius
harrism Nov 24, 2022
5b87d80
Reinstate early out for empty
harrism Nov 24, 2022
02ad17b
tests
harrism Nov 24, 2022
2675fef
Add make_box_output_iterator and make_geometry_id_iterator factories.
harrism Nov 30, 2022
947da30
box type
harrism Nov 30, 2022
18642c1
use make_geometry_id_iterator
harrism Nov 30, 2022
2fdd802
Use box type
harrism Nov 30, 2022
bec3e95
doc
harrism Nov 30, 2022
7f85e72
Correct tparam name in doc
harrism Nov 30, 2022
1ebaea8
implementation tparam names
harrism Nov 30, 2022
a9bf663
header-only linestring_bounding_boxes refactor
harrism Nov 30, 2022
2df0fae
Merge branch 'branch-23.02' into fea-header-only-polygon-bboxes
harrism Dec 6, 2022
6f5bf15
Add deduction guides.
harrism Dec 7, 2022
de41f67
Fix index_to_geometry_id to actually return an ID and fix examples in…
harrism Dec 7, 2022
26acde0
Merge branch 'branch-23.02' into fea-header-only-polygon-bboxes
harrism Dec 13, 2022
63f770b
Merge branch 'branch-23.02' into fea-header-only-polygon-bboxes
harrism Dec 13, 2022
4b27c39
Generalize expect_segment_equivalent to expect_vec_2d_pair_equivalent…
harrism Dec 13, 2022
c86a332
Document segment and make more generic.
harrism Dec 13, 2022
79a9168
doc
harrism Dec 13, 2022
e0fc84a
doc
harrism Dec 13, 2022
fb1f2be
Missed first->v1, second -> v2
harrism Dec 13, 2022
fc2b339
Comply with GeoArrow spec for geometry and part offsets.
harrism Dec 13, 2022
fd8a67e
Add column API doc precondition about offsets for GeoArrow
harrism Dec 13, 2022
586e471
Fix python tests and column-based API offset size expectations
harrism Dec 14, 2022
53d3e0e
As above for linestring
harrism Dec 14, 2022
bce13d3
Add insufficient offsets test
harrism Dec 14, 2022
69ea0a1
include
harrism Dec 14, 2022
d0f7541
Add missing param docs
harrism Dec 14, 2022
434bf2f
Merge branch 'branch-23.02' into fea-header-only-polygon-bboxes
harrism Dec 14, 2022
b22019a
Fix quadtree bounding box tests for arrow offsets
harrism Dec 14, 2022
54f3bb0
Fix spatial join pytest
harrism Dec 14, 2022
d630cbb
Merge branch 'branch-23.02' into fea-header-only-polygon-bboxes
harrism Dec 14, 2022
7e1576a
Fix segment conflicts
harrism Dec 14, 2022
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
Next Next commit
Add failing tests and empty header-only implementation
  • Loading branch information
harrism committed Nov 23, 2022
commit a23f06ab4fc5f665e5f1a3588a3a6a3e85e0b571
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2022, 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 <rmm/cuda_stream_view.hpp>

namespace cuspatial {

template <class OffsetIteratorA,
class OffsetIteratorB,
class PointIterator,
class BoundingBoxIterator>
BoundingBoxIterator polygon_bounding_boxes(OffsetIteratorA polygon_offsets_first,
OffsetIteratorA polygon_offsets_last,
OffsetIteratorB polygon_ring_offsets_first,
OffsetIteratorB polygon_ring_offsets_last,
PointIterator polygon_points_first,
PointIterator polygon_points_last,
BoundingBoxIterator output_first,
rmm::cuda_stream_view stream)
{
return BoundingBoxIterator{};
}
} // namespace cuspatial
37 changes: 37 additions & 0 deletions cpp/include/cuspatial/experimental/polygon_bounding_boxes.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2022, 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 <rmm/cuda_stream_view.hpp>

namespace cuspatial {

template <class OffsetIteratorA,
class OffsetIteratorB,
class PointIterator,
class BoundingBoxIterator>
BoundingBoxIterator polygon_bounding_boxes(OffsetIteratorA polygon_offsets_first,
OffsetIteratorA polygon_offsets_last,
OffsetIteratorB polygon_ring_offsets_first,
OffsetIteratorB polygon_ring_offsets_last,
PointIterator polygon_points_first,
PointIterator polygon_points_last,
BoundingBoxIterator output_first,
rmm::cuda_stream_view stream = rmm::cuda_stream_default);
}

#include <cuspatial/experimental/detail/polygon_bounding_boxes.cuh>
8 changes: 6 additions & 2 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -74,8 +74,8 @@ ConfigureTest(POINT_QUADTREE_TEST
ConfigureTest(LINESTRING_BBOX_TEST
spatial/linestring_bbox_test.cu)

ConfigureTest(POLYGON_BBOX_TEST
spatial/polygon_bbox_test.cu)
ConfigureTest(POLYGON_BOUNDING_BOXES_TEST
spatial/polygon_bounding_boxes_test.cu)

ConfigureTest(POINT_DISTANCE_TEST
spatial/point_distance_test.cpp)
@@ -113,6 +113,10 @@ ConfigureTest(SPATIAL_WINDOW_POINT_TEST
# Experimental API
ConfigureTest(HAVERSINE_TEST_EXP
experimental/spatial/haversine_test.cu)

ConfigureTest(POLYGON_BOUNDING_BOXES_TEST_EXP
experimental/spatial/polygon_bounding_boxes_test.cu)

ConfigureTest(POINT_DISTANCE_TEST_EXP
experimental/spatial/point_distance_test.cu)

145 changes: 145 additions & 0 deletions cpp/tests/experimental/spatial/polygon_bounding_boxes_test.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright (c) 2022, 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.
*/

#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>

#include <cuspatial/error.hpp>
#include <cuspatial/experimental/polygon_bounding_boxes.cuh>
#include <cuspatial/vec_2d.hpp>

#include <gtest/gtest.h>

template <typename T>
struct PolygonBoundingBoxTest : public ::testing::Test {
};

using cuspatial::vec_2d;

using TestTypes = ::testing::Types<float, double>;

TYPED_TEST_CASE(PolygonBoundingBoxTest, TestTypes);

TYPED_TEST(PolygonBoundingBoxTest, test_empty)
{
using T = TypeParam;

auto poly_offsets = make_device_vector<int32_t>({});
auto ring_offsets = make_device_vector<int32_t>({});
auto points = make_device_vector<vec_2d<T>>({});

auto bbox_min = rmm::device_vector<cuspatial::vec_2d<T>>(poly_offsets.size());
auto bbox_max = rmm::device_vector<cuspatial::vec_2d<T>>(poly_offsets.size());

auto bboxes_begin = thrust::make_zip_iterator(bbox_min.begin(), bbox_max.begin());

auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
points.begin(),
points.end(),
bboxes_begin);

EXPECT_EQ(std::distance(bboxes_begin, bboxes_end), 0);
}

TYPED_TEST(PolygonBoundingBoxTest, test_one)
{
using T = TypeParam;

auto poly_offsets = make_device_vector<int32_t>({0});
auto ring_offsets = make_device_vector<int32_t>({0});
auto points = make_device_vector<vec_2d<T>>(
{{2.488450, 5.856625}, {1.333584, 5.008840}, {3.460720, 4.586599}});

auto bbox_min = rmm::device_vector<cuspatial::vec_2d<T>>(poly_offsets.size());
auto bbox_max = rmm::device_vector<cuspatial::vec_2d<T>>(poly_offsets.size());

auto bboxes_begin = thrust::make_zip_iterator(bbox_min.begin(), bbox_max.begin());

auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
points.begin(),
points.end(),
bboxes_begin);

EXPECT_EQ(std::distance(bboxes_begin, bboxes_end), 1);

auto bbox_min_expected = make_device_vector<vec_2d<T>>({{1.333584, .586599}});
auto bbox_max_expected = make_device_vector<vec_2d<T>>({{3.460720, 5.856625}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(bbox_min, bbox_min_expected);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(bbox_max, bbox_max_expected);
}

TYPED_TEST(PolygonBoundingBoxTest, test_small)
{
using T = TypeParam;

auto poly_offsets = make_device_vector<int32_t>({0, 1, 2, 3});
auto ring_offsets = make_device_vector<int32_t>({0, 3, 8, 12});
auto points = make_device_vector<vec_2d<T>>({// ring 1
{2.488450, 5.856625},
{1.333584, 5.008840},
{3.460720, 4.586599},
// ring 2
{5.039823, 4.229242},
{5.561707, 1.825073},
{7.103516, 1.503906},
{7.190674, 4.025879},
{5.998939, 5.653384},
// ring 3
{5.998939, 1.235638},
{5.573720, 0.197808},
{6.703534, 0.086693},
{5.998939, 1.235638},
// ring 4
{2.088115, 4.541529},
{1.034892, 3.530299},
{2.415080, 2.896937},
{3.208660, 3.745936},
{2.088115, 4.54152}});

auto bbox_min = rmm::device_vector<cuspatial::vec_2d<T>>(poly_offsets.size());
auto bbox_max = rmm::device_vector<cuspatial::vec_2d<T>>(poly_offsets.size());

auto bboxes_begin = thrust::make_zip_iterator(bbox_min.begin(), bbox_max.begin());

auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
points.begin(),
points.end(),
bboxes_begin);

EXPECT_EQ(std::distance(bboxes_begin, bboxes_end), 4);

auto bbox_min_expected =
make_device_vector<vec_2d<T>>({{1.3335840000000001, 4.5865989999999996},
{5.0398230000000002, 1.503906},
{5.5737199999999998, 0.086693000000000006},
{1.0348919999999999, 2.8969369999999999}});
auto bbox_max_expected =
make_device_vector<vec_2d<T>>({{3.4607199999999998, 5.8566250000000002},
{7.1906739999999996, 5.653384},
{6.7035340000000003, 1.235638},
{3.2086600000000001, 4.5415289999999997}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(bbox_min, bbox_min_expected);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(bbox_max, bbox_max_expected);
}
File renamed without changes.