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

        # Test basic point
        ps = "POINT (1.0 2.0)"
        po = Point.from_wkt(ps)
        self.assertEqual(po.x, 1.0)
        self.assertEqual(po.y, 2.0)

        # Test bad point strings
        bps = "POIN (1.0 2.0)"
        with self.assertRaises(ValueError):
            bpo = Point.from_wkt(bps)
        bps = "POINT (1.0 2.0 3.0 4.0 5.0"
        with self.assertRaises(ValueError):
            bpo = Point.from_wkt(bps)

        # Points get truncated automatically
        tps = "POINT (9.0 2.0 3.0 4.0 5.0)"
        tpo = Point.from_wkt(tps)
        self.assertEqual(tpo.x, 9.0)
        self.assertEqual(tpo.y, 2.0)

        # Test point with NAN
        ps = "POINT (NAN NAN)"
        po = Point.from_wkt(ps)
        self.assertTrue(math.isnan(po.x))
        self.assertTrue(math.isnan(po.y))
    def test_point_parse(self):
        """
        This test exercises the parsing logic our POINT WKT object
        @since 1.2
        @jira_ticket PYTHON-641
        @test_category dse geometric
        @expected_result We should be able to form POINT objects from properly formatted WKT strings
        """

        # Test basic point
        ps = "POINT (1.0 2.0)"
        po = Point.from_wkt(ps)
        self.assertEqual(po.x, 1.0)
        self.assertEqual(po.y, 2.0)

        # Test bad point strings
        bps = "POIN (1.0 2.0)"
        with self.assertRaises(ValueError):
            bpo = Point.from_wkt(bps)
        bps = "POINT (1.0 2.0 3.0 4.0 5.0"
        with self.assertRaises(ValueError):
            bpo = Point.from_wkt(bps)

        # Points get truncated automatically
        tps = "POINT (9.0 2.0 3.0 4.0 5.0)"
        tpo = Point.from_wkt(tps)
        self.assertEqual(tpo.x, 9.0)
        self.assertEqual(tpo.y, 2.0)

        # Test point with NAN
        ps = "POINT (NAN NAN)"
        po = Point.from_wkt(ps)
        self.assertTrue(math.isnan(po.x))
        self.assertTrue(math.isnan(po.y))
Beispiel #3
0
 def objectify(cls, v, _):
     return Point.from_wkt(v)
 def deserialize(cls, value):
     return Point.from_wkt(value)