From 55646ce236f6aff44bb1b3ea3773bbdd59c268d6 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 20 Aug 2012 16:26:41 -0700 Subject: [PATCH] fix group_by on layer to be std::string const& and reflect in python --- bindings/python/mapnik_layer.cpp | 8 ++++++++ include/mapnik/layer.hpp | 2 +- src/layer.cpp | 2 +- tests/python_tests/layer_test.py | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/python_tests/layer_test.py diff --git a/bindings/python/mapnik_layer.cpp b/bindings/python/mapnik_layer.cpp index ae99e5971..71f9935d6 100644 --- a/bindings/python/mapnik_layer.cpp +++ b/bindings/python/mapnik_layer.cpp @@ -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()), + &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()), "The styles list attached to this layer.\n" diff --git a/include/mapnik/layer.hpp b/include/mapnik/layer.hpp index 1be1b23c0..78a17441c 100644 --- a/include/mapnik/layer.hpp +++ b/include/mapnik/layer.hpp @@ -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. diff --git a/src/layer.cpp b/src/layer.cpp index 09fbb0eb6..44abff6fb 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -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_; } diff --git a/tests/python_tests/layer_test.py b/tests/python_tests/layer_test.py new file mode 100644 index 000000000..5e23fd684 --- /dev/null +++ b/tests/python_tests/layer_test.py @@ -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]