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..5d72bd7 --- /dev/null +++ b/include/mapbox/geometry/feature.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include + +#include + +#include +#include +#include +#include + +namespace mapbox { namespace geometry { + +struct value; + +using value_base = mapbox::util::variant>, + mapbox::util::recursive_wrapper>>; + +struct value : value_base +{ + using value_base::value_base; +}; + +template +struct feature +{ + using geometry_type = mapbox::geometry::geometry; // Fully qualified to avoid GCC -fpermissive error. + 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 62ddeb9..60df829 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -76,6 +76,17 @@ static void testGeometryCollection() { assert(gc1.size() == 0); } +static void testFeature() { + feature pf { point() }; + assert(pf.geometry.is>()); + assert(pf.properties.size() == 0); +} + +static 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; }