be able to pass down scale_factor to python grid renderering

This commit is contained in:
Dane Springmeyer 2014-09-12 15:50:00 -07:00
parent f888e0a9f6
commit dcd21e75d9
3 changed files with 30 additions and 18 deletions

View file

@ -220,7 +220,10 @@ void render_with_detector(
void render_layer2(mapnik::Map const& map,
mapnik::image_32& image,
unsigned layer_idx)
unsigned layer_idx,
double scale_factor,
unsigned offset_x,
unsigned offset_y)
{
std::vector<mapnik::layer> const& layers = map.layers();
std::size_t layer_num = layers.size();
@ -233,7 +236,7 @@ void render_layer2(mapnik::Map const& map,
python_unblock_auto_block b;
mapnik::layer const& layer = layers[layer_idx];
mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
mapnik::agg_renderer<mapnik::image_32> ren(map,image,scale_factor,offset_x,offset_y);
std::set<std::string> names;
ren.apply(layer,names);
}
@ -730,12 +733,25 @@ BOOST_PYTHON_MODULE(_mapnik)
));
def("render_layer", &render_layer2,
(arg("map"),arg("image"),args("layer"))
(arg("map"),
arg("image"),
arg("layer"),
arg("scale_factor")=1.0,
arg("offset_x")=0,
arg("offset_y")=0
)
);
#if defined(GRID_RENDERER)
def("render_layer", &mapnik::render_layer_for_grid,
(arg("map"),arg("grid"),args("layer"),arg("fields")=boost::python::list())
(arg("map"),
arg("grid"),
arg("layer"),
arg("fields")=boost::python::list(),
arg("scale_factor")=1.0,
arg("offset_x")=0,
arg("offset_y")=0
)
);
#endif

View file

@ -339,15 +339,13 @@ boost::python::dict grid_encode( T const& grid, std::string const& format, bool
template boost::python::dict grid_encode( mapnik::grid const& grid, std::string const& format, bool add_features, unsigned int resolution);
template boost::python::dict grid_encode( mapnik::grid_view const& grid, std::string const& format, bool add_features, unsigned int resolution);
/* new approach: key comes from grid object
* grid size should be same as the map
* encoding, resizing handled as method on grid object
* whether features are dumped is determined by argument not 'fields'
*/
void render_layer_for_grid(mapnik::Map const& map,
mapnik::grid & grid,
unsigned layer_idx, // TODO - layer by name or index
boost::python::list const& fields)
unsigned layer_idx,
boost::python::list const& fields,
double scale_factor,
unsigned offset_x,
unsigned offset_y)
{
std::vector<mapnik::layer> const& layers = map.layers();
std::size_t layer_num = layers.size();
@ -390,7 +388,7 @@ void render_layer_for_grid(mapnik::Map const& map,
attributes.insert(join_field);
}
mapnik::grid_renderer<mapnik::grid> ren(map,grid,1.0,0,0);
mapnik::grid_renderer<mapnik::grid> ren(map,grid,scale_factor,offset_x,offset_y);
mapnik::layer const& layer = layers[layer_idx];
ren.apply(layer,attributes);
}

View file

@ -66,15 +66,13 @@ void grid_encode_utf(T const& grid_type,
template <typename T>
boost::python::dict grid_encode( T const& grid, std::string const& format, bool add_features, unsigned int resolution);
/* new approach: key comes from grid object
* grid size should be same as the map
* encoding, resizing handled as method on grid object
* whether features are dumped is determined by argument not 'fields'
*/
void render_layer_for_grid(const mapnik::Map& map,
mapnik::grid& grid,
unsigned layer_idx, // TODO - layer by name or index
boost::python::list const& fields);
boost::python::list const& fields,
double scale_factor,
unsigned offset_x,
unsigned offset_y);
}