apply #2350 to master/3.x too
This commit is contained in:
parent
072a914906
commit
c604e925f5
2 changed files with 20 additions and 3 deletions
|
@ -253,9 +253,17 @@ void ogr_datasource::init(mapnik::parameters const& params)
|
|||
OGRLayer* layer = layer_.layer();
|
||||
|
||||
// initialize envelope
|
||||
OGREnvelope envelope;
|
||||
layer->GetExtent(&envelope);
|
||||
extent_.init(envelope.MinX, envelope.MinY, envelope.MaxX, envelope.MaxY);
|
||||
boost::optional<std::string> ext = params.get<std::string>("extent");
|
||||
if (ext && !ext->empty())
|
||||
{
|
||||
extent_.from_string(*ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
OGREnvelope envelope;
|
||||
layer->GetExtent(&envelope);
|
||||
extent_.init(envelope.MinX, envelope.MinY, envelope.MaxX, envelope.MaxY);
|
||||
}
|
||||
|
||||
// scan for index file
|
||||
// TODO - layer names don't match dataset name, so this will break for
|
||||
|
|
|
@ -60,6 +60,15 @@ if 'ogr' in mapnik.DatasourceCache.plugin_names():
|
|||
# fs = ds.all_features()
|
||||
# eq_(len(fs),1)
|
||||
|
||||
# OGR plugin extent parameter
|
||||
def test_ogr_extent_parameter():
|
||||
ds = mapnik.Ogr(file='../data/shp/world_merc.shp',layer_by_index=0,extent='-1,-1,1,1')
|
||||
e = ds.envelope()
|
||||
eq_(e.minx,-1)
|
||||
eq_(e.miny,-1)
|
||||
eq_(e.maxx,1)
|
||||
eq_(e.maxy,1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|
||||
|
|
Loading…
Reference in a new issue