apply patch from mishok13 from #wherecamp to expose dash array list in python along with a small test case - closes #317

This commit is contained in:
Dane Springmeyer 2009-05-24 04:14:35 +00:00
parent 80a5bdf6e3
commit b2570bd866
4 changed files with 37 additions and 2 deletions

View File

@ -30,6 +30,7 @@ Patches
- John Hague
- Dennis Luxen
- Tom MacWright
- Andrii Mishkovskyi
- Dražen Odobašić
- Martijn van Oosterhout
- Cameron Patrick

View File

@ -14,6 +14,8 @@ For a complete change history, see the SVN log.
0.6.1 SVN
---------
- Python: Exposed dash_array get method (#317)
- OGCServer: Made lxml dependency optional (r1085) (#303)
- Rasters: Handle rounding to allow better alignment of raster layers (r1079) (#295)

View File

@ -26,9 +26,30 @@
#include <mapnik/stroke.hpp>
#include "mapnik_enumeration.hpp"
using namespace mapnik;
namespace {
using namespace boost::python;
list get_dashes(mapnik::stroke &stroke)
{
list l;
if (stroke.has_dash()) {
mapnik::dash_array const& dash = stroke.get_dash_array();
mapnik::dash_array::const_iterator iter = dash.begin();
mapnik::dash_array::const_iterator end = dash.end();
for (; iter != end; ++iter) {
l.append(make_tuple(iter->first, iter->second));
}
}
return l;
}
}
void export_stroke ()
{
using namespace mapnik;
using namespace boost::python;
enumeration_<line_cap_e>("line_cap")
@ -52,6 +73,8 @@ void export_stroke ()
.add_property("opacity",&stroke::get_opacity,&stroke::set_opacity)
.add_property("line_cap",&stroke::get_line_cap,&stroke::set_line_cap)
.add_property("line_join",&stroke::get_line_join,&stroke::set_line_join)
// todo combine into single get/set property
.def("add_dash",&stroke::add_dash)
.def("get_dashes", get_dashes)
;
}

View File

@ -46,7 +46,7 @@ def test_pointsymbolizer_missing_image():
# PointSymbolizer pickling
def test_pointsymbolizer_pickle():
raise Todo("PointSymbolizer does not support pickling yet.")
# PolygonSymbolizer initialization
def test_polygonsymbolizer_init():
p = mapnik.PolygonSymbolizer()
@ -81,6 +81,15 @@ def test_stroke_init():
eq_(s.line_cap, mapnik.line_cap.BUTT_CAP)
eq_(s.line_join, mapnik.line_join.MITER_JOIN)
# Stroke dashes
def test_stroke_dash_arrays():
s = mapnik.Stroke()
s.add_dash(1,2)
s.add_dash(3,4)
s.add_dash(5,6)
eq_(s.get_dashes(), [(1,2),(3,4),(5,6)])
# Stroke pickling
def test_stroke_pickle():
raise Todo("Stroke does not support pickling yet.")