diff --git a/src/envelope.cpp b/src/envelope.cpp index 90b824210..75ffd6d2f 100644 --- a/src/envelope.cpp +++ b/src/envelope.cpp @@ -307,21 +307,27 @@ namespace mapnik template Envelope& Envelope::operator*=(T t) { - minx_ *= t; - miny_ *= t; - maxx_ *= t; - maxy_ *= t; - return *this; + coord c = center(); + T sx = 0.5 * width() * t; + T sy = 0.5 * height() * t; + minx_ = static_cast(c.x - sx); + maxx_ = static_cast(c.x + sx); + miny_ = static_cast(c.y - sy); + maxy_ = static_cast(c.y + sy); + return *this; } - + template Envelope& Envelope::operator/=(T t) { - minx_ /= t; - miny_ /= t; - maxx_ /= t; - maxy_ /= t; - return *this; + coord c = center(); + T sx = 0.5 * width() / t; + T sy = 0.5 * height() / t; + minx_ = static_cast(c.x - sx); + maxx_ = static_cast(c.x + sx); + miny_ = static_cast(c.y - sy); + maxy_ = static_cast(c.y + sy); + return *this; } template class Envelope;