示例#1
0
static enum protoCmd render(struct xmlmapconfig * map, int x, int y, int z, metaTile &tiles)
{
    int render_size_tx = MIN(METATILE, map->prj->aspect_x * (1 << z));
    int render_size_ty = MIN(METATILE, map->prj->aspect_y * (1 << z));

    map->map.resize(render_size_tx*map->tilesize, render_size_ty*map->tilesize);
    map->map.zoom_to_box(tile2prjbounds(map->prj, x, y, z));
    if (map->map.buffer_size() == 0) { // Only set buffer size if the buffer size isn't explicitly set in the mapnik stylesheet.
        map->map.set_buffer_size(128);
    }
    //m.zoom(size+1);

    mapnik::image_32 buf(render_size_tx*map->tilesize, render_size_ty*map->tilesize);
    try {
      mapnik::agg_renderer<mapnik::image_32> ren(map->map,buf);
      ren.apply();
    } catch (std::exception const& ex) {
      syslog(LOG_ERR, "ERROR: failed to render TILE %s %d %d-%d %d-%d", map->xmlname, z, x, x+render_size_tx-1, y, y+render_size_ty-1);
      syslog(LOG_ERR, "   reason: %s", ex.what());
      return cmdNotDone;
    }

    // Split the meta tile into an NxN grid of tiles
    unsigned int xx, yy;
    for (yy = 0; yy < render_size_ty; yy++) {
        for (xx = 0; xx < render_size_tx; xx++) {
            mapnik::image_view<mapnik::image_data_32> vw(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf.data());
            tiles.set(xx, yy, save_to_string(vw, "png256"));
        }
    }
    return cmdDone; // OK
}
示例#2
0
static enum protoCmd render(Map &m, char *xmlname, projection &prj, int x, int y, int z, unsigned int size, metaTile &tiles)
{
    int render_size = 256 * size;
    double p0x = x * 256;
    double p0y = (y + size) * 256;
    double p1x = (x + size) * 256;
    double p1y = y * 256;

    //std::cout << "META TILE " << z << " " << x << "-" << x+size-1 << " " << y << "-" << y+size-1 << "\n";

    tiling.fromPixelToLL(p0x, p0y, z);
    tiling.fromPixelToLL(p1x, p1y, z);

    prj.forward(p0x, p0y);
    prj.forward(p1x, p1y);

    mapnik::box2d<double> bbox(p0x, p0y, p1x,p1y);
    m.resize(render_size, render_size);
    m.zoom_to_box(bbox);
    m.set_buffer_size(128);
    //m.zoom(size+1);

    mapnik::image_32 buf(render_size, render_size);
    mapnik::agg_renderer<mapnik::image_32> ren(m,buf);
    ren.apply();

    // Split the meta tile into an NxN grid of tiles
    unsigned int xx, yy;
    for (yy = 0; yy < size; yy++) {
        for (xx = 0; xx < size; xx++) {
            mapnik::image_view<mapnik::image_data_32> vw(xx * 256, yy * 256, 256, 256, buf.data());
            tiles.set(xx, yy, save_to_string(vw, "png256"));
        }
    }
//    std::cout << "DONE TILE " << xmlname << " " << z << " " << x << "-" << x+size-1 << " " << y << "-" << y+size-1 << "\n";
    syslog(LOG_DEBUG, "DEBUG: DONE TILE %s %d %d-%d %d-%d", xmlname, z, x, x+size-1, y, y+size-1);
    return cmdDone; // OK
}