• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mapnik2.render函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mapnik2.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了render函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: index

  def index(self):
    x   = cherrypy.request.headers['x']
    y   = cherrypy.request.headers['y']
    z   = cherrypy.request.headers['z']
    img = mapnik.Image()
    img.background = self._mapnik_map.background

    if not x or not y or not z:
      error_msg = "Failed request:\n\tx: %s\n\ty: %s\n\tz: %s\n" % (x, y, z)
      cherrypy.reponse.headers["Status"] = "400"
      return error_msg
    else:
      # NOTE: Process request correctly
      x         = int(x)
      y         = int(y)
      z         = int(z)
      envelope  = self.merc.xyz_to_envelope(x,y,zoom)

      if self.envelope.intersects(envelope):
        self._mapnik_map.zoom_to_box(envelope)
        self._mapnik_map.buffer_size = self.buffer_size
        mapnik.render(self._mapnik_map, img)
        cherrypy.reponse.headers["Status"] = "200"

    return img.tostring('png256')
开发者ID:bordicon,项目名称:cherrytile,代码行数:25,代码来源:server.py


示例2: rpc_renderArea

    def rpc_renderArea(self, minlat, minlon, maxlat, maxlon):
        """
        Renders a map for the given coordin
        """
        Map = None

        LandmassShapefile = 'cape/Interface/ne_110m_admin_0_countries.shp'

        merc = mapnik.Projection(
            '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m [email protected] '
            '+no_defs +over')

        # long/lat in degrees, aka ESPG:4326 and "WGS 84" 
        longlat = mapnik.Projection('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
        # can also be constructed as:
        #longlat = mapnik.Projection('+init=epsg:4326')

        im = mapnik.Image(self.mapsize)

        m = self.rendermap
        m.srs = merc.params()
        bbox = mapnik.Box2d(minlat, minlon, maxlat, maxlon)
        transform = mapnik.ProjTransform(longlat, merc)
        merc_bbox = transform.forward(bbox)

        m.zoom_to_box(merc_bbox)
        mapnik.render(m, im)
        Map = im.tostring('png')

        return (True, Map)
开发者ID:ri0t,项目名称:cape,代码行数:30,代码来源:MapRenderer.py


示例3: render_tile

    def render_tile(self, x, y, z):
        # Calculate pixel positions of bottom-left & top-right
        p0 = (x * TILE_SIZE, (y + 1) * TILE_SIZE)
        p1 = ((x + 1) * TILE_SIZE, y * TILE_SIZE)

        # Convert to LatLong (EPSG:4326)
        l0 = self.tileproj.fromPixelToLL(p0, z)
        l1 = self.tileproj.fromPixelToLL(p1, z)

        # Convert to map projection (e.g. mercator co-ords EPSG:900913)
        c0 = self.prj.forward(mapnik.Coord(l0[0], l0[1]))
        c1 = self.prj.forward(mapnik.Coord(l1[0], l1[1]))

        # Bounding box for the tile
        if hasattr(mapnik, "mapnik_version") and mapnik.mapnik_version() >= 800:
            bbox = mapnik.Box2d(c0.x, c0.y, c1.x, c1.y)
        else:
            bbox = mapnik.Envelope(c0.x, c0.y, c1.x, c1.y)
        render_size = TILE_SIZE
        self.m.resize(render_size, render_size)
        self.m.zoom_to_box(bbox)
        self.m.buffer_size = 128

        # Render image with default Agg renderer
        im = mapnik.Image(render_size, render_size)
        mapnik.render(self.m, im)
        self.writer.write(x, y, z, im)
开发者ID:RevathiZoho,项目名称:mapnik-stylesheets,代码行数:27,代码来源:polytiles.py


示例4: render

    def render(self, filename, tile_x, tile_y, zoom):
        """
        Render a single tile to a given filename.
        """
        print 'Rendering %s' % (filename)

        # Calculate pixel positions of bottom-left & top-right
        half_width = self.width / 2
        half_height = self.height / 2
        px0 = (tile_x * self.width, (tile_y + 1) * self.height)
        px1 = ((tile_x + 1) * self.width, tile_y * self.height)

        # Convert tile coords to LatLng
        ll0 = self.tile_projection.fromPixelToLL(px0, zoom);
        ll1 = self.tile_projection.fromPixelToLL(px1, zoom);
        
        # Convert LatLng to map coords
        c0 = self.map_projection.forward(mapnik2.Coord(ll0[0], ll0[1]))
        c1 = self.map_projection.forward(mapnik2.Coord(ll1[0], ll1[1]))

        # Create bounding box for the render
        bbox = mapnik2.Box2d(c0.x, c0.y, c1.x, c1.y)

        self.mapnik_map.zoom_to_box(bbox)
        self.mapnik_map.buffer_size = self.buffer_size 

        # Render image with default renderer
        image = mapnik2.Image(self.width, self.height)
        mapnik2.render(self.mapnik_map, image)
        image.save(filename, self.filetype)
开发者ID:seanlee928,项目名称:invar,代码行数:30,代码来源:renderer.py


示例5: get_one

    def get_one(self, tile):
        bbox = self.tilegrid.extent(tile.tilecoord, self.buffer)
        bbox2d = mapnik.Box2d(bbox[0], bbox[1], bbox[2], bbox[3])

        size = tile.tilecoord.n * self.tilegrid.tile_size + 2 * self.buffer
        self.mapnik.resize(size, size)
        self.mapnik.zoom_to_box(bbox2d)

        if self.output_format == "grid":
            grid = mapnik.Grid(self.tilegrid.tile_size, self.tilegrid.tile_size)
            for n, l in enumerate(self.mapnik.layers):
                if l.name in self.layers_fields:
                    mapnik.render_layer(self.mapnik, grid, layer=n, fields=self.layers_fields[l.name])

            encode = grid.encode("utf", resolution=self.resolution)
            if self.drop_empty_utfgrid and len(encode["data"].keys()) == 0:
                return None
            tile.data = dumps(encode)
        else:
            # Render image with default Agg renderer
            im = mapnik.Image(size, size)
            mapnik.render(self.mapnik, im)
            tile.data = im.tostring(self.output_format)

        return tile
开发者ID:sbrunner,项目名称:tilecloud,代码行数:25,代码来源:mapnik_.py


示例6: drawTile_bbox

    def drawTile_bbox(self,bbox,imgx,imgy,fname):
        """Call Mapnik to draw a map image for data in
        bounding box bbox.  The image size is imgx by imgy pixels, and
        the output filename is fname.

        29sep2009  GJ  ORIGINAL VERSION, based on generate_image.py
        06jan2010  GJ  Renamed to drawTile_bbox from drawTile
        """
        mapfile = str(self.preferences_list['mapfile'])
        map_uri = str(fname)
        print ("mapfile=%s" % mapfile)

        # png image
        m = mapnik.Map(imgx,imgy)
        mapnik.load_map(m,mapfile)
        m.zoom_to_box(bbox)
        im = mapnik.Image(imgx,imgy)

        if HAS_MAPNIK2:
            # We apply the scale factor to the map
            print 'using scale factors from mapnik2'
            scale_factor = float( self.preferences_list['dpi'] ) / 72
            print "Scale factor is: ", scale_factor, "================="
            mapnik.render(m, im, scale_factor)
        else:
            print 'NOT using scale_factors'
            mapnik.render(m, im)
            
        view = im.view(0,0,imgx,imgy) # x,y,width,height
        view.save(map_uri,'png')
开发者ID:hixi,项目名称:townguide,代码行数:30,代码来源:townguide.py


示例7: render_tile

    def render_tile(self, tile_uri, x, y, z):
        # Calculate pixel positions of bottom-left & top-right
        p0 = (x * 256, (y + 1) * 256)
        p1 = ((x + 1) * 256, y * 256)

        # Convert to LatLong (EPSG:4326)
        l0 = self.tileproj.fromPixelToLL(p0, z)
        l1 = self.tileproj.fromPixelToLL(p1, z)

        # Convert to map projection (e.g. mercator co-ords EPSG:900913)
        c0 = self.prj.forward(mapnik.Coord(l0[0], l0[1]))
        c1 = self.prj.forward(mapnik.Coord(l1[0], l1[1]))

        # Bounding box for the tile
        if hasattr(mapnik, "mapnik_version") and mapnik.mapnik_version() >= 800:
            bbox = mapnik.Box2d(c0.x, c0.y, c1.x, c1.y)
        else:
            bbox = mapnik.Envelope(c0.x, c0.y, c1.x, c1.y)
        render_size = 256
        self.m.resize(render_size, render_size)
        self.m.zoom_to_box(bbox)
        self.m.buffer_size = 128

        # Render image with default Agg renderer
        im = mapnik.Image(render_size, render_size)
        mapnik.render(self.m, im)

        # Ensure the tile isn't blank before saving
        if not im.tostring("png") == self.blankTileStr:
            im.save(tile_uri, "png256")
            # Return True if the tile was saved
            return True
        else:
            return False
开发者ID:Cribstone,项目名称:Transit-Board-Hotel,代码行数:34,代码来源:generate_tiles.py


示例8: get

 def get(self):
     mapfile = os.path.join(DATA_PATH, 'hazard', 'flood.shp')
     #mapfile = os.path.join(DATA_PATH, 'impact', 'impact.json')
     filename = os.path.join(DATA_PATH, 'pdf', 'report_map.pdf')
     filename2 = os.path.join(DATA_PATH, 'pdf', 'report_map.png')
     map = mapnik2.Map(600, 400)
     
     map.background = mapnik2.Color('steelblue')
     s = mapnik2.Style()
     r = mapnik2.Rule()
     polygon_symbolizer = mapnik2.PolygonSymbolizer(mapnik2.Color('#f2eff9'))
     r.symbols.append(polygon_symbolizer)
     line_symbolizer = mapnik2.LineSymbolizer(mapnik2.Color('rgb(50%,50%,50%)'),0.1)
     r.symbols.append(line_symbolizer)
     s.rules.append(r)
     map.append_style('My Style',s)
     ds = mapnik2.Shapefile(file=mapfile)
     layer = mapnik2.Layer('world')
     layer.datasource = ds
     layer.styles.append('My Style')
     map.layers.append(layer)
     map.zoom_all()
     mapnik2.render_to_file(map, filename2, 'png')
     
     #bbox = mapnik.Envelope(-180.0,-90.0,180.0,90.0)
     #map.zoom_to_box(bbox)
     surface = cairo.PDFSurface(filename, map.width, map.height)
     mapnik2.render(map, surface)
     surface.finish()
     
     with open(filename) as data:
         pdf = data.read()
         data.close()
         self.set_header("Content-Type", "application/pdf")
         self.write(pdf)
开发者ID:warex03,项目名称:WebSAFE,代码行数:35,代码来源:handlers.py


示例9: test_raster_warping_does_not_overclip_source

def test_raster_warping_does_not_overclip_source():
    lyrSrs = "+init=epsg:32630"
    mapSrs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
    lyr = mapnik2.Layer('dataraster', lyrSrs)
    if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names():
        lyr.datasource = mapnik2.Gdal(
            file = '../data/raster/dataraster.tif',
            band = 1,
            )
        sym = mapnik2.RasterSymbolizer()
        sym.colorizer = mapnik2.RasterColorizer(mapnik2.COLORIZER_DISCRETE, mapnik2.Color(255,255,0))
        rule = mapnik2.Rule()
        rule.symbols.append(sym)
        style = mapnik2.Style()
        style.rules.append(rule)
        _map = mapnik2.Map(256,256, mapSrs)
        _map.background=mapnik2.Color('white')
        _map.append_style('foo', style)
        lyr.styles.append('foo')
        _map.layers.append(lyr)
        _map.zoom_to_box(mapnik2.Box2d(3,42,4,43))
    
        im = mapnik2.Image(_map.width,_map.height)
        mapnik2.render(_map, im)
        # save a png somewhere so we can see it
        save_data('test_raster_warping_does_not_overclip_source.png',
                  im.tostring('png'))
        assert im.view(0,200,1,1).tostring()=='\xff\xff\x00\xff'
开发者ID:h0st1le,项目名称:pymapnik2,代码行数:28,代码来源:raster_symbolizer_test.py


示例10: test_raster_warping

def test_raster_warping():
    lyrSrs = "+init=epsg:32630"
    mapSrs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
    lyr = mapnik2.Layer('dataraster', lyrSrs)
    if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names():
        lyr.datasource = mapnik2.Gdal(
            file = '../data/raster/dataraster.tif',
            band = 1,
            )
        sym = mapnik2.RasterSymbolizer()
        sym.colorizer = mapnik2.RasterColorizer(mapnik2.COLORIZER_DISCRETE, mapnik2.Color(255,255,0))
        rule = mapnik2.Rule()
        rule.symbols.append(sym)
        style = mapnik2.Style()
        style.rules.append(rule)
        _map = mapnik2.Map(256,256, mapSrs)
        _map.append_style('foo', style)
        lyr.styles.append('foo')
        _map.layers.append(lyr)
        prj_trans = mapnik2.ProjTransform(mapnik2.Projection(mapSrs),
                                          mapnik2.Projection(lyrSrs)) 
        _map.zoom_to_box(prj_trans.backward(lyr.envelope()))
    
        im = mapnik2.Image(_map.width,_map.height)
        mapnik2.render(_map, im)
        # save a png somewhere so we can see it
        save_data('test_raster_warping.png', im.tostring('png'))
        imdata = im.tostring()
        assert contains_word('\xff\xff\x00\xff', imdata)
开发者ID:h0st1le,项目名称:pymapnik2,代码行数:29,代码来源:raster_symbolizer_test.py


示例11: renderToPdf

def renderToPdf(envLL, filename, sizex, sizey):
    """Renders the specified Box2d and zoom level as a PDF"""
    basefilename = os.path.splitext(filename)[0]
    mergedpdf = None
    for mapname in MAPNIK_LAYERS:
        print 'Rendering', mapname
        # Render layer PDF.
        localfilename = basefilename + '_' + mapname + '.pdf';
        file = open(localfilename, 'wb')
        surface = cairo.PDFSurface(file.name, sizex, sizey) 
        envMerc = LLToMerc(envLL)
        map = mapnik.Map(sizex, sizey)
        mapnik.load_map(map, mapname + ".xml")
        map.zoom_to_box(envMerc)
        mapnik.render(map, surface)
        surface.finish()
        file.close()
        # Merge with master.
        if not mergedpdf:            
            mergedpdf = PdfFileWriter()
            localpdf = PdfFileReader(open(localfilename, "rb"))
            page = localpdf.getPage(0)
            mergedpdf.addPage(page)
        else:
            localpdf = PdfFileReader(open(localfilename, "rb"))
            page.mergePage(localpdf.getPage(0))
    output = open(filename, 'wb')
    mergedpdf.write(output)
    output.close()
开发者ID:calvinmetcalf,项目名称:TopOSM,代码行数:29,代码来源:toposm.py


示例12: generate_map_tile

    def generate_map_tile(self, m, filename, z, x, y):
        # Code taken from OSM generate_tiles.py
        proj = GoogleProjection()
        mprj = mapnik.Projection(m.srs)

        p0 = (x * 256, (y + 1) * 256)
        p1 = ((x + 1) * 256, y * 256)
        l0 = proj.fromPixelToLL(p0, z);
        l1 = proj.fromPixelToLL(p1, z);
        c0 = mprj.forward(mapnik.Coord(l0[0], l0[1]))
        c1 = mprj.forward(mapnik.Coord(l1[0], l1[1]))

        if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 800:
            bbox = mapnik.Box2d(c0.x, c0.y, c1.x, c1.y)
        else:
            bbox = mapnik.Envelope(c0.x, c0.y, c1.x, c1.y)

        m.resize(256, 256)
        m.zoom_to_box(bbox)

        im = mapnik.Image(256, 256)
        mapnik.render(m, im)
        # See https://github.com/mapnik/mapnik/wiki/OutputFormats for output
        # formats and special parameters. The default here is 32 bit PNG with 8
        # bit per component and alpha channel.
        if mapnik_version == 2:
            im.save(str(filename), "png32")
        else:
            im.save(str(filename), "png")
开发者ID:hrpt-se,项目名称:hrpt,代码行数:29,代码来源:models.py


示例13: renderArea

    def renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom):
        """
        """
        if self.mapnik is None:
            self.mapnik = mapnik.Map(0, 0)

            if exists(self.mapfile):
                mapnik.load_map(self.mapnik, str(self.mapfile))

            else:
                handle, filename = mkstemp()
                os.write(handle, urlopen(self.mapfile).read())
                os.close(handle)

                mapnik.load_map(self.mapnik, filename)
                os.unlink(filename)

        self.mapnik.width = width
        self.mapnik.height = height
        self.mapnik.zoom_to_box(mapnik.Envelope(xmin, ymin, xmax, ymax))

        img = mapnik.Image(width, height)
        mapnik.render(self.mapnik, img)

        img = Image.fromstring("RGBA", (width, height), img.tostring())

        return img
