diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a171c0872..01566030b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: hooks: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v11.1.0 + rev: v15.0.7 hooks: - id: clang-format types_or: [c, c++, cuda] diff --git a/cpp/include/cuspatial/detail/nvtx/nvtx3.hpp b/cpp/include/cuspatial/detail/nvtx/nvtx3.hpp index fb90ea668..a77a73640 100644 --- a/cpp/include/cuspatial/detail/nvtx/nvtx3.hpp +++ b/cpp/include/cuspatial/detail/nvtx/nvtx3.hpp @@ -585,10 +585,10 @@ constexpr auto has_name_member() noexcept -> decltype(T::name, bool()) */ class domain { public: - domain(domain const&) = delete; + domain(domain const&) = delete; domain& operator=(domain const&) = delete; domain(domain&&) = delete; - domain& operator=(domain&&) = delete; + domain& operator=(domain&&) = delete; /** * @brief Returns reference to an instance of a function local static @@ -663,8 +663,7 @@ class domain { * applications will be grouped together. * */ - struct global { - }; + struct global {}; private: /** @@ -870,12 +869,12 @@ class color { */ constexpr nvtxColorType_t get_type() const noexcept { return _type; } - color() = delete; - ~color() = default; - color(color const&) = default; + color() = delete; + ~color() = default; + color(color const&) = default; color& operator=(color const&) = default; color(color&&) = default; - color& operator=(color&&) = default; + color& operator=(color&&) = default; private: /** @@ -937,12 +936,12 @@ class category { */ constexpr id_type get_id() const noexcept { return id_; } - category() = delete; - ~category() = default; - category(category const&) = default; + category() = delete; + ~category() = default; + category(category const&) = default; category& operator=(category const&) = default; category(category&&) = default; - category& operator=(category&&) = default; + category& operator=(category&&) = default; private: id_type const id_{}; ///< category's unique identifier @@ -1226,12 +1225,12 @@ class registered_message { */ nvtxStringHandle_t get_handle() const noexcept { return handle_; } - registered_message() = delete; - ~registered_message() = default; - registered_message(registered_message const&) = default; + registered_message() = delete; + ~registered_message() = default; + registered_message(registered_message const&) = default; registered_message& operator=(registered_message const&) = default; registered_message(registered_message&&) = default; - registered_message& operator=(registered_message&&) = default; + registered_message& operator=(registered_message&&) = default; private: nvtxStringHandle_t const handle_{}; ///< The handle returned from @@ -1612,11 +1611,11 @@ class event_attributes { attributes_.messageType = m.get_type(); } - ~event_attributes() = default; - event_attributes(event_attributes const&) = default; + ~event_attributes() = default; + event_attributes(event_attributes const&) = default; event_attributes& operator=(event_attributes const&) = default; event_attributes(event_attributes&&) = default; - event_attributes& operator=(event_attributes&&) = default; + event_attributes& operator=(event_attributes&&) = default; /** * @brief Get raw pointer to underlying NVTX attributes object. @@ -1741,10 +1740,10 @@ class domain_thread_range { */ domain_thread_range() : domain_thread_range{event_attributes{}} {} - domain_thread_range(domain_thread_range const&) = delete; + domain_thread_range(domain_thread_range const&) = delete; domain_thread_range& operator=(domain_thread_range const&) = delete; domain_thread_range(domain_thread_range&&) = delete; - domain_thread_range& operator=(domain_thread_range&&) = delete; + domain_thread_range& operator=(domain_thread_range&&) = delete; /** * @brief Destroy the domain_thread_range, ending the NVTX range event. @@ -1819,7 +1818,7 @@ class domain_process_range { if (not moved_from_) { nvtxRangeEnd(range_id_); } } - domain_process_range(domain_process_range const&) = delete; + domain_process_range(domain_process_range const&) = delete; domain_process_range& operator=(domain_process_range const&) = delete; domain_process_range(domain_process_range&& other) noexcept : range_id_{other.range_id_} diff --git a/cpp/include/cuspatial_test/base_fixture.hpp b/cpp/include/cuspatial_test/base_fixture.hpp index ae92c9fd3..52635c34d 100644 --- a/cpp/include/cuspatial_test/base_fixture.hpp +++ b/cpp/include/cuspatial_test/base_fixture.hpp @@ -54,8 +54,7 @@ class RMMResourceMixin { * class MyTestFixture : public cuspatial::test::BaseFixture {}; * ``` */ -class BaseFixture : public RMMResourceMixin, public ::testing::Test { -}; +class BaseFixture : public RMMResourceMixin, public ::testing::Test {}; /** * @brief Base test fixture class from which libcuspatial test with only value parameterization @@ -79,8 +78,7 @@ class BaseFixture : public RMMResourceMixin, public ::testing::Test { */ template class BaseFixtureWithParam : public RMMResourceMixin, - public ::testing::TestWithParam> { -}; + public ::testing::TestWithParam> {}; /** * @brief Floating point types to be used in libcuspatial tests diff --git a/cpp/scripts/run-clang-format.py b/cpp/scripts/run-clang-format.py index 435d83ffb..f47ac53a2 100644 --- a/cpp/scripts/run-clang-format.py +++ b/cpp/scripts/run-clang-format.py @@ -22,7 +22,7 @@ import tempfile -EXPECTED_VERSION = "11.1.0" +EXPECTED_VERSION = "15.0.7" VERSION_REGEX = re.compile(r"clang-format version ([0-9.]+)") # NOTE: populate this list with more top-level dirs as we add more of them to the cuspatial repo DEFAULT_DIRS = ["cpp/include", diff --git a/cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu b/cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu index 983be7c79..ddb8f7df5 100644 --- a/cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu +++ b/cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu @@ -26,8 +26,7 @@ // by the quadtree_point_in_polygon_test_small.cu test file. template -struct JoinQuadtreeAndBoundingBoxesErrorTest : public cuspatial::test::BaseFixture { -}; +struct JoinQuadtreeAndBoundingBoxesErrorTest : public cuspatial::test::BaseFixture {}; using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu b/cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu index 6825f3c06..a982632c8 100644 --- a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu +++ b/cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu @@ -42,8 +42,7 @@ */ template -struct PIPRefineTestLarge : public cuspatial::test::BaseFixture { -}; +struct PIPRefineTestLarge : public cuspatial::test::BaseFixture {}; using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu b/cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu index 60822cee3..f4e164877 100644 --- a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu +++ b/cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu @@ -34,8 +34,7 @@ * fully tested. */ template -struct PIPRefineTestSmall : public cuspatial::test::BaseFixture { -}; +struct PIPRefineTestSmall : public cuspatial::test::BaseFixture {}; using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu b/cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu index d5fd8e984..e4ca29b6b 100644 --- a/cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu +++ b/cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu @@ -27,8 +27,7 @@ #include template -struct QuadtreePointToLinestringTestSmall : public cuspatial::test::BaseFixture { -}; +struct QuadtreePointToLinestringTestSmall : public cuspatial::test::BaseFixture {}; using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/operators/linestrings_test.cu b/cpp/tests/experimental/operators/linestrings_test.cu index 1a6eea28b..bdfc508ea 100644 --- a/cpp/tests/experimental/operators/linestrings_test.cu +++ b/cpp/tests/experimental/operators/linestrings_test.cu @@ -40,8 +40,7 @@ template using optional_vec2d = thrust::optional>; template -struct SegmentIntersectionTest : public BaseFixture { -}; +struct SegmentIntersectionTest : public BaseFixture {}; using TestTypes = ::testing::Types; TYPED_TEST_CASE(SegmentIntersectionTest, TestTypes); diff --git a/cpp/tests/experimental/spatial/haversine_test.cu b/cpp/tests/experimental/spatial/haversine_test.cu index de96895d3..f733e6445 100644 --- a/cpp/tests/experimental/spatial/haversine_test.cu +++ b/cpp/tests/experimental/spatial/haversine_test.cu @@ -26,8 +26,7 @@ #include template -struct HaversineTest : public ::testing::Test { -}; +struct HaversineTest : public ::testing::Test {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/spatial/linestring_bounding_boxes_test.cu b/cpp/tests/experimental/spatial/linestring_bounding_boxes_test.cu index 3ccfa8013..25bcb4f6e 100644 --- a/cpp/tests/experimental/spatial/linestring_bounding_boxes_test.cu +++ b/cpp/tests/experimental/spatial/linestring_bounding_boxes_test.cu @@ -25,8 +25,7 @@ #include template -struct LinestringBoundingBoxTest : public ::testing::Test { -}; +struct LinestringBoundingBoxTest : public ::testing::Test {}; using cuspatial::vec_2d; using cuspatial::test::make_device_vector; diff --git a/cpp/tests/experimental/spatial/linestring_distance_test.cu b/cpp/tests/experimental/spatial/linestring_distance_test.cu index 22dc5b10a..79727bee9 100644 --- a/cpp/tests/experimental/spatial/linestring_distance_test.cu +++ b/cpp/tests/experimental/spatial/linestring_distance_test.cu @@ -29,11 +29,9 @@ using namespace cuspatial; using namespace cuspatial::test; template -struct PairwiseLinestringDistanceTest : public ::testing::Test { -}; +struct PairwiseLinestringDistanceTest : public ::testing::Test {}; -struct PairwiseLinestringDistanceTestUntyped : public ::testing::Test { -}; +struct PairwiseLinestringDistanceTestUntyped : public ::testing::Test {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/spatial/linestring_distance_test_medium.cu b/cpp/tests/experimental/spatial/linestring_distance_test_medium.cu index e007190f4..36bcb444d 100644 --- a/cpp/tests/experimental/spatial/linestring_distance_test_medium.cu +++ b/cpp/tests/experimental/spatial/linestring_distance_test_medium.cu @@ -34,8 +34,7 @@ using namespace cuspatial; using namespace cuspatial::test; template -struct PairwiseLinestringDistanceTestMedium : public ::testing::Test { -}; +struct PairwiseLinestringDistanceTestMedium : public ::testing::Test {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu b/cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu index 22247526f..3a807ccfa 100644 --- a/cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu +++ b/cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu @@ -32,8 +32,7 @@ using namespace cuspatial; using namespace cuspatial::test; template -struct PairwisePointInPolygonTest : public ::testing::Test { -}; +struct PairwisePointInPolygonTest : public ::testing::Test {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = ::testing::Types; @@ -43,13 +42,13 @@ TYPED_TEST(PairwisePointInPolygonTest, OnePolygonOneRing) { using T = TypeParam; auto point_list = std::vector>{{-2.0, 0.0}, - {2.0, 0.0}, - {0.0, -2.0}, - {0.0, 2.0}, - {-0.5, 0.0}, - {0.5, 0.0}, - {0.0, -0.5}, - {0.0, 0.5}}; + {2.0, 0.0}, + {0.0, -2.0}, + {0.0, 2.0}, + {-0.5, 0.0}, + {0.5, 0.0}, + {0.0, -0.5}, + {0.0, 0.5}}; auto poly_offsets = make_device_vector({0, 1}); auto poly_ring_offsets = make_device_vector({0, 5}); auto poly_point = make_device_vector>( @@ -90,15 +89,15 @@ TYPED_TEST(PairwisePointInPolygonTest, TwoPolygonsOneRingEach) auto poly_offsets = make_device_vector({0, 1, 2}); auto poly_ring_offsets = make_device_vector({0, 5, 10}); auto poly_point = make_device_vector>({{-1.0, -1.0}, - {-1.0, 1.0}, - {1.0, 1.0}, - {1.0, -1.0}, - {-1.0, -1.0}, - {0.0, 1.0}, - {1.0, 0.0}, - {0.0, -1.0}, - {-1.0, 0.0}, - {0.0, 1.0}}); + {-1.0, 1.0}, + {1.0, 1.0}, + {1.0, -1.0}, + {-1.0, -1.0}, + {0.0, 1.0}, + {1.0, 0.0}, + {0.0, -1.0}, + {-1.0, 0.0}, + {0.0, 1.0}}); auto got = rmm::device_vector(2); auto expected = std::vector({false, false, false, false, true, true, true, true}); @@ -129,15 +128,15 @@ TYPED_TEST(PairwisePointInPolygonTest, OnePolygonTwoRings) auto poly_offsets = make_device_vector({0, 1}); auto poly_ring_offsets = make_device_vector({0, 5, 10}); auto poly_point = make_device_vector>({{-1.0, -1.0}, - {1.0, -1.0}, - {1.0, 1.0}, - {-1.0, 1.0}, - {-1.0, -1.0}, - {-0.5, -0.5}, - {-0.5, 0.5}, - {0.5, 0.5}, - {0.5, -0.5}, - {-0.5, -0.5}}); + {1.0, -1.0}, + {1.0, 1.0}, + {-1.0, 1.0}, + {-1.0, -1.0}, + {-0.5, -0.5}, + {-0.5, 0.5}, + {0.5, 0.5}, + {0.5, -0.5}, + {-0.5, -0.5}}); auto got = rmm::device_vector(1); auto expected = std::vector{0b0, 0b0, 0b1, 0b0, 0b1}; @@ -299,8 +298,7 @@ TYPED_TEST(PairwisePointInPolygonTest, 32PolygonSupport) EXPECT_EQ(ret, got.end()); } -struct PairwisePointInPolygonErrorTest : public PairwisePointInPolygonTest { -}; +struct PairwisePointInPolygonErrorTest : public PairwisePointInPolygonTest {}; TEST_F(PairwisePointInPolygonErrorTest, InsufficientPoints) { diff --git a/cpp/tests/experimental/spatial/point_in_polygon_test.cu b/cpp/tests/experimental/spatial/point_in_polygon_test.cu index 79d6aa35f..3777495df 100644 --- a/cpp/tests/experimental/spatial/point_in_polygon_test.cu +++ b/cpp/tests/experimental/spatial/point_in_polygon_test.cu @@ -50,13 +50,13 @@ TYPED_TEST_CASE(PointInPolygonTest, TestTypes); TYPED_TEST(PointInPolygonTest, OnePolygonOneRing) { auto test_point = this->make_device_points({{-2.0, 0.0}, - {2.0, 0.0}, - {0.0, -2.0}, - {0.0, 2.0}, - {-0.5, 0.0}, - {0.5, 0.0}, - {0.0, -0.5}, - {0.0, 0.5}}); + {2.0, 0.0}, + {0.0, -2.0}, + {0.0, 2.0}, + {-0.5, 0.0}, + {0.5, 0.0}, + {0.0, -0.5}, + {0.0, 0.5}}); auto poly_offsets = this->make_device_offsets({0, 1}); auto poly_ring_offsets = this->make_device_offsets({0, 5}); auto poly_point = @@ -87,13 +87,13 @@ TYPED_TEST(PointInPolygonTest, OnePolygonOneRing) TYPED_TEST(PointInPolygonTest, OnePolygonOneRingUnclosed) { auto test_point = this->make_device_points({{-2.0, 0.0}, - {2.0, 0.0}, - {0.0, -2.0}, - {0.0, 2.0}, - {-0.5, 0.0}, - {0.5, 0.0}, - {0.0, -0.5}, - {0.0, 0.5}}); + {2.0, 0.0}, + {0.0, -2.0}, + {0.0, 2.0}, + {-0.5, 0.0}, + {0.5, 0.0}, + {0.0, -0.5}, + {0.0, 0.5}}); auto poly_offsets = this->make_device_offsets({0, 1}); auto poly_ring_offsets = this->make_device_offsets({0, 4}); auto poly_point = this->make_device_points({{-1.0, -1.0}, {1.0, -1.0}, {1.0, 0.0}, {1.0, 1.0}}); @@ -129,15 +129,15 @@ TYPED_TEST(PointInPolygonTest, TwoPolygonsOneRingEach) auto poly_offsets = this->make_device_offsets({0, 1, 2}); auto poly_ring_offsets = this->make_device_offsets({0, 5, 10}); auto poly_point = this->make_device_points({{-1.0, -1.0}, - {-1.0, 1.0}, - {1.0, 1.0}, - {1.0, -1.0}, - {-1.0, -1.0}, - {0.0, 1.0}, - {1.0, 0.0}, - {0.0, -1.0}, - {-1.0, 0.0}, - {0.0, 1.0}}); + {-1.0, 1.0}, + {1.0, 1.0}, + {1.0, -1.0}, + {-1.0, -1.0}, + {0.0, 1.0}, + {1.0, 0.0}, + {0.0, -1.0}, + {-1.0, 0.0}, + {0.0, 1.0}}); auto got = rmm::device_vector(test_point.size()); auto expected = std::vector({0b00, 0b00, 0b00, 0b00, 0b11, 0b11, 0b11, 0b11}); @@ -163,15 +163,15 @@ TYPED_TEST(PointInPolygonTest, OnePolygonTwoRings) auto poly_offsets = this->make_device_offsets({0, 2}); auto poly_ring_offsets = this->make_device_offsets({0, 5, 10}); auto poly_point = this->make_device_points({{-1.0, -1.0}, - {1.0, -1.0}, - {1.0, 1.0}, - {-1.0, 1.0}, - {-1.0, -1.0}, - {-0.5, -0.5}, - {-0.5, 0.5}, - {0.5, 0.5}, - {0.5, -0.5}, - {-0.5, -0.5}}); + {1.0, -1.0}, + {1.0, 1.0}, + {-1.0, 1.0}, + {-1.0, -1.0}, + {-0.5, -0.5}, + {-0.5, 0.5}, + {0.5, 0.5}, + {0.5, -0.5}, + {-0.5, -0.5}}); auto got = rmm::device_vector(test_point.size()); auto expected = std::vector{0b0, 0b0, 0b1, 0b0, 0b1}; @@ -323,8 +323,7 @@ TYPED_TEST(PointInPolygonTest, 31PolygonSupport) EXPECT_EQ(ret, got.end()); } -struct PointInPolygonErrorTest : public PointInPolygonTest { -}; +struct PointInPolygonErrorTest : public PointInPolygonTest {}; TYPED_TEST(PointInPolygonTest, SelfClosingLoopLeftEdgeMissing) { diff --git a/cpp/tests/experimental/spatial/point_linestring_distance_test.cu b/cpp/tests/experimental/spatial/point_linestring_distance_test.cu index 6ee3b3438..16fc520e2 100644 --- a/cpp/tests/experimental/spatial/point_linestring_distance_test.cu +++ b/cpp/tests/experimental/spatial/point_linestring_distance_test.cu @@ -36,8 +36,7 @@ namespace cuspatial { namespace test { template -struct PairwisePointLinestringDistanceTest : public ::testing::Test { -}; +struct PairwisePointLinestringDistanceTest : public ::testing::Test {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu b/cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu index f32fca12a..5163a3287 100644 --- a/cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu +++ b/cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu @@ -35,8 +35,7 @@ using namespace cuspatial; using namespace cuspatial::test; template -struct PairwisePointLinestringNearestPointsTest : public ::testing::Test { -}; +struct PairwisePointLinestringNearestPointsTest : public ::testing::Test {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = ::testing::Types; diff --git a/cpp/tests/experimental/spatial/polygon_bounding_boxes_test.cu b/cpp/tests/experimental/spatial/polygon_bounding_boxes_test.cu index 981b2ded2..fff8ef28a 100644 --- a/cpp/tests/experimental/spatial/polygon_bounding_boxes_test.cu +++ b/cpp/tests/experimental/spatial/polygon_bounding_boxes_test.cu @@ -25,8 +25,7 @@ #include template -struct PolygonBoundingBoxTest : public ::testing::Test { -}; +struct PolygonBoundingBoxTest : public ::testing::Test {}; using cuspatial::vec_2d; using cuspatial::test::make_device_vector; diff --git a/cpp/tests/experimental/trajectory/derive_trajectories_test.cu b/cpp/tests/experimental/trajectory/derive_trajectories_test.cu index 20ffd32c9..f81656e2c 100644 --- a/cpp/tests/experimental/trajectory/derive_trajectories_test.cu +++ b/cpp/tests/experimental/trajectory/derive_trajectories_test.cu @@ -37,8 +37,7 @@ #include template -struct DeriveTrajectoriesTest : public ::testing::Test { -}; +struct DeriveTrajectoriesTest : public ::testing::Test {}; using TestTypes = ::testing::Types; TYPED_TEST_CASE(DeriveTrajectoriesTest, TestTypes); diff --git a/cpp/tests/indexing/point_quadtree_test.cpp b/cpp/tests/indexing/point_quadtree_test.cpp index ef5c98b25..93978e093 100644 --- a/cpp/tests/indexing/point_quadtree_test.cpp +++ b/cpp/tests/indexing/point_quadtree_test.cpp @@ -27,8 +27,7 @@ #include #include -struct QuadtreeOnPointErrorTest : public cudf::test::BaseFixture { -}; +struct QuadtreeOnPointErrorTest : public cudf::test::BaseFixture {}; TYPED_TEST_CASE(QuadtreeOnPointIndexingTest, cudf::test::FloatingPointTypes); diff --git a/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp b/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp index 0c4baf989..d0fe5586a 100644 --- a/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp +++ b/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp @@ -29,8 +29,7 @@ #include template -struct JoinQuadtreeAndBoundingBoxesErrorTest : public cudf::test::BaseFixture { -}; +struct JoinQuadtreeAndBoundingBoxesErrorTest : public cudf::test::BaseFixture {}; TYPED_TEST_CASE(JoinQuadtreeAndBoundingBoxesErrorTest, cudf::test::FloatingPointTypes); diff --git a/cpp/tests/spatial/hausdorff_test.cpp b/cpp/tests/spatial/hausdorff_test.cpp index 2f005e39f..6cf59c9a8 100644 --- a/cpp/tests/spatial/hausdorff_test.cpp +++ b/cpp/tests/spatial/hausdorff_test.cpp @@ -37,8 +37,7 @@ using namespace test; constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; template -struct HausdorffTest : public BaseFixture { -}; +struct HausdorffTest : public BaseFixture {}; TYPED_TEST_CASE(HausdorffTest, cudf::test::FloatingPointTypes); diff --git a/cpp/tests/spatial/haversine_test.cpp b/cpp/tests/spatial/haversine_test.cpp index a617292f7..c91b899dd 100644 --- a/cpp/tests/spatial/haversine_test.cpp +++ b/cpp/tests/spatial/haversine_test.cpp @@ -32,8 +32,7 @@ using namespace cudf::test; constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; template -struct HaversineTest : public BaseFixture { -}; +struct HaversineTest : public BaseFixture {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = Types; @@ -100,8 +99,7 @@ TYPED_TEST(HaversineTest, MismatchSize) } template -struct HaversineUnsupportedTypesTest : public BaseFixture { -}; +struct HaversineUnsupportedTypesTest : public BaseFixture {}; using UnsupportedTypes = RemoveIf>, NumericTypes>; TYPED_TEST_CASE(HaversineUnsupportedTypesTest, UnsupportedTypes); @@ -119,8 +117,7 @@ TYPED_TEST(HaversineUnsupportedTypesTest, MismatchSize) } template -struct HaversineUnsupportedChronoTypesTest : public BaseFixture { -}; +struct HaversineUnsupportedChronoTypesTest : public BaseFixture {}; TYPED_TEST_CASE(HaversineUnsupportedChronoTypesTest, ChronoTypes); diff --git a/cpp/tests/spatial/linestring_bounding_boxes_test.cpp b/cpp/tests/spatial/linestring_bounding_boxes_test.cpp index 2f7c98318..fb409a22b 100644 --- a/cpp/tests/spatial/linestring_bounding_boxes_test.cpp +++ b/cpp/tests/spatial/linestring_bounding_boxes_test.cpp @@ -22,8 +22,7 @@ #include -struct LinestringBoundingBoxErrorTest : public ::testing::Test { -}; +struct LinestringBoundingBoxErrorTest : public ::testing::Test {}; using T = float; diff --git a/cpp/tests/spatial/linestring_distance_test.cpp b/cpp/tests/spatial/linestring_distance_test.cpp index 95a34b82f..b4622980b 100644 --- a/cpp/tests/spatial/linestring_distance_test.cpp +++ b/cpp/tests/spatial/linestring_distance_test.cpp @@ -34,11 +34,9 @@ template using wrapper = fixed_width_column_wrapper; template -struct PairwiseLinestringDistanceTest : public BaseFixture { -}; +struct PairwiseLinestringDistanceTest : public BaseFixture {}; -struct PairwiseLinestringDistanceTestUntyped : public BaseFixture { -}; +struct PairwiseLinestringDistanceTestUntyped : public BaseFixture {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = FloatingPointTypes; diff --git a/cpp/tests/spatial/linestring_intersection_test.cpp b/cpp/tests/spatial/linestring_intersection_test.cpp index 6d53ffe4c..9110c7197 100644 --- a/cpp/tests/spatial/linestring_intersection_test.cpp +++ b/cpp/tests/spatial/linestring_intersection_test.cpp @@ -208,8 +208,7 @@ struct LinestringIntersectionTest : public LinestringIntersectionTestBase { } }; -struct LinestringIntersectionTestUntyped : public LinestringIntersectionTestBase { -}; +struct LinestringIntersectionTestUntyped : public LinestringIntersectionTestBase {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = FloatingPointTypes; diff --git a/cpp/tests/spatial/pairwise_point_in_polygon_test.cpp b/cpp/tests/spatial/pairwise_point_in_polygon_test.cpp index b9ff8d56d..97d9f7b7c 100644 --- a/cpp/tests/spatial/pairwise_point_in_polygon_test.cpp +++ b/cpp/tests/spatial/pairwise_point_in_polygon_test.cpp @@ -31,8 +31,7 @@ template using wrapper = fixed_width_column_wrapper; template -struct PairwisePointInPolygonTest : public BaseFixture { -}; +struct PairwisePointInPolygonTest : public BaseFixture {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = FloatingPointTypes; @@ -60,8 +59,7 @@ TYPED_TEST(PairwisePointInPolygonTest, Empty) } template -struct PairwisePointInPolygonUnsupportedTypesTest : public BaseFixture { -}; +struct PairwisePointInPolygonUnsupportedTypesTest : public BaseFixture {}; using UnsupportedTestTypes = RemoveIf, NumericTypes>; TYPED_TEST_CASE(PairwisePointInPolygonUnsupportedTypesTest, UnsupportedTestTypes); @@ -84,8 +82,7 @@ TYPED_TEST(PairwisePointInPolygonUnsupportedTypesTest, UnsupportedPointType) } template -struct PairwisePointInPolygonUnsupportedChronoTypesTest : public BaseFixture { -}; +struct PairwisePointInPolygonUnsupportedChronoTypesTest : public BaseFixture {}; TYPED_TEST_CASE(PairwisePointInPolygonUnsupportedChronoTypesTest, ChronoTypes); @@ -107,8 +104,7 @@ TYPED_TEST(PairwisePointInPolygonUnsupportedChronoTypesTest, UnsupportedPointChr cuspatial::logic_error); } -struct PairwisePointInPolygonErrorTest : public BaseFixture { -}; +struct PairwisePointInPolygonErrorTest : public BaseFixture {}; TEST_F(PairwisePointInPolygonErrorTest, MismatchTestPointXYLength) { diff --git a/cpp/tests/spatial/point_distance_test.cpp b/cpp/tests/spatial/point_distance_test.cpp index 1f04b6bc7..841d142ef 100644 --- a/cpp/tests/spatial/point_distance_test.cpp +++ b/cpp/tests/spatial/point_distance_test.cpp @@ -32,8 +32,7 @@ using namespace cudf; using namespace cudf::test; template -struct PairwisePointDistanceTest : public ::testing::Test { -}; +struct PairwisePointDistanceTest : public ::testing::Test {}; using TestTypes = ::testing::Types; @@ -107,8 +106,7 @@ TYPED_TEST(PairwisePointDistanceTest, MultiToMultiEmpty) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect, *got); } -struct PairwisePointDistanceTestThrow : public ::testing::Test { -}; +struct PairwisePointDistanceTestThrow : public ::testing::Test {}; TEST_F(PairwisePointDistanceTestThrow, SizeMismatch) { diff --git a/cpp/tests/spatial/point_in_polygon_test.cpp b/cpp/tests/spatial/point_in_polygon_test.cpp index 56cf75392..42b15fc0e 100644 --- a/cpp/tests/spatial/point_in_polygon_test.cpp +++ b/cpp/tests/spatial/point_in_polygon_test.cpp @@ -31,8 +31,7 @@ template using wrapper = fixed_width_column_wrapper; template -struct PointInPolygonTest : public BaseFixture { -}; +struct PointInPolygonTest : public BaseFixture {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = FloatingPointTypes; @@ -60,8 +59,7 @@ TYPED_TEST(PointInPolygonTest, Empty) } template -struct PointInPolygonUnsupportedTypesTest : public BaseFixture { -}; +struct PointInPolygonUnsupportedTypesTest : public BaseFixture {}; using UnsupportedTestTypes = RemoveIf, NumericTypes>; TYPED_TEST_CASE(PointInPolygonUnsupportedTypesTest, UnsupportedTestTypes); @@ -84,8 +82,7 @@ TYPED_TEST(PointInPolygonUnsupportedTypesTest, UnsupportedPointType) } template -struct PointInPolygonUnsupportedChronoTypesTest : public BaseFixture { -}; +struct PointInPolygonUnsupportedChronoTypesTest : public BaseFixture {}; TYPED_TEST_CASE(PointInPolygonUnsupportedChronoTypesTest, ChronoTypes); @@ -107,8 +104,7 @@ TYPED_TEST(PointInPolygonUnsupportedChronoTypesTest, UnsupportedPointChronoType) cuspatial::logic_error); } -struct PointInPolygonErrorTest : public BaseFixture { -}; +struct PointInPolygonErrorTest : public BaseFixture {}; TEST_F(PointInPolygonErrorTest, EmptyPolygonOffsets) { diff --git a/cpp/tests/spatial/point_linestring_distance_test.cpp b/cpp/tests/spatial/point_linestring_distance_test.cpp index 7f5e15e13..870ab806d 100644 --- a/cpp/tests/spatial/point_linestring_distance_test.cpp +++ b/cpp/tests/spatial/point_linestring_distance_test.cpp @@ -32,8 +32,7 @@ using namespace cudf; using namespace cudf::test; template -struct PairwisePointLinestringDistanceTest : public ::testing::Test { -}; +struct PairwisePointLinestringDistanceTest : public ::testing::Test {}; using TestTypes = ::testing::Types; @@ -94,8 +93,7 @@ TYPED_TEST(PairwisePointLinestringDistanceTest, OnePairMultiPointMultiLinestring CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect, *got); } -struct PairwisePointLinestringDistanceTestThrow : public ::testing::Test { -}; +struct PairwisePointLinestringDistanceTestThrow : public ::testing::Test {}; TEST_F(PairwisePointLinestringDistanceTestThrow, PointTypeMismatch) { diff --git a/cpp/tests/spatial/point_linestring_nearest_points_test.cpp b/cpp/tests/spatial/point_linestring_nearest_points_test.cpp index 969cb3841..3be28e671 100644 --- a/cpp/tests/spatial/point_linestring_nearest_points_test.cpp +++ b/cpp/tests/spatial/point_linestring_nearest_points_test.cpp @@ -30,8 +30,7 @@ using namespace cudf; using namespace cudf::test; template -struct PairwisePointLinestringNearestPointsTest : public ::testing::Test { -}; +struct PairwisePointLinestringNearestPointsTest : public ::testing::Test {}; using TestTypes = ::testing::Types; @@ -134,8 +133,7 @@ TYPED_TEST(PairwisePointLinestringNearestPointsTest, MultiPointMultiLineString) CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_nearest_points, *nearest_points); } -struct PairwisePointLinestringNearestPointsThrowTest : public ::testing::Test { -}; +struct PairwisePointLinestringNearestPointsThrowTest : public ::testing::Test {}; TEST_F(PairwisePointLinestringNearestPointsThrowTest, OddNumberOfCoordinates) { diff --git a/cpp/tests/spatial/polygon_bounding_boxes_test.cpp b/cpp/tests/spatial/polygon_bounding_boxes_test.cpp index 8638f37b4..b161f9989 100644 --- a/cpp/tests/spatial/polygon_bounding_boxes_test.cpp +++ b/cpp/tests/spatial/polygon_bounding_boxes_test.cpp @@ -24,8 +24,7 @@ #include #include -struct PolygonBoundingBoxErrorTest : public ::testing::Test { -}; +struct PolygonBoundingBoxErrorTest : public ::testing::Test {}; using T = float; diff --git a/cpp/tests/spatial/sinusoidal_projection_test.cu b/cpp/tests/spatial/sinusoidal_projection_test.cu index 867d600a5..051e92678 100644 --- a/cpp/tests/spatial/sinusoidal_projection_test.cu +++ b/cpp/tests/spatial/sinusoidal_projection_test.cu @@ -30,8 +30,7 @@ using namespace cudf::test; constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; template -struct SinusoidalProjectionTest : public BaseFixture { -}; +struct SinusoidalProjectionTest : public BaseFixture {}; // float and double are logically the same but would require separate tests due to precision. using TestTypes = Types; @@ -190,8 +189,7 @@ TYPED_TEST(SinusoidalProjectionTest, MismatchSize) } template -struct LatLonToCartesianUnsupportedTypesTest : public BaseFixture { -}; +struct LatLonToCartesianUnsupportedTypesTest : public BaseFixture {}; using UnsupportedTestTypes = RemoveIf>, NumericTypes>; TYPED_TEST_CASE(LatLonToCartesianUnsupportedTypesTest, UnsupportedTestTypes); @@ -209,8 +207,7 @@ TYPED_TEST(LatLonToCartesianUnsupportedTypesTest, MismatchSize) } template -struct LatLonToCartesianUnsupportedChronoTypesTest : public BaseFixture { -}; +struct LatLonToCartesianUnsupportedChronoTypesTest : public BaseFixture {}; TYPED_TEST_CASE(LatLonToCartesianUnsupportedChronoTypesTest, ChronoTypes); diff --git a/cpp/tests/spatial_window/spatial_window_test.cpp b/cpp/tests/spatial_window/spatial_window_test.cpp index c7aff236f..3d56bce16 100644 --- a/cpp/tests/spatial_window/spatial_window_test.cpp +++ b/cpp/tests/spatial_window/spatial_window_test.cpp @@ -30,13 +30,11 @@ constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; template -struct SpatialRangeTest : public cudf::test::BaseFixture { -}; +struct SpatialRangeTest : public cudf::test::BaseFixture {}; using TestTypes = cudf::test::Types; -struct SpatialWindowErrorTest : public cudf::test::BaseFixture { -}; +struct SpatialWindowErrorTest : public cudf::test::BaseFixture {}; TEST_F(SpatialWindowErrorTest, TypeMismatch) { @@ -66,8 +64,7 @@ struct IsFloat { using NonFloatTypes = cudf::test::RemoveIf; template -struct SpatialWindowUnsupportedTypesTest : public cudf::test::BaseFixture { -}; +struct SpatialWindowUnsupportedTypesTest : public cudf::test::BaseFixture {}; TYPED_TEST_CASE(SpatialWindowUnsupportedTypesTest, NonFloatTypes); @@ -82,8 +79,7 @@ TYPED_TEST(SpatialWindowUnsupportedTypesTest, ShouldThrow) } template -struct SpatialWindowUnsupportedChronoTypesTest : public cudf::test::BaseFixture { -}; +struct SpatialWindowUnsupportedChronoTypesTest : public cudf::test::BaseFixture {}; TYPED_TEST_CASE(SpatialWindowUnsupportedChronoTypesTest, cudf::test::ChronoTypes); diff --git a/cpp/tests/trajectory/test_derive_trajectories.cpp b/cpp/tests/trajectory/test_derive_trajectories.cpp index 747a7add6..90b10dc22 100644 --- a/cpp/tests/trajectory/test_derive_trajectories.cpp +++ b/cpp/tests/trajectory/test_derive_trajectories.cpp @@ -28,8 +28,7 @@ #include -struct DeriveTrajectoriesErrorTest : public cuspatial::test::BaseFixture { -}; +struct DeriveTrajectoriesErrorTest : public cuspatial::test::BaseFixture {}; TEST_F(DeriveTrajectoriesErrorTest, SizeMismatch) { diff --git a/cpp/tests/trajectory/test_trajectory_bounding_boxes.cu b/cpp/tests/trajectory/test_trajectory_bounding_boxes.cu index bfb0a5cff..fc7dc0432 100644 --- a/cpp/tests/trajectory/test_trajectory_bounding_boxes.cu +++ b/cpp/tests/trajectory/test_trajectory_bounding_boxes.cu @@ -19,8 +19,7 @@ #include #include -struct TrajectoryBoundingBoxesErrorTest : public cuspatial::test::BaseFixture { -}; +struct TrajectoryBoundingBoxesErrorTest : public cuspatial::test::BaseFixture {}; TEST_F(TrajectoryBoundingBoxesErrorTest, SizeMismatch) { diff --git a/cpp/tests/trajectory/test_trajectory_distances_and_speeds.cu b/cpp/tests/trajectory/test_trajectory_distances_and_speeds.cu index 2787c6475..b23a73e2e 100644 --- a/cpp/tests/trajectory/test_trajectory_distances_and_speeds.cu +++ b/cpp/tests/trajectory/test_trajectory_distances_and_speeds.cu @@ -23,8 +23,7 @@ #include -struct TrajectoryDistanceSpeedErrorTest : public cuspatial::test::BaseFixture { -}; +struct TrajectoryDistanceSpeedErrorTest : public cuspatial::test::BaseFixture {}; TEST_F(TrajectoryDistanceSpeedErrorTest, SizeMismatch) { diff --git a/cpp/tests/utility_test/test_float_equivalent.cu b/cpp/tests/utility_test/test_float_equivalent.cu index df2b743a1..ef462178f 100644 --- a/cpp/tests/utility_test/test_float_equivalent.cu +++ b/cpp/tests/utility_test/test_float_equivalent.cu @@ -26,8 +26,7 @@ using namespace cuspatial; using namespace cuspatial::test; template -struct ULPFloatingPointEquivalenceTest : public ::testing::Test { -}; +struct ULPFloatingPointEquivalenceTest : public ::testing::Test {}; using TestTypes = ::testing::Types; diff --git a/cpp/tests/utility_test/test_multipoint_factory.cu b/cpp/tests/utility_test/test_multipoint_factory.cu index 5e1d77f88..f7b1ba0a4 100644 --- a/cpp/tests/utility_test/test_multipoint_factory.cu +++ b/cpp/tests/utility_test/test_multipoint_factory.cu @@ -23,8 +23,7 @@ using namespace cuspatial::detail; using namespace cuspatial::test; template -struct MultiPointFactoryTest : public BaseFixture { -}; +struct MultiPointFactoryTest : public BaseFixture {}; using TestTypes = ::testing::Types; TYPED_TEST_CASE(MultiPointFactoryTest, TestTypes); diff --git a/data/json2soa.cpp b/data/json2soa.cpp index 04f225d0b..e42a890dc 100644 --- a/data/json2soa.cpp +++ b/data/json2soa.cpp @@ -1,230 +1,231 @@ // g++ json2soa.cpp cJSON.c -o json2soa -O3 //./json2soa schema_HWY_20_AND_LOCUST-filtered.json locust -1 -#include -#include +#include +#include #include +#include +#include +#include #include -#include -#include +#include +#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include #include +#include #include +#include +#include #include "cJSON.h" using namespace std; -#define MAXLINE 4096 +#define MAXLINE 4096 #define NUM_FIELDS 5 typedef unsigned int uint; typedef unsigned short ushort; -typedef struct Time -{ - uint y : 6; - uint m : 4; - uint d : 5; - uint hh : 5; - uint mm : 6; - uint ss : 6; - uint wd: 3; - uint yd: 9; - uint mili: 10; - uint pid:10; -}Time; - -ostream& operator<<(ostream& os, const Time & t) +typedef struct Time { + uint y : 6; + uint m : 4; + uint d : 5; + uint hh : 5; + uint mm : 6; + uint ss : 6; + uint wd : 3; + uint yd : 9; + uint mili : 10; + uint pid : 10; +} Time; + +ostream& operator<<(ostream& os, const Time& t) { - os << t.y<<","< -void append_map(map& m, const T& key) +void append_map(map& m, const T& key) { - typename map::iterator it=m.find(key); - if(it==m.end()) - m[key]=1; - else - it->second++; + typename map::iterator it = m.find(key); + if (it == m.end()) + m[key] = 1; + else + it->second++; } template -int output_map(const map& m) +int output_map(const map& m) { - int cnt=0; - typename map::const_iterator it = m.begin(); - for(; it != m.end(); ++it) - { - std::cout<<"("<< it->first<<")==>"<< it->second<<"\n"; - cnt+=it->second; - } - return cnt; + int cnt = 0; + typename map::const_iterator it = m.begin(); + for (; it != m.end(); ++it) { + std::cout << "(" << it->first << ")==>" << it->second << "\n"; + cnt += it->second; + } + return cnt; } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - printf("sizeof(Time)=%ld\n",sizeof(Time)); - //std::map t_map; - //std::map p_map; - std::map oid_map; - - char line[MAXLINE]; - - struct timeval t0,t1; - gettimeofday(&t0, NULL); - - if (argc!=4) - { - printf("USAGE: %s in_fn out_root run_num(-1 for all)\n", argv[0]); - exit(1); - } - const char * in_name=argv[1]; - const char * out_root=argv[2]; - enum FIELDS {time_id=0, objid_id,bbox_id,location_id,coordinate_id}; - const char * out_ext[NUM_FIELDS]={".time",".objectid",".bbox",".location",".coordinate"}; - - FILE *in_fp=fopen(in_name,"r"); - if(in_fp==NULL) - { - printf("can not open data file %s for input\n",in_name); - return -1; - } - - FILE *out_fp[NUM_FIELDS]; - for(int i=0;ivaluestring; - struct tm it; - strptime(t_str, "%Y-%m-%dT%H:%M:%S", &it); - char *p=strstr(t_str,"."); - p++; - char st[4]; - strncpy(st,p,3); - st[3]='\n'; - int in_mili=atoi(st); - //printf("s=%s t=%s:%3d %d\n",t_str,asctime(&it),in_mili,it.tm_year); - - Time ot; - ot.y = it.tm_year - 100;//shifting starting year from 1900 to 2000, max 64 years allowed - ot.m =it.tm_mon; - ot.d =it.tm_mday; - ot.hh=it.tm_hour; - ot.mm=it.tm_min; - ot.ss=it.tm_sec; - ot.wd=it.tm_wday; - ot.yd=it.tm_yday; - ot.mili=in_mili; - //append_map(t_map,ot); - - cJSON* place= cJSON_GetObjectItem(root,"place"); - string place_str=cJSON_GetObjectItem(place,"id")->valuestring; - //cout<valuestring; - //cout<valuedouble; - double toplefty=cJSON_GetObjectItem(bbox,"toplefty")->valuedouble; - double bottomrightx=cJSON_GetObjectItem(bbox,"bottomrightx")->valuedouble; - double bottomrighty=cJSON_GetObjectItem(bbox,"bottomrighty")->valuedouble; - //printf("%15.10f %15.10f %15.10f %15.10f\n",topleftx, toplefty, bottomrightx,bottomrighty); - fwrite(&topleftx,sizeof(double),1,out_fp[bbox_id]); - fwrite(&toplefty,sizeof(double),1,out_fp[bbox_id]); - fwrite(&bottomrightx,sizeof(double),1,out_fp[bbox_id]); - fwrite(&bottomrighty,sizeof(double),1,out_fp[bbox_id]); - - double lat=cJSON_GetObjectItem(location,"lat")->valuedouble; - double lon=cJSON_GetObjectItem(location,"lon")->valuedouble; - double alt=cJSON_GetObjectItem(location,"alt")->valuedouble; - //printf("%15.10f %15.10f %15.10f\n",lat, lon, alt); - fwrite(&lat,sizeof(double),1,out_fp[location_id]); - fwrite(&lon,sizeof(double),1,out_fp[location_id]); - fwrite(&alt,sizeof(double),1,out_fp[location_id]); - - double x=cJSON_GetObjectItem(coordinate,"x")->valuedouble; - double y=cJSON_GetObjectItem(coordinate,"y")->valuedouble; - double z=cJSON_GetObjectItem(coordinate,"z")->valuedouble; - //printf("%15.10f %15.10f %15.10f\n",x, y, z); - fwrite(&x,sizeof(double),1,out_fp[coordinate_id]); - fwrite(&y,sizeof(double),1,out_fp[coordinate_id]); - fwrite(&z,sizeof(double),1,out_fp[coordinate_id]); - - cJSON_Delete(root); - pos++; - if(pos==run_num) - break; - + printf("sizeof(Time)=%ld\n", sizeof(Time)); + // std::map t_map; + // std::map p_map; + std::map oid_map; + + char line[MAXLINE]; + + struct timeval t0, t1; + gettimeofday(&t0, NULL); + + if (argc != 4) { + printf("USAGE: %s in_fn out_root run_num(-1 for all)\n", argv[0]); + exit(1); + } + const char* in_name = argv[1]; + const char* out_root = argv[2]; + enum FIELDS { time_id = 0, objid_id, bbox_id, location_id, coordinate_id }; + const char* out_ext[NUM_FIELDS] = {".time", ".objectid", ".bbox", ".location", ".coordinate"}; + + FILE* in_fp = fopen(in_name, "r"); + if (in_fp == NULL) { + printf("can not open data file %s for input\n", in_name); + return -1; + } + + FILE* out_fp[NUM_FIELDS]; + for (int i = 0; i < NUM_FIELDS; i++) { + char out_name[100]; + strcpy(out_name, out_root); + strcat(out_name, out_ext[i]); + out_fp[i] = fopen(out_name, "wb"); + if (out_fp[i] == NULL) { + printf("can not open data file %s for output\n", out_name); + return -1; } - fclose(in_fp); - for(int i=0;ivaluestring; + struct tm it; + strptime(t_str, "%Y-%m-%dT%H:%M:%S", &it); + char* p = strstr(t_str, "."); + p++; + char st[4]; + strncpy(st, p, 3); + st[3] = '\n'; + int in_mili = atoi(st); + // printf("s=%s t=%s:%3d %d\n",t_str,asctime(&it),in_mili,it.tm_year); + + Time ot; + ot.y = it.tm_year - 100; // shifting starting year from 1900 to 2000, max 64 years allowed + ot.m = it.tm_mon; + ot.d = it.tm_mday; + ot.hh = it.tm_hour; + ot.mm = it.tm_min; + ot.ss = it.tm_sec; + ot.wd = it.tm_wday; + ot.yd = it.tm_yday; + ot.mili = in_mili; + // append_map(t_map,ot); + + cJSON* place = cJSON_GetObjectItem(root, "place"); + string place_str = cJSON_GetObjectItem(place, "id")->valuestring; + // cout<valuestring; + // cout<valuedouble; + double toplefty = cJSON_GetObjectItem(bbox, "toplefty")->valuedouble; + double bottomrightx = cJSON_GetObjectItem(bbox, "bottomrightx")->valuedouble; + double bottomrighty = cJSON_GetObjectItem(bbox, "bottomrighty")->valuedouble; + // printf("%15.10f %15.10f %15.10f %15.10f\n",topleftx, toplefty, bottomrightx,bottomrighty); + fwrite(&topleftx, sizeof(double), 1, out_fp[bbox_id]); + fwrite(&toplefty, sizeof(double), 1, out_fp[bbox_id]); + fwrite(&bottomrightx, sizeof(double), 1, out_fp[bbox_id]); + fwrite(&bottomrighty, sizeof(double), 1, out_fp[bbox_id]); + + double lat = cJSON_GetObjectItem(location, "lat")->valuedouble; + double lon = cJSON_GetObjectItem(location, "lon")->valuedouble; + double alt = cJSON_GetObjectItem(location, "alt")->valuedouble; + // printf("%15.10f %15.10f %15.10f\n",lat, lon, alt); + fwrite(&lat, sizeof(double), 1, out_fp[location_id]); + fwrite(&lon, sizeof(double), 1, out_fp[location_id]); + fwrite(&alt, sizeof(double), 1, out_fp[location_id]); + + double x = cJSON_GetObjectItem(coordinate, "x")->valuedouble; + double y = cJSON_GetObjectItem(coordinate, "y")->valuedouble; + double z = cJSON_GetObjectItem(coordinate, "z")->valuedouble; + // printf("%15.10f %15.10f %15.10f\n",x, y, z); + fwrite(&x, sizeof(double), 1, out_fp[coordinate_id]); + fwrite(&y, sizeof(double), 1, out_fp[coordinate_id]); + fwrite(&z, sizeof(double), 1, out_fp[coordinate_id]); + + cJSON_Delete(root); + pos++; + if (pos == run_num) break; + } + fclose(in_fp); + for (int i = 0; i < NUM_FIELDS; i++) + fclose(out_fp[i]); + // printf("output time map.................%d\n",output_map(t_map)); + // printf("output place id map.................%d\n",output_map(p_map)); + printf("output object id map.................%d\n", output_map(oid_map)); + printf("num_rec=%lu\n", pos); + return 0; } \ No newline at end of file diff --git a/data/poly2soa.cpp b/data/poly2soa.cpp index 393fde162..62b70b15e 100644 --- a/data/poly2soa.cpp +++ b/data/poly2soa.cpp @@ -1,262 +1,239 @@ // g++ -I /usr/local/include -L /usr/local/lib poly2soa.cpp -lgdal -o poly2soa // ./poly2soa its.cat itsroi.ply -#include +#include +#include +#include +#include #include -#include +#include +#include #include #include -#include #include -#include -#include -#include -#include +#include +#include "cpl_conv.h" +#include "cpl_string.h" #include "gdal.h" +#include "gdal_alg.h" #include "gdal_priv.h" -#include "cpl_conv.h" #include "ogr_api.h" +#include "ogr_geometry.h" #include "ogr_srs_api.h" -#include "cpl_string.h" #include "ogrsf_frmts.h" -#include "gdal_alg.h" -#include "ogr_geometry.h" using namespace std; -void GDALCollectRingsFromGeometry( - OGRGeometry *poShape, - std::vector &aPointX, std::vector &aPointY, - std::vector &aPartSize ) +void GDALCollectRingsFromGeometry(OGRGeometry* poShape, + std::vector& aPointX, + std::vector& aPointY, + std::vector& aPartSize) { - if( poShape == NULL ) - return; - - OGRwkbGeometryType eFlatType = wkbFlatten(poShape->getGeometryType()); - int i; - - if ( eFlatType == wkbPoint ) - { - OGRPoint *poPoint = (OGRPoint *) poShape; - int nNewCount = aPointX.size() + 1; - - aPointX.reserve( nNewCount ); - aPointY.reserve( nNewCount ); - aPointX.push_back( poPoint->getX()); - aPointY.push_back( poPoint->getY()); - aPartSize.push_back( 1 ); + if (poShape == NULL) return; + + OGRwkbGeometryType eFlatType = wkbFlatten(poShape->getGeometryType()); + int i; + + if (eFlatType == wkbPoint) { + OGRPoint* poPoint = (OGRPoint*)poShape; + int nNewCount = aPointX.size() + 1; + + aPointX.reserve(nNewCount); + aPointY.reserve(nNewCount); + aPointX.push_back(poPoint->getX()); + aPointY.push_back(poPoint->getY()); + aPartSize.push_back(1); + } else if (eFlatType == wkbLineString) { + OGRLineString* poLine = (OGRLineString*)poShape; + int nCount = poLine->getNumPoints(); + int nNewCount = aPointX.size() + nCount; + + aPointX.reserve(nNewCount); + aPointY.reserve(nNewCount); + for (i = nCount - 1; i >= 0; i--) { + aPointX.push_back(poLine->getX(i)); + aPointY.push_back(poLine->getY(i)); } - else if ( eFlatType == wkbLineString ) - { - OGRLineString *poLine = (OGRLineString *) poShape; - int nCount = poLine->getNumPoints(); - int nNewCount = aPointX.size() + nCount; - - aPointX.reserve( nNewCount ); - aPointY.reserve( nNewCount ); - for ( i = nCount - 1; i >= 0; i-- ) - { - aPointX.push_back( poLine->getX(i)); - aPointY.push_back( poLine->getY(i)); - } - aPartSize.push_back( nCount ); - } - else if ( EQUAL(poShape->getGeometryName(),"LINEARRING") ) - { - OGRLinearRing *poRing = (OGRLinearRing *) poShape; - int nCount = poRing->getNumPoints(); - int nNewCount = aPointX.size() + nCount; - - aPointX.reserve( nNewCount ); - aPointY.reserve( nNewCount ); - for ( i = nCount - 1; i >= 0; i-- ) - { - aPointX.push_back( poRing->getX(i)); - aPointY.push_back( poRing->getY(i)); - } - aPartSize.push_back( nCount ); + aPartSize.push_back(nCount); + } else if (EQUAL(poShape->getGeometryName(), "LINEARRING")) { + OGRLinearRing* poRing = (OGRLinearRing*)poShape; + int nCount = poRing->getNumPoints(); + int nNewCount = aPointX.size() + nCount; + + aPointX.reserve(nNewCount); + aPointY.reserve(nNewCount); + for (i = nCount - 1; i >= 0; i--) { + aPointX.push_back(poRing->getX(i)); + aPointY.push_back(poRing->getY(i)); } - else if( eFlatType == wkbPolygon ) - { - OGRPolygon *poPolygon = (OGRPolygon *) poShape; + aPartSize.push_back(nCount); + } else if (eFlatType == wkbPolygon) { + OGRPolygon* poPolygon = (OGRPolygon*)poShape; - GDALCollectRingsFromGeometry( poPolygon->getExteriorRing(), - aPointX, aPointY, aPartSize ); + GDALCollectRingsFromGeometry(poPolygon->getExteriorRing(), aPointX, aPointY, aPartSize); - for( i = 0; i < poPolygon->getNumInteriorRings(); i++ ) - GDALCollectRingsFromGeometry( poPolygon->getInteriorRing(i), - aPointX, aPointY, aPartSize ); - } + for (i = 0; i < poPolygon->getNumInteriorRings(); i++) + GDALCollectRingsFromGeometry(poPolygon->getInteriorRing(i), aPointX, aPointY, aPartSize); + } - else if( eFlatType == wkbMultiPoint - || eFlatType == wkbMultiLineString - || eFlatType == wkbMultiPolygon - || eFlatType == wkbGeometryCollection ) - { - OGRGeometryCollection *poGC = (OGRGeometryCollection *) poShape; + else if (eFlatType == wkbMultiPoint || eFlatType == wkbMultiLineString || + eFlatType == wkbMultiPolygon || eFlatType == wkbGeometryCollection) { + OGRGeometryCollection* poGC = (OGRGeometryCollection*)poShape; - for( i = 0; i < poGC->getNumGeometries(); i++ ) - GDALCollectRingsFromGeometry( poGC->getGeometryRef(i), - aPointX, aPointY, aPartSize ); - } - else - { - CPLDebug( "GDAL", "Rasterizer ignoring non-polygonal geometry." ); - } + for (i = 0; i < poGC->getNumGeometries(); i++) + GDALCollectRingsFromGeometry(poGC->getGeometryRef(i), aPointX, aPointY, aPartSize); + } else { + CPLDebug("GDAL", "Rasterizer ignoring non-polygonal geometry."); + } } -int addData(const OGRLayerH layer,vector& g_len_v,vector&f_len_v,vector&r_len_v,vector&xx_v, vector&yy_v) +int addData(const OGRLayerH layer, + vector& g_len_v, + vector& f_len_v, + vector& r_len_v, + vector& xx_v, + vector& yy_v) { - int num_feature=0; - OGR_L_ResetReading( layer ); - OGRFeatureH hFeat; - int this_rings=0,this_points=0; - while( (hFeat = OGR_L_GetNextFeature( layer )) != NULL ) - { - OGRGeometry *poShape=(OGRGeometry *)OGR_F_GetGeometryRef( hFeat ); - if(poShape==NULL) - { - cout<<"error:............shape is NULL"<getGeometryType()); - if( eFlatType == wkbPolygon ) - { - OGRPolygon *poPolygon = (OGRPolygon *) poShape; - this_rings+=(poPolygon->getNumInteriorRings()+1); - } - else - { - } - std::vector aPointX; - std::vector aPointY; - std::vector aPartSize; - GDALCollectRingsFromGeometry( poShape, aPointX, aPointY, aPartSize ); - if(aPartSize.size()==0) - { - printf("warning: aPartSize.size()==0\n"); - //num_feature++; - } - xx_v.insert(xx_v.end(), aPointX.begin(),aPointX.end()); - yy_v.insert(yy_v.end(), aPointY.begin(),aPointY.end()); - r_len_v.insert(r_len_v.end(),aPartSize.begin(),aPartSize.end()); - f_len_v.push_back(aPartSize.size()); - OGR_F_Destroy( hFeat ); - num_feature++; - } - g_len_v.push_back(num_feature); - return num_feature; + int num_feature = 0; + OGR_L_ResetReading(layer); + OGRFeatureH hFeat; + int this_rings = 0, this_points = 0; + while ((hFeat = OGR_L_GetNextFeature(layer)) != NULL) { + OGRGeometry* poShape = (OGRGeometry*)OGR_F_GetGeometryRef(hFeat); + if (poShape == NULL) { + cout << "error:............shape is NULL" << endl; + num_feature++; + continue; + } + OGRwkbGeometryType eFlatType = wkbFlatten(poShape->getGeometryType()); + if (eFlatType == wkbPolygon) { + OGRPolygon* poPolygon = (OGRPolygon*)poShape; + this_rings += (poPolygon->getNumInteriorRings() + 1); + } else { + } + std::vector aPointX; + std::vector aPointY; + std::vector aPartSize; + GDALCollectRingsFromGeometry(poShape, aPointX, aPointY, aPartSize); + if (aPartSize.size() == 0) { + printf("warning: aPartSize.size()==0\n"); + // num_feature++; + } + xx_v.insert(xx_v.end(), aPointX.begin(), aPointX.end()); + yy_v.insert(yy_v.end(), aPointY.begin(), aPointY.end()); + r_len_v.insert(r_len_v.end(), aPartSize.begin(), aPartSize.end()); + f_len_v.push_back(aPartSize.size()); + OGR_F_Destroy(hFeat); + num_feature++; + } + g_len_v.push_back(num_feature); + return num_feature; } -void process_coll(char *catfn,vector& g_len_v,vector&f_len_v,vector&r_len_v,vector&xx_v, vector&yy_v) +void process_coll(char* catfn, + vector& g_len_v, + vector& f_len_v, + vector& r_len_v, + vector& xx_v, + vector& yy_v) { - FILE *fp; - if((fp=fopen(catfn,"r"))==NULL) - { - printf("can not open catalog file\n"); - exit(-1); - } - int this_seq=0; - //while(!feof(fp)) - for(int i=0;i<1;i++) - { - char fn[100]; - fscanf(fp,"%s",fn); - GDALDatasetH hDS = GDALOpenEx( fn, GDAL_OF_VECTOR, NULL, NULL, NULL ); - if(hDS==NULL) - { - printf("hDS is NULL, skipping 1......\n"); - //skiplist.push_back(fn); - continue; - } + FILE* fp; + if ((fp = fopen(catfn, "r")) == NULL) { + printf("can not open catalog file\n"); + exit(-1); + } + int this_seq = 0; + // while(!feof(fp)) + for (int i = 0; i < 1; i++) { + char fn[100]; + fscanf(fp, "%s", fn); + GDALDatasetH hDS = GDALOpenEx(fn, GDAL_OF_VECTOR, NULL, NULL, NULL); + if (hDS == NULL) { + printf("hDS is NULL, skipping 1......\n"); + // skiplist.push_back(fn); + continue; + } - OGRLayerH hLayer = GDALDatasetGetLayer( hDS,0 ); - if( hLayer == NULL ) - { - printf( "Unable to find layer 0, skipping 2......\n"); - //skiplist.push_back(fn); - continue; - } - printf("%d %s \n",this_seq,fn); - int num0=addData(hLayer,g_len_v,f_len_v,r_len_v,xx_v,yy_v); - if(num0==0) - { - printf("zero features, skipping 3......\n"); - //skiplist.push_back(fn); - } - this_seq++; - } + OGRLayerH hLayer = GDALDatasetGetLayer(hDS, 0); + if (hLayer == NULL) { + printf("Unable to find layer 0, skipping 2......\n"); + // skiplist.push_back(fn); + continue; + } + printf("%d %s \n", this_seq, fn); + int num0 = addData(hLayer, g_len_v, f_len_v, r_len_v, xx_v, yy_v); + if (num0 == 0) { + printf("zero features, skipping 3......\n"); + // skiplist.push_back(fn); + } + this_seq++; + } } -int main(int argc,char** argv) +int main(int argc, char** argv) { - if(argc!=3) - { - printf("EXE cat_fn out_fn \n"); - exit(-1); - } - vector g_len_v,f_len_v,r_len_v; - vector xx_v, yy_v; - - GDALAllRegister(); - char *inc=argv[1]; - timeval start, end; - gettimeofday(&start, NULL); - printf("catalog=%s output=%s\n",argv[1],argv[2]); - process_coll(inc,g_len_v,f_len_v,r_len_v,xx_v, yy_v); - printf("skip list.............\n"); - gettimeofday(&end, NULL); - long diff = end.tv_sec*1000000+end.tv_usec - start.tv_sec * 1000000-start.tv_usec; - printf("CPU Processing time.......%10.2f\n",diff/(float)1000); - printf("%lu %lu %lu %lu\n",g_len_v.size(),f_len_v.size(),r_len_v.size(),xx_v.size()); - - int gc=g_len_v.size(); - int fc=0,rc=0,vc=0; - printf("#of groups(datasets)=%d\n",gc); - for(int g=0;g g_len_v, f_len_v, r_len_v; + vector xx_v, yy_v; + + GDALAllRegister(); + char* inc = argv[1]; + timeval start, end; + gettimeofday(&start, NULL); + printf("catalog=%s output=%s\n", argv[1], argv[2]); + process_coll(inc, g_len_v, f_len_v, r_len_v, xx_v, yy_v); + printf("skip list.............\n"); + gettimeofday(&end, NULL); + long diff = end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec; + printf("CPU Processing time.......%10.2f\n", diff / (float)1000); + printf("%lu %lu %lu %lu\n", g_len_v.size(), f_len_v.size(), r_len_v.size(), xx_v.size()); + + int gc = g_len_v.size(); + int fc = 0, rc = 0, vc = 0; + printf("#of groups(datasets)=%d\n", gc); + for (int g = 0; g < gc; g++) { + printf("#of features: (%d,%d,%d)\n", g, fc, g_len_v[g]); + for (int f = fc; f < fc + g_len_v[g]; f++) { + printf("#of rings= (%d,%d,%d)\n", f, fc, f_len_v[f]); + for (int r = rc; r < rc + f_len_v[f]; r++) { + printf("#of vertices (%d,%d,%d)\n", r, rc, r_len_v[r]); + printf("...v:"); + for (int v = vc; v < rc + r_len_v[r]; v++) + printf("%5d", v); + printf("\n"); + vc += r_len_v[r]; + } + rc += f_len_v[f]; + } + fc += g_len_v[g]; + } - FILE *fp=fopen(argv[2],"wb"); - assert(fp!=NULL); + printf("%d %d %d %d\n", gc, fc, rc, vc); - fwrite(&gc,sizeof(int),1,fp); - fwrite(&fc,sizeof(int),1,fp); - fwrite(&rc,sizeof(int),1,fp); - fwrite(&vc,sizeof(int),1,fp); + FILE* fp = fopen(argv[2], "wb"); + assert(fp != NULL); - int *g_p=&(g_len_v[0]); - int *f_p=&(f_len_v[0]); - int *r_p=&(r_len_v[0]); - double *x_p=&(xx_v[0]); - double *y_p=&(yy_v[0]); + fwrite(&gc, sizeof(int), 1, fp); + fwrite(&fc, sizeof(int), 1, fp); + fwrite(&rc, sizeof(int), 1, fp); + fwrite(&vc, sizeof(int), 1, fp); - fwrite(g_p,sizeof(int),gc,fp); - fwrite(f_p,sizeof(int),fc,fp); - fwrite(r_p,sizeof(int),rc,fp); - fwrite(x_p,sizeof(double),vc,fp); - fwrite(y_p,sizeof(double),vc,fp); + int* g_p = &(g_len_v[0]); + int* f_p = &(f_len_v[0]); + int* r_p = &(r_len_v[0]); + double* x_p = &(xx_v[0]); + double* y_p = &(yy_v[0]); - fclose(fp); + fwrite(g_p, sizeof(int), gc, fp); + fwrite(f_p, sizeof(int), fc, fp); + fwrite(r_p, sizeof(int), rc, fp); + fwrite(x_p, sizeof(double), vc, fp); + fwrite(y_p, sizeof(double), vc, fp); + fclose(fp); }