diff --git a/include/mapnik/json/create_geometry.hpp b/include/mapnik/json/create_geometry.hpp index 780a1d4cc..54270a848 100644 --- a/include/mapnik/json/create_geometry.hpp +++ b/include/mapnik/json/create_geometry.hpp @@ -44,7 +44,10 @@ struct create_point } template - void operator()(T const&) const {} // no-op - shouldn't get here + void operator()(T const&) const + { + throw std::runtime_error("Failed to parse geojson geometry"); + } Geometry & geom_; }; @@ -56,21 +59,21 @@ struct create_linestring void operator() (ring const& points) const { + mapnik::geometry::line_string line; std::size_t size = points.size(); - if (size > 1) + line.reserve(size); + for (auto && pt : points) { - mapnik::geometry::line_string line; - line.reserve(size); - for (auto && pt : points) - { - line.emplace_back(std::move(pt)); - } - geom_ = std::move(line); + line.emplace_back(std::move(pt)); } + geom_ = std::move(line); } template - void operator()(T const&) const {} // no-op - shouldn't get here + void operator()(T const&) const + { + throw std::runtime_error("Failed to parse geojson geometry"); + } Geometry & geom_; }; @@ -107,7 +110,10 @@ struct create_polygon } template - void operator()(T const&) const {} // no-op - shouldn't get here + void operator()(T const&) const + { + throw std::runtime_error("Failed to parse geojson geometry"); + } Geometry & geom_; }; @@ -131,7 +137,10 @@ struct create_multipoint } template - void operator()(T const&) const {} // no-op - shouldn't get here + void operator()(T const&) const + { + throw std::runtime_error("Failed to parse geojson geometry"); + } Geometry & geom_; }; @@ -161,7 +170,10 @@ struct create_multilinestring } template - void operator()(T const&) const {} // no-op - shouldn't get here + void operator()(T const&) const + { + throw std::runtime_error("Failed to parse geojson geometry"); + } Geometry & geom_; }; @@ -202,7 +214,10 @@ struct create_multipolygon } template - void operator()(T const&) const {} // no-op - shouldn't get here + void operator()(T const&) const + { + throw std::runtime_error("Failed to parse geojson geometry"); + } Geometry & geom_; }; @@ -232,6 +247,7 @@ void create_geometry (Geometry & geom, int type, mapnik::json::positions const& util::apply_visitor(create_multipolygon(geom), coords); break; default: + throw std::runtime_error("Failed to parse geojson geometry"); break; } }