本文整理汇总了Python中mapnik.save_map_to_string函数的典型用法代码示例。如果您正苦于以下问题:Python save_map_to_string函数的具体用法?Python save_map_to_string怎么用?Python save_map_to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_map_to_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_arbitrary_parameters_attached_to_map
def test_arbitrary_parameters_attached_to_map():
m = mapnik.Map(256,256)
mapnik.load_map(m,'../data/good_maps/extra_arbitary_map_parameters.xml')
eq_(len(m.parameters),5)
eq_(m.parameters['key'],'value2')
eq_(m.parameters['key3'],'value3')
eq_(m.parameters['unicode'],u'iván')
eq_(m.parameters['integer'],10)
eq_(m.parameters['decimal'],.999)
m2 = mapnik.Map(256,256)
for k,v in m.parameters:
m2.parameters.append(mapnik.Parameter(k,v))
eq_(len(m2.parameters),5)
eq_(m2.parameters['key'],'value2')
eq_(m2.parameters['key3'],'value3')
eq_(m2.parameters['unicode'],u'iván')
eq_(m2.parameters['integer'],10)
eq_(m2.parameters['decimal'],.999)
map_string = mapnik.save_map_to_string(m)
m3 = mapnik.Map(256,256)
mapnik.load_map_from_string(m3,map_string)
eq_(len(m3.parameters),5)
eq_(m3.parameters['key'],'value2')
eq_(m3.parameters['key3'],'value3')
eq_(m3.parameters['unicode'],u'iván')
eq_(m3.parameters['integer'],10)
eq_(m3.parameters['decimal'],.999)
开发者ID:1060460048,项目名称:mapnik,代码行数:27,代码来源:extra_map_props_test.py
示例2: test_arbitrary_parameters_attached_to_map
def test_arbitrary_parameters_attached_to_map():
m = mapnik.Map(256, 256)
mapnik.load_map(m, "../data/good_maps/extra_arbitary_map_parameters.xml")
eq_(len(m.parameters), 5)
eq_(m.parameters["key"], "value2")
eq_(m.parameters["key3"], "value3")
eq_(m.parameters["unicode"], u"iván")
eq_(m.parameters["integer"], 10)
eq_(m.parameters["decimal"], 0.999)
m2 = mapnik.Map(256, 256)
for k, v in m.parameters:
m2.parameters.append(mapnik.Parameter(k, v))
eq_(len(m2.parameters), 5)
eq_(m2.parameters["key"], "value2")
eq_(m2.parameters["key3"], "value3")
eq_(m2.parameters["unicode"], u"iván")
eq_(m2.parameters["integer"], 10)
eq_(m2.parameters["decimal"], 0.999)
map_string = mapnik.save_map_to_string(m)
m3 = mapnik.Map(256, 256)
mapnik.load_map_from_string(m3, map_string)
eq_(len(m3.parameters), 5)
eq_(m3.parameters["key"], "value2")
eq_(m3.parameters["key3"], "value3")
eq_(m3.parameters["unicode"], u"iván")
eq_(m3.parameters["integer"], 10)
eq_(m3.parameters["decimal"], 0.999)
开发者ID:kiivihal,项目名称:python-mapnik,代码行数:27,代码来源:extra_map_props_test.py
示例3: 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
示例4: test_serializing_arbitrary_parameters
def test_serializing_arbitrary_parameters():
m = mapnik.Map(256,256)
m.parameters.append(mapnik.Parameter('width',m.width))
m.parameters.append(mapnik.Parameter('height',m.height))
m2 = mapnik.Map(1,1)
mapnik.load_map_from_string(m2,mapnik.save_map_to_string(m))
eq_(m2.parameters['width'],m.width)
eq_(m2.parameters['height'],m.height)
开发者ID:Blaxxun,项目名称:mapnik,代码行数:9,代码来源:extra_map_props_test.py
示例5: test_load_save_map
def test_load_save_map():
map = mapnik.Map(256,256)
in_map = "../data/good_maps/raster_symbolizer.xml"
mapnik.load_map(map, in_map)
out_map = mapnik.save_map_to_string(map)
assert 'RasterSymbolizer' in out_map
assert 'RasterColorizer' in out_map
assert 'stop' in out_map
开发者ID:noirbizarre,项目名称:pymapnik2,代码行数:9,代码来源:raster_symbolizer_test.py
示例6: render_on_demand_as_loop
def render_on_demand_as_loop(self, tile_uri, zoom, zentral_tile):
rendered_tiles = []
tileBunch = new_object.getTileBunch(zentral_tile)
for tile in tileBunch:
if not os.path.isdir(tile_uri + '/' + str(tile[0])):
os.mkdir(tile_uri + '/' + str(tile[0]))
uri = tile_uri + '/' + str(tile[0]) + '/' + str(tile[1]) + '.png'
arg = (tile_dir, mapnik.save_map_to_string(self.mapnik_map), maxZoom, uri,tile[0], tile[1], zoom)
scale = rendering.pure_tile_rendering(arg)
rendered_tiles.append(uri)
return rendered_tiles, scale
开发者ID:RaKl,项目名称:TileGen,代码行数:11,代码来源:TilesDialog.py
示例7: on_btn_ok_clicked
def on_btn_ok_clicked(self, widget, data=None):
"""The user has elected to save the changes.
Called before the dialog returns Gtk.ResponseType.OK from run().
"""
logs = os.getenv("HOME") + '/TileGen/log-files/'
wobj = open(logs+'TileGen-last-mapfile.xml', 'w')
wobj.write(mapnik.save_map_to_string(self.mapnik_map))
wobj.close
func.writeToLog('Deleted tile_dir! %s' %os.system(' rm -rf '+ tile_dir),logs)
pass
开发者ID:RaKl,项目名称:TileGen,代码行数:12,代码来源:TilesDialog.py
示例8: test_load_save_map
def test_load_save_map():
map = mapnik.Map(256, 256)
in_map = "../visual_tests/styles/raster_symbolizer.xml"
try:
mapnik.load_map(map, in_map)
out_map = mapnik.save_map_to_string(map)
assert "RasterSymbolizer" in out_map
assert "RasterColorizer" in out_map
assert "stop" in out_map
except RuntimeError, e:
# only test datasources that we have installed
if not "Could not create datasource" in str(e):
raise RuntimeError(str(e))
开发者ID:olt,项目名称:mapnik,代码行数:14,代码来源:raster_symbolizer_test.py
示例9: test_load_save_map
def test_load_save_map():
map = mapnik.Map(256, 256)
in_map = "../data/good_maps/raster_symbolizer.xml"
try:
mapnik.load_map(map, in_map)
out_map = mapnik.save_map_to_string(map)
assert 'RasterSymbolizer' in out_map
assert 'RasterColorizer' in out_map
assert 'stop' in out_map
except RuntimeError as e:
# only test datasources that we have installed
if not 'Could not create datasource' in str(e):
raise RuntimeError(str(e))
开发者ID:cbenz,项目名称:python-mapnik,代码行数:14,代码来源:raster_symbolizer_test.py
示例10: test_load_save_load_map
def test_load_save_load_map():
map = mapnik.Map(256,256)
in_map = "../data/good_maps/glyph_symbolizer.xml"
mapnik.load_map(map, in_map)
style = map.find_style('arrows')
sym = style.rules[0].symbols[0]
assert isinstance(sym, mapnik.GlyphSymbolizer)
assert sym.angle_mode == mapnik.angle_mode.AZIMUTH
out_map = mapnik.save_map_to_string(map).decode('utf8')
map = mapnik.Map(256,256)
mapnik.load_map_from_string(map, out_map.encode('utf8'))
assert 'GlyphSymbolizer' in out_map
# make sure non-ascii characters are well supported since most interesting
# glyphs for symbology are usually in that range
assert u'í' in out_map, out_map
开发者ID:mojodna,项目名称:debian-mapnik,代码行数:16,代码来源:glyph_symbolizer_test.py
示例11: compare_map
def compare_map(xml):
m = mapnik.Map(256, 256)
absolute_base = os.path.abspath(os.path.dirname(xml))
mapnik.load_map(m, xml, False, absolute_base)
(handle, test_map) = tempfile.mkstemp(suffix='.xml', prefix='mapnik-temp-map1-')
os.close(handle)
(handle, test_map2) = tempfile.mkstemp(suffix='.xml', prefix='mapnik-temp-map2-')
os.close(handle)
if os.path.exists(test_map):
os.remove(test_map)
mapnik.save_map(m, test_map)
new_map = mapnik.Map(256, 256)
mapnik.load_map(new_map, test_map,False,absolute_base)
open(test_map2,'w').write(mapnik.save_map_to_string(new_map))
diff = ' diff %s %s' % (os.path.abspath(test_map),os.path.abspath(test_map2))
try:
eq_(open(test_map).read(),open(test_map2).read())
except AssertionError, e:
raise AssertionError('serialized map "%s" not the same after being reloaded, \ncompare with command:\n\n$%s' % (xml,diff))
开发者ID:Nobis99,项目名称:openstreetmap-tiles-docker,代码行数:19,代码来源:save_map_test.py
示例12: render_on_demand_as_loop
def render_on_demand_as_loop(self, tile_uri, zoom, central_tile):
rendered_tiles = []
tileBunch = self.TileCalcs.getTileBunch(central_tile)
for tile in tileBunch:
if not os.path.isdir(tile_uri + "/" + str(tile[0])):
os.mkdir(tile_uri + "/" + str(tile[0]))
uri = tile_uri + "/" + str(tile[0]) + "/" + str(tile[1]) + ".png"
arg = (
self.params.getTilesHome(),
mapnik.save_map_to_string(self.tileParams.getMapnikMap()),
self.tileParams.getMaxZoom(),
uri,
tile[0],
tile[1],
zoom,
)
scale = rendering.pure_tile_rendering(arg)
rendered_tiles.append(uri)
return rendered_tiles, scale
开发者ID:RaKl,项目名称:TileGen,代码行数:19,代码来源:TilesWindow.py
示例13: on_comboboxtext_layer_changed
def on_comboboxtext_layer_changed(self, widget, data=None):
self.ui.comboboxtext_style.remove_all()
chosen_layer = self.ui.comboboxtext_layer.get_active_text()
self.mapnik_styles = []
#find the chosen layer
for layer in self.mapnik_map.layers.__iter__():
if chosen_layer == layer.name:
source_params = xmlFunc.getDatasourceFromString(mapnik.save_map_to_string(self.mapnik_map),chosen_layer)
type = source_params['type']
#print type
if type == 'shape' or type == 'postgis':
self.datasource = (source_params['type'], layer.datasource, source_params)
self.layerSRS = layer.srs
for style in layer.styles:
self.mapnik_styles.append(style)
self.ui.comboboxtext_style.append_text(style)
else:
print 'Please implement the missing type: %s' %type
self.ui.comboboxtext_style.append_text('Layer type: %s ... it is not implemented yet!' %type)
开发者ID:RaKl,项目名称:TileGen,代码行数:19,代码来源:TilesDialog.py
示例14: test_loading_fontset_from_python
def test_loading_fontset_from_python():
m = mapnik.Map(256,256)
fset = mapnik.FontSet('foo')
fset.add_face_name('Comic Sans')
fset.add_face_name('Papyrus')
eq_(fset.name,'foo')
fset.name = 'my-set'
eq_(fset.name,'my-set')
m.append_fontset('my-set', fset)
sty = mapnik.Style()
rule = mapnik.Rule()
tsym = mapnik.TextSymbolizer()
eq_(tsym.fontset,None)
tsym.fontset = fset
rule.symbols.append(tsym)
sty.rules.append(rule)
m.append_style('Style',sty)
serialized_map = mapnik.save_map_to_string(m)
eq_('fontset-name="my-set"' in serialized_map,True)
开发者ID:Blaxxun,项目名称:mapnik,代码行数:19,代码来源:fontset_test.py
示例15: test_load_save_load_map
def test_load_save_load_map():
map = mapnik.Map(256, 256)
in_map = "../data/good_maps/glyph_symbolizer.xml"
try:
mapnik.load_map(map, in_map)
style = map.find_style("arrows")
sym = style.rules[0].symbols[0]
assert isinstance(sym, mapnik.GlyphSymbolizer)
assert sym.angle_mode == mapnik.angle_mode.AZIMUTH
out_map = mapnik.save_map_to_string(map).decode("utf8")
map = mapnik.Map(256, 256)
mapnik.load_map_from_string(map, out_map.encode("utf8"))
assert "GlyphSymbolizer" in out_map
# make sure non-ascii characters are well supported since most interesting
# glyphs for symbology are usually in that range
assert u"í" in out_map, out_map
except RuntimeError, e:
# only test datasources that we have installed
if not "Could not create datasource" in str(e):
raise RuntimeError(e)
开发者ID:netconstructor,项目名称:mapnik,代码行数:21,代码来源:glyph_symbolizer_test.py
示例16: compare_map
def compare_map(xml):
m = mapnik.Map(256, 256)
absolute_base = os.path.abspath(os.path.dirname(xml))
try:
mapnik.load_map(m, xml, False, absolute_base)
except RuntimeError as e:
# only test datasources that we have installed
if not 'Could not create datasource' in str(e) \
and not 'could not connect' in str(e):
raise RuntimeError(str(e))
return
(handle, test_map) = tempfile.mkstemp(
suffix='.xml', prefix='mapnik-temp-map1-')
os.close(handle)
(handle, test_map2) = tempfile.mkstemp(
suffix='.xml', prefix='mapnik-temp-map2-')
os.close(handle)
if os.path.exists(test_map):
os.remove(test_map)
mapnik.save_map(m, test_map)
new_map = mapnik.Map(256, 256)
mapnik.load_map(new_map, test_map, False, absolute_base)
with open(test_map2, 'w') as f:
f.write(mapnik.save_map_to_string(new_map))
diff = ' diff -u %s %s' % (os.path.abspath(test_map),
os.path.abspath(test_map2))
try:
with open(test_map) as f1:
with open(test_map2) as f2:
eq_(f1.read(), f2.read())
except AssertionError as e:
raise AssertionError(
'serialized map "%s" not the same after being reloaded, \ncompare with command:\n\n$%s' %
(xml, diff))
if os.path.exists(test_map):
os.remove(test_map)
else:
# Fail, the map wasn't written
return False
开发者ID:cbenz,项目名称:python-mapnik,代码行数:40,代码来源:save_map_test.py
示例17: render_on_demand_as_multiprocessing
def render_on_demand_as_multiprocessing(self, tile_uri, zoom, zentral_tile):
rendered_tiles = []
args = []
tileBunch = new_object.getTileBunch(zentral_tile)
for tile in tileBunch:
if not os.path.isdir(tile_uri + '/' + str(tile[0])):
os.mkdir(tile_uri + '/' + str(tile[0]))
uri = tile_uri + '/' + str(tile[0]) + '/' + str(tile[1]) + '.png'
arg = (tile_dir, mapnik.save_map_to_string(self.mapnik_map), maxZoom, uri,tile[0], tile[1], zoom)
args.append(arg)
rendered_tiles.append(uri)
#Process tile rendering as multiprocessing using internal modul of python
#Help: http://www.ibm.com/developerworks/aix/library/au-multiprocessing/
#alternative Multiprocessing...especially when an object (unconvertable to String-format) should be send to function
#Process(target=rendering.pure_tile_rendering, args=(tile_dir, self.mapnik_map, maxZoom, uri,tile[0], tile[1], zoom)).start()
#rendered_tiles.append(uri)
pool = Pool(processes = 9)
results = pool.map(rendering.pure_tile_rendering, args)
scale = results[0]
return rendered_tiles, scale
开发者ID:RaKl,项目名称:TileGen,代码行数:23,代码来源:TilesDialog.py
示例18: test
def test():
# TODO: Write a better test
# 1. Construct map in memory
# 2. Save map as XML
# 3. Load map to a second object
# 4. Compare both map objects
map = mapnik.Map(256, 256)
in_map = "../data/good_maps/osm-styles.xml"
mapnik.load_map(map, in_map)
test_map = "test_map.xml"
mapnik.save_map(map, test_map)
new_map = mapnik.Map(256, 256)
mapnik.load_map(new_map, test_map)
eq_(open(test_map).read(),mapnik.save_map_to_string(new_map))
if os.path.exists(test_map):
os.remove(test_map)
else:
# Fail, the map wasn't written
return False
开发者ID:craton-,项目名称:php_mapnik,代码行数:24,代码来源:save_map_test.py
示例19: on_mnu_export_mapfile_activate
def on_mnu_export_mapfile_activate(self, widget, data=None):
name = "TileGen-last-mapfile.xml"
wobj = open(self.params.getLogfilesHome() + name, "w")
wobj.write(mapnik.save_map_to_string(self.mapnik_map))
wobj.close
self.ui.label_status.set_text("Mapfile '%s' was exported to: \n\t%s" % (name, self.params.getLogfilesHome()))
开发者ID:RaKl,项目名称:TileGen,代码行数:6,代码来源:TilegenWindow.py
示例20: on_mnu_export_mapfile_activate
def on_mnu_export_mapfile_activate(self, widget, data=None):
name = 'GeneralCarto-last-mapfile.xml'
wobj = open(self.logs+name, 'w')
wobj.write(mapnik.save_map_to_string(self.mapnik_map))
wobj.close
self.ui.label_status.set_text("Mapfile '%s' was exported to: \n\t%s" %(name, self.logs))
开发者ID:milkbread,项目名称:GeneralCarto,代码行数:6,代码来源:GeneralcartoWindow.py
注:本文中的mapnik.save_map_to_string函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论