def test_line_parse(self):
        """
        This test exercises the parsing logic our LINESTRING WKT object
        @since 1.2
        @jira_ticket PYTHON-641
        @test_category dse geometric
        @expected_result We should be able to form LINESTRINGS objects from properly formatted WKT strings
        """

        # Test simple line string
        ls = "LINESTRING (1.0 2.0, 3.0 4.0, 5.0 6.0)"
        lo = LineString.from_wkt(ls)
        lo_expected_cords = ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0))
        self.assertEqual(lo.coords, lo_expected_cords)

        # Test very long line string
        long_ls = self._construct_line_string(10000)
        long_lo = LineString.from_wkt(long_ls)
        self.assertEqual(len(long_lo.coords), 10000)
        self.assertEqual(long_lo.coords,
                         self._construct_line_string_expected_cords(10000))

        # Test line string with negative numbers
        ls = "LINESTRING (-1.3 1.2, 3.23 -4.54, 1.34 -9.26)"
        lo = LineString.from_wkt(ls)
        lo_expected_cords = ((-1.3, 1.2), (3.23, -4.54), (1.34, -9.26))
        self.assertEqual(lo.coords, lo_expected_cords)

        # Test bad line strings
        bls = "LINESTRIN (1.0 2.0, 3.0 4.0, 5.0 6.0)"
        with self.assertRaises(ValueError):
            blo = LineString.from_wkt(bls)
        bls = "LINESTRING (1.0 2.0 3.0 4.0 5.0"
        with self.assertRaises(ValueError):
            blo = LineString.from_wkt(bls)

        # Test with NAN
        ls = "LINESTRING (NAN NAN, NAN NAN)"
        lo = LineString.from_wkt(ls)
        self.assertEqual(len(lo.coords), 2)
        for cords in lo.coords:
            for cord in cords:
                self.assertTrue(math.isnan(cord))
Exemplo n.º 2
0
 def deserialize(cls, value, reader=None):
     return LineString.from_wkt(value)