Beispiel #1
0
def test_bad_units():
    h = '89754e64993ffff'
    e = '139754e64993ffff'

    assert h3.h3_is_valid(h)
    assert h3.h3_unidirectional_edge_is_valid(e)

    with pytest.raises(H3ValueError):
        h3.cell_area(h, unit='foot-pounds')

    with pytest.raises(H3ValueError):
        h3.exact_edge_length(h, unit='foot-pounds')

    with pytest.raises(H3ValueError):
        h3.point_dist((0, 0), (0, 0), unit='foot-pounds')
def test_edge():
    h1 = '8928308280fffff'
    h2 = '89283082873ffff'

    assert not h3.h3_indexes_are_neighbors(h1, h1)
    assert h3.h3_indexes_are_neighbors(h1, h2)

    e = h3.get_h3_unidirectional_edge(h1, h2)

    assert e == '12928308280fffff'
    assert h3.h3_unidirectional_edge_is_valid(e)
    assert not h3.h3_is_valid(e)

    assert h3.get_origin_h3_index_from_unidirectional_edge(e) == h1
    assert h3.get_destination_h3_index_from_unidirectional_edge(e) == h2

    assert h3.get_h3_indexes_from_unidirectional_edge(e) == (h1, h2)
def test_edges():
    h = '8928308280fffff'

    with pytest.raises(H3ValueError):
        h3.get_h3_unidirectional_edge(h, h)

    h2 = h3.hex_ring(h, 2).pop()
    with pytest.raises(H3ValueError):
        h3.get_h3_unidirectional_edge(h, h2)

    e_bad = '14928308280ffff1'
    assert not h3.h3_unidirectional_edge_is_valid(e_bad)

    with pytest.raises(H3EdgeError):
        h3.get_origin_h3_index_from_unidirectional_edge(e_bad)

    with pytest.raises(H3EdgeError):
        h3.get_destination_h3_index_from_unidirectional_edge(e_bad)

    with pytest.raises(H3EdgeError):
        h3.get_h3_indexes_from_unidirectional_edge(e_bad)
def test_edge_is_valid_fail():
    e_invalid = {}
    assert not h3.h3_unidirectional_edge_is_valid(e_invalid)
Beispiel #5
0
def test_h3_unidirectional_edge_is_valid():
    assert not h3.h3_unidirectional_edge_is_valid('8928308280fffff')
    assert h3.h3_unidirectional_edge_is_valid('11928308280fffff')
Beispiel #6
0
def test_get_h3_unidirectional_edge():
    out = h3.get_h3_unidirectional_edge('8928308280fffff', '8928308280bffff')
    assert h3.h3_unidirectional_edge_is_valid(out)

    with pytest.raises(ValueError):
        h3.get_h3_unidirectional_edge('821c07fffffffff', '8928308280fffff')