开发者ID:ricebeans,项目名称:TileStache,代码行数:27,代码来源:Providers.py


示例14: render_tile

    def render_tile(self, tile_uri, x, y, z):
        # Calculate pixel positions of bottom-left & top-right
        p0 = (x * 256, (y + 1) * 256)
        p1 = ((x + 1) * 256, y * 256)

        # Convert to LatLong (EPSG:4326)
        l0 = self.tileproj.fromPixelToLL(p0, z);
        l1 = self.tileproj.fromPixelToLL(p1, z);

        # Convert to map projection (e.g. mercator co-ords EPSG:900913)
        c0 = self.prj.forward(mapnik.Coord(l0[0],l0[1]))
        c1 = self.prj.forward(mapnik.Coord(l1[0],l1[1]))

        # Bounding box for the tile
        if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 800:
            bbox = mapnik.Box2d(c0.x,c0.y, c1.x,c1.y)
        else:
            bbox = mapnik.Envelope(c0.x,c0.y, c1.x,c1.y)
        render_size = 256
        self.m.resize(render_size, render_size)
        self.m.zoom_to_box(bbox)
        if(self.m.buffer_size < 128):
            self.m.buffer_size = 128

        # Render image with default Agg renderer
        im = mapnik.Image(render_size, render_size)
        mapnik.render(self.m, im)
        im.save(tile_uri, 'png256')
