GeoJSON - make geometry
element stricter and throw on invalid input.
This commit is contained in:
parent
8a18ef93e0
commit
d9063db0a0
1 changed files with 30 additions and 14 deletions
|
@ -44,7 +44,10 @@ struct create_point
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
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_;
|
||||
};
|
||||
|
||||
|
@ -55,11 +58,9 @@ struct create_linestring
|
|||
: geom_(geom) {}
|
||||
|
||||
void operator() (ring const& points) const
|
||||
{
|
||||
std::size_t size = points.size();
|
||||
if (size > 1)
|
||||
{
|
||||
mapnik::geometry::line_string<double> line;
|
||||
std::size_t size = points.size();
|
||||
line.reserve(size);
|
||||
for (auto && pt : points)
|
||||
{
|
||||
|
@ -67,10 +68,12 @@ struct create_linestring
|
|||
}
|
||||
geom_ = std::move(line);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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 <typename T>
|
||||
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 <typename T>
|
||||
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 <typename T>
|
||||
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 <typename T>
|
||||
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<Geometry>(geom), coords);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Failed to parse geojson geometry");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue