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


Python mapscript.layerObj函数代码示例

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


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

示例1: create_default_layer

def create_default_layer():
    layer = mapscript.layerObj()
    layer.classitem = "fooitem"
    layer.data = "/path/to/shapefile"
    layer.dump = mapscript.MS_TRUE
    layer.filteritem = "foofilteritem"
    layer.setFilter("foofilter")
    layer.group = 'foogroup'
    layer.labelcache = mapscript.MS_OFF
    layer.labelitem = 'foolabelitem'
    layer.labelmaxscaledenom=1000
    layer.labelminscaledenom=100
    layer.maxscaledenom = 1000
    layer.minscaledenom = 100
    layer.metadata.set("fookey","foovalue")
    layer.name = "foobar"
    layer.offsite.setHex("#000001")
    layer.opacity=50
    layer.postlabelcache = mapscript.MS_TRUE
    layer.setProjection("+init=epsg:27572")
    layer.sizeunits = mapscript.MS_MILES
    layer.status = mapscript.MS_OFF
    layer.template = "footemplate"
    layer.tileindex = "/path/to/shp"
    layer.tileitem = "footileitem"
    layer.type = mapscript.MS_LAYER_POINT
    layer.units = mapscript.MS_DD
    layer.insertClass(create_default_class())

    return layer
开发者ID:camptocamp,项目名称:Studio,代码行数:30,代码来源:test_mapfile_parser.py

示例2:

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

示例3: addBgLayer

def addBgLayer(conf,m,size,zoomlevel,ext,typ="osm"):
    import json,mapscript,time,shutil
    delta=(100*(2**(18-zoomlevel)))
    ext0=json.dumps((float(ext[0])-delta,float(ext[3])+delta,float(ext[2])+delta,float(ext[1])-delta)).replace("[","").replace("]","").replace(" ","")
    hreq=conf["main"]["serverAddress"]+"?service=WPS&version=1.0.0&request=Execute&Identifier=raster-tools.translate&DataInputs=InputDSN=base_layers/mq-"+typ+".xml;OutputDSN=tmp_"+conf["senv"]["MMID"]+str(time.clock()).split(".")[1]+";Format=GTiff;OutSize="+str(size[0]*1.5)+","+str(size[1]*1.5)+";ProjWin="+ext0+"&RawDataOutput=Result&language="+conf["main"]["language"]
    import urllib2
    u = urllib2.urlopen(hreq)
    fName=u.read()
    fName1=fName.replace(".tif",str(time.clock()).split(".")[1]+".tif")
    shutil.move(fName,fName1)
    nl=mapscript.layerObj(m)
    nl.updateFromString('''LAYER 
 NAME "BaseLayerMap" 
 TYPE RASTER
 UNITS METERS
 STATUS ON
 DATA "'''+fName1+'''"
 PROCESSING "RESAMPLE=AVERAGE"
 PROJECTION 
   "init=epsg:900913"
 END
END''')
    ordon=()
    ordon+=((m.numlayers-1),)
    for a in range(0,m.numlayers-1):
        ordon+=(a,)
    m.setLayerOrder(ordon)
开发者ID:mapmint,项目名称:mapmint,代码行数:27,代码来源:service.py

示例4: __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

示例5: testLayerConstructorNoArg

 def testLayerConstructorNoArg(self):
     """test layer constructor with no argument"""
     layer = mapscript.layerObj()
     assert layer.__class__.__name__ == "layerObj"
     assert layer.thisown == 1
     assert layer.index == -1
     assert layer.map is None, layer.map
开发者ID:dmorissette,项目名称:mapserver,代码行数:7,代码来源:layer_test.py

示例6: create_featuretypemodel

    def create_featuretypemodel(self, ft_name, ds_name, metadata={}):
        if self.has_featuretypemodel(ft_name, ds_name):
            raise KeyExists(ft_name)

        ft = FeatureTypeModel(mapscript.layerObj(self.mapfile.ms))
        ft.update(self, ft_name, ds_name, metadata)
        return ft
开发者ID:juanluisrp,项目名称:mra,代码行数:7,代码来源:mapfile.py

示例7: testLayerObj

 def testLayerObj(self):
     self.initMap()
     layer = mapscript.layerObj(self.map)
     self.map = None
     assert str(layer.p_map).find('mapscript.mapObj') != -1
     gc.collect()
     assert layer.map is not None, layer.map
开发者ID:dmorissette,项目名称:mapserver,代码行数:7,代码来源:parentreference_test.py

示例8: testDrawMapWithSecondPolygon

    def testDrawMapWithSecondPolygon(self):
        """draw a blue polygon and a red polygon"""
        p = self.map.getLayerByName('POLYGON')
        ip = mapscript.layerObj(self.map)
        ip.type = mapscript.MS_LAYER_POLYGON
        ip.status = mapscript.MS_DEFAULT
        c0 = mapscript.classObj(ip)

        # turn off first polygon layer's color
        p.getClass(0).getStyle(0).color.setRGB(-1, -1, -1)

        # copy this style to inline polygon layer, then change outlinecolor
        c0.insertStyle(p.getClass(0).getStyle(0))
        st0 = c0.getStyle(0)
        st0.outlinecolor.setRGB(255, 0, 0)

        # pull out the first feature from polygon layer, shift it
        # and use this as an inline feature in new layer
        p.open()
        p.template = "FAKE"  # set a template so the layer can be queried
        p.queryByIndex(self.map, -1, 0, mapscript.MS_TRUE)
        res = p.getResult(0)
        s0 = p.getShape(res)
        p.close()
        r0 = s0.bounds
        r1 = mapscript.rectObj(r0.minx-0.1, r0.miny-0.1, r0.maxx-0.1, r0.maxy-0.1)
        s1 = r1.toPolygon()

        ip.addFeature(s1)
        img = self.map.draw()
        img.save('test_drawmapw2ndpolygon.png')
