Module: H3::Regions
Overview
Region functions.
Instance Method Summary collapse
-
#h3_set_to_linked_geo(h3_indexes) ⇒ Array<Array<Array<Float>>>
Derive a nested array of coordinates from a list of H3 indexes.
-
#max_polyfill_size(geo_polygon, resolution) ⇒ Integer
Derive the maximum number of H3 indexes that could be returned from the input.
-
#polyfill(geo_polygon, resolution) ⇒ Array<Integer>
Derive a list of H3 indexes that fall within a given geo polygon structure.
Methods included from Bindings::Base
attach_predicate_function, extended
Instance Method Details
#h3_set_to_linked_geo(h3_indexes) ⇒ Array<Array<Array<Float>>>
Derive a nested array of coordinates from a list of H3 indexes.
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/h3/regions.rb', line 139 def h3_set_to_linked_geo(h3_indexes) h3_set = H3Indexes.with_contents(h3_indexes) linked_geo_polygon = LinkedGeoPolygon.new Bindings::Private.h3_set_to_linked_geo(h3_set, h3_indexes.size, linked_geo_polygon) # The algorithm in h3 currently only handles 1 polygon extract_linked_geo_polygon(linked_geo_polygon).first ensure Bindings::Private.destroy_linked_polygon(linked_geo_polygon) end |
#max_polyfill_size(geo_polygon, resolution) ⇒ Integer
Derive the maximum number of H3 indexes that could be returned from the input.
or a coordinates nested array.
51 52 53 54 |
# File 'lib/h3/regions.rb', line 51 def max_polyfill_size(geo_polygon, resolution) geo_polygon = geo_json_to_coordinates(geo_polygon) if geo_polygon.is_a?(String) Bindings::Private.max_polyfill_size(build_polygon(geo_polygon), resolution) end |
#polyfill(geo_polygon, resolution) ⇒ Array<Integer>
Derive a list of H3 indexes that fall within a given geo polygon structure.
coordinates nested array.
105 106 107 108 109 110 111 |
# File 'lib/h3/regions.rb', line 105 def polyfill(geo_polygon, resolution) geo_polygon = geo_json_to_coordinates(geo_polygon) if geo_polygon.is_a?(String) max_size = max_polyfill_size(geo_polygon, resolution) out = H3Indexes.of_size(max_size) Bindings::Private.polyfill(build_polygon(geo_polygon), resolution, out) out.read end |