module

Polygon

Inherits Miscellaneous < H3::Bindings::Base < H3::Bindings::Private < H3::Bindings::Types < H3::Bindings::Types < H3::Bindings::Base < H3::Bindings::Private < H3::Bindings::Types < H3::Bindings::Types

Instance methods

cells_to_multi_polygon(h3_set : Array(UInt64)) : Array(Array(Array(Tuple(Float64, Float64))))

Convert a set of H3 cells to a linked multi-polygon structure.

Returns an array of polygons, where each polygon is an array of loops, and each loop is an array of coordinate pairs (lat, lng) in degrees.

@param [Array<Integer>] h3_set An array of valid H3 indexes.

@example Convert cells to polygon outlines. cells = [612933930963697663] H3.cells_to_multi_polygon(cells)

@return [Array<Array<Array<Tuple(Float64, Float64)>>>] Array of polygons (each polygon is an array of loops, each loop is coordinates).

Source
max_polygon_to_cells_size(polygon : Array(Tuple(Float64, Float64)), resolution : Int32, holes : Array(Array(Tuple(Float64, Float64))) = [] of Array(Tuple(Float64, Float64)), flags : UInt32 = 0_u32) : Int64

Derive the maximum number of H3 cells that could fill a given polygon at the specified resolution.

@param [Array<Tuple(Float64, Float64)>] polygon Outer boundary coordinates (lat, lng) in degrees. @param [Array<Array<Tuple(Float64, Float64)>>] holes Interior boundary (hole) coordinates in degrees. @param [Integer] resolution The desired H3 resolution (0-15). @param [Integer] flags Containment mode flags (default 0 = center containment).

@example Get the max number of cells for a polygon. polygon = [{37.813318, -122.4089866}, {37.7866302, -122.3805436}, {37.7198061, -122.3544736}, {37.7076131, -122.5123436}] H3.max_polygon_to_cells_size(polygon, 9)

@return [Integer] Maximum number of H3 cells.

Source
polygon_to_cells(polygon : Array(Tuple(Float64, Float64)), resolution : Int32, holes : Array(Array(Tuple(Float64, Float64))) = [] of Array(Tuple(Float64, Float64)), flags : UInt32 = 0_u32) : Array(UInt64)

Fill a polygon with H3 cells at the specified resolution.

@param [Array<Tuple(Float64, Float64)>] polygon Outer boundary coordinates (lat, lng) in degrees. @param [Array<Array<Tuple(Float64, Float64)>>] holes Interior boundary (hole) coordinates in degrees. @param [Integer] resolution The desired H3 resolution (0-15). @param [Integer] flags Containment mode flags (default 0 = center containment).

@example Fill a polygon with H3 cells. polygon = [{37.813318, -122.4089866}, {37.7866302, -122.3805436}, {37.7198061, -122.3544736}, {37.7076131, -122.5123436}] H3.polygon_to_cells(polygon, 9)

@return [Array<Integer>] Array of H3 indexes filling the polygon.

Source