From 4a8b7a6301e4b093c99329d0a16fbee6c535f312 Mon Sep 17 00:00:00 2001 From: wanglu Date: Mon, 25 Mar 2019 09:42:49 +0800 Subject: This is a application for display turn by run navigation information. Change-Id: I0866a7d9ffa347c0935b4d00259ad1a74cd00d6e Signed-off-by: wanglu --- include/mapbox/geometry/feature.hpp | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 include/mapbox/geometry/feature.hpp (limited to 'include/mapbox/geometry/feature.hpp') diff --git a/include/mapbox/geometry/feature.hpp b/include/mapbox/geometry/feature.hpp new file mode 100644 index 0000000..3bdd484 --- /dev/null +++ b/include/mapbox/geometry/feature.hpp @@ -0,0 +1,81 @@ +#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 -- cgit 1.2.3-korg