开发者ID:zachatrocity,项目名称:mapnik-fork,代码行数:28,代码来源:generate_tiles_multiprocess.py


示例15: render_dynamic

 def render_dynamic(self, painter):
     if self.mapnik_map:
         w = painter.device().width()
         h = painter.device().height()
         # using canvas dims leads to shift in QGIS < 1.3...
         #w = self.canvas.width()
         #h = self.canvas.height()
         try:
             self.mapnik_map.resize(w,h)
         except:
             self.mapnik_map.width = w
             self.mapnik_map.height = h
         if self.qCanvas:
             can = self.qCanvas
         else:
             can = self.canvas
         try:
             e = can.extent()
         except:
             can = self.canvas
             e = can.extent()
         bbox = mapnik.Envelope(e.xMinimum(),e.yMinimum(),
                                e.xMaximum(),e.yMaximum())
         self.mapnik_map.zoom_to_box(bbox)
         im = mapnik.Image(w,h)
         mapnik.render(self.mapnik_map,im)
         if os.name == 'nt':
             qim = QImage()
             qim.loadFromData(QByteArray(im.tostring('png')))
             painter.drawImage(0,0,qim)
         else:
             qim = QImage(im.tostring(),w,h,QImage.Format_ARGB32)
             painter.drawImage(0,0,qim.rgbSwapped())
         can.refresh()
