How to use the h3.h3.Geofence 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 / h3 / h3.py View on Github external
def _polygon_array_to_geofence(polygon_array, geo_json_conformant=False):
    num_verts = len(polygon_array)
    GeoCoordArray = GeoCoord * num_verts
    geo_coord_array = GeoCoordArray()
    for i in range(num_verts):
        geo_coord_array[i] = _coord_array_to_geo_coord(polygon_array[i],
                                                       geo_json_conformant)

    return Geofence(num_verts, cast(geo_coord_array, c_void_p))
github uber / h3-py / h3 / h3.py View on Github external
def _geo_json_to_geo_json_lite(geo_json, geo_json_conformant=False):
    if geo_json['type'] != 'Polygon':
        raise Exception('Only Polygon GeoJSON supported')
    num_holes = len(geo_json['coordinates']) - 1
    geofence = _polygon_array_to_geofence(geo_json['coordinates'][0],
                                          geo_json_conformant)
    holes = None
    if num_holes > 0:
        Holes = Geofence * num_holes
        holes = Holes()
        for i in range(num_holes):
            holes[i] = _polygon_array_to_geofence(
                geo_json['coordinates'][i + 1], geo_json_conformant)

    return GeoJsonLite(geofence, num_holes, cast(holes, c_void_p))