Apply patch from Marcin to handle smooth transitions between raster layers for both gdal and raster plugin - closed #295

This commit is contained in:
Dane Springmeyer 2009-04-07 23:06:51 +00:00
parent 4276ae24fe
commit 544cbb249a
5 changed files with 23 additions and 19 deletions

View file

@ -14,6 +14,8 @@ For a complete change history, see the SVN log.
0.6.1 SVN 0.6.1 SVN
--------- ---------
- Rasters: Handle rounding to allow better alignment of raster layers (r1079) (#295)
- AGG Renderer: Added option to control output JPEG quality (r1078) (#198) - AGG Renderer: Added option to control output JPEG quality (r1078) (#198)
- Plugins: Fixed segfault in OGC Plugin with empty geometries (r1074) (#292) - Plugins: Fixed segfault in OGC Plugin with empty geometries (r1074) (#292)

View file

@ -125,10 +125,10 @@ feature_ptr gdal_featureset::next()
Envelope<double> intersection = raster_extent.intersect(query_extent_); Envelope<double> intersection = raster_extent.intersect(query_extent_);
Envelope<double> box = t.forward(intersection); Envelope<double> box = t.forward(intersection);
int start_x = int(box.minx()); int start_x = int(box.minx()+0.5);
int start_y = int(box.miny()); int start_y = int(box.miny()+0.5);
int width = int(box.width()); int width = int(box.width()+0.5);
int height = int(box.height()); int height = int(box.height()+0.5);
if (width > 0 && height > 0) if (width > 0 && height > 0)
{ {

View file

@ -68,8 +68,8 @@ feature_ptr raster_featureset<LookupPolicy>::next()
Envelope<double> intersect=extent_.intersect(curIter_->envelope()); Envelope<double> intersect=extent_.intersect(curIter_->envelope());
Envelope<double> ext=t.forward(intersect); Envelope<double> ext=t.forward(intersect);
ImageData32 image((int)ext.width(),(int)ext.height()); ImageData32 image((int)(ext.width()+0.5),(int)(ext.height()+0.5));
reader->read((int)ext.minx(),(int)ext.miny(),image); reader->read((int)(ext.minx()+0.5),(int)(ext.miny()+0.5),image);
feature->set_raster(mapnik::raster_ptr(new raster(intersect,image))); feature->set_raster(mapnik::raster_ptr(new raster(intersect,image)));
} }
} }

View file

@ -669,6 +669,8 @@ namespace mapnik
{ {
Envelope<double> ext=t_.forward(raster->ext_); Envelope<double> ext=t_.forward(raster->ext_);
ImageData32 target(int(ext.width() + 0.5),int(ext.height() + 0.5)); ImageData32 target(int(ext.width() + 0.5),int(ext.height() + 0.5));
int start_x = int(ext.minx()+0.5);
int start_y = int(ext.miny()+0.5);
if (sym.get_scaling() == "fast"){ if (sym.get_scaling() == "fast"){
scale_image<ImageData32>(target,raster->data_); scale_image<ImageData32>(target,raster->data_);
@ -682,31 +684,31 @@ namespace mapnik
if (sym.get_mode() == "normal"){ if (sym.get_mode() == "normal"){
if (sym.get_opacity() == 1.0) { if (sym.get_opacity() == 1.0) {
pixmap_.set_rectangle(int(ext.minx()),int(ext.miny()),target); pixmap_.set_rectangle(start_x,start_y,target);
} else { } else {
pixmap_.set_rectangle_alpha2(target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.set_rectangle_alpha2(target,start_x,start_y, sym.get_opacity());
} }
} else if (sym.get_mode() == "grain_merge"){ } else if (sym.get_mode() == "grain_merge"){
pixmap_.template merge_rectangle<MergeGrain> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<MergeGrain> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "grain_merge2"){ } else if (sym.get_mode() == "grain_merge2"){
pixmap_.template merge_rectangle<MergeGrain2> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<MergeGrain2> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "multiply"){ } else if (sym.get_mode() == "multiply"){
pixmap_.template merge_rectangle<Multiply> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<Multiply> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "multiply2"){ } else if (sym.get_mode() == "multiply2"){
pixmap_.template merge_rectangle<Multiply2> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<Multiply2> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "divide"){ } else if (sym.get_mode() == "divide"){
pixmap_.template merge_rectangle<Divide> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<Divide> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "divide2"){ } else if (sym.get_mode() == "divide2"){
pixmap_.template merge_rectangle<Divide2> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<Divide2> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "screen"){ } else if (sym.get_mode() == "screen"){
pixmap_.template merge_rectangle<Screen> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<Screen> (target,start_x,start_y, sym.get_opacity());
} else if (sym.get_mode() == "hard_light"){ } else if (sym.get_mode() == "hard_light"){
pixmap_.template merge_rectangle<HardLight> (target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.template merge_rectangle<HardLight> (target,start_x,start_y, sym.get_opacity());
} else { } else {
if (sym.get_opacity() == 1.0){ if (sym.get_opacity() == 1.0){
pixmap_.set_rectangle(int(ext.minx()),int(ext.miny()),target); pixmap_.set_rectangle(start_x,start_y,target);
} else { } else {
pixmap_.set_rectangle_alpha2(target,int(ext.minx()),int(ext.miny()), sym.get_opacity()); pixmap_.set_rectangle_alpha2(target,start_x,start_y, sym.get_opacity());
} }
} }
// TODO: other modes? (add,diff,sub,...) // TODO: other modes? (add,diff,sub,...)

View file

@ -987,7 +987,7 @@ namespace mapnik
cairo_context context(context_); cairo_context context(context_);
//TODO -- support for advanced image merging //TODO -- support for advanced image merging
context.add_image(int(ext.minx()), int(ext.miny()), target, sym.get_opacity()); context.add_image(int(ext.minx()+0.5), int(ext.miny()+0.5), target, sym.get_opacity());
} }
} }