def save(self, output): MapServer.save(self,output) name = "%s-%s-%s"%(output.identifier, self.process.identifier,self.sessId) service_url = '/'.join([config.getConfigValue('geoserver', 'geoserveraddress'), self.workspace.name]) if self.datatype == "raster": # save logging.info("upload raster file with name: {0} ".format(name)) self.cat.create_coveragestore(name, output.value, self.workspace, False) # construct the wcs url return urllib2.quote('/'.join( (service_url, 'wcs') ) + "?SERVICE=WCS"+ "&REQUEST=GetCoverage"+ "&VERSION=1.0.0"+ "&COVERAGE="+name+"&CRS="+output.projection+ "&BBOX=%s,%s,%s,%s"%(output.bbox[0],output.bbox[1],output.bbox[2],output.bbox[3])+ "&HEIGHT=%s" %(output.height)+"&WIDTH=%s"%(output.width)+"&FORMAT=%s"%output.format["mimetype"]) elif self.datatype == "vector": #save logging.info("upload vector file with name: {0} ".format(name)) zip_shpf,lyname = self.compressFeatureData(output.value) self.cat.create_featurestore(name, zip_shpf, self.workspace, False) # construct the wfs url return urllib2.quote('/'.join( (service_url, 'wfs') ) + "?SERVICE=WFS"+ "&REQUEST=GetFeature"+ "&VERSION=1.0.0"+ "&TYPENAME="+lyname) else: return None
def __init__(self, process, sessId): MapServer.__init__(self, process, sessId) # initial myself # the catagory of this geoserver self.cat = Catalog( '/'.join( (config.getConfigValue('geoserver', 'geoserveraddress'), 'rest') ), config.getConfigValue('geoserver', 'admin'), config.getConfigValue('geoserver', 'adminpassword') ) # get the workspace that datas will be saved and if workspace not set at configure file or # not exit then the default workspace will be used self.workspace = self.cat.get_workspace ( config.getConfigValue('geoserver', 'workspace') ) if not self.workspace: self.workspace = self.cat.get_default_workspace()
def __init__(self, process, sessId): MapServer.__init__(self, process, sessId) # initial myself # the catagory of this geoserver self.cat = Catalog( '/'.join((config.getConfigValue('geoserver', 'geoserveraddress'), 'rest')), config.getConfigValue('geoserver', 'admin'), config.getConfigValue('geoserver', 'adminpassword')) # get the workspace that datas will be saved and if workspace not set at configure file or # not exit then the default workspace will be used self.workspace = self.cat.get_workspace( config.getConfigValue('geoserver', 'workspace')) if not self.workspace: self.workspace = self.cat.get_default_workspace()
def save(self, output): MapServer.save(self, output) name = "%s-%s-%s" % (output.identifier, self.process.identifier, self.sessId) service_url = '/'.join([ config.getConfigValue('geoserver', 'geoserveraddress'), self.workspace.name ]) if self.datatype == "raster": # save logging.info("upload raster file with name: {0} ".format(name)) self.cat.create_coveragestore(name, output.value, self.workspace, False) # construct the wcs url return urllib2.quote('/'.join((service_url, 'wcs')) + "?SERVICE=WCS" + "&REQUEST=GetCoverage" + "&VERSION=1.0.0" + "&COVERAGE=" + name + "&CRS=" + output.projection + "&BBOX=%s,%s,%s,%s" % (output.bbox[0], output.bbox[1], output.bbox[2], output.bbox[3]) + "&HEIGHT=%s" % (output.height) + "&WIDTH=%s" % (output.width) + "&FORMAT=%s" % output.format["mimetype"]) elif self.datatype == "vector": #save logging.info("upload vector file with name: {0} ".format(name)) zip_shpf, lyname = self.compressFeatureData(output.value) self.cat.create_featurestore(name, zip_shpf, self.workspace, False) # construct the wfs url return urllib2.quote('/'.join((service_url, 'wfs')) + "?SERVICE=WFS" + "&REQUEST=GetFeature" + "&VERSION=1.0.0" + "&TYPENAME=" + lyname) else: return None