fix group_by on layer to be std::string const& and reflect in python

This commit is contained in:
Dane Springmeyer 2012-08-20 16:26:41 -07:00
parent 3be516a805
commit 55646ce236
4 changed files with 37 additions and 2 deletions

View file

@ -304,6 +304,14 @@ void export_layer()
">>> lyr.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'\n"
)
.add_property("group_by",
make_function(&layer::group_by,return_value_policy<copy_const_reference>()),
&layer::set_group_by,
"Get/Set the optional layer group name.\n"
"\n"
"More details at https://github.com/mapnik/mapnik/wiki/Grouped-rendering:\n"
)
.add_property("styles",
make_function(_styles_,return_value_policy<reference_existing_object>()),
"The styles list attached to this layer.\n"

View file

@ -171,7 +171,7 @@ public:
/*!
* @return The field rendering of this layer is grouped by.
*/
std::string group_by() const;
std::string const& group_by() const;
/*!
* @brief Attach a datasource for this layer.

View file

@ -237,7 +237,7 @@ void layer::set_group_by(std::string column)
group_by_ = column;
}
std::string layer::group_by() const
std::string const& layer::group_by() const
{
return group_by_;
}

View file

@ -0,0 +1,27 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from nose.tools import *
import mapnik
# Map initialization
def test_layer_init():
l = mapnik.Layer('test')
eq_(l.name,'test')
eq_(l.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
eq_(l.envelope(),mapnik.Box2d())
eq_(l.clear_label_cache,False)
eq_(l.cache_features,False)
eq_(l.visible(1),True)
eq_(l.active,True)
eq_(l.datasource,None)
eq_(l.queryable,False)
eq_(l.minzoom,0.0)
eq_(l.maxzoom > 1e+6,True)
eq_(l.group_by,"")
eq_(l.maximum_extent,None)
eq_(l.buffer_size,0.0)
eq_(len(l.styles),0)
if __name__ == "__main__":
[eval(run)() for run in dir() if 'test_' in run]