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)
def create_layermodel(self, st_type, store, name, metadata={}): if self.has_layermodel(st_type, store, name): raise KeyExists((st_type, store, name)) lm = self.__ms2model(mapscript.layerObj(self.ms), st_type=st_type) lm.update(store, name, metadata) return lm
def __init__(self, path, create=False, needed=False, fontset=None, config=None): self.path = path self.filename = os.path.basename(self.path) self.name = os.path.splitext(self.filename)[0] if os.path.exists(self.path): if create and not needed: raise KeyExists(self.filename) create = False elif needed: create = True if create: self.ms = mapscript.mapObj() # and adding some default values... self.ms.name = self.name self.ms.setProjection(config.get("projection", "+init=epsg:4326")) self.ms.setExtent(*config.get("extent", [-180, -90, 180, 90])) self.ms.units = tools.get_units(config.get("units", "DD")) self.ms.setSize(1, 1) for outputformat in [ v for k in OUTPUTFORMAT.keys() for v in list(OUTPUTFORMAT[k].values()) ]: self.ms.appendOutputFormat(outputformat) for k, v in config.get('metadata', {}).iteritems(): self.set_metadata(k, v) for ows in ("ows", "wms", "wfs", "wcs"): self.set_metadata("%s_enable_request" % ows, "*") if 'onlineresource' in config: onlineresource = urlparse.urljoin(config.get('onlineresource'), self.ms.name) self.set_metadata('ows_onlineresource', onlineresource) fontset and self.ms.setFontSet(fontset) else: self.ms = mapscript.mapObj(self.path)
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)) # Configure the layer according to the model. model.configure_layer(layer, l_enabled) layer.ms.name = l_name layer.ms.template = "foo.html" # layer.enable() # Add metadata. metadata = { "wms_srs": self.get_metadata("ows_srs"), } metadata.update(l_metadata) layer.update_metadatas(metadata) # Set default style. layer.set_default_style(self)
def __init__(self, path, create=False, needed=False): self.path = path self.filename = os.path.basename(self.path) self.name = os.path.splitext(self.filename)[0] if os.path.exists(self.path): if create and not needed: raise KeyExists(self.filename) create = False elif needed: create = True if create: self.ms = mapscript.mapObj() # and adding some default values... self.ms.name = self.name self.ms.setProjection( "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") self.ms.setExtent(-180, -90, 180, 90) self.ms.units = mapscript.MS_DD for ows in ("wms", "wfs", "wcs"): self.set_metadata("%s_enable_request" % ows, "") else: self.ms = mapscript.mapObj(self.path)
def create_store(self, st_type, name, configuration): with self.mra_metadata("%ss" % st_type, {}) as stores: if name in stores: raise KeyExists(name) stores[name] = configuration
def create_layergroup(self, lg_name, mra_metadata={}): with self.mra_metadata("layergroups", {}) as layergroups: if lg_name in layergroups: raise KeyExists(lg_name) layergroups[lg_name] = mra_metadata return LayerGroup(lg_name, self)