本文整理汇总了Python中mapscript.mapObj函数的典型用法代码示例。如果您正苦于以下问题:Python mapObj函数的具体用法?Python mapObj怎么用?Python mapObj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapObj函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: open
def open(self):
self.filename = str(QtGui.QFileDialog.getOpenFileName(None, "Select one file to open", self.firstDir, "MapFile (*.map);;Text (*.txt);;All (*.*)"))
self.map = mapscript.mapObj(self.filename)
try:
self.map = mapscript.mapObj(self.filename)
except Exception:
self.ui.statusbar.showMessage('Error: opening mapfile failed.')
self.ui.statusbar.showMessage('Info: mapfile opened.')
self.updateMapStructure()
开发者ID:yjacolin,项目名称:MapfileEditor,代码行数:10,代码来源:main.py
示例2: saveGeorefProject
def saveGeorefProject(conf,inputs,outputs):
import mmsession
import mapfile.service as ms
mapfile=conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["map"]["value"]+".map"
m = mapscript.mapObj(mapfile)
conf["senv"]["mmGeoDST"]=m.web.metadata.get("mmGeoDST")
conf["senv"]["mmGeoDSO"]=m.web.metadata.get("mmGeoDSO")
if inputs.has_key("dso") and inputs["dso"]["value"]=="NULL":
inputs["dso"]["value"]=m.getLayer(0).name
conf["senv"]["mmGeoMap"]=inputs["dso"]["value"]
import shutil
ofile=m.getLayer(0).data
shutil.copy2(ofile,conf["main"]["tmpPath"])
conf["senv"]["mmGeoImg"]=ofile.split('/')[len(ofile.split('/'))-1]
mmsession.save(conf)
try:
os.mkdir(conf["main"]["dataPath"]+"/georeferencer_maps/"+inputs["dso"]["value"])
except:
pass
if not(os.path.isfile(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")) or (inputs.has_key("force") and inputs["force"]["value"]=="true"):
try:
import glob
for name in glob.glob(conf["main"]["dataPath"]+"/georeferencer_maps/"+inputs["map"]["value"]+"/*.csv"):
shutil.copy2(name,conf["main"]["dataPath"]+"/georeferencer_maps/"+inputs["dso"]["value"])
except Exception,e:
print >> sys.stderr,e
pass
m.save(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")
开发者ID:gislite,项目名称:mapmint,代码行数:32,代码来源:service.py
示例3: testMapWithDefaultMap
def testMapWithDefaultMap(self):
"""ReferenceCountingTestCase.testTestMap: test map constructor with default map file"""
test_map = mapscript.mapObj(TESTMAPFILE)
assert test_map.__class__.__name__ == "mapObj"
assert test_map.thisown == 1
assert test_map.refcount == 1
assert test_map.getLayer(0).refcount == 2
开发者ID:dmorissette,项目名称:mapserver,代码行数:7,代码来源:refcount_test.py
示例4: main
def main(map_file):
map = mapscript.mapObj(map_file)
map.setMetaData("ows_onlineresource", "http://dummy.org/")
ows_req = mapscript.OWSRequest()
ows_req.type = mapscript.MS_GET_REQUEST
ows_req.setParameter("SERVICE", "WMS")
ows_req.setParameter("VERSION", "1.1.0")
ows_req.setParameter("REQUEST", "GetCapabilities")
mapscript.msIO_installStdoutToBuffer()
dispatch_status = map.OWSDispatch(ows_req)
if dispatch_status != mapscript.MS_SUCCESS:
print("An error occurred")
content_type = mapscript.msIO_stripStdoutBufferContentType()
mapscript.msIO_stripStdoutBufferContentHeaders()
result = mapscript.msIO_getStdoutBufferBytes()
# [('Content-Type', 'application/vnd.ogc.wms_xml; charset=UTF-8'), ('Content-Length', '11385')]
response_headers = [('Content-Type', content_type),
('Content-Length', str(len(result)))]
assert int(response_headers[1][1]) > 0
dom = xml.dom.minidom.parseString(result)
print(dom.toprettyxml(indent="", newl=""))
开发者ID:dmorissette,项目名称:mapserver,代码行数:30,代码来源:wxs.py
示例5: get_style_from_mapserver
def get_style_from_mapserver(request):
if request.method == 'GET':
layerName = request.GET.get('layer_name')
map = mapscript.mapObj(openthingis.settings.MAPSERVER_MAPFILE)
layer = map.getLayerByName(layerName)
sld = layer.generateSLD()
return HttpResponse(sld, content_type='application/xml')
开发者ID:jrodrigo,项目名称:openthingis,代码行数:7,代码来源:stylerviews.py
示例6: __init__
def __init__(self,parent,id,size):
wx.InitAllImageHandlers()
self.size = size
#setup map object
self.map = mapscript.mapObj()
self.map.width = size[0]
self.map.height = size[1]
#self.map.setProjection('proj=latlong,ellps=WGS84')
self.map.setProjection('proj=lcc,ellps=GRS80')
# set the output format
self.map.setOutputFormat(mapscript.outputFormatObj('GD/PNG') )
self.map.interlace = False #PIL can't handle interlaced PNGs
topo=mapscript.layerObj(None)
topo.name="topo"
topo.type=mapscript.MS_LAYER_RASTER
topo.connectiontype=mapscript.MS_RASTER
topo.setProjection('proj=lcc,ellps=GRS80,datum=NAD83')
topo.status = mapscript.MS_ON
topo.tileindex="maps/index.shp"
topo.tileitem="location"
layerNum = self.map.insertLayer(topo)
#fn = self.lookupTopoFilename(0)
#self.loadRaster(fn)
BufferedCanvas.__init__(self,parent,id)
开发者ID:BackupTheBerlios,项目名称:freedomflies-svn,代码行数:26,代码来源:map.py
示例7: getMapObj
def getMapObj(self):
mapObj = None
try:
mapObj = mapscript.mapObj(self.mapfile)
except mapscript.MapServerError as err:
self.messageTextEdit.append( str(err) )
return mapObj
开发者ID:sourcepole,项目名称:qgis-mapfile-tools,代码行数:7,代码来源:mapfile_renderer.py
示例8: saveGeoreferencedProject
def saveGeoreferencedProject(conf,inputs,outputs):
import mmsession
import mapfile.service as ms
mapfile=inputs["dst"]["value"]+"ds_ows.map"
m = mapscript.mapObj(mapfile)
ms.removeAllLayers(m,inputs["dso"]["value"])
m.web.metadata.set("mmGeoDST",inputs["dst"]["value"])
conf["senv"]["mmGeoDST"]=inputs["dst"]["value"]
m.web.metadata.set("mmGeoDSO",inputs["dso"]["value"])
conf["senv"]["mmGeoDSO"]=inputs["dso"]["value"]
conf["senv"]["mmGeoMap"]=inputs["dso"]["value"]
import shutil
ofile=m.getLayer(0).data
shutil.copy2(ofile,conf["main"]["tmpPath"])
conf["senv"]["mmGeoImg"]=ofile.split('/')[len(ofile.split('/'))-1]
if inputs.keys().count("gcpfile")>0:
m.web.metadata.set("mmGeoGCPFile",inputs["gcpfile"]["value"])
conf["senv"]["mmGeoGCPFile"]=inputs["gcpfile"]["value"]
mmsession.save(conf)
if not(os.path.isfile(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")):
m.save(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")
outputs["Result"]["value"]=zoo._("Georeference Project saved")
return zoo.SERVICE_SUCCEEDED
开发者ID:gislite,项目名称:mapmint,代码行数:28,代码来源:service.py
示例9: SecureAccess
def SecureAccess(conf,inputs,outputs):
global myCookies
mapfile=conf["main"]["dataPath"]+"/public_maps/project_"+inputs["server"]["value"]+".map"
try:
myMap=mapscript.mapObj(mapfile)
except:
conf["lenv"]["message"]=zoo._("Unable to find any project with this name!")
return zoo.SERVICE_FAILED
c = auth.getCon(conf)
prefix=auth.getPrefix(conf)
if not(validToken(c,prefix,inputs["token"]["value"])):
conf["lenv"]["message"]=zoo._("Unable to validate your token!")
return zoo.SERVICE_FAILED
if not(validIp(conf,c,prefix,inputs["ip"]["value"],0,[inputs["server"]["value"]])):
conf["lenv"]["message"]=zoo._("You are not allowed to access the ressource using this ip address!")
return zoo.SERVICE_FAILED
q=None
if inputs["Query"]["mimeType"]=="application/json":
import json
q=json.loads(inputs["Query"]["value"])
myAutorizedGroups=myMap.web.metadata.get('mm_access_groups').split(',')
if myAutorizedGroups.count('public')==0 and not(q is None or q["request"].upper()=="GETCAPABILITIES" or q["request"].upper()=="GETLEGENDGRAPHIC") and not(tryIdentifyUser(conf,inputs["user"]["value"],inputs["password"]["value"])):
conf["lenv"]["message"]=zoo._("You are not allowed to access the ressource using this user / password!")
conf["lenv"]["status_code"]="401 Unauthorized"
print >> sys.stderr,conf["lenv"]
return zoo.SERVICE_FAILED
if conf.keys().count("senv")==0:
conf["senv"]={"group": getGroupFromToken(c,prefix,inputs["token"]["value"])}
else:
print >> sys.stderr,conf["senv"]
try:
myCurrentGroups=conf["senv"]["group"].split(',')
except Exception,e:
myCurrentGroups=[]
开发者ID:mapmint,项目名称:mapmint,代码行数:34,代码来源:service.py
示例10: update_latest_mapfile
def update_latest_mapfile(self, mapfile, shapePath, geotifRelativePath):
'''
Update the 'latest' mapfile.
Inputs:
mapfile - Full path to the mapfile.
shapePath - Value to attribute to the mapfile's 'shapepath'
variable.
geotifRelativePath - Relative path to the geotiff. This path
is relative to the shapePath argument.
'''
mapObj = mapscript.mapObj(mapfile)
mapObj.shapepath = shapePath
mapWMSMetadata = mapObj.web.metadata
mapWMSMetadata.set('wms_onlineresource',
'http://%s/cgi-bin/mapserv?map=%s&' \
% (self.host.host, mapfile))
layer = mapObj.getLayerByName(self.product.short_name)
layer.data = geotifRelativePath
layerAbstract = '%s product generated for the %s timeslot.' % \
(self.product.short_name,
self.timeslot.strftime('%Y-%m-%d %H:%M'))
layer.metadata.set('wms_abstract', layerAbstract)
mapObj.save(mapfile)
return mapfile
开发者ID:ricardogsilva,项目名称:webg2system,代码行数:30,代码来源:mappers.py
示例11: __init__
def __init__(self, request, **kwargs):
"""
Method to setup map object based on the input parameters. The map
object represents the mapserver mapfile and is used to render
the wms requests.
"""
# Store arguments
self.request = request
self.kwargs = kwargs
# Create mapobject
self.map_object = mapscript.mapObj()
self.register_symbolset()
self.register_layers()
# Set map object properties
self.map_object.setProjection('init=epsg:3857')
self.map_object.setExtent(-180, -90, 180, 90)
self.map_object.setSize(256, 256)
self.map_object.setMetaData('wms_title', self.title)
self.map_object.setMetaData('wms_srs', 'epsg:' + ' epsg:'.join(self.srs))
self.map_object.setMetaData('wms_enable_request',
' '.join(self.enable_requests))
self.map_object.outputformat.transparent = mapscript.MS_ON
# Set legend item size
self.map_object.legend.keysizex = self.legend_size[0]
self.map_object.legend.keysizey = self.legend_size[1]
# Allow debugging
if settings.DEBUG:
self.map_object.debug = mapscript.MS_ON
开发者ID:geodesign,项目名称:django-wms,代码行数:33,代码来源:maps.py
示例12: _render
def _render(self, inputFile, outputFile):
mapfile = 'MapRenderer/static.map'
# print "Input From: " + inputFile
# print "Output to: " + outputFile
#check output directory exists
if not os.path.exists(self.outputPath):
os.makedirs(self.outputPath)
try:
m = mapscript.mapObj(mapfile)
m.setSize(1542,2523)
#set layer data file
layer = m.getLayerByName("dispersal")
layer.data = inputFile
m.draw().save(outputFile)
except mapscript.MapServerError as e:
print e
pass
#log.critical(e)
except IOError as e:
print e
pass
开发者ID:pumped,项目名称:dispm,代码行数:25,代码来源:MapGenerator.py
示例13: mapserver
def mapserver(params,mapfile):
""" Function implementing mapserver functionality.
params: dictionary of query string of a mapserver GET request
mapfile: path to mapfile
returns: tuple with content type and response body
"""
helper.dbg("creating map for: " + mapfile)
request = mapscript.OWSRequest()
#request.loadParams()
for k in params:
#helper.dbg( "%s : %s" % (k,params[k]))
request.setParameter(k,params[k])
# change the style INSPIRE:DEFAULT back to an empty string otherwise Mapserver will complain
styles = request.getValueByName('STYLES')
if (styles is not None and styles.count(default_style) > 0):
styles = styles.replace(default_style, "")
request.setParameter("STYLES", styles)
style = request.getValueByName('STYLE')
if style == default_style:
request.setParameter("STYLE", "")
map = mapscript.mapObj( mapfile )
mapscript.msIO_installStdoutToBuffer()
map.OWSDispatch( request )
content_type = mapscript.msIO_stripStdoutBufferContentType()
content = mapscript.msIO_getStdoutBufferBytes()
operation = request.getValueByName('REQUEST')
version = request.getValueByName('VERSION')
if (version == '1.3.0' or version is None) and operation.upper() == 'GETCAPABILITIES':
content = altercapabilities(content, namespace, prefix, schemaLocation, language)
#response = 'Content-type: %s\n%s' % (content_type,content)
return [content_type, content]
开发者ID:xmichael,项目名称:igibs,代码行数:34,代码来源:viewservice.py
示例14: bug_673
def bug_673():
if string.find(mapscript.msGetVersion(),'SUPPORTS=PROJ') == -1:
return 'skip'
map = mapscript.mapObj('../misc/ogr_direct.map')
map.setProjection('+proj=utm +zone=11 +datum=WGS84')
layer = map.getLayer(0)
# Draw map without reprojection.
layer.setProjection('+proj=utm +zone=11 +datum=WGS84')
img1 = map.draw()
# Draw map with reprojection
map.setProjection('+proj=latlong +datum=WGS84')
map.setExtent(-117.25,43.02,-117.21,43.05)
img2 = map.draw()
try:
os.mkdir('result')
except:
pass
img2.save( 'result/bug673.png' )
# Verify we got the image we expected ... at least hopefully we didn't
# get all white which would indicate the bug is back.
return pmstestlib.compare_and_report( 'bug673.png' )
开发者ID:buldi,项目名称:msautotest,代码行数:33,代码来源:bug_check.py
示例15: wms
def wms(request):
import mapscript
image = None
for field in ['IMAGE', 'COVERAGE', 'image', 'coverage', 'id', 'ID']:
if field in request.GET: image = request.GET[field]
try:
image = int(image)
obj = Map.objects.get(pk=image)
filename = obj.warped
except:
filename = "%s" % image
filename = "%s/%s" % (settings.MAP_PATH, os.path.basename(filename))
ows = mapscript.OWSRequest()
for k, v in request.GET.items():
if k.lower() in ['image', 'coverage']: continue
ows.setParameter(k, v)
ows.setParameter("LAYERS", "image")
ows.setParameter("COVERAGE", "image")
map = mapscript.mapObj('%s/wms.map' % settings.BASE_PATH)
raster = mapscript.layerObj(map)
raster.name = 'image'
raster.type = mapscript.MS_LAYER_RASTER
raster.data = filename
raster.status = mapscript.MS_DEFAULT
raster.setProjection( "+init=epsg:4326" )
raster.dump = mapscript.MS_TRUE
raster.metadata.set("wcs_formats", "GEOTIFF JPEG2000")
mapscript.msIO_installStdoutToBuffer()
contents = map.OWSDispatch(ows)
content_type = mapscript.msIO_stripStdoutBufferContentType()
content = mapscript.msIO_getStdoutBufferBytes()
return HttpResponse(content, content_type = content_type)
开发者ID:aaronr,项目名称:labs-rectifier,代码行数:32,代码来源:views.py
示例16:
def main:
map = mapscript.mapObj()
map.name = 'Test Map'
map.setSize(300, 300)
map.setExtent(-180.0,-90.0,180.0,90.0)
map.imagecolor.setRGB(80, 180, 80)
map.units = mapscript.MS_DD
layer = mapscript.layerObj(map)
layer.name = "regioni"
layer.type = mapscript.MS_LAYER_POLYGON
layer.status = mapscript.MS_DEFAULT
layer.data = os.getcwd() + '/../data/regioni'
class1 = mapscript.classObj(layer)
class1.name = "Regioni"
style = mapscript.styleObj(class1)
style.outlinecolor.setRGB(100, 100, 100)
style.color.setRGB(200, 200, 200)
extent = layer.getExtent()
map.setExtent(extent.minx, extent.miny, extent.maxx, extent.maxy)
mapimage = map.draw()
mapimage.save(os.getcwd() + '/../images/mapscript_map.png')
开发者ID:BodduMallikarjun,项目名称:python-gis-workshop,代码行数:25,代码来源:mapscript_api.py
示例17: testSetExtent
def testSetExtent(self):
"""MapExtentTestCase.testSetExtent: test the setting of a mapObj's extent"""
test_map = mapscript.mapObj(TESTMAPFILE)
e = test_map.extent
result = test_map.setExtent(e.minx, e.miny, e.maxx, e.maxy)
self.assertAlmostEqual(test_map.scaledenom, 14.24445829)
assert result == mapscript.MS_SUCCESS, result
开发者ID:dmorissette,项目名称:mapserver,代码行数:7,代码来源:map_test.py
示例18: draw_map
def draw_map(name, save=0):
# print("making map in thread %s" % (name))
mo = mapscript.mapObj(TESTMAPFILE)
im = mo.draw()
if save:
im.save('threadtest_%s.png' % (name))
开发者ID:dmorissette,项目名称:mapserver,代码行数:7,代码来源:thread_test.py
示例19: draw_map_wms
def draw_map_wms(name, save=0):
# print("making map in thread %s" % (name))
mo = mapscript.mapObj(TESTMAPFILE)
# WFS layer
lo = mapscript.layerObj()
lo.name = 'jpl_wms'
lo.setProjection('+init=epsg:4326')
lo.connectiontype = mapscript.MS_WMS
lo.connection = 'http://vmap0.tiles.osgeo.org/wms/vmap0?'
lo.metadata.set('wms_service', 'WMS')
lo.metadata.set('wms_server_version', '1.1.1')
lo.metadata.set('wms_name', 'basic')
lo.metadata.set('wms_style', 'visual')
lo.metadata.set('wms_format', 'image/jpeg')
lo.type = mapscript.MS_LAYER_RASTER
lo.status = mapscript.MS_DEFAULT
lo.debug = mapscript.MS_ON
mo.insertLayer(lo)
if not mo.web.imagepath:
mo.web.imagepath = os.environ.get('TEMP', None) or INCOMING
mo.debug = mapscript.MS_ON
mo.selectOutputFormat('image/jpeg')
im = mo.draw()
if save:
im.save('threadtest_wms_%s.jpg' % (name))
开发者ID:dmorissette,项目名称:mapserver,代码行数:27,代码来源:thread_test.py
示例20: build
def build(self):
"""
Build a mapObj
"""
uri = reverse("wms_endpoint")
m = mapscript.mapObj()
m.name = self.name
m.setProjection("init=epsg:{}".format(self.projection))
m.shapepath = ""
m.units = self.units
m.setMetaData("ows_title", self.name)
m.setMetaData("ows_onlineresource",
"http://{}{}".format(settings.HOST_NAME, uri))
m.setMetaData("wms_srs", "EPSG:{}".format(self.projection))
m.setMetaData("wms_enable_request", self.ows_enable_request)
m.setMetaData("wms_encoding", "utf-8")
m.imagetype = "png"
m.extent = self.extent.build()
m.setSize(*self.MAP_SIZE)
if self.image_color is not None:
m.imageColor = self.image_color.build()
else:
m.imageColor = mapscript.colorObj(255, 255, 255)
for layer in self.layers.all():
m.insertLayer(layer.build())
return m
开发者ID:ricardogsilva,项目名称:django-mapserver,代码行数:27,代码来源:models.py
注:本文中的mapscript.mapObj函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论