コード例 #1
0
ファイル: parsers.py プロジェクト: gvallarelli/NRML
    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
コード例 #2
0
ファイル: parsers.py プロジェクト: MaksimEritov/oq-nrmllib
    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
コード例 #3
0
ファイル: utils_test.py プロジェクト: larsbutler/oq-nrmllib
    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)
コード例 #4
0
ファイル: utils_test.py プロジェクト: GEMStudents/oq-nrmllib
    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)
コード例 #5
0
ファイル: utils_test.py プロジェクト: GEMStudents/oq-nrmllib
    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)
コード例 #6
0
ファイル: utils_test.py プロジェクト: gvallarelli/NRML
    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)
コード例 #7
0
ファイル: utils_test.py プロジェクト: larsbutler/oq-nrmllib
    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)
コード例 #8
0
ファイル: utils_test.py プロジェクト: gvallarelli/NRML
    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)