Esempio n. 1
0
    def _parse_area(cls, src_elem):
        """
        :param src_elem:
            :class:`lxml.etree._Element` instance representing a source.
        :returns:
            Fully populated :class:`openquake.nrmllib.models.AreaSource`
            object.
        """
        area = models.AreaSource()
        cls._set_common_attrs(area, src_elem)

        area_geom = models.AreaGeometry()
        area.geometry = area_geom

        [gml_pos_list] = _xpath(src_elem, './/gml:posList')
        coords = gml_pos_list.text.split()
        # Area source polygon geometries are always 2-dimensional and on the
        # Earth's surface (depth == 0.0).
        area_geom.wkt = utils.coords_to_poly_wkt(coords, 2)

        area_geom.upper_seismo_depth = float(
            _xpath(src_elem, './/nrml:upperSeismoDepth')[0].text)
        area_geom.lower_seismo_depth = float(
            _xpath(src_elem, './/nrml:lowerSeismoDepth')[0].text)

        area.mfd = cls._parse_mfd(src_elem)
        area.nodal_plane_dist = cls._parse_nodal_plane_dist(src_elem)
        area.hypo_depth_dist = cls._parse_hypo_depth_dist(src_elem)

        return area
Esempio n. 2
0
    def _parse_area(cls, src_elem):
        """
        :param src_elem:
            :class:`lxml.etree._Element` instance representing a source.
        :returns:
            Fully populated :class:`openquake.nrmllib.models.AreaSource`
            object.
        """
        area = models.AreaSource()
        cls._set_common_attrs(area, src_elem)

        area_geom = models.AreaGeometry()
        area.geometry = area_geom

        [gml_pos_list] = _xpath(src_elem, './/gml:posList')
        coords = gml_pos_list.text.split()
        # Area source polygon geometries are always 2-dimensional and on the
        # Earth's surface (depth == 0.0).
        area_geom.wkt = utils.coords_to_poly_wkt(coords, 2)

        area_geom.upper_seismo_depth = float(
            _xpath(src_elem, './/nrml:upperSeismoDepth')[0].text)
        area_geom.lower_seismo_depth = float(
            _xpath(src_elem, './/nrml:lowerSeismoDepth')[0].text)

        area.mfd = cls._parse_mfd(src_elem)
        area.nodal_plane_dist = cls._parse_nodal_plane_dist(src_elem)
        area.hypo_depth_dist = cls._parse_hypo_depth_dist(src_elem)

        return area
Esempio n. 3
0
    def test_coords_to_poly_wkt_2d(self):
        expected = 'POLYGON((1.0 1.0, 2.0 2.0, 3.0 3.0, 1.0 1.0))'

        coords = [1.0, '1.0', '2.0', 2.0, 3.0, '3.0']

        actual = utils.coords_to_poly_wkt(coords, 2)

        self.assertEqual(expected, actual)
Esempio n. 4
0
    def test_coords_to_poly_wkt_3d(self):
        expected = "POLYGON((1.0 1.0 0.1, 2.0 2.0 0.2, 3.0 3.0 0.3, 1.0 1.0 0.1))"

        coords = [1.0, "1.0", 0.1, "2.0", 2.0, "0.2", 3.0, "3.0", 0.3]

        actual = utils.coords_to_poly_wkt(coords, 3)

        self.assertEqual(expected, actual)
Esempio n. 5
0
    def test_coords_to_poly_wkt_2d(self):
        expected = "POLYGON((1.0 1.0, 2.0 2.0, 3.0 3.0, 1.0 1.0))"

        coords = [1.0, "1.0", "2.0", 2.0, 3.0, "3.0"]

        actual = utils.coords_to_poly_wkt(coords, 2)

        self.assertEqual(expected, actual)
Esempio n. 6
0
    def test_coords_to_poly_wkt_2d(self):
        expected = 'POLYGON((1.0 1.0, 2.0 2.0, 3.0 3.0, 1.0 1.0))'

        coords = [1.0, '1.0', '2.0', 2.0, 3.0, '3.0']

        actual = utils.coords_to_poly_wkt(coords, 2)

        self.assertEqual(expected, actual)
Esempio n. 7
0
    def test_coords_to_poly_wkt_3d(self):
        expected = (
            'POLYGON((1.0 1.0 0.1, 2.0 2.0 0.2, 3.0 3.0 0.3, 1.0 1.0 0.1))')

        coords = [1.0, '1.0', 0.1, '2.0', 2.0, '0.2', 3.0, '3.0', 0.3]

        actual = utils.coords_to_poly_wkt(coords, 3)

        self.assertEqual(expected, actual)
Esempio n. 8
0
    def test_coords_to_poly_wkt_3d(self):
        expected = (
            'POLYGON((1.0 1.0 0.1, 2.0 2.0 0.2, 3.0 3.0 0.3, 1.0 1.0 0.1))')

        coords = [1.0, '1.0', 0.1, '2.0', 2.0, '0.2', 3.0, '3.0', 0.3]

        actual = utils.coords_to_poly_wkt(coords, 3)

        self.assertEqual(expected, actual)