コード例 #1
0
def test_line_cx_selection(gp_line, rect):
    x0, y0, x1, y1 = rect
    for xslice in get_slices(x0, x1):
        for yslice in get_slices(y0, y1):
            expected = LineArray.from_geopandas(gp_line.cx[xslice, yslice])
            result = LineArray.from_geopandas(gp_line).cx[xslice, yslice]
            assert all(expected == result)
コード例 #2
0
def test_line_intersects_rect(gp_line, rect):
    sg_rect = sg.box(*rect)

    expected = gp_line.intersects(sg_rect)
    lines = LineArray.from_geopandas(gp_line)

    # Test LineArray.intersects_rect
    result = lines.intersects_bounds(rect)
    np.testing.assert_equal(result, expected)

    # Test LineArray.intersects_rect with inds
    inds = np.flipud(np.arange(0, len(lines)))
    result = lines.intersects_bounds(rect, inds)
    np.testing.assert_equal(result, np.flipud(expected))

    # Test Line.intersects_rect
    result = np.array([line.intersects_bounds(rect) for line in lines])
    np.testing.assert_equal(result, expected)