How to use the h3.uncompact function in h3

To help you get started, we’ve selected a few h3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / h3-py / tests / test_cells_and_edges.py View on Github external
def test_uncompact():

    h_uncomp, h_comp, res = test_compact()

    out = h3.uncompact(h_comp, res)

    assert out == h_uncomp
github uber / h3-py / tests / test_h3.py View on Github external
def test_compact_and_uncompact_nothing():
    assert h3.compact([]) == set()
    assert h3.uncompact([], 9) == set()
github uber / h3-py / tests / test_h3.py View on Github external
def test_uncompact_error():
    hexagons = [h3.geo_to_h3(37, -122, 10)]

    with pytest.raises(Exception):
        h3.uncompact(hexagons, 5)
github uber / h3-py / tests / test_h3.py View on Github external
[37.813318999983238, -122.4089866999972145],
                [37.7866302000007224, -122.3805436999997056],
                [37.7198061999978478, -122.3544736999993603],
                [37.7076131999975672, -122.5123436999983966],
                [37.7835871999971715, -122.5247187000021967],
                [37.8151571999998453, -122.4798767000009008],
            ]
        ]
    }

    hexes = h3.polyfill(geo, 9)

    compact_hexes = h3.compact(hexes)
    assert len(compact_hexes) == 209

    uncompact_hexes = h3.uncompact(compact_hexes, 9)
    assert len(uncompact_hexes) == 1253
github uber / h3-py / tests / test_cells_and_edges.py View on Github external
def test_uncompact_cell_input():
    # `uncompact` takes in a collection of cells, not a single cell.
    # Since a python string is seen as a Iterable collection,
    # inputting a single cell string can raise weird errors.

    # Ensure we get a reasonably helpful answer
    with pytest.raises(H3CellError):
        h3.uncompact('8001fffffffffff', 1)
github uber / h3-py / tests / test_cells_and_edges.py View on Github external
h3.h3_distance(h, h)

    with pytest.raises(H3CellError):
        h3.k_ring(h, 1)

    with pytest.raises(H3CellError):
        h3.hex_ring(h, 1)

    with pytest.raises(H3CellError):
        h3.h3_to_children(h, 11)

    with pytest.raises(H3CellError):
        h3.compact({h})

    with pytest.raises(H3CellError):
        h3.uncompact({h}, 10)