From 9ee98a06160ee2b234e92db70eb18e128fc76e5d Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Thu, 6 Jun 2019 16:31:25 +0900 Subject: add hubtbt --- include/mapbox/geometry/box.hpp | 34 -------- include/mapbox/geometry/envelope.hpp | 33 ------- include/mapbox/geometry/feature.hpp | 81 ------------------ include/mapbox/geometry/for_each_point.hpp | 45 ---------- include/mapbox/geometry/geometry.hpp | 53 ------------ include/mapbox/geometry/line_string.hpp | 21 ----- include/mapbox/geometry/multi_line_string.hpp | 21 ----- include/mapbox/geometry/multi_point.hpp | 21 ----- include/mapbox/geometry/multi_polygon.hpp | 21 ----- include/mapbox/geometry/point.hpp | 35 -------- include/mapbox/geometry/point_arithmetic.hpp | 119 -------------------------- include/mapbox/geometry/polygon.hpp | 31 ------- 12 files changed, 515 deletions(-) delete mode 100644 include/mapbox/geometry/box.hpp delete mode 100644 include/mapbox/geometry/envelope.hpp delete mode 100644 include/mapbox/geometry/feature.hpp delete mode 100644 include/mapbox/geometry/for_each_point.hpp delete mode 100644 include/mapbox/geometry/geometry.hpp delete mode 100644 include/mapbox/geometry/line_string.hpp delete mode 100644 include/mapbox/geometry/multi_line_string.hpp delete mode 100644 include/mapbox/geometry/multi_point.hpp delete mode 100644 include/mapbox/geometry/multi_polygon.hpp delete mode 100644 include/mapbox/geometry/point.hpp delete mode 100644 include/mapbox/geometry/point_arithmetic.hpp delete mode 100644 include/mapbox/geometry/polygon.hpp (limited to 'include/mapbox/geometry') diff --git a/include/mapbox/geometry/box.hpp b/include/mapbox/geometry/box.hpp deleted file mode 100644 index bf81b70..0000000 --- a/include/mapbox/geometry/box.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include - -namespace mapbox { -namespace geometry { - -template -struct box -{ - using point_type = point; - - constexpr box(point_type const& min_, point_type const& max_) - : min(min_), max(max_) - {} - - point_type min; - point_type max; -}; - -template -constexpr bool operator==(box const& lhs, box const& rhs) -{ - return lhs.min == rhs.min && lhs.max == rhs.max; -} - -template -constexpr bool operator!=(box const& lhs, box const& rhs) -{ - return lhs.min != rhs.min || lhs.max != rhs.max; -} - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/envelope.hpp b/include/mapbox/geometry/envelope.hpp deleted file mode 100644 index 8603583..0000000 --- a/include/mapbox/geometry/envelope.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include - -#include - -namespace mapbox { -namespace geometry { - -template -box envelope(G const& geometry) -{ - using limits = std::numeric_limits; - - T min_t = limits::has_infinity ? -limits::infinity() : limits::min(); - T max_t = limits::has_infinity ? limits::infinity() : limits::max(); - - point min(max_t, max_t); - point max(min_t, min_t); - - for_each_point(geometry, [&] (point const& point) { - if (min.x > point.x) min.x = point.x; - if (min.y > point.y) min.y = point.y; - if (max.x < point.x) max.x = point.x; - if (max.y < point.y) max.y = point.y; - }); - - return box(min, max); -} - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/feature.hpp b/include/mapbox/geometry/feature.hpp deleted file mode 100644 index 3bdd484..0000000 --- a/include/mapbox/geometry/feature.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include - -#include - -#include -#include -#include -#include -#include - -namespace mapbox { -namespace geometry { - -struct value; - -struct null_value_t -{ - constexpr null_value_t() {} - constexpr null_value_t(std::nullptr_t) {} -}; - -constexpr bool operator==(const null_value_t&, const null_value_t&) { return true; } -constexpr bool operator!=(const null_value_t&, const null_value_t&) { return false; } - -constexpr null_value_t null_value = null_value_t(); - -// Multiple numeric types (uint64_t, int64_t, double) are present in order to support -// the widest possible range of JSON numbers, which do not have a maximum range. -// Implementations that produce `value`s should use that order for type preference, -// using uint64_t for positive integers, int64_t for negative integers, and double -// for non-integers and integers outside the range of 64 bits. -using value_base = mapbox::util::variant>, - mapbox::util::recursive_wrapper>>; - -struct value : value_base -{ - using value_base::value_base; -}; - -using property_map = std::unordered_map; - -// The same considerations and requirement for numeric types apply as for `value_base`. -using identifier = mapbox::util::variant; - -template -struct feature -{ - using coordinate_type = T; - using geometry_type = mapbox::geometry::geometry; // Fully qualified to avoid GCC -fpermissive error. - - geometry_type geometry; - property_map properties {}; - std::experimental::optional id {}; -}; - -template -constexpr bool operator==(feature const& lhs, feature const& rhs) -{ - return lhs.id == rhs.id && lhs.geometry == rhs.geometry && lhs.properties == rhs.properties; -} - -template -constexpr bool operator!=(feature const& lhs, feature const& rhs) -{ - return !(lhs == rhs); -} - -template class Cont = std::vector> -struct feature_collection : Cont> -{ - using coordinate_type = T; - using feature_type = feature; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/for_each_point.hpp b/include/mapbox/geometry/for_each_point.hpp deleted file mode 100644 index 44d6e77..0000000 --- a/include/mapbox/geometry/for_each_point.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include - -namespace mapbox { -namespace geometry { - -template -auto for_each_point(Point&& point, F&& f) - -> decltype(point.x, point.y, void()) -{ - f(std::forward(point)); -} - -template -auto for_each_point(Container&& container, F&& f) - -> decltype(container.begin(), container.end(), void()); - -template -void for_each_point(mapbox::util::variant const& geom, F&& f) -{ - mapbox::util::variant::visit(geom, [&] (auto const& g) { - for_each_point(g, f); - }); -} - -template -void for_each_point(mapbox::util::variant & geom, F&& f) -{ - mapbox::util::variant::visit(geom, [&] (auto & g) { - for_each_point(g, f); - }); -} - -template -auto for_each_point(Container&& container, F&& f) - -> decltype(container.begin(), container.end(), void()) -{ - for (auto& e: container) { - for_each_point(e, f); - } -} - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/geometry.hpp b/include/mapbox/geometry/geometry.hpp deleted file mode 100644 index a3970bf..0000000 --- a/include/mapbox/geometry/geometry.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -#include - -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct geometry_collection; - -template -using geometry_base = mapbox::util::variant, - line_string, - polygon, - multi_point, - multi_line_string, - multi_polygon, - geometry_collection>; - -template -struct geometry : geometry_base -{ - using coordinate_type = T; - using geometry_base::geometry_base; - - /* - * The default constructor would create a point geometry with default-constructed coordinates; - * i.e. (0, 0). Since this is not particularly useful, and could hide bugs, it is disabled. - */ - geometry() = delete; -}; - -template class Cont> -struct geometry_collection : Cont> -{ - using coordinate_type = T; - using geometry_type = geometry; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/line_string.hpp b/include/mapbox/geometry/line_string.hpp deleted file mode 100644 index 6d811ce..0000000 --- a/include/mapbox/geometry/line_string.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -// mapbox -#include -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct line_string : Cont > -{ - using coordinate_type = T; - using point_type = point; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/multi_line_string.hpp b/include/mapbox/geometry/multi_line_string.hpp deleted file mode 100644 index 07a7a1d..0000000 --- a/include/mapbox/geometry/multi_line_string.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -// mapbox -#include -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct multi_line_string : Cont> -{ - using coordinate_type = T; - using line_string_type = line_string; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/multi_point.hpp b/include/mapbox/geometry/multi_point.hpp deleted file mode 100644 index a3c73cf..0000000 --- a/include/mapbox/geometry/multi_point.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -// mapbox -#include -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct multi_point : Cont> -{ - using coordinate_type = T; - using point_type = point; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/multi_polygon.hpp b/include/mapbox/geometry/multi_polygon.hpp deleted file mode 100644 index ad230a0..0000000 --- a/include/mapbox/geometry/multi_polygon.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -// mapbox -#include -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct multi_polygon : Cont> -{ - using coordinate_type = T; - using polygon_type = polygon; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/point.hpp b/include/mapbox/geometry/point.hpp deleted file mode 100644 index 0cba499..0000000 --- a/include/mapbox/geometry/point.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -namespace mapbox { -namespace geometry { - -template -struct point -{ - using coordinate_type = T; - - constexpr point() - : x(), y() - {} - constexpr point(T x_, T y_) - : x(x_), y(y_) - {} - - T x; - T y; -}; - -template -constexpr bool operator==(point const& lhs, point const& rhs) -{ - return lhs.x == rhs.x && lhs.y == rhs.y; -} - -template -constexpr bool operator!=(point const& lhs, point const& rhs) -{ - return !(lhs == rhs); -} - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/point_arithmetic.hpp b/include/mapbox/geometry/point_arithmetic.hpp deleted file mode 100644 index 3940e5b..0000000 --- a/include/mapbox/geometry/point_arithmetic.hpp +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once - -namespace mapbox { -namespace geometry { - -template -constexpr point operator+(point const& lhs, point const& rhs) -{ - return point(lhs.x + rhs.x, lhs.y + rhs.y); -} - -template -constexpr point operator+(point const& lhs, T const& rhs) -{ - return point(lhs.x + rhs, lhs.y + rhs); -} - -template -constexpr point operator-(point const& lhs, point const& rhs) -{ - return point(lhs.x - rhs.x, lhs.y - rhs.y); -} - -template -constexpr point operator-(point const& lhs, T const& rhs) -{ - return point(lhs.x - rhs, lhs.y - rhs); -} - -template -constexpr point operator*(point const& lhs, point const& rhs) -{ - return point(lhs.x * rhs.x, lhs.y * rhs.y); -} - -template -constexpr point operator*(point const& lhs, T const& rhs) -{ - return point(lhs.x * rhs, lhs.y * rhs); -} - -template -constexpr point operator/(point const& lhs, point const& rhs) -{ - return point(lhs.x / rhs.x, lhs.y / rhs.y); -} - -template -constexpr point operator/(point const& lhs, T const& rhs) -{ - return point(lhs.x / rhs, lhs.y / rhs); -} - -template -constexpr point& operator+=(point& lhs, point const& rhs) -{ - lhs.x += rhs.x; - lhs.y += rhs.y; - return lhs; -} - -template -constexpr point& operator+=(point& lhs, T const& rhs) -{ - lhs.x += rhs; - lhs.y += rhs; - return lhs; -} - -template -constexpr point& operator-=(point& lhs, point const& rhs) -{ - lhs.x -= rhs.x; - lhs.y -= rhs.y; - return lhs; -} - -template -constexpr point& operator-=(point& lhs, T const& rhs) -{ - lhs.x -= rhs; - lhs.y -= rhs; - return lhs; -} - -template -constexpr point& operator*=(point& lhs, point const& rhs) -{ - lhs.x *= rhs.x; - lhs.y *= rhs.y; - return lhs; -} - -template -constexpr point& operator*=(point& lhs, T const& rhs) -{ - lhs.x *= rhs; - lhs.y *= rhs; - return lhs; -} - -template -constexpr point& operator/=(point& lhs, point const& rhs) -{ - lhs.x /= rhs.x; - lhs.y /= rhs.y; - return lhs; -} - -template -constexpr point& operator/=(point& lhs, T const& rhs) -{ - lhs.x /= rhs; - lhs.y /= rhs; - return lhs; -} - -} // namespace geometry -} // namespace mapbox diff --git a/include/mapbox/geometry/polygon.hpp b/include/mapbox/geometry/polygon.hpp deleted file mode 100644 index 99a66aa..0000000 --- a/include/mapbox/geometry/polygon.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -// mapbox -#include - -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct linear_ring : Cont> -{ - using coordinate_type = T; - using point_type = point; - using container_type = Cont; - using container_type::container_type; -}; - -template class Cont = std::vector> -struct polygon : Cont> -{ - using coordinate_type = T; - using linear_ring_type = linear_ring; - using container_type = Cont; - using container_type::container_type; -}; - -} // namespace geometry -} // namespace mapbox -- cgit 1.2.3-korg