From 22d8fbe7f0b60e3a87f6a79bcb1161ab3db04caf Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 3 Feb 2010 12:19:57 +0000 Subject: [PATCH] + consistent raster bbox calc : x0 = int(minx+0.5) y0 = int(miny+0.5) x1 = int(maxx+0.5) y1 = int(maxy+0.5) width = x1 - x0 height = y1 - y0 --- plugins/input/raster/raster_featureset.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 8ecb5a477..c03157225 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -73,10 +73,21 @@ feature_ptr raster_featureset::next() CoordTransform t(image_width,image_height,extent_,0,0); box2d intersect=bbox_.intersect(curIter_->envelope()); box2d ext=t.forward(intersect); - image_data_32 image(int(ext.width()+0.5),int(ext.height()+0.5)); - reader->read(int(ext.minx()+0.5),int(ext.miny()+0.5),image); - feature->set_raster(mapnik::raster_ptr(new raster(intersect,image))); - } + + int start_x = int(ext.minx() + 0.5); + int start_y = int(ext.miny() + 0.5); + int end_x = int(ext.maxx() + 0.5); + int end_y = int(ext.maxy() + 0.5); + + unsigned w = end_x - start_x; + unsigned h = end_y - start_y; + if ( w > 0 && h > 0) + { + image_data_32 image(w,h); + reader->read(start_x,start_y,image); + feature->set_raster(mapnik::raster_ptr(new raster(intersect,image))); + } + } } } catch (...)