Skip to content
Browse files

Merge branch 'master' of github.com:mapnik/mapnik

  • Loading branch information...
2 parents fca5646 + 97463ab commit 52cf481043be26366391c8f9843b1fa603e4abcd @springmeyer springmeyer committed Sep 21, 2012
Showing with 16 additions and 11 deletions.
  1. +2 −2 src/proj_transform.cpp
  2. +14 −9 src/warp.cpp
View
4 src/proj_transform.cpp
@@ -150,7 +150,7 @@ bool proj_transform::backward (double * x, double * y , double * z, int point_co
}
}
- do {
+ {
#if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480
mutex::scoped_lock lock(projection::mutex_);
#endif
@@ -160,7 +160,7 @@ bool proj_transform::backward (double * x, double * y , double * z, int point_co
{
return false;
}
- } while(false);
+ }
if (is_source_longlat_)
{
View
23 src/warp.cpp
@@ -58,17 +58,19 @@ void reproject_and_scale_raster(raster & target, raster const& source,
CoordTransform tt(target.data_.width(), target.data_.height(),
target.ext_, offset_x, offset_y);
unsigned i, j;
- unsigned mesh_nx = ceil(source.data_.width()/double(mesh_size)+1);
- unsigned mesh_ny = ceil(source.data_.height()/double(mesh_size)+1);
+ unsigned mesh_nx = ceil(source.data_.width()/double(mesh_size) + 1);
+ unsigned mesh_ny = ceil(source.data_.height()/double(mesh_size) + 1);
ImageData<double> xs(mesh_nx, mesh_ny);
ImageData<double> ys(mesh_nx, mesh_ny);
// Precalculate reprojected mesh
- for(j=0; j<mesh_ny; j++) {
- for (i=0; i<mesh_nx; i++) {
- xs(i,j) = i*mesh_size;
- ys(i,j) = j*mesh_size;
+ for(j=0; j<mesh_ny; ++j)
+ {
+ for (i=0; i<mesh_nx; ++i)
+ {
+ xs(i,j) = std::min(i*mesh_size,source.data_.width());
+ ys(i,j) = std::min(j*mesh_size,source.data_.height());
ts.backward(&xs(i,j), &ys(i,j));
}
}
@@ -144,8 +146,10 @@ void reproject_and_scale_raster(raster & target, raster const& source,
}
// Project mesh cells into target interpolating raster inside each one
- for(j=0; j<mesh_ny-1; j++) {
- for (i=0; i<mesh_nx-1; i++) {
+ for(j=0; j<mesh_ny-1; j++)
+ {
+ for (i=0; i<mesh_nx-1; i++)
+ {
double polygon[8] = {xs(i,j), ys(i,j),
xs(i+1,j), ys(i+1,j),
xs(i+1,j+1), ys(i+1,j+1),
@@ -165,7 +169,8 @@ void reproject_and_scale_raster(raster & target, raster const& source,
unsigned y0 = j * mesh_size;
unsigned x1 = (i+1) * mesh_size;
unsigned y1 = (j+1) * mesh_size;
-
+ x1 = std::min(x1, source.data_.width());
+ y1 = std::min(y1, source.data_.height());
agg::trans_affine tr(polygon, x0, y0, x1, y1);
if (tr.is_valid())
{

0 comments on commit 52cf481

Please sign in to comment.
Something went wrong with that request. Please try again.