开发者ID:ghelobytes,项目名称:quantumnik,代码行数:34,代码来源:quantumnik.py


示例16: render_legend

def render_legend(mapfile, tile_uri):
    m = mapnik.Map(1024, 2048)
    # Load style XML
    mapnik.load_map(m, mapfile, True)
    # Obtain <Map> projection
    prj = mapnik.Projection(m.srs)
    # Projects between tile pixel co-ordinates and LatLong (EPSG:4326)
    tileproj = GoogleProjection(20)

    # Convert to map projection (e.g. mercator co-ords EPSG:900913)
    c0 = prj.forward(mapnik.Coord(14.4503,50.0673))
    c1 = prj.forward(mapnik.Coord(14.457,50.0678))

    # Bounding box for the tile
    if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 800:
        bbox = mapnik.Box2d(c0.x,c0.y, c1.x,c1.y)
    else:
        bbox = mapnik.Envelope(c0.x,c0.y, c1.x,c1.y)
    render_size_x = 1024
    render_size_y = 1500
    m.resize(render_size_x, render_size_y)
    m.zoom_to_box(bbox)
    m.buffer_size = 128

    # Render image with default Agg renderer
    im = mapnik.Image(render_size_x, render_size_y)
    mapnik.render(m, im)
    im.save(tile_uri, 'png256')

    surface = cairo.SVGSurface('legend.svg', render_size_x, render_size_y)
    mapnik.render(m, surface)
    surface.finish()
