geometry_envelope - add missing linear_ring

This commit is contained in:
artemp 2015-12-17 12:03:19 +00:00
parent bd21e452d1
commit e0c756ee8d
2 changed files with 16 additions and 9 deletions

View file

@ -41,7 +41,7 @@ struct geometry_envelope
{ {
return mapnik::util::apply_visitor(*this, geom); return mapnik::util::apply_visitor(*this, geom);
} }
void operator() (mapnik::geometry::geometry_empty const&) const {} void operator() (mapnik::geometry::geometry_empty const&) const {}
template <typename T> template <typename T>
@ -60,30 +60,36 @@ struct geometry_envelope
bool first = true; bool first = true;
for (auto const& pt : line) for (auto const& pt : line)
{ {
if (first && !bbox.valid()) if (first && !bbox.valid())
{ {
bbox.init(pt.x, pt.y, pt.x, pt.y); bbox.init(pt.x, pt.y, pt.x, pt.y);
first = false; first = false;
} }
else else
{ {
bbox.expand_to_include(pt.x, pt.y); bbox.expand_to_include(pt.x, pt.y);
} }
} }
} }
template <typename T>
void operator() (mapnik::geometry::linear_ring<T> const& ring) const
{
(*this)(static_cast<mapnik::geometry::line_string<T> const&>(ring));
}
template <typename T> template <typename T>
void operator() (mapnik::geometry::polygon<T> const& poly) const void operator() (mapnik::geometry::polygon<T> const& poly) const
{ {
bool first = true; bool first = true;
for (auto const& pt : poly.exterior_ring) for (auto const& pt : poly.exterior_ring)
{ {
if (first && !bbox.valid()) if (first && !bbox.valid())
{ {
bbox.init(pt.x, pt.y, pt.x, pt.y); bbox.init(pt.x, pt.y, pt.x, pt.y);
first = false; first = false;
} }
else else
{ {
bbox.expand_to_include(pt.x, pt.y); bbox.expand_to_include(pt.x, pt.y);
} }
@ -96,12 +102,12 @@ struct geometry_envelope
bool first = true; bool first = true;
for (auto const& pt : multi_point) for (auto const& pt : multi_point)
{ {
if (first && !bbox.valid()) if (first && !bbox.valid())
{ {
bbox.init(pt.x, pt.y, pt.x, pt.y); bbox.init(pt.x, pt.y, pt.x, pt.y);
first = false; first = false;
} }
else else
{ {
bbox.expand_to_include(pt.x, pt.y); bbox.expand_to_include(pt.x, pt.y);
} }
@ -140,7 +146,7 @@ struct geometry_envelope
template <typename T> template <typename T>
mapnik::box2d<double> envelope(T const& geom) mapnik::box2d<double> envelope(T const& geom)
{ {
box2d<double> bbox; box2d<double> bbox;
detail::geometry_envelope op(bbox); detail::geometry_envelope op(bbox);
op(geom); op(geom);
@ -149,4 +155,3 @@ mapnik::box2d<double> envelope(T const& geom)
} // end ns geometry } // end ns geometry
} // end ns mapnik } // end ns mapnik

View file

@ -31,6 +31,7 @@ template MAPNIK_DECL mapnik::box2d<double> envelope(mapnik::base_symbolizer_help
template MAPNIK_DECL mapnik::box2d<double> envelope(geometry_empty const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(geometry_empty const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(point<double> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(point<double> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(line_string<double> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(line_string<double> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(linear_ring<double> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(polygon<double> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(polygon<double> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(multi_point<double> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(multi_point<double> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(multi_line_string<double> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(multi_line_string<double> const& geom);
@ -40,6 +41,7 @@ template MAPNIK_DECL mapnik::box2d<double> envelope(geometry_collection<double>
template MAPNIK_DECL mapnik::box2d<double> envelope(geometry<std::int64_t> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(geometry<std::int64_t> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(point<std::int64_t> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(point<std::int64_t> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(line_string<std::int64_t> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(line_string<std::int64_t> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(linear_ring<std::int64_t> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(polygon<std::int64_t> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(polygon<std::int64_t> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(multi_point<std::int64_t> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(multi_point<std::int64_t> const& geom);
template MAPNIK_DECL mapnik::box2d<double> envelope(multi_line_string<std::int64_t> const& geom); template MAPNIK_DECL mapnik::box2d<double> envelope(multi_line_string<std::int64_t> const& geom);