当前位置: 首页>>代码示例>>C++>>正文


C++ Map::resize方法代码示例

本文整理汇总了C++中mapnik::Map::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::resize方法的具体用法?C++ Map::resize怎么用?C++ Map::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mapnik::Map的用法示例。


在下文中一共展示了Map::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render

 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;
 }
开发者ID:mapycz,项目名称:mapnik,代码行数:23,代码来源:renderer.hpp

示例2: RenderTile

//------------------------------------------------------------------------------
void TileRenderer::RenderTile(std::string tile_uri, mapnik::Map m, int x, int y, int zoom, GoogleProjection tileproj, mapnik::projection prj, bool verbose, bool overrideTile, bool lockEnabled, std::string compositionLayerPath, std::string compositionMode, double compositionAlpha)
{
   if(!overrideTile && FileSystem::FileExists(tile_uri))
   {
      return;
   }
   else
   {
	   
       
      // Calculate pixel positions of bottom-left & top-right
      ituple p0(x * 256, (y + 1) * 256);
      ituple p1((x + 1) * 256, y * 256);

      // Convert to LatLong (EPSG:4326)
      dtuple l0 = tileproj.pixel2GeoCoord(p0, zoom);
      dtuple l1 = tileproj.pixel2GeoCoord(p1, zoom);

	  

      // Convert to map projection (e.g. mercator co-ords EPSG:900913)
      dtuple c0(l0.a,l0.b);
      dtuple c1(l1.a,l1.b);
      prj.forward(c0.a, c0.b);
      prj.forward(c1.a, c1.b);

      // Bounding box for the tile
#ifndef MAPNIK_2
      mapnik::Envelope<double> bbox = mapnik::Envelope<double>(c0.a,c0.b,c1.a,c1.b);
      m.resize(256,256);
      m.zoomToBox(bbox);
#else
      mapnik::box2d<double> bbox(c0.a,c0.b,c1.a,c1.b);
      m.resize(256,256);
      m.zoom_to_box(bbox);
#endif
      m.set_buffer_size(128);

      // Render image with default Agg renderer

#ifndef MAPNIK_2
      mapnik::Image32 buf(m.getWidth(),m.getHeight());
      mapnik::agg_renderer<mapnik::Image32> ren(m,buf);
#else
      mapnik::image_32 buf(m.width(), m.height());
      mapnik::agg_renderer<mapnik::image_32> ren(m,buf);
#endif
      ren.apply();
      if(lockEnabled)
      {
         int lockhandle = FileSystem::Lock(tile_uri);
#ifndef MAPNIK_2
		 Compose(compositionLayerPath, compositionMode, compositionAlpha, m.getWidth(),m.getHeight(),&buf, zoom, x,y);
         mapnik::save_to_file<mapnik::ImageData32>(buf.data(),tile_uri,"png");
#else
	 Compose(compositionLayerPath, compositionMode, compositionAlpha, m.width(),m.height(),&buf, zoom, x,y);
	 mapnik::save_to_file<mapnik::image_data_32>(buf.data(),tile_uri,"png");
#endif
         FileSystem::Unlock(tile_uri, lockhandle);
      }
      else
      {
#ifndef MAPNIK_2
		 Compose(compositionLayerPath, compositionMode, compositionAlpha, m.getWidth(),m.getHeight(),&buf, zoom, x,y);
         mapnik::save_to_file<mapnik::ImageData32>(buf.data(),tile_uri,"png");
#else
		Compose(compositionLayerPath, compositionMode, compositionAlpha, m.width(),m.height(),&buf, zoom, x,y);
		mapnik::save_to_file<mapnik::image_data_32>(buf.data(),tile_uri,"png");
#endif
      }
   }
}
开发者ID:Kasheftin,项目名称:DataProcessing,代码行数:73,代码来源:rendertile.cpp


注:本文中的mapnik::Map::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。