开发者ID:dmorissette,项目名称:mapserver,代码行数:31,代码来源:style_test.py

示例9: get_map

    def get_map(self, tile):
        import mapscript
        wms = MapServer.get_map(self, tile)
        bounds = tile.bounds()
        # XXX FIXME: I don't think this will work with other projections?
        scale  = self.INCHES_PER_DEGREE * (bounds[2]-bounds[0])/tile.size()[0]

        sql    = """SELECT dr.id, layername, data, type, min_scale, max_scale, srs, offsite,
                      ds.name, description, attribution, url
                      FROM view_datarecord dr, view_recordtypes rt,
                           view_datasource ds
                      WHERE type_id = rt.id
                      AND datasource_id = ds.id
                      AND bbox && 'BOX3D(%s %s, %s %s)'::box3d
                      AND %f >= min_scale and %f <= max_scale
                      AND active 
                      ORDER BY data_resolution DESC""" % (bounds + (scale, scale))

        cursor = self.db.cursor()
        cursor.execute(sql)
        for id, name, data, type, min_scale, max_scale, srs, offsite, \
            title, description, attribution, url in cursor:
            raster = mapscript.layerObj(wms)
            raster.name   = "layer_%s" % id
            raster.group  = "world"
            raster.type   = mapscript.MS_LAYER_RASTER
            raster.status = mapscript.MS_DEFAULT
            if srs and type == "WMS":
                raster.setProjection( "+init=" + srs.lower() )
            else:
                raster.setProjection( "+init=" + tile.layer.srs.lower() )
            if offsite:
                offsite = map(int, offsite.split(" "))  
                raster.offsite = mapscript.colorObj(offsite[0], offsite[1], offsite[2])
            else:    
                raster.offsite = mapscript.colorObj(0,0,0)

            metadata = {
                "srs": "EPSG:4326",
                "format": "image/jpeg",
                "server_version": "1.1.1",
                "name": name,
                "title": title,
                "abstract": description,
                "attribution_title": attribution,
                "attribution_onlineresource": url }

            for key, val in metadata.items():
                raster.metadata.set("wms_" + key, val)

            if type == "GeoTIFF":
                raster.data = os.path.join(self.image_path, data)
            elif type == "Tile Index":
                raster.tileindex = os.path.join(self.image_path, data)
                # XXX BUG: we don't set tileitem b/c it's not in the d/b
            elif type == "WMS":
                raster.connectiontype = mapscript.MS_WMS
                raster.connection = data
         
        return wms
开发者ID:jj0hns0n,项目名称:oam-original,代码行数:60,代码来源:oam.py

示例10: 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

示例11: 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

示例12: testConstructorWithArg

 def testConstructorWithArg(self):
     lyr = mapscript.layerObj()
     lyr.name = 'foo'
     c = mapscript.classObj(lyr)
     assert c.thisown == 1
     assert c.layer.name == lyr.name
     assert c.numstyles == 0
开发者ID:dmorissette,项目名称:mapserver,代码行数:7,代码来源:class_test.py

示例13: create_layer

    def create_layer(self, model, l_name, l_enabled, l_metadata={}):
        if self.has_layer(l_name):
            raise KeyExists(l_name)

        # Create the layer.
        layer = Layer(mapscript.layerObj(self.ms))

        # Add some default metadata.
        dflt_metadata = {
            "ows_title": l_name,
            "ows_abstract": l_name,
            "wms_srs": "EPSG:4326"
            }

        for k, v in dflt_metadata.iteritems():
            l_metadata.setdefault(k, v)
        l_metadata["ows_name"] = l_name

        # Update layer.
        layer.update(l_name, l_enabled, l_metadata)

        # Configure the layer according to the model.
        model.configure_layer(layer, l_enabled)

        # Set default style.
        layer.set_default_style(self)
开发者ID:jivechang,项目名称:mra,代码行数:26,代码来源:mra.py

示例14: create_layermodel

    def create_layermodel(self, st_type, store, name, metadata={}):
        if self.has_layermodel(st_type, store, name):
            raise KeyExists((st_type, store, name))
        ft = self.__ms2model(mapscript.layerObj(self.ms), st_type=st_type)

        ft.update(store, name, metadata)
        return ft
开发者ID:neogeo-technologies,项目名称:mra,代码行数:7,代码来源:mra.py

示例15: create_coveragemodel

    def create_coveragemodel(self, c_name, cs_name, metadata={}):
        if self.has_coveragemodel(c_name, cs_name):
            raise KeyExists(c_name)

        c = CoverageModel(mapscript.layerObj(self.mapfile.ms))
        c.update(self, c_name, cs_name, metadata)
        return c
开发者ID:juanluisrp,项目名称:mra,代码行数:7,代码来源:mapfile.py


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