Example #1
0
    def _parse_complex_geometry(cls, src_elem):
        """
        :param src_elem:
            :class:`lxml.etree._Element` instance representing a geometry.
        :returns:
            Fully populated
            :class:`openquake.nrmllib.models.ComplexFaultGeometry` object.
        """
        complex_geom = models.ComplexFaultGeometry()

        [top_edge] = _xpath(src_elem, './/nrml:faultTopEdge//gml:posList')
        top_coords = top_edge.text.split()
        complex_geom.top_edge_wkt = utils.coords_to_linestr_wkt(top_coords, 3)

        [bottom_edge] = _xpath(src_elem,
                               './/nrml:faultBottomEdge//gml:posList')
        bottom_coords = bottom_edge.text.split()
        complex_geom.bottom_edge_wkt = utils.coords_to_linestr_wkt(
            bottom_coords, 3)

        # Optional itermediate edges:
        int_edges = _xpath(src_elem, './/nrml:intermediateEdge//gml:posList')
        for edge in int_edges:
            coords = edge.text.split()
            complex_geom.int_edges.append(
                utils.coords_to_linestr_wkt(coords, 3))

        return complex_geom
Example #2
0
    def _parse_complex_geometry(cls, src_elem):
        """
        :param src_elem:
            :class:`lxml.etree._Element` instance representing a geometry.
        :returns:
            Fully populated
            :class:`openquake.nrmllib.models.ComplexFaultGeometry` object.
        """
        complex_geom = models.ComplexFaultGeometry()

        [top_edge] = _xpath(src_elem, './/nrml:faultTopEdge//gml:posList')
        top_coords = top_edge.text.split()
        complex_geom.top_edge_wkt = utils.coords_to_linestr_wkt(top_coords, 3)

        [bottom_edge] = _xpath(
            src_elem, './/nrml:faultBottomEdge//gml:posList')
        bottom_coords = bottom_edge.text.split()
        complex_geom.bottom_edge_wkt = utils.coords_to_linestr_wkt(
            bottom_coords, 3)

        # Optional itermediate edges:
        int_edges = _xpath(src_elem, './/nrml:intermediateEdge//gml:posList')
        for edge in int_edges:
            coords = edge.text.split()
            complex_geom.int_edges.append(
                utils.coords_to_linestr_wkt(coords, 3))

        return complex_geom
Example #3
0
    def test_coords_to_linestr_wkt_3d(self):
        expected = 'LINESTRING(1.0 1.0 2.0, 2.0 3.0 3.0)'

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

        actual = utils.coords_to_linestr_wkt(coords, 3)

        self.assertEqual(expected, actual)
Example #4
0
    def test_coords_to_linestr_wkt_3d(self):
        expected = "LINESTRING(1.0 1.0 2.0, 2.0 3.0 3.0)"

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

        actual = utils.coords_to_linestr_wkt(coords, 3)

        self.assertEqual(expected, actual)
Example #5
0
    def test_coords_to_linestr_wkt_3d(self):
        expected = 'LINESTRING(1.0 1.0 2.0, 2.0 3.0 3.0)'

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

        actual = utils.coords_to_linestr_wkt(coords, 3)

        self.assertEqual(expected, actual)
Example #6
0
    def test_coords_to_linestr_wkt_2d(self):
        expected = 'LINESTRING(1.0 1.0, 2.0 2.0, 3.0 3.0)'

        # Mixed input types for robustness testing
        coords = [1.0, '1.0', '2.0', 2.0, 3.0, '3.0']

        actual = utils.coords_to_linestr_wkt(coords, 2)

        self.assertEqual(expected, actual)
Example #7
0
    def test_coords_to_linestr_wkt_2d(self):
        expected = "LINESTRING(1.0 1.0, 2.0 2.0, 3.0 3.0)"

        # Mixed input types for robustness testing
        coords = [1.0, "1.0", "2.0", 2.0, 3.0, "3.0"]

        actual = utils.coords_to_linestr_wkt(coords, 2)

        self.assertEqual(expected, actual)
Example #8
0
    def test_coords_to_linestr_wkt_2d(self):
        expected = 'LINESTRING(1.0 1.0, 2.0 2.0, 3.0 3.0)'

        # Mixed input types for robustness testing
        coords = [1.0, '1.0', '2.0', 2.0, 3.0, '3.0']

        actual = utils.coords_to_linestr_wkt(coords, 2)

        self.assertEqual(expected, actual)
Example #9
0
    def _parse_simple_geometry(cls, src_elem):
        """
        :param src_elem:
            :class:`lxml.etree._Element` instance representing a geometry.
        :returns:
            Fully populated
            :class:`openquake.nrmllib.models.SimpleFaultGeometry` object.
        """
        simple_geom = models.SimpleFaultGeometry()

        [gml_pos_list] = _xpath(src_elem, './/gml:posList')
        coords = gml_pos_list.text.split()
        simple_geom.wkt = utils.coords_to_linestr_wkt(coords, 2)

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

        return simple_geom
Example #10
0
    def _parse_simple_geometry(cls, src_elem):
        """
        :param src_elem:
            :class:`lxml.etree._Element` instance representing a geometry.
        :returns:
            Fully populated
            :class:`openquake.nrmllib.models.SimpleFaultGeometry` object.
        """
        simple_geom = models.SimpleFaultGeometry()

        [gml_pos_list] = _xpath(src_elem, './/gml:posList')
        coords = gml_pos_list.text.split()
        simple_geom.wkt = utils.coords_to_linestr_wkt(coords, 2)

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

        return simple_geom