def test_polygonize_line_square_cap_style(): diag = 1 / math.sqrt(2) line = GeoVector(LineString([(0, 0), (1, 1)])) expected_result = GeoVector( Polygon([(1, 1 + diag), (1 + diag, 1), (0, -diag), (-diag, 0)])) result = line.polygonize(1, cap_style_line=CAP_STYLE.square) assert result == expected_result
def test_polygonize_point(): point = GeoVector(Point([0, 0])) expected_bounds = (-0.5, -0.5, 0.5, 0.5) expected_area = math.pi * 0.5**2 result = point.polygonize(1) result_shape = result.get_shape(result.crs) assert result_shape.bounds == expected_bounds assert result_shape.area == approx(expected_area, rel=1e-2)
def test_polygonize_line_square_cap_style(): diag = 1 / math.sqrt(2) line = GeoVector(LineString([(0, 0), (1, 1)])) expected_result = GeoVector( Polygon([(1, 1 + diag), (1 + diag, 1), (0, -diag), (-diag, 0)])) result = line.polygonize(1, cap_style_line=CAP_STYLE.square) # Don't use result == expected_result as topology might be different assert result.equals(expected_result)
def test_polygonize_line(): diag = 1 / math.sqrt(2) line = GeoVector(LineString([(0, 0), (1, 1)])) expected_result = GeoVector( Polygon([(1 - diag / 2, 1 + diag / 2), (1 + diag / 2, 1 - diag / 2), (diag / 2, -diag / 2), (-diag / 2, diag / 2)])) result = line.polygonize(1) assert result == expected_result