本文整理汇总了Python中mapnik.mapnik_version函数的典型用法代码示例。如果您正苦于以下问题:Python mapnik_version函数的具体用法?Python mapnik_version怎么用?Python mapnik_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapnik_version函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: finish_initializing
def finish_initializing(self, builder): # pylint: disable=E1002
"""Set up the main window"""
super(GeneralcartoWindow, self).finish_initializing(builder)
self.AboutDialog = AboutGeneralcartoDialog
self.PreferencesDialog = PreferencesGeneralcartoDialog
####
#initialize some global variables
self.checkbutton_open = False
self.shapefile = ''
# Get a reference to the builder and set up the signals.
self.builder = builder
self.ui = builder.get_ui(self)
#initialize the entry for the zoomlevels for the tile rendering
self.ui.entry1.set_text('0')
self.ui.entry2.set_text('18')
print 'Mapnik_version = %s' %mapnik.mapnik_version()
if mapnik.mapnik_version() < 200100:
print "You're having a too old version of mapnik...install minimum version 2.1.0!!!"
sys.exit()
#initialize the size of the tile buffer
self.buffer_size = 128
self.ui.entry_buffer.set_text(str(self.buffer_size))
home = os.getenv("HOME")
self.generalHome = home + '/GeneralCarto/'
if not os.path.isdir(self.generalHome):
os.mkdir(self.generalHome)
self.logs = self.generalHome + 'log-files/'
if not os.path.isdir(self.logs):
os.mkdir(self.logs)
self.tile_dir = self.generalHome + 'tiles/'
if not os.path.isdir(self.tile_dir):
os.mkdir(self.tile_dir)
self.previewImage = self.generalHome + "user_image.png"
self.path = ""
self.xml_files_folder = self.generalHome + 'xmlfiles/'
if not os.path.isdir(self.xml_files_folder):
os.mkdir(self.xml_files_folder)
self.menuItemIndicator = "< "
self.textEditor = 'gedit'
#self.loadWindows()
self.tileButtonVisibility(False)
self.initializedMapfile = False
self.initialLoad = True
开发者ID:milkbread,项目名称:GeneralCarto,代码行数:53,代码来源:GeneralcartoWindow.py
示例2: render_tile
def render_tile(self, x, y, z, utf_grid):
# 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
if utf_grid is True:
grid = mapnik.Grid(self.m.width,self.m.height)
mapnik.render_layer(self.m, grid, layer=0, fields=['html_exp'])
utfgrid = grid.encode('utf', resolution=4)
return json.dumps(utfgrid);
else:
im = mapnik.Image(render_size, render_size)
mapnik.render(self.m, im)
return im.tostring('png');
开发者ID:orfon,项目名称:ringo-mapnik,代码行数:34,代码来源:render_tile.py
示例3: 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)
im.save(tile_uri, 'png256')
开发者ID:mossplix,项目名称:mappit,代码行数:28,代码来源:test.py
示例4: render_tile
def render_tile(self, tile_uri, x, y, z, buffer_size):
tile = (x,y)
c0, c1 = self.calcTileCoordinates(tile, z)
tile_extent = (c0.x,c0.y, c1.x,c1.y)
#dest_file = "WebGen_WPS_file.xml"
#folder = "/home/klammer/Software/Quickly/tilegen/data/media/"
#test = makeWPSfile(tile_extent, folder+dest_file)
#if test > 0:
# sendFile(dest_file, folder)
# 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 = buffer_size
# Render image with default Agg renderer
im = mapnik.Image(render_size, render_size)
mapnik.render(self.m, im)
im.save(tile_uri, 'png256')
开发者ID:RaKl,项目名称:TileGen,代码行数:26,代码来源:rendering.py
示例5: fews_point_style
def fews_point_style(jdbc_source, filterkey, locationkey, parameterkey,
nodata=False, styles=None, lookup=None):
"""
Make mapnik point_style for fews point with given filterkey.
Copied from lizard_fewsunblobbed.
"""
point_style_name, output_filename = fews_symbol_name(
jdbc_source, filterkey, locationkey, parameterkey,
nodata, styles, lookup)
output_filename_abs = os.path.join(
settings.MEDIA_ROOT, 'generated_icons', output_filename)
# use filename in mapnik pointsymbolizer
if mapnik.mapnik_version() < 800:
point_looks = mapnik.PointSymbolizer(
str(output_filename_abs), 'png', 16, 16)
else:
point_looks = mapnik.PointSymbolizer(
mapnik.PathExpression(str(output_filename_abs)))
point_looks.allow_overlap = True
layout_rule = mapnik.Rule()
layout_rule.symbols.append(point_looks)
# We use 'class' to filter the correct style for the locations
layout_rule.filter = mapnik.Filter(
"[style] = '%s'" % str(point_style_name))
point_style = mapnik.Style()
point_style.rules.append(layout_rule)
return point_style_name, point_style
开发者ID:bugkiwi,项目名称:lizard-fewsjdbc,代码行数:31,代码来源:layers.py
示例6: run
def run(self):
while True:
if not self.queue.empty():
# get point from queue
point = self.queue.get() # point is a tuple
# print point in gui
self.object_map["work_frame"].text.insert(tk.END, "%i,%i\n" % (point[0], point[1]))
self.object_map["work_frame"].text.yview(tk.END)
# make point
pds = mapnik.PointDatasource()
pds.add_point(point[0], point[1], "Name", "d")
# create point symbolizer for blue icons
if mapnik.mapnik_version() >= 800:
point = mapnik.PointSymbolizer(mapnik.PathExpression("y2.png"))
else:
point = mapnik.PointSymbolizer("y2.png", "png", 25, 25)
point.allow_overlap = True
s = mapnik.Style()
r = mapnik.Rule()
r.symbols.append(point)
s.rules.append(r)
self.layer2 = mapnik.Layer("GPS Coord")
self.layer2.datasource = pds
self.layer2.styles.append("Style")
self.map.append_style("Style", s)
self.map.layers.append(self.layer2)
self.draw()
开发者ID:sbobovyc,项目名称:Tracker,代码行数:35,代码来源:Controller.py
示例7: renderPage
def renderPage(ll,file):
z = 2
#imgx = 987 * z
#imgy = 801 * z
imgx = int(987 * z )
imgy = int(987 * z *0.77 )
m = mapnik.Map(imgx,imgy)
mapnik.load_map(m,mapfile)
prj = 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")
c0 = prj.forward(mapnik.Coord(ll[0],ll[1]))
c1 = prj.forward(mapnik.Coord(ll[2],ll[3]))
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.zoom_to_box(bbox)
im = mapnik.Image(imgx,imgy)
mapnik.render(m, im)
view = im.view(0,0,imgx,imgy) # x,y,width,height
map_uri=file + '.png'
view.save(map_uri,'png')
file=open(file+'.svg' ,'w')
surface=cairo.SVGSurface(file.name,imgx,imgy)
mapnik.render(m,surface)
#c = cairo.Context(surface)
#c.move_to(50,50)
#c.show_text('testing')
surface.finish();
开发者ID:ssinger,项目名称:cake-maker,代码行数:32,代码来源:cake-maker.py
示例8: render
def render(self, stylefile, bbox, output, width, height):
"""
Render the specified bbox (minx, miny, maxx, maxy) with Mapnik
"""
if not self._mapnik:
self._mapnik = mapnik.Map(width, height)
# Load style XML
mapnik.load_map(self._mapnik, stylefile, True)
# Obtain <Map> projection
self._prj = mapnik.Projection(self._mapnik.srs)
# Convert to map projection
assert len(bbox) == 4, "Provide a bounding box tuple (minx, miny, maxx, maxy)"
c0 = self._prj.forward(mapnik.Coord(bbox[0],bbox[1]))
c1 = self._prj.forward(mapnik.Coord(bbox[2],bbox[3]))
# 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)
self._mapnik.resize(width, height)
self._mapnik.zoom_to_box(bbox)
self._mapnik.buffer_size = 128
# Render image with default Agg renderer
im = mapnik.Image(width, height)
mapnik.render(self._mapnik, im)
im.save(output, 'png256')
开发者ID:Adapptor,项目名称:landez,代码行数:30,代码来源:tiles.py
示例9: GetFeatureInfo
def GetFeatureInfo(self, params, querymethodname='query_point'):
m = self._buildMap(params)
if params['info_format'] == 'text/plain':
writer = TextFeatureInfo()
elif params['info_format'] == 'text/xml':
writer = XMLFeatureInfo()
if params['query_layers'] and params['query_layers'][0] == '__all__':
for layerindex, layer in enumerate(m.layers):
featureset = getattr(m, querymethodname)(layerindex, params['i'], params['j'])
features = featureset.features
if features:
writer.addlayer(layer.name)
for feat in features:
writer.addfeature()
if mapnik_version() >= 800:
for prop,value in feat.attributes.iteritems():
writer.addattribute(prop, value)
else:
for prop in feat.properties:
writer.addattribute(prop[0], prop[1])
else:
for layerindex, layername in enumerate(params['query_layers']):
if layername in params['layers']:
# TODO - pretty sure this is bogus, we can't pull from m.layers by the layerindex of the
# 'query_layers' subset, need to pull from:
# self.mapfactory.layers[layername]
if m.layers[layerindex].queryable:
featureset = getattr(m, querymethodname)(layerindex, params['i'], params['j'])
features = featureset.features
if features:
writer.addlayer(m.layers[layerindex].name)
for feat in features:
writer.addfeature()
if mapnik_version() >= 800:
for prop,value in feat.attributes.iteritems():
writer.addattribute(prop, value)
else:
for prop in feat.properties:
writer.addattribute(prop[0], prop[1])
else:
raise OGCException('Requested query layer "%s" is not marked queryable.' % layername, 'LayerNotQueryable')
else:
raise OGCException('Requested query layer "%s" not in the LAYERS parameter.' % layername)
return Response(params['info_format'], str(writer))
开发者ID:junosw,项目名称:juno-public,代码行数:44,代码来源:common.py
示例10: GetMap
def GetMap(self, params):
m = self._buildMap(params)
im = Image(params['width'], params['height'])
render(m, im)
format = PIL_TYPE_MAPPING[params['format']]
if mapnik_version() >= 200300:
# Mapnik 2.3 uses png8 as default, use png32 for backwards compatibility
if format == 'png':
format = 'png32'
return Response(params['format'].replace('8',''), im.tostring(format))
开发者ID:xkwangy,项目名称:OGCServer,代码行数:10,代码来源:common.py
示例11: serialize
def serialize(xml,options):
try:
import mapnik
except:
sys.exit(color_text(1,'Error: saving xml requires Mapnik python bindings to be installed'))
m = mapnik.Map(1,1)
if options.from_string:
mapnik.load_map_from_string(m,xml,True)
else:
mapnik.load_map(m,xml,True)
if options.output:
mapnik.save_map(m,options.output)
else:
if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 700:
print mapnik.save_map_to_string(m)
else:
sys.exit(color_text(1,'Minor error: printing XML to stdout requires Mapnik >=0.7.0, please provide a second argument to save the output to a file'))
开发者ID:ParveenArora,项目名称:MeraMap,代码行数:17,代码来源:generate_xml.py
示例12: get_bbox
def get_bbox(self, x, y, z):
# Calculate pixel positions of bottom-left & top-right
p0 = (x * self.render_size, (y + 1) * self.render_size)
p1 = ((x + 1) * self.render_size, y * self.render_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:
return mapnik.Box2d(c0.x,c0.y, c1.x,c1.y)
else:
return mapnik.Envelope(c0.x,c0.y, c1.x,c1.y)
开发者ID:RouxRC,项目名称:nosfinanceslocales,代码行数:18,代码来源:mapnik_render.py
示例13: get_bbox
def get_bbox(self):
# Calculate pixel positions of bottom-left & top-right
p0 = (self.mtx0 * TILE_SIZE, (self.mty0 + self.metatile) * TILE_SIZE)
p1 = ((self.mtx0 + self.metatile) * TILE_SIZE, self.mty0 * TILE_SIZE)
# Convert to LatLong (EPSG:4326)
l0 = self.tileproj.fromPixelToLL(p0, self.zoom);
l1 = self.tileproj.fromPixelToLL(p1, self.zoom);
# 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)
return bbox
开发者ID:jojoaddison,项目名称:polytiles,代码行数:19,代码来源:polytiles.py
示例14: render_image
def render_image(self, extent, img_size, settings):
# Выбираем объекты по экстенту
feature_query = self.layer.feature_query()
feature_query.intersects(box(*extent, srid=self.layer.srs_id))
feature_query.geom()
features = feature_query()
ds = mapnik.MemoryDatasource()
for (id, f) in enumerate(features):
if mapnik.mapnik_version() < 200100:
feature = mapnik.Feature(id)
else:
feature = mapnik.Feature(mapnik.Context(), id)
feature.add_geometries_from_wkb(f.geom.wkb)
ds.add_feature(feature)
style_content = str(self.style_content)
m = mapnik.Map(img_size[0], img_size[1])
mapnik.load_map_from_string(m, style_content)
m.zoom_to_box(mapnik.Box2d(*extent))
layer = mapnik.Layer('main')
layer.datasource = ds
root = ET.fromstring(style_content)
styles = [s.attrib.get('name') for s in root.iter('Style')]
for s in styles:
layer.styles.append(s)
m.layers.append(layer)
img = mapnik.Image(img_size[0], img_size[1])
mapnik.render(m, img)
data = img.tostring('png')
# Преобразуем изображение из PNG в объект PIL
buf = StringIO()
buf.write(data)
buf.seek(0)
img = Image.open(buf)
return img
开发者ID:nextgis,项目名称:nextgisweb_mapnik,代码行数:42,代码来源:models.py
示例15: render_tile
def render_tile(self, w, h):
self.m.resize(w, h)
#self.m.zoom_to_box(self.lyr.envelope())
bb = (self.lyr.envelope().minx,self.lyr.envelope().miny,self.lyr.envelope().maxx,self.lyr.envelope().maxy)
lW = bb[2] - bb[0]
lH = bb[3] - bb[1]
lR = lW/lH
r = w/h
mW = 0
mH = 0
if lR > r:
mH = (lW * h)/(w * lH)
elif r < lR:
mW = (w * lH) / (lW * h)
x1 = bb[0] - 0.5*mW
x2 = bb[2] + 0.5*mW
y1 = bb[1] - 0.5*mH
y2 = bb[3] + 0.5*mH
c0 = self.prj.forward(mapnik.Coord(x1, y1))
c1 = self.prj.forward(mapnik.Coord(x2,y2))
# Bounding box for the tile
if hasattr(mapnik, 'mapnik_version') and mapnik.mapnik_version() >= 800:
bb = mapnik.Box2d(c0.x, c0.y, c1.x, c1.y)
else:
bb = mapnik.Envelope(c0.x, c0.y, c1.x, c1.y)
self.m.zoom_to_box(bb)
self.m.buffer_size = 128
# Render image with default Agg renderer
im = mapnik.Image(w, h)
mapnik.render(self.m, im)
im.save(str(self.png), 'png')
开发者ID:MapofLife,项目名称:MOL,代码行数:40,代码来源:GenerateOverview.py
示例16: finish_initializing
def finish_initializing(self, builder): # pylint: disable=E1002
"""Set up the main window"""
super(TilegenWindow, self).finish_initializing(builder)
self.AboutDialog = AboutTilegenDialog
self.PreferencesDialog = PreferencesTilegenDialog
####
# initialize some global variables
self.checkbutton_open = False
self.shapefile = ""
# Get a reference to the builder and set up the signals.
self.builder = builder
self.ui = builder.get_ui(self)
# initialize all params
self.params = preferences.FilesNLogs()
# initialize all definitions
self.definitions = preferences.Definitions()
self.menuItemIndicator = self.definitions.getIndicator()
# set the min- & maxzoom and buffer
self.defineTilingParams()
self.project = preferences.ProjectFile()
# check the installed mapnik version
if mapnik.mapnik_version() < self.definitions.getMinMapnikVersion()[0]:
print self.definitions.getMinMapnikVersion()[1]
self.params.writeToLog(self.definitions.getMinMapnikVersion()[1])
sys.exit()
self.setProjectTitle()
self.ui.label_title.set_alignment(0, 0)
self.tileButtonVisibility(False)
self.initializedMapfile = False
self.initialLoad = True
self.reloaded = False
开发者ID:RaKl,项目名称:TileGen,代码行数:39,代码来源:TilegenWindow.py
示例17: render
def render(self, bbox, width=None, height=None):
"""
Render the specified tile with Mapnik
"""
width = width or self.tilesize
height = height or self.tilesize
if not self._mapnik:
if not width:
self.tile_size,
self._mapnik = mapnik.Map(width, height)
# Load style XML
mapnik.load_map(self._mapnik, self.stylefile, True)
# Obtain <Map> projection
self._prj = mapnik.Projection(self._mapnik.srs)
# Convert to map projection
assert len(bbox) == 4, _("Provide a bounding box tuple (minx, miny, maxx, maxy)")
c0 = self._prj.forward(mapnik.Coord(bbox[0], bbox[1]))
c1 = self._prj.forward(mapnik.Coord(bbox[2], bbox[3]))
# 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)
self._mapnik.resize(width, height)
self._mapnik.zoom_to_box(bbox)
self._mapnik.buffer_size = 128
# Render image with default Agg renderer
tmpfile = NamedTemporaryFile(delete=False)
im = mapnik.Image(width, height)
mapnik.render(self._mapnik, im)
im.save(tmpfile.name, "png256") # TODO: mapnik output only to file?
tmpfile.close()
content = open(tmpfile.name).read()
os.unlink(tmpfile.name)
return content
开发者ID:marty-stranger,项目名称:landez,代码行数:39,代码来源:sources.py
示例18: render_tile
def render_tile(self, tile_dir, x, y, z):
# Calculate pixel positions of bottom-left & top-right
p0 = (x * 256 * aggregate, (y + 1) * 256 * aggregate)
p1 = ((x + 1) * 256 * aggregate, y * 256 * aggregate)
# 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 * aggregate
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)
for i in range(0, aggregate):
# check if we have directories in place
str_x = "%s" % (x * aggregate + i)
zoom = "%s" % z
if not os.path.isdir(tile_dir + zoom + "/" + str_x):
os.mkdir(tile_dir + zoom + "/" + str_x)
for j in range(0, aggregate):
view = im.view(i * 256, j * 256, 256, 256)
# print(i*256,j*256,(i+1)*256,(j+1)*256)
str_y = "%s" % (y * aggregate + j)
tile_uri = tile_dir + zoom + "/" + str_x + "/" + str_y + ".png"
view.save(tile_uri, "png256")
开发者ID:auto-mat,项目名称:rendering-PNK-ZM,代码行数:39,代码来源:generate_tiles_agregated.py
示例19: simpleRendering
def simpleRendering(image, stylesheet, extent):
mapfile = stylesheet
map_uri = image
imgx = 256
imgy = 256
m = mapnik.Map(imgx,imgy)
mapnik.load_map(m,mapfile)
#print 'simple Rendering'
#print m.layers
if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 800:
bbox = mapnik.Box2d(extent[0],extent[2],extent[1],extent[3])
else:
bbox = mapnik.Envelope(extent[0],extent[2],extent[1],extent[3])
m.zoom_to_box(bbox)
im = mapnik.Image(imgx,imgy)
mapnik.render(m, im)
view = im.view(0,0,imgx,imgy) # x,y,width,height
view.save(map_uri,'png')
开发者ID:RaKl,项目名称:TileGen,代码行数:22,代码来源:rendering.py
示例20: 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
if utf_grid == "true":
grid = mapnik.Grid(self.m.width,self.m.height)
mapnik.render_layer(self.m, grid, layer=0, fields=['html_exp'])
tilefilename = tile_uri[:-4] + '.json'
utfgrid = grid.encode('utf', resolution=4)
with open(tilefilename, 'w') as file:
file.write(json.dumps(utfgrid))
else:
# Render image with default Agg renderer
im = mapnik.Image(render_size, render_size)
mapnik.render(self.m, im)
im.save(tile_uri, 'png256')
开发者ID:orfon,项目名称:ringo-mapnik,代码行数:38,代码来源:generate_tiles.py
注:本文中的mapnik.mapnik_version函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论