예제 #1
0
#include "vector_tile.pb.h"
#pragma GCC diagnostic pop

TEST_CASE("pbf vector tile input")
{
    unsigned tile_size = 4096;
    mapnik::Map map(256,256,"+init=epsg:3857");
    mapnik::layer lyr("layer",map.srs());
    lyr.set_datasource(testing::build_ds(0,0));
    map.add_layer(lyr);
    mapnik::vector_tile_impl::processor ren(map);
    mapnik::vector_tile_impl::tile out_tile = ren.create_tile(0,0,0,tile_size);
    CHECK(out_tile.is_painted() == true);
    CHECK(out_tile.is_empty() == false);
    vector_tile::Tile tile;
    tile.ParseFromString(out_tile.get_buffer());
    // serialize to message
    std::string buffer;
    CHECK(tile.SerializeToString(&buffer));
    CHECK(147 == buffer.size());
    // now create new objects
    mapnik::Map map2(256,256,"+init=epsg:3857");
    vector_tile::Tile tile2;
    CHECK(tile2.ParseFromString(buffer));
    CHECK(1 == tile2.layers_size());
    vector_tile::Tile_Layer const& layer2 = tile2.layers(0);
    CHECK(std::string("layer") == layer2.name());
    CHECK(1 == layer2.features_size());

    mapnik::layer lyr2("layer",map.srs());
예제 #2
0
boost::python::object mvt_get_buffer(mapnik::vector_tile_impl::tile const& tile)
{
    std::string const& buf = tile.get_buffer();
    return boost::python::object(boost::python::handle<>(
        PyBytes_FromStringAndSize(buf.data(), buf.size())));
}