Ejemplo n.º 1
0
    def _buildMetadata(self, parse_remote_metadata=False):
        """set up capabilities metadata objects: """

        self.updateSequence = self._capabilities.attrib.get("updateSequence")

        # ServiceIdentification
        val = self._capabilities.find(
            nspath_eval("ows:ServiceIdentification", namespaces))
        if val is not None:
            self.identification = ServiceIdentification(
                val, self.owscommon.namespace)
        # ServiceProvider
        val = self._capabilities.find(
            nspath_eval("ows:ServiceProvider", namespaces))
        if val is not None:
            self.provider = ServiceProvider(val, self.owscommon.namespace)
        # ServiceOperations metadata
        self.operations = []
        for elem in self._capabilities.findall(
                nspath_eval("ows:OperationsMetadata/ows:Operation",
                            namespaces)):
            self.operations.append(
                OperationsMetadata(elem, self.owscommon.namespace))
        self.constraints = {}
        for elem in self._capabilities.findall(
                nspath_eval("ows:OperationsMetadata/ows:Constraint",
                            namespaces)):
            self.constraints[elem.attrib["name"]] = Constraint(
                elem, self.owscommon.namespace)
        self.parameters = {}
        for elem in self._capabilities.findall(
                nspath_eval("ows:OperationsMetadata/ows:Parameter",
                            namespaces)):
            self.parameters[elem.attrib["name"]] = Parameter(
                elem, self.owscommon.namespace)

        # FilterCapabilities
        val = self._capabilities.find(
            nspath_eval("ogc:Filter_Capabilities", namespaces))
        self.filters = FilterCapabilities(val)

        # serviceContents metadata: our assumption is that services use a top-level
        # layer as a metadata organizer, nothing more.

        self.contents = {}
        features = self._capabilities.findall(
            nspath_eval("wfs:FeatureTypeList/wfs:FeatureType", namespaces))
        if features is not None:
            for feature in features:
                cm = ContentMetadata(feature,
                                     parse_remote_metadata,
                                     headers=self.headers,
                                     auth=self.auth)
                self.contents[cm.id] = cm

        # exceptions
        self.exceptions = [
            f.text
            for f in self._capabilities.findall("Capability/Exception/Format")
        ]
Ejemplo n.º 2
0
    def _build_metadata(self):
        """
            Set up capabilities metadata objects
        """

        self.updateSequence = self._capabilities.attrib.get('updateSequence')

        # ows:ServiceIdentification metadata
        service_id_element = self._capabilities.find(nspath_eval('ows:ServiceIdentification', namespaces))
        self.identification = ows.ServiceIdentification(service_id_element)

        # ows:ServiceProvider metadata
        service_provider_element = self._capabilities.find(nspath_eval('ows:ServiceProvider', namespaces))
        self.provider = ows.ServiceProvider(service_provider_element)

        # ows:OperationsMetadata metadata
        self.operations=[]
        for elem in self._capabilities.findall(nspath_eval('ows:OperationsMetadata/ows:Operation', namespaces)):
            self.operations.append(ows.OperationsMetadata(elem))

        # sos:FilterCapabilities
        filters = self._capabilities.find(nspath_eval('sos:Filter_Capabilities', namespaces))
        if filters is not None:
            self.filters = FilterCapabilities(filters)
        else:
            self.filters = None

        # sos:Contents metadata
        self.contents = {}
        self.offerings = []
        for offering in self._capabilities.findall(nspath_eval('sos:Contents/sos:ObservationOfferingList/sos:ObservationOffering', namespaces)):
            off = SosObservationOffering(offering)
            self.contents[off.id] = off
            self.offerings.append(off)