3636#include < pybind11/stl.h>
3737#include < pybind11/stl_bind.h>
3838
39- // boost
40- // #include <boost/compute/iterator/transform_iterator.hpp>
41-
4239namespace py = pybind11;
4340
4441using mapnik::color;
@@ -48,6 +45,8 @@ using mapnik::layer;
4845using mapnik::Map;
4946
5047PYBIND11_MAKE_OPAQUE (std::vector<mapnik::layer>);
48+ PYBIND11_MAKE_OPAQUE (std::map<std::string, mapnik::feature_type_style>);
49+
5150
5251namespace {
5352std::vector<layer>& (Map::*set_layers)() = &Map::layers;
@@ -116,29 +115,13 @@ void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> >
116115 }
117116}
118117
119- // struct extract_style
120- // {
121- // using result_type = py::tuple;
122- // result_type operator() (std::map<std::string, mapnik::feature_type_style>::value_type const& val) const
123- // {
124- // return py::make_tuple(val.first, val.second);
125- // }
126- // };
127-
128- // using style_extract_iterator = boost::transform_iterator<extract_style, Map::const_style_iterator>;
129- // using style_range = std::pair<style_extract_iterator,style_extract_iterator>;
130-
131- // style_range _styles_ (mapnik::Map const& m)
132- // {
133- // return style_range(
134- // boost::make_transform_iterator<extract_style>(m.begin_styles(), extract_style()),
135- // boost::make_transform_iterator<extract_style>(m.end_styles(), extract_style()));
136- // }
118+
137119} // namespace
138120
139121void export_map (py::module const & m)
140122{
141123 py::bind_vector<std::vector<mapnik::layer>>(m, " Layers" , py::module_local ());
124+ py::bind_map<std::map<std::string, mapnik::feature_type_style>>(m, " Styles" , py::module_local ());
142125 // aspect ratio fix modes
143126 py::enum_<mapnik::Map::aspect_fix_mode>(m, " aspect_fix_mode" )
144127 .value (" GROW_BBOX" , mapnik::Map::GROW_BBOX)
@@ -152,11 +135,6 @@ void export_map(py::module const& m)
152135 .value (" RESPECT" , mapnik::Map::RESPECT)
153136 ;
154137
155- // py::class_<style_range>(m, "StyleRange")
156- // .def("__iter__",
157- // boost::python::range(&style_range::first, &style_range::second))
158- // ;
159-
160138 py::class_<Map>(m, " Map" ," The map object." )
161139 .def (py::init<int , int , std::string const &>(),
162140 " Create a Map with a width and height as integers and, optionally,\n "
@@ -241,10 +219,16 @@ void export_map(py::module const& m)
241219 " <mapnik._mapnik.Style object at 0x654f0>\n " ,
242220 py::arg (" name" )
243221 )
244-
245- .def (" styles" , [] (mapnik::Map const & m) {
246- return py::make_iterator (m.begin_styles (), m.end_styles ());
247- }, py::keep_alive<0 , 1 >())
222+ .def_property (" styles" ,
223+ (std::map<std::string, mapnik::feature_type_style> const & (mapnik::Map::*)() const )
224+ &mapnik::Map::styles,
225+ (std::map<std::string, mapnik::feature_type_style>& (mapnik::Map::*)())
226+ &mapnik::Map::styles,
227+ " Returns list of Styles"
228+ " associated with this Map object" )
229+ // .def("styles", [] (mapnik::Map const& m) {
230+ // return py::make_iterator(m.begin_styles(), m.end_styles());
231+ // }, py::keep_alive<0, 1>())
248232
249233 .def (" pan" ,&Map::pan,
250234 " Set the Map center at a given x,y location\n "
0 commit comments