From fbb102b975ebb8fa2cccffe1fc089a1133ae6f2c Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Sun, 1 Feb 2009 12:15:30 +0000 Subject: [PATCH] + changed operator* and operator/ behaviour as per #206 --- src/envelope.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) 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;