def test_properties_PolyInput(self): out_poly = ((0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0)) pi = PolyInput(out_poly) outside_poly = ((1, 2, 0), (5, 2, 0), (5, 9, 0), (1, 9, 0)) inside_polys = (((3, 3, 0), (2.5, 4, 0), (2, 3, 0)), ((4, 8, 0), (3, 7, 0), (2, 8, 0))) poly_corners = (0, 1, 2, 3) pts = ((1, 2, 3), (4, 5, 6), (0, 5, 7)) size_func = InterpLinear(pts) elev_func = InterpIdw(pts) seed_points = ((3, 3, 0), (4, 3, 0), (4, 8, 0), (3, 8, 0)) relaxation_method = "spring_relaxation" self.assertEqual(4, len(pi.outside_polygon)) pi.outside_polygon = outside_poly self.assertArraysEqual(outside_poly, pi.outside_polygon) self.assertEqual(0, len(pi.inside_polygons)) pi.inside_polygons = inside_polys self.assertInsidePolysEqual(inside_polys, pi.inside_polygons) self.assertEqual(0, len(pi.patch_polygon_corners)) pi.patch_polygon_corners = poly_corners self.assertArraysEqual(poly_corners, pi.patch_polygon_corners) self.assertEqual(1.0, pi.bias) pi.bias = 0.3 self.assertEqual(0.3, pi.bias) self.assertEqual(None, pi.size_function) pi.size_function = size_func self.assertEqual(size_func.to_string(), pi.size_function.to_string()) self.assertEqual(None, pi.elev_function) pi.elev_function = elev_func self.assertEqual(elev_func.to_string(), pi.elev_function.to_string()) self.assertEqual(-1, pi.const_size_bias) pi.const_size_bias = 4.0 self.assertEqual(4.0, pi.const_size_bias) self.assertEqual(-1, pi.const_size_function) pi.const_size_function = 1.2 self.assertEqual(1.2, pi.const_size_function) self.assertEqual(False, pi.remove_internal_four_triangle_pts) pi.remove_internal_four_triangle_pts = True self.assertEqual(True, pi.remove_internal_four_triangle_pts) self.assertEqual(0, len(pi.seed_points)) pi.seed_points = seed_points self.assertArraysEqual(seed_points, pi.seed_points) self.assertEqual("", pi.relaxation_method) pi.relaxation_method = relaxation_method self.assertEqual(relaxation_method, pi.relaxation_method)
def test_creating_PolyInput(self): outside_poly = ((1, 2, 0), (5, 2, 0), (5, 9, 0), (1, 9, 0)) inside_polys = (((3, 3, 0), (2.5, 4, 0), (2, 3, 0)), ((4, 8, 0), (3, 7, 0), (2, 8, 0))) poly_corners = (0, 1, 2, 3) bias = 3.14159 pts = ((1, 0, 0), (10, 0, 0), (10, 10, 0)) size_func = InterpLinear(pts) elev_func = InterpIdw(pts) pi = PolyInput(outside_polygon=outside_poly, inside_polygons=inside_polys, bias=bias, size_function=size_func, patch_polygon_corners=poly_corners, elev_function=elev_func) self.assertIsInstance(pi, PolyInput) self.assertArraysEqual(outside_poly, pi.outside_polygon) self.assertInsidePolysEqual(inside_polys, pi.inside_polygons) self.assertEqual(bias, pi.bias) self.assertEqual(size_func.to_string(), pi.size_function.to_string()) self.assertEqual(elev_func.to_string(), pi.elev_function.to_string()) self.assertEqual(-1, pi.const_size_bias) self.assertEqual(-1, pi.const_size_function) self.assertEqual(False, pi.remove_internal_four_triangle_pts)