def test_land_cross(
    pt1,
    pt2,
    res1,
    res2,
    ):
    """
    try a single LE that should be crossing land
    """

    # a very simple raster:

    (w, h) = (20, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny vertical line:

    raster[10, :] = 1

    # pt1 = ( 5, 5)
    # pt2 = (15, 5)

    result = find_first_pixel(raster, pt1, pt2)

    print result
    assert result[0] == res1
    assert result[1] == res2
def test_land_cross_diag(
    pt1,
    pt2,
    prev_pt,
    hit_pt,
    ):
    """
    try a single LE that should be crossing land
    with a diagonal land line..
    """

    # a very simple raster:

    (w, h) = (10, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny digonal line part way:

    raster[0, 0] = 1
    raster[1, 1] = 1
    raster[2, 2] = 1
    raster[3, 3] = 1
    raster[4, 4] = 1

    result = find_first_pixel(raster, pt1, pt2)

    print pt1, pt2, prev_pt, hit_pt
    print result
    assert result[0] == prev_pt
    assert result[1] == hit_pt
def test_points_outside_grid(
    pt1,
    pt2,
    prev_pt,
    hit_pt,
    ):
    """
    try a single LE that should be crossing land
    with points starting or ending outside grid
    """

    # a very simple raster:

    (w, h) = (20, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny vertical line:

    raster[10, :] = 1

    result = find_first_pixel(raster, pt1, pt2)

    print pt1, pt2, prev_pt, hit_pt
    print result
    assert result[0] == prev_pt
    assert result[1] == hit_pt
Beispiel #4
0
def test_points_outside_grid(
    pt1,
    pt2,
    prev_pt,
    hit_pt,
):
    """
    try a single LE that should be crossing land
    with points starting or ending outside grid
    """

    # a very simple raster:

    (w, h) = (20, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny vertical line:

    raster[10, :] = 1

    result = find_first_pixel(raster, pt1, pt2)

    print pt1, pt2, prev_pt, hit_pt
    print result
    assert result[0] == prev_pt
    assert result[1] == hit_pt
Beispiel #5
0
def test_land_cross(
    pt1,
    pt2,
    res1,
    res2,
):
    """
    try a single LE that should be crossing land
    """

    # a very simple raster:

    (w, h) = (20, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny vertical line:

    raster[10, :] = 1

    # pt1 = ( 5, 5)
    # pt2 = (15, 5)

    result = find_first_pixel(raster, pt1, pt2)

    print result
    assert result[0] == res1
    assert result[1] == res2
Beispiel #6
0
def test_land_cross_diag(
    pt1,
    pt2,
    prev_pt,
    hit_pt,
):
    """
    try a single LE that should be crossing land
    with a diagonal land line..
    """

    # a very simple raster:

    (w, h) = (10, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny digonal line part way:

    raster[0, 0] = 1
    raster[1, 1] = 1
    raster[2, 2] = 1
    raster[3, 3] = 1
    raster[4, 4] = 1

    result = find_first_pixel(raster, pt1, pt2)

    print pt1, pt2, prev_pt, hit_pt
    print result
    assert result[0] == prev_pt
    assert result[1] == hit_pt
Beispiel #7
0
def test_off_to_off(pt1, pt2):
    """test  movement that is entirely off the raster"""
    # a very simple raster -- no land
    (w, h) = (20, 20)
    raster = np.zeros((w, h), dtype=np.uint8)
    result = find_first_pixel(raster, pt1, pt2)

    assert result is None
Beispiel #8
0
def test_off_to_off(pt1, pt2):
    """test  movement that is entirely off the raster"""
    # a very simple raster -- no land
    (w, h) = (20, 20)
    raster = np.zeros((w, h), dtype=np.uint8)
    result = find_first_pixel(raster, pt1, pt2)

    assert result is None
Beispiel #9
0
def test_way_off(pt2):
    # a very simple raster -- no land
    (w, h) = (20, 20)
    raster = np.zeros((w, h), dtype=np.uint8)
    # a little block in the middle
    # raster[8:12, 8:12] = 1
    pt1 = (10, 10)
    print pt1
    print pt2
    result = find_first_pixel(raster, pt1, pt2)

    assert result is None
Beispiel #10
0
def test_way_off(pt2):
    # a very simple raster -- no land
    (w, h) = (20, 20)
    raster = np.zeros((w, h), dtype=np.uint8)
    # a little block in the middle
    # raster[8:12, 8:12] = 1
    pt1 = (10, 10)
    print pt1
    print pt2
    result = find_first_pixel(raster, pt1, pt2)

    assert result is None
def test_land_not_cross(pt1, pt2):
    """
    try a single LE that should be crossing land
    """

    # a very simple raster:

    (w, h) = (20, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny vertical line:

    raster[10, :] = 1

    result = find_first_pixel(raster, pt1, pt2)

    assert result is None
Beispiel #12
0
def test_land_not_cross(pt1, pt2):
    """
    try a single LE that should be crossing land
    """

    # a very simple raster:

    (w, h) = (20, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny vertical line:

    raster[10, :] = 1

    result = find_first_pixel(raster, pt1, pt2)

    assert result is None
    (w, h) = (10, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny diagonal line part way:

    raster[0, 0] = 1
    raster[1, 1] = 1
    raster[2, 2] = 1
    raster[3, 3] = 1
    raster[4, 4] = 1

    pt1 = (0, 8)
    pt2 = (9, 0)

    print 'checking:'
    print pt1
    print pt2
    result = find_first_pixel(raster, pt1, pt2)

    print result

    pt1 = (pt1[1], pt1[0])
    pt2 = (pt2[1], pt2[0])

    print 'checking:'
    print pt1
    print pt2
    result = find_first_pixel(raster, pt1, pt2)

    print result
Beispiel #14
0
    (w, h) = (10, 10)
    raster = np.zeros((w, h), dtype=np.uint8)

    # a single skinny diagonal line part way:

    raster[0, 0] = 1
    raster[1, 1] = 1
    raster[2, 2] = 1
    raster[3, 3] = 1
    raster[4, 4] = 1

    pt1 = (0, 8)
    pt2 = (9, 0)

    print 'checking:'
    print pt1
    print pt2
    result = find_first_pixel(raster, pt1, pt2)

    print result

    pt1 = (pt1[1], pt1[0])
    pt2 = (pt2[1], pt2[0])

    print 'checking:'
    print pt1
    print pt2
    result = find_first_pixel(raster, pt1, pt2)

    print result