开发者ID:auto-mat,项目名称:rendering-PNK-ZM,代码行数:32,代码来源:generate_legend.py


示例17: process

    def process(self, tile):
        #from lat,lng bbox to mapnik bbox
        p0 = self.map_proj.forward(Coord(tile.bbox[0][1],tile.bbox[0][0]))
        p1 = self.map_proj.forward(Coord(tile.bbox[1][1],tile.bbox[1][0]))
        bbox = Box2d(p0,p1)        
        image = Image(tile.size[0],tile.size[1])
        features = None
        
        result = self._check_region(bbox)
        if result is not None:
            if result[0]:
                result[1].resize(image.width(),image.height())
                result[1].zoom_to_box(bbox)
                self.adjust_language(result(1), tile.lang)
                render(result[1],image)
                features = self.save_rendered_metadata(result[1], tile.size, tile.dimensions)
            else :
                mq_logging.info("COMPOSITE MAP: %s" % result[2])
                default_image = Image(tile.size[0],tile.size[1])
                # mask style
                self.mask_map.resize(image.width(),image.height())
                self.mask_map.zoom_to_box(bbox)
                self.adjust_language(self.mask_map, tile.lang)
                render(self.mask_map,image)
                
                # default style
                self.default_map.resize(default_image.width(),default_image.height())
                self.default_map.zoom_to_box(bbox)
                self.adjust_language(self.default_map, tile.lang)
                render(self.default_map,default_image)
                features = self.save_rendered_metadata(self.default_map, tile.size, tile.dimensions)
                
                # composite DST_OUT
                default_image.composite(image,CompositeOp.dst_out)
                
                # current style
                result[1].resize(image.width(),image.height())
                result[1].zoom_to_box(bbox)
                image.set_alpha(0)
                self.adjust_language(result[1], tile.lang)
                render(result[1],image)
                if features is not None:
                    features.features.extend(self.save_rendered_metadata(result[1], tile.size, tile.dimensions).features)
                else:
                    features = self.save_rendered_metadata(result[1], tile.size, tile.dimensions)

                # blend 
                image.blend(0,0,default_image,1.0)                
        else :
            # use default style
            self.default_map.resize(image.width(),image.height())
            self.default_map.zoom_to_box(bbox)
            self.adjust_language(self.default_map, tile.lang)
            render(self.default_map,image)
            features = self.save_rendered_metadata(self.default_map, tile.size, tile.dimensions)

        #convert to PIL image
        image = PIL.Image.frombuffer('RGBA', (image.width(), image.height()), image.tostring(), 'raw', 'RGBA', 0, 3)

        return RenderResult.from_image(tile, image, features)
