void render_layer_for_grid(mapnik::Map const& map, mapnik::grid & grid, 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(); if (layer_idx >= layer_num) { std::ostringstream s; s << "Zero-based layer index '" << layer_idx << "' not valid, only '" << layer_num << "' layers are in map\n"; throw std::runtime_error(s.str()); } // convert python list to std::set boost::python::ssize_t num_fields = boost::python::len(fields); for(boost::python::ssize_t i=0; i<num_fields; i++) { boost::python::extract<std::string> name(fields[i]); if (name.check()) { grid.add_field(name()); } else { std::stringstream s; s << "list of field names must be strings"; throw mapnik::value_error(s.str()); } } // copy field names std::set<std::string> attributes = grid.get_fields(); // todo - make this a static constant std::string known_id_key = "__id__"; if (attributes.find(known_id_key) != attributes.end()) { attributes.erase(known_id_key); } std::string join_field = grid.get_key(); if (known_id_key != join_field && attributes.find(join_field) == attributes.end()) { attributes.insert(join_field); } 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); }
void render_layer2(const mapnik::Map& map, mapnik::image_32& image, unsigned layer_idx) { std::vector<mapnik::layer> const& layers = map.layers(); std::size_t layer_num = layers.size(); if (layer_idx >= layer_num) { std::ostringstream s; s << "Zero-based layer index '" << layer_idx << "' not valid, only '" << layer_num << "' layers are in map\n"; throw std::runtime_error(s.str()); } 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); std::set<std::string> names; ren.apply(layer,names); }
void render_layer2(mapnik::Map const& map, mapnik::image_any& image, 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(); if (layer_idx >= layer_num) { std::ostringstream s; s << "Zero-based layer index '" << layer_idx << "' not valid, only '" << layer_num << "' layers are in map\n"; throw std::runtime_error(s.str()); } python_unblock_auto_block b; mapnik::layer const& layer = layers[layer_idx]; std::set<std::string> names; mapnik::util::apply_visitor(agg_renderer_visitor_4(map, scale_factor, offset_x, offset_y, layer, names), image); }