How to use the h3.polyfill 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_h3.py View on Github external
def test_compact_and_uncompact():
    geo = {
        'type': 'Polygon',
        'coordinates': [
            [
                [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_h3.py View on Github external
def test_polyfill_geo_json_compliant():
    geo = {
        'type': 'Polygon',
        'coordinates': [
            [
                [-122.4089866999972145, 37.813318999983238],
                [-122.3805436999997056, 37.7866302000007224],
                [-122.3544736999993603, 37.7198061999978478],
                [-122.5123436999983966, 37.7076131999975672],
                [-122.5247187000021967, 37.7835871999971715],
                [-122.4798767000009008, 37.8151571999998453],
            ]
        ]
    }

    out = h3.polyfill(geo, 9, True)
    assert len(out) > 1000
github uber / h3-py / tests / test_h3.py View on Github external
[37.8151571999998453, -122.4798767000009008],
            ],
            [
                [37.7869802, -122.4471197],
                [37.7664102, -122.4590777],
                [37.7710682, -122.4137097],
            ],
            [
                [37.747976, -122.490025],
                [37.731550, -122.503758],
                [37.725440, -122.452603],
            ]
        ]
    }

    out = h3.polyfill(geo, 9)
    assert len(out) > 1000
github uber / h3-py / tests / test_h3.py View on Github external
def test_polyfill_null_island():
    geo = {
        "type": "Polygon",
        "coordinates": [
            [
                [-3.218994140625, -3.0856655287215378],
                [-3.218994140625, 3.6888551431470478],
                [3.5815429687499996, 3.6888551431470478],
                [3.5815429687499996, -3.0856655287215378],
                [-3.218994140625, -3.0856655287215378],
            ]
        ]
    }

    out = h3.polyfill(geo, 4, True)
    assert len(out) > 10
github uber / h3-py / tests / test_h3.py View on Github external
def test_polyfill_far_east():
    geo = {
        'type': 'Polygon',
        'coordinates': [
            [
                [142.86483764648438, 41.92578147109541],
                [142.86483764648438, 42.29965889253408],
                [143.41552734375, 42.29965889253408],
                [143.41552734375, 41.92578147109541],
                [142.86483764648438, 41.92578147109541],
            ]
        ]
    }

    out = h3.polyfill(geo, 9, True)
    assert len(out) > 10
github uber / h3-py / tests / test_h3.py View on Github external
def test_polyfill_southern_tip():
    geo = {
        'type': 'Polygon',
        'coordinates': [
            [
                [-67.642822265625, -55.41654360858007],
                [-67.642822265625, -54.354955689554096],
                [-64.742431640625, -54.354955689554096],
                [-64.742431640625, -55.41654360858007],
                [-67.642822265625, -55.41654360858007],
            ]
        ]
    }

    out = h3.polyfill(geo, 9, True)
    assert len(out) > 10
github uber / h3-py / tests / test_h3.py View on Github external
def test_polyfill_bogus_geo_json():
    with pytest.raises(ValueError):
        bad_geo = {'type': 'whatwhat'}
        h3.polyfill(bad_geo, 9)
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],
            ],
            [
                [37.7869802, -122.4471197],
                [37.7664102, -122.4590777],
                [37.7710682, -122.4137097],
            ]
        ]
    }

    out = h3.polyfill(geo, 9)
    assert len(out) > 1000
github uber / h3-py / tests / test_h3.py View on Github external
def test_polyfill():
    geo = {
        'type': 'Polygon',
        'coordinates': [
            [
                [37.813318999983238, -122.4089866999972145],
                [37.7866302000007224, -122.3805436999997056],
                [37.7198061999978478, -122.3544736999993603],
                [37.7076131999975672, -122.5123436999983966],
                [37.7835871999971715, -122.5247187000021967],
                [37.8151571999998453, -122.4798767000009008]
            ]
        ]
    }

    out = h3.polyfill(geo, 9)
    assert len(out) > 1000