From 6803ee1190b309a5330eeb49abc3eaa569e414f8 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 29 Apr 2016 15:37:52 -0700 Subject: [PATCH] Add feature type --- include/mapbox/geometry.hpp | 10 +++++++++ include/mapbox/geometry/feature.hpp | 33 +++++++++++++++++++++++++++++ tests/test.cpp | 15 ++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 include/mapbox/geometry.hpp create mode 100644 include/mapbox/geometry/feature.hpp diff --git a/include/mapbox/geometry.hpp b/include/mapbox/geometry.hpp new file mode 100644 index 0000000..361552e --- /dev/null +++ b/include/mapbox/geometry.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/mapbox/geometry/feature.hpp b/include/mapbox/geometry/feature.hpp new file mode 100644 index 0000000..0934c08 --- /dev/null +++ b/include/mapbox/geometry/feature.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +#include + +#include +#include +#include + +namespace mapbox { namespace geometry { + +using value = mapbox::util::variant; + +template +struct feature +{ + using geometry_type = geometry; + using property_map = std::unordered_map; + + geometry_type geometry; + property_map properties; +}; + +template class Cont = std::vector> +struct feature_collection : Cont> +{ + using feature_type = feature; + using container_type = Cont; + using container_type::container_type; +}; + +}} diff --git a/tests/test.cpp b/tests/test.cpp index e4f346a..d348f22 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -76,6 +76,17 @@ void testGeometryCollection() { assert(gc1.size() == 0); } +void testFeature() { + feature pf { point() }; + assert(pf.geometry.is>()); + assert(pf.properties.size() == 0); +} + +void testFeatureCollection() { + feature_collection fc1; + assert(fc1.size() == 0); +} + int main() { testPoint(); testMultiPoint(); @@ -85,5 +96,7 @@ int main() { testMultiPolygon(); testGeometry(); testGeometryCollection(); + testFeature(); + testFeatureCollection(); return 0; }