开发者ID:joto,项目名称:MapQuest-Render-Stack,代码行数:60,代码来源:mapnik.py


示例18: draw

 def draw(self):
     zoom = self.style.get('zoom')
     # save context
     self.ctx.save()
     self.ctx.scale(zoom, zoom)
     mapnik2.render(self.m, self.ctx)
     # restore saved context
     self.ctx.restore()
开发者ID:tkharju,项目名称:toe,代码行数:8,代码来源:render.py


示例19: test_simplest_render

def test_simplest_render():
    m = mapnik2.Map(256, 256)
    i = mapnik2.Image(m.width, m.height)

    mapnik2.render(m, i)

    s = i.tostring()

    eq_(s, 256 * 256 * '\x00\x00\x00\x00')
开发者ID:dpaleino,项目名称:mapnik,代码行数:9,代码来源:render_test.py


示例20: test_render_points

def test_render_points():
    # Test for effectivenes of ticket #402 (borderline points get lost on reprojection)
    raise Todo("See: http://trac.mapnik2.org/ticket/402")

    if not mapnik2.has_pycairo():
        return

    # create and populate point datasource (WGS84 lat-lon coordinates)
    places_ds = mapnik2.PointDatasource()
    places_ds.add_point(142.48, -38.38, "Name", "Westernmost Point")  # westernmost
    places_ds.add_point(143.10, -38.60, "Name", "Southernmost Point")  # southernmost
    # create layer/rule/style
    s = mapnik2.Style()
    r = mapnik2.Rule()
    symb = mapnik2.PointSymbolizer()
    symb.allow_overlap = True
    r.symbols.append(symb)
    s.rules.append(r)
    lyr = mapnik2.Layer("Places", "+proj=latlon +datum=WGS84")
    lyr.datasource = places_ds
    lyr.styles.append("places_labels")
    # latlon bounding box corners
    ul_lonlat = mapnik2.Coord(142.30, -38.20)
    lr_lonlat = mapnik2.Coord(143.40, -38.80)
    # render for different projections
    projs = {
        "latlon": "+proj=latlon +datum=WGS84",
        "merc": "+proj=merc +datum=WGS84 +k=1.0 +units=m +over +no_defs",
        "google": "+proj=merc +ellps=sphere +R=6378137 +a=6378137 +units=m",
        "utm": "+proj=utm +zone=54 +datum=WGS84",
    }
    from cairo import SVGSurface

    for projdescr in projs.iterkeys():
        m = mapnik2.Map(1000, 500, projs[projdescr])
        m.append_style("places_labels", s)
        m.layers.append(lyr)
        p = mapnik2.Projection(projs[projdescr])
        m.zoom_to_box(p.forward(mapnik2.Box2d(ul_lonlat, lr_lonlat)))
        # Render to SVG so that it can be checked how many points are there with string comparison
        import StringIO

        svg_memory_file = StringIO.StringIO()
        surface = SVGSurface(svg_memory_file, m.width, m.height)
        mapnik2.render(m, surface)
        surface.flush()
        surface.finish()
        svg = svg_memory_file.getvalue()
        svg_memory_file.close()
        num_points_present = len(places_ds.all_features())
        num_points_rendered = svg.count("<image ")
        eq_(
            num_points_present,
            num_points_rendered,
            "Not all points were rendered (%d instead of %d) at projection %s"
            % (num_points_rendered, num_points_present, projdescr),
        )
开发者ID:achoch,项目名称:mapnik,代码行数:57,代码来源:render_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mapper.device函数代码示例发布时间:2022-05-27
下一篇:
Python mapnik2.mapnik_version函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap