From e0c756ee8d90c9cd1cbc67c8b5e2ce5d7451128a Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 17 Dec 2015 12:03:19 +0000 Subject: [PATCH] geometry_envelope - add missing linear_ring --- include/mapnik/geometry_envelope_impl.hpp | 23 ++++++++++++++--------- src/geometry_envelope.cpp | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/mapnik/geometry_envelope_impl.hpp b/include/mapnik/geometry_envelope_impl.hpp index dbed6aa47..5c39bc386 100644 --- a/include/mapnik/geometry_envelope_impl.hpp +++ b/include/mapnik/geometry_envelope_impl.hpp @@ -41,7 +41,7 @@ struct geometry_envelope { return mapnik::util::apply_visitor(*this, geom); } - + void operator() (mapnik::geometry::geometry_empty const&) const {} template @@ -60,30 +60,36 @@ struct geometry_envelope bool first = true; for (auto const& pt : line) { - if (first && !bbox.valid()) + if (first && !bbox.valid()) { bbox.init(pt.x, pt.y, pt.x, pt.y); first = false; } - else + else { bbox.expand_to_include(pt.x, pt.y); } } } + template + void operator() (mapnik::geometry::linear_ring const& ring) const + { + (*this)(static_cast const&>(ring)); + } + template void operator() (mapnik::geometry::polygon const& poly) const { bool first = true; 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); first = false; } - else + else { bbox.expand_to_include(pt.x, pt.y); } @@ -96,12 +102,12 @@ struct geometry_envelope bool first = true; for (auto const& pt : multi_point) { - if (first && !bbox.valid()) + if (first && !bbox.valid()) { bbox.init(pt.x, pt.y, pt.x, pt.y); first = false; } - else + else { bbox.expand_to_include(pt.x, pt.y); } @@ -140,7 +146,7 @@ struct geometry_envelope template mapnik::box2d envelope(T const& geom) -{ +{ box2d bbox; detail::geometry_envelope op(bbox); op(geom); @@ -149,4 +155,3 @@ mapnik::box2d envelope(T const& geom) } // end ns geometry } // end ns mapnik - diff --git a/src/geometry_envelope.cpp b/src/geometry_envelope.cpp index 0aa3466f1..5b3ade6f2 100644 --- a/src/geometry_envelope.cpp +++ b/src/geometry_envelope.cpp @@ -31,6 +31,7 @@ template MAPNIK_DECL mapnik::box2d envelope(mapnik::base_symbolizer_help template MAPNIK_DECL mapnik::box2d envelope(geometry_empty const& geom); template MAPNIK_DECL mapnik::box2d envelope(point const& geom); template MAPNIK_DECL mapnik::box2d envelope(line_string const& geom); +template MAPNIK_DECL mapnik::box2d envelope(linear_ring const& geom); template MAPNIK_DECL mapnik::box2d envelope(polygon const& geom); template MAPNIK_DECL mapnik::box2d envelope(multi_point const& geom); template MAPNIK_DECL mapnik::box2d envelope(multi_line_string const& geom); @@ -40,6 +41,7 @@ template MAPNIK_DECL mapnik::box2d envelope(geometry_collection template MAPNIK_DECL mapnik::box2d envelope(geometry const& geom); template MAPNIK_DECL mapnik::box2d envelope(point const& geom); template MAPNIK_DECL mapnik::box2d envelope(line_string const& geom); +template MAPNIK_DECL mapnik::box2d envelope(linear_ring const& geom); template MAPNIK_DECL mapnik::box2d envelope(polygon const& geom); template MAPNIK_DECL mapnik::box2d envelope(multi_point const& geom); template MAPNIK_DECL mapnik::box2d envelope(multi_line_string const& geom);