def __init__(self,url,xml): self.version='1.0.0' self.url = url # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) #serviceIdentification metadata subelem=self._capabilities.find(ns('Service')) self.identification=ServiceIdenfication(subelem) #serviceProvider metadata self.provider=None subelem=self._capabilities.find(ns('Service/')+ns('responsibleParty')) if subelem is not None: self.provider=ServiceProvider(subelem) #serviceOperations metadata self.operations=[] for elem in self._capabilities.find(ns('Capability/')+ns('Request')).getchildren(): self.operations.append(OperationMetadata(elem)) #serviceContents metadata self.contents={} for elem in self._capabilities.findall(ns('ContentMetadata/')+ns('CoverageOfferingBrief')): cm=ContentMetadata(elem, self) self.contents[cm.id]=cm #exceptions self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')]
def __init__(self, url, xml, cookies): self.version = '1.1.0' self.url = url self.cookies = cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) #build metadata objects: #serviceIdentification metadata elem = self._capabilities.find( '{http://www.opengis.net/wcs/1.1/ows}ServiceIdentification') if elem is None: elem = self._capabilities.find( '{http://www.opengis.net/ows}ServiceIdentification') self.identification = ServiceIdentification(elem) #serviceProvider elem = self._capabilities.find( '{http://www.opengis.net/ows}ServiceProvider') self.provider = ServiceProvider(elem) #serviceOperations self.operations = [] for elem in self._capabilities.findall( '{http://www.opengis.net/wcs/1.1/ows}OperationsMetadata/{http://www.opengis.net/wcs/1.1/ows}Operation/' ): self.operations.append(Operation(elem)) # exceptions - ***********TO DO ************* self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')] # serviceContents: our assumption is that services use a top-level layer # as a metadata organizer, nothing more. self.contents = {} top = self._capabilities.find( '{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary' ) for elem in self._capabilities.findall( '{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary/{http://www.opengis.net/wcs/1.1}CoverageSummary' ): cm = ContentMetadata(elem, top, self) self.contents[cm.id] = cm if self.contents == {}: #non-hierarchical. top = None for elem in self._capabilities.findall( '{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary' ): cm = ContentMetadata(elem, top, self) #make the describeCoverage requests to populate the supported formats/crs attributes self.contents[cm.id] = cm
def __init__(self, url, xml, cookies): self.version = '2.0.1' self.url = url self.cookies = cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) # check for exceptions se = self._capabilities.find('Exception') if se is not None: err_message = str(se.text).strip() raise ServiceException(err_message, xml) #build metadata objects: #serviceIdentification metadata elem = self._capabilities.find(OWS.ServiceIdentification) if elem is None: elem = self._capabilities.find(OWS.ServiceIdentification) self.identification = ServiceIdentification(elem) #serviceProvider elem = self._capabilities.find(OWS.ServiceProvider) self.provider = ServiceProvider(elem) #serviceOperations self.operations = [] for elem in self._capabilities.findall(OWS.OperationsMetadata + '/' + OWS.Operation): self.operations.append(Operation(elem)) # exceptions - ***********TO DO ************* self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')] # serviceContents: our assumption is that services use a top-level layer # as a metadata organizer, nothing more. self.contents = {} top = self._capabilities.find(WCS.Contents + '/' + WCS.CoverageSummary) for elem in self._capabilities.findall(WCS.Contents + '/' + WCS.CoverageSummary + '/' + WCS.CoverageSummary): cm = ContentMetadata(elem, top, self) self.contents[cm.id] = cm if self.contents == {}: #non-hierarchical. top = None for elem in self._capabilities.findall(WCS.Contents + '/' + WCS.CoverageSummary): cm = ContentMetadata(elem, top, self) #make the describeCoverage requests to populate the supported formats/crs attributes self.contents[cm.id] = cm
def __init__(self,url,xml, cookies): self.version='1.1.0' self.url = url self.cookies=cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) # check for exceptions se = self._capabilities.find('{http://www.opengis.net/ows/1.1}Exception') if se is not None: err_message = str(se.text).strip() raise ServiceException(err_message, xml) #build metadata objects: #serviceIdentification metadata elem=self._capabilities.find('{http://www.opengis.net/wcs/1.1/ows}ServiceIdentification') if elem is None: elem=self._capabilities.find('{http://www.opengis.net/ows/1.1}ServiceIdentification') self.identification=ServiceIdentification(elem) #serviceProvider elem=self._capabilities.find('{http://www.opengis.net/ows/1.1}ServiceProvider') self.provider=ServiceProvider(elem) #serviceOperations self.operations = [] for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1/ows}OperationsMetadata/{http://www.opengis.net/wcs/1.1/ows}Operation/'): self.operations.append(Operation(elem)) # exceptions - ***********TO DO ************* self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')] # serviceContents: our assumption is that services use a top-level layer # as a metadata organizer, nothing more. self.contents = {} top = self._capabilities.find('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary') for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary/{http://www.opengis.net/wcs/1.1}CoverageSummary'): cm=ContentMetadata(elem, top, self) self.contents[cm.id]=cm if self.contents=={}: #non-hierarchical. top=None for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary'): cm=ContentMetadata(elem, top, self) #make the describeCoverage requests to populate the supported formats/crs attributes self.contents[cm.id]=cm
def __init__(self, url, xml, cookies): self.version = '1.0.0' self.url = url self.cookies = cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version, self.cookies) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) # check for exceptions se = self._capabilities.find('ServiceException') if se is not None: err_message = str(se.text).strip() raise ServiceException(err_message, xml) #serviceIdentification metadata subelem = self._capabilities.find(ns('Service')) self.identification = ServiceIdentification(subelem) #serviceProvider metadata subelem = self._capabilities.find( ns('Service/') + ns('responsibleParty')) self.provider = ServiceProvider(subelem) #serviceOperations metadata self.operations = [] for elem in self._capabilities.find(ns('Capability/') + ns('Request'))[:]: self.operations.append(OperationMetadata(elem)) #serviceContents metadata self.contents = {} for elem in self._capabilities.findall( ns('ContentMetadata/') + ns('CoverageOfferingBrief')): cm = ContentMetadata(elem, self) self.contents[cm.id] = cm #Some WCS servers (wrongly) advertise 'Content' OfferingBrief instead. if self.contents == {}: for elem in self._capabilities.findall( ns('ContentMetadata/') + ns('ContentOfferingBrief')): cm = ContentMetadata(elem, self) self.contents[cm.id] = cm #exceptions self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')]
def __init__(self,url,xml, cookies): self.version='1.0.0' self.url = url self.cookies=cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version, self.cookies) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) # check for exceptions se = self._capabilities.find('ServiceException') if se is not None: err_message = str(se.text).strip() raise ServiceException(err_message, xml) #serviceIdentification metadata subelem=self._capabilities.find(ns('Service')) self.identification=ServiceIdentification(subelem) #serviceProvider metadata subelem=self._capabilities.find(ns('Service/')+ns('responsibleParty')) self.provider=ServiceProvider(subelem) #serviceOperations metadata self.operations=[] for elem in self._capabilities.find(ns('Capability/')+ns('Request'))[:]: self.operations.append(OperationMetadata(elem)) #serviceContents metadata self.contents={} for elem in self._capabilities.findall(ns('ContentMetadata/')+ns('CoverageOfferingBrief')): cm=ContentMetadata(elem, self) self.contents[cm.id]=cm #Some WCS servers (wrongly) advertise 'Content' OfferingBrief instead. if self.contents=={}: for elem in self._capabilities.findall(ns('ContentMetadata/')+ns('ContentOfferingBrief')): cm=ContentMetadata(elem, self) self.contents[cm.id]=cm #exceptions self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')]
def __init__(self, url, xml, cookies): self.version = "1.0.0" self.url = url self.cookies = cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version, self.cookies) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) # serviceIdentification metadata subelem = self._capabilities.find(ns("Service")) self.identification = ServiceIdentification(subelem) # serviceProvider metadata subelem = self._capabilities.find(ns("Service/") + ns("responsibleParty")) self.provider = ServiceProvider(subelem) # serviceOperations metadata self.operations = [] for elem in self._capabilities.find(ns("Capability/") + ns("Request"))[:]: self.operations.append(OperationMetadata(elem)) # serviceContents metadata self.contents = {} for elem in self._capabilities.findall(ns("ContentMetadata/") + ns("CoverageOfferingBrief")): cm = ContentMetadata(elem, self) self.contents[cm.id] = cm # Some WCS servers (wrongly) advertise 'Content' OfferingBrief instead. if self.contents == {}: for elem in self._capabilities.findall(ns("ContentMetadata/") + ns("ContentOfferingBrief")): cm = ContentMetadata(elem, self) self.contents[cm.id] = cm # exceptions self.exceptions = [f.text for f in self._capabilities.findall("Capability/Exception/Format")]
def __init__(self,url,xml, cookies): capabilities = etree.fromstring(xml) version = capabilities.get('version') self.version=version # sometimes a wcs 1.1.1 namespace is used ... capsnamespaces = capabilities.nsmap global WCS_NAMESPACE, OWS_NAMESPACE OWS_NAMESPACE = capsnamespaces['ows'] if 'wcs' in capsnamespaces: WCS_NAMESPACE = capsnamespaces['wcs'] else: # sometimes the WCS namespace is the default one, returned in the capsnamespaces with None as key... WCS_NAMESPACE = [v for k,v in capsnamespaces.items() if k is None][0] self.url = url self.cookies=cookies # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) #build metadata objects: #serviceIdentification metadata elem=self._capabilities.find(nspath('ServiceIdentification',OWS_NAMESPACE)) print elem self.identification=ServiceIdentification(elem,OWS_NAMESPACE) #serviceProvider elem=self._capabilities.find(nspath('ServiceProvider',OWS_NAMESPACE)) self.provider=ServiceProvider(elem,OWS_NAMESPACE) #serviceOperations self.operations = [] for elem in self._capabilities.findall(nspath('OperationsMetadata/Operation')): self.operations.append(Operation(elem)) # exceptions - ***********TO DO ************* self.exceptions = [f.text for f \ in self._capabilities.findall(nspath('Capability/Exception/Format'))] # serviceContents: our assumption is that services use a top-level layer # as a metadata organizer, nothing more. self.contents = {} top = self._capabilities.find(nspath('Contents/CoverageSummary', WCS_NAMESPACE)) for elem in self._capabilities.findall(nspath('Contents/CoverageSummary/CoverageSummary', WCS_NAMESPACE)): cm=ContentMetadata(elem, top, self) self.contents[cm.id]=cm if self.contents=={}: #non-hierarchical. top=None for elem in self._capabilities.findall(nspath('Contents/CoverageSummary', WCS_NAMESPACE)): #print elem cm=ContentMetadata(elem, top, self) #make the describeCoverage requests to populate the supported formats/crs attributes self.contents[cm.id]=cm