Exemple #1
0
    def test_closed(self):
        pl = Polyline(init_points=[(1, 0), (1, 1), (0, 2)])
        self.assertFalse(pl.isClosed())
        pl.addPoint(1, 0)
        self.assertEqual(4, len(pl))
        self.assertTrue(pl.isClosed())

        pl = Polyline(init_points=[(1, 0), (1, 1), (0, 2)])
        self.assertFalse(pl.isClosed())
        pl.assertClosed()
        self.assertEqual(4, len(pl))
        self.assertTrue(pl.isClosed())
Exemple #2
0
    def test_extend_to_edge(self):
        bound = Polyline(init_points=[(0, 0), (1, 0), (1, 1), (0, 1)])
        l1 = Polyline(init_points=[(-1, 0.5), (0.5, 0.5)])
        l2 = Polyline(init_points=[(0.25, 0.25), (0.75, 0.75)])

        # Bound is not closed
        with self.assertRaises(AssertionError):
            GeometryTools.extendToEdge(bound, l1)

        bound.assertClosed()
        # l1 is not fully contained in bound
        with self.assertRaises(ValueError):
            GeometryTools.extendToEdge(bound, l1)

        l3 = GeometryTools.extendToEdge(bound, l2)
        self.assertEqual(l3[0], (0.00, 0.00))
        self.assertEqual(l3[1], (0.25, 0.25))
        self.assertEqual(l3[2], (0.75, 0.75))
        self.assertEqual(l3[3], (1.00, 1.00))
        self.assertEqual(len(l3), 4)