revert r1348 by enforcing map clipping by layer bounds, re-opens #420, closes #486, see also http://trac.mapnik.org/wiki/BoundsClipping

This commit is contained in:
Dane Springmeyer 2010-01-10 21:42:44 +00:00
parent 17945c57ec
commit a3c1f9090b
2 changed files with 22 additions and 18 deletions

View file

@ -124,32 +124,33 @@ namespace mapnik
Envelope<double> ext = m_.get_buffered_extent(); Envelope<double> ext = m_.get_buffered_extent();
projection proj1(lay.srs()); projection proj1(lay.srs());
proj_transform prj_trans(proj0,proj1); proj_transform prj_trans(proj0,proj1);
double mx0 = ext.minx();
double my0 = ext.miny();
double mz0 = 0.0;
double mx1 = ext.maxx();
double my1 = ext.maxy();
double mz1 = 0.0;
// project main map projection into layers extent
prj_trans.forward(mx0,my0,mz0);
prj_trans.forward(mx1,my1,mz1);
// if no intersection then nothing to do for layer
Envelope<double> layer_ext = lay.envelope(); Envelope<double> layer_ext = lay.envelope();
if ( mx0 > layer_ext.maxx() || mx1 < layer_ext.minx() || my0 > layer_ext.maxy() || my1 < layer_ext.miny() ) double lx0 = layer_ext.minx();
double ly0 = layer_ext.miny();
double lz0 = 0.0;
double lx1 = layer_ext.maxx();
double ly1 = layer_ext.maxy();
double lz1 = 0.0;
// back project layers extent into main map projection
prj_trans.backward(lx0,ly0,lz0);
prj_trans.backward(lx1,ly1,lz1);
// if no intersection then nothing to do for layer
if ( lx0 > ext.maxx() || lx1 < ext.minx() || ly0 > ext.maxy() || ly1 < ext.miny() )
{ {
return; return;
} }
// clip query bbox // clip query bbox
mx0 = std::max(layer_ext.minx(),mx0); lx0 = std::max(ext.minx(),lx0);
my0 = std::max(layer_ext.miny(),my0); ly0 = std::max(ext.miny(),ly0);
mx1 = std::min(layer_ext.maxx(),mx1); lx1 = std::min(ext.maxx(),lx1);
my1 = std::min(layer_ext.maxy(),my1); ly1 = std::min(ext.maxy(),ly1);
Envelope<double> bbox(mx0,my0,mx1,my1); prj_trans.forward(lx0,ly0,lz0);
prj_trans.forward(lx1,ly1,lz1);
Envelope<double> bbox(lx0,ly0,lx1,ly1);
double resolution = m_.getWidth()/bbox.width(); double resolution = m_.getWidth()/bbox.width();
query q(bbox,resolution,scale_denom); //BBOX query query q(bbox,resolution,scale_denom); //BBOX query

View file

@ -3,6 +3,7 @@
from nose.tools import * from nose.tools import *
import os, mapnik import os, mapnik
from utilities import Todo
def test_simplest_render(): def test_simplest_render():
m = mapnik.Map(256, 256) m = mapnik.Map(256, 256)
@ -68,6 +69,8 @@ def test_render_from_serialization():
def test_render_points(): def test_render_points():
# Test for effectivenes of ticket #402 (borderline points get lost on reprojection) # Test for effectivenes of ticket #402 (borderline points get lost on reprojection)
raise Todo("See: http://trac.mapnik.org/ticket/402")
if not mapnik.has_pycairo(): return if not mapnik.has_pycairo(): return
# create and populate point datasource (WGS84 lat-lon coordinates) # create and populate point datasource (WGS84 lat-lon coordinates)