Merge pull request #1157 from mapnik/stroke-as-reference

make stroke property on line_symbolizer a reference when accessed from python (not a copy)
This commit is contained in:
Dane Springmeyer 2012-07-31 18:20:55 -07:00
commit f60f40c939
2 changed files with 10 additions and 1 deletions

View file

@ -57,7 +57,7 @@ void export_line_symbolizer()
"Set/get the rasterization method of the line of the point")
.add_property("stroke",make_function
(&line_symbolizer::get_stroke,
return_value_policy<copy_const_reference>()),
return_value_policy<reference_existing_object>()),
&line_symbolizer::set_stroke)
.add_property("smooth",
&line_symbolizer::smooth,

View file

@ -21,6 +21,15 @@ def test_line_symbolizer_init():
s = mapnik.LineSymbolizer()
eq_(s.rasterizer, mapnik.line_rasterizer.FULL)
def test_line_symbolizer_stroke_reference():
l = mapnik.LineSymbolizer(mapnik.Color('green'),0.1)
l.stroke.add_dash(.1,.1)
l.stroke.add_dash(.1,.1)
eq_(l.stroke.get_dashes(), [(.1,.1),(.1,.1)])
eq_(l.stroke.color,mapnik.Color('green'))
eq_(l.stroke.opacity,1.0)
assert_almost_equal(l.stroke.width,0.1)
# ShieldSymbolizer initialization
def test_shieldsymbolizer_init():
s = mapnik.ShieldSymbolizer(mapnik.Expression('[Field Name]'), 'DejaVu Sans Bold', 6, mapnik.Color('#000000'), mapnik.PathExpression('../data/images/dummy.png'))