void render_with_vars(mapnik::Map const& map, mapnik::image_any& image, boost::python::dict const& d, double scale_factor = 1.0, unsigned offset_x = 0u, unsigned offset_y = 0u) { mapnik::attributes vars = mapnik::dict2attr(d); mapnik::request req(map.width(),map.height(),map.get_current_extent()); req.set_buffer_size(map.buffer_size()); python_unblock_auto_block b; mapnik::util::apply_visitor(agg_renderer_visitor_3(map, req, vars, scale_factor, offset_x, offset_y), image); }
image_type render(mapnik::Map & map, double scale_factor, map_size const & tiles) const { mapnik::box2d<double> box = map.get_current_extent(); image_type image(map.width(), map.height()); map.resize(image.width() / tiles.width, image.height() / tiles.height); double tile_box_width = box.width() / tiles.width; double tile_box_height = box.height() / tiles.height; for (std::size_t tile_y = 0; tile_y < tiles.height; tile_y++) { for (std::size_t tile_x = 0; tile_x < tiles.width; tile_x++) { mapnik::box2d<double> tile_box( box.minx() + tile_x * tile_box_width, box.miny() + tile_y * tile_box_height, box.minx() + (tile_x + 1) * tile_box_width, box.miny() + (tile_y + 1) * tile_box_height); map.zoom_to_box(tile_box); image_type tile(ren.render(map, scale_factor)); set_rectangle(tile, image, tile_x * tile.width(), (tiles.height - 1 - tile_y) * tile.height()); } } return image; }
bool make_vector_tile(tile &tile, unsigned int path_multiplier, mapnik::Map const& map, int buffer_size, double scale_factor, unsigned int offset_x, unsigned int offset_y, unsigned int tolerance, const std::string &image_format, mapnik::scaling_method_e scaling_method, double scale_denominator, boost::optional<const post_processor &> pp) { typedef backend backend_type; typedef mapnik::vector::processor<backend_type> renderer_type; backend_type backend(tile.mapnik_tile(), path_multiplier, map, pp); mapnik::request request(map.width(), map.height(), map.get_current_extent()); request.set_buffer_size(buffer_size); renderer_type ren(backend, map, request, scale_factor, offset_x, offset_y, tolerance, image_format, scaling_method); ren.apply(scale_denominator); return ren.painted(); }
#include <streambuf> TEST_CASE( "pbf vector tile input", "should be able to parse message and render point" ) { typedef mapnik::vector_tile_impl::backend_pbf backend_type; typedef mapnik::vector_tile_impl::processor<backend_type> renderer_type; typedef vector_tile::Tile tile_type; tile_type tile; backend_type backend(tile,16); unsigned tile_size = 256; mapnik::box2d<double> bbox(-20037508.342789,-20037508.342789,20037508.342789,20037508.342789); mapnik::Map map(tile_size,tile_size,"+init=epsg:3857"); mapnik::layer lyr("layer",map.srs()); lyr.set_datasource(testing::build_ds(0,0)); map.add_layer(lyr); map.zoom_to_box(bbox); mapnik::request m_req(map.width(),map.height(),map.get_current_extent()); renderer_type ren(backend,map,m_req); ren.apply(); // serialize to message std::string buffer; CHECK(tile.SerializeToString(&buffer)); CHECK(151 == buffer.size()); // now create new objects mapnik::Map map2(tile_size,tile_size,"+init=epsg:3857"); tile_type tile2; CHECK(tile2.ParseFromString(buffer)); std::string key(""); CHECK(false == mapnik::vector_tile_impl::is_solid_extent(tile2,key)); CHECK("" == key); CHECK(false == mapnik::vector_tile_impl::is_solid_extent(buffer,key)); CHECK("" == key);