def get_coverages(self):
        cov_elems = get_elements("ContentMetadata/CoverageOffering", self.root,
                                 namespace=self.xmlns)
        coverages = []
        for cov_elem in cov_elems:
            name = get_elements_text("name", cov_elem, single_elem=True,
                                     namespace=self.xmlns)
            label = get_elements_text("label", cov_elem, single_elem=True,
                                      namespace=self.xmlns)
            bbox = self._get_bbox(cov_elem, namespace=self.xmlns)
            coverages.append(Coverage(name=name, label=label, bbox=bbox))

        return CoverageList(coverages)
    def _get_bbox(self, root, namespace=None):
        """
        Extact the bounding spatial values and return in a list.

        returns:
            list

        """
        bbox_lower = get_elements_text("boundedBy/Envelope/lowerCorner",
                                       root, single_elem=True,
                                       namespace=namespace)
        bbox_upper = get_elements_text("boundedBy/Envelope/upperCorner",
                                       root, single_elem=True,
                                       namespace=namespace)
        return self._bbox_as_list(bbox_lower, bbox_upper)
    def _get_values(self, root, namespace=None):
        """
        Values are given under the element path "values/singleValue". Given a root
        element, extract all values and return in list.

        Args:

        * root: xml.etree.ElementTree.Element
            The element inside which the values are nested.

        Kwargs:

        * single_elem: boolean
            If True, this raises an error if more than one element is found. It
            also changes the return type to a single value (instead of list).

        * namespace: string or None
            The xml namespace for the value element.

        returns:
            list of strings or string (if single_elem=True)


        """
        return get_elements_text("values/singleValue", root,
                                 namespace=namespace)
    def _get_axis_describer_values(self, name, root, namespace=None):
        """
        Get all elements that come under the AxisDescription element;
        e.g. initialisation, forecast time, elevation.

        Args:

        * name: string
            The name of the axis describer.

        * root: xml.etree.ElementTree.Element
            The element inside which the values are nested.

        Kwargs:

        * namespace: string or None
            The xml namespace for the AxisDescription element.

        """
        axis_elems = get_elements("rangeSet/RangeSet/axisDescription/"\
                                  "AxisDescription",
                                  root, namespace=namespace)
        for axis_elem in axis_elems:
            elem_name = get_elements_text("name", root=axis_elem,
                                          single_elem=True,
                                          namespace=namespace)
            if elem_name == name:
                return self._get_values(axis_elem, namespace=namespace)
        return []
 def get_coverages(self):
     cov_ids_elem = get_elements("coverageIdList", self.root,
                                 single_elem=True,
                                 namespace=self.metocean)
     cov_ids = get_elements_text("CoverageSummary/CoverageId", cov_ids_elem,
                                 namespace=self.wcs)
     return CoverageList([Coverage(cov_id) for cov_id in cov_ids])
 def _get_reference_times(self, root):
     ref_time_elem = get_elements("referenceTimeList/ReferenceTime",
                                  root,
                                  single_elem=True,
                                  namespace=self.metocean)
     return get_elements_text("timePosition",
                              ref_time_elem,
                              namespace=self.gml)
 def get_coverage_ids(self):
     contents_elem = get_elements("Contents",
                                  self.root,
                                  single_elem=True,
                                  namespace=self.wcs)
     return get_elements_text("CoverageSummary/CoverageId",
                              contents_elem,
                              namespace=self.wcs)
    def _get_bbox(self, root, namespace=None):
        """
        Extact the bounding spatial values and return in a list.

        returns:
            list

        """
        bbox_lower = get_elements_text("boundedBy/Envelope/lowerCorner",
                                       root,
                                       single_elem=True,
                                       namespace=namespace)
        bbox_upper = get_elements_text("boundedBy/Envelope/upperCorner",
                                       root,
                                       single_elem=True,
                                       namespace=namespace)
        return self._bbox_as_list(bbox_lower, bbox_upper)
 def get_ref_time(self):
     ref_time_elem = get_elements("referenceTime",
                                  self.root,
                                  single_elem=True,
                                  namespace=self.metocean)
     return get_elements_text("TimeInstant/timePosition",
                              ref_time_elem,
                              namespace=self.gml)
 def get_coverages(self):
     cov_ids_elem = get_elements("coverageIdList",
                                 self.root,
                                 single_elem=True,
                                 namespace=self.metocean)
     cov_ids = get_elements_text("CoverageSummary/CoverageId",
                                 cov_ids_elem,
                                 namespace=self.wcs)
     return CoverageList([Coverage(cov_id) for cov_id in cov_ids])
    def test_single_elem(self):
        # If single_elem true, a single string (not a list) should be
        # returned.
        found_text = xml_reader.get_elements_text("elemTwo/name", xml_simple_root,
                                       single_elem=True)
        self.assertEqual(found_text, "Element 2")

        # An error should be raised if more than one are found.
        self.assertRaises(UserWarning, xml_reader.get_elements_text,
                          "elemTwo/values/singleValue", xml_simple_root,
                          single_elem=True)
예제 #12
0
 def get_ref_time(self):
     extension_elem = get_elements("metadata/Extension", self.root,
                                   single_elem=True, namespace=self.gmlcov)
     source_obs_elem = get_elements("extensionProperty/"\
                                    "MetOceanCoverageMetadata/"\
                                    "sourceObservationProperty/"\
                                    "SourceObservation", extension_elem,
                                    single_elem=True,
                                    namespace=self.metocean)
     value_elem = get_elements("parameter/NamedValue/value",
                               source_obs_elem, single_elem=True,
                               namespace=self.om)
     return get_elements_text("TimeInstant/timePosition", value_elem,
                              single_elem=True, namespace=self.gml)
 def get_ref_time(self):
     extension_elem = get_elements("metadata/Extension",
                                   self.root,
                                   single_elem=True,
                                   namespace=self.gmlcov)
     source_obs_elem = get_elements("extensionProperty/"\
                                    "MetOceanCoverageMetadata/"\
                                    "sourceObservationProperty/"\
                                    "SourceObservation", extension_elem,
                                    single_elem=True,
                                    namespace=self.metocean)
     value_elem = get_elements("parameter/NamedValue/value",
                               source_obs_elem,
                               single_elem=True,
                               namespace=self.om)
     return get_elements_text("TimeInstant/timePosition",
                              value_elem,
                              single_elem=True,
                              namespace=self.gml)
예제 #14
0
 def get_label(self):
     return get_elements_text("label", self.root, single_elem=True,
                               namespace=self.xmlns)
예제 #15
0
 def get_name(self):
     return get_elements_text("name", self.root, single_elem=True,
                              namespace=self.xmlns)
예제 #16
0
 def get_coverage_ids(self):
     contents_elem = get_elements("Contents", self.root, single_elem=True,
                                  namespace=self.wcs)
     return get_elements_text("CoverageSummary/CoverageId", contents_elem,
                              namespace=self.wcs)
예제 #17
0
 def _get_collection_id(self, col_elem):
     return get_elements_text("coverageCollectionId", col_elem,
                              single_elem=True,
                              namespace=self.metocean)
예제 #18
0
 def get_coverage_name(self):
     return get_elements_text("CoverageId", self.root, single_elem=True,
                              namespace=self.wcs)
 def get_coverage_name(self):
     return get_elements_text("CoverageId",
                              self.root,
                              single_elem=True,
                              namespace=self.wcs)
예제 #20
0
 def get_collection_id(self):
     return get_elements_text("coverageCollectionId", self.root,
                              single_elem=True, namespace=self.metocean)
예제 #21
0
 def get_CRSs(self):
     return get_elements_text("supportedCRSs/requestCRSs", self.root,
                              namespace=self.xmlns)
예제 #22
0
 def get_interpolations(self):
     return get_elements_text("supportedInterpolations/interpolationMethod",
                              self.root, namespace=self.xmlns)
 def _get_collection_id(self, col_elem):
     return get_elements_text("coverageCollectionId",
                              col_elem,
                              single_elem=True,
                              namespace=self.metocean)
예제 #24
0
 def _get_reference_times(self, root):
     ref_time_elem = get_elements("referenceTimeList/ReferenceTime",
                                  root, single_elem=True,
                                  namespace=self.metocean)
     return get_elements_text("timePosition", ref_time_elem,
                              namespace=self.gml)
예제 #25
0
 def get_formats(self):
     return get_elements_text("supportedFormats/formats", self.root,
                              namespace=self.xmlns)
예제 #26
0
 def get_ref_time(self):
     ref_time_elem = get_elements("referenceTime", self.root,
                                  single_elem=True,
                                  namespace=self.metocean)
     return get_elements_text("TimeInstant/timePosition", ref_time_elem,
                              namespace=self.gml)
 def get_collection_id(self):
     return get_elements_text("coverageCollectionId",
                              self.root,
                              single_elem=True,
                              namespace=self.metocean)
 def test_simple_text(self):
     found_text = xml_reader.get_elements_text("elemTwo/name", xml_simple_root)
     self.assertEqual(found_text[0], "Element 2")