Module: H3::Inspection
Overview
Index inspection functions.
Instance Method Summary collapse
-
#base_cell(h3_index) ⇒ Integer
Derives the base cell number of the given H3 index.
-
#class_3_resolution?(h3_index) ⇒ Boolean
Determine whether the given H3 index has a resolution with Class III orientation.
-
#faces(h3_index) ⇒ Array<Integer>
Find all icosahedron faces intersected by a given H3 index.
-
#from_string(h3_string) ⇒ Integer
Derives the H3 index for a given hexadecimal string representation.
-
#max_face_count(h3_index) ⇒ Integer
Returns the maximum number of icosahedron faces the given H3 index may intersect.
-
#pentagon?(h3_index) ⇒ Boolean
Determine whether the given H3 index is a pentagon.
-
#resolution(h3_index) ⇒ Integer
Derive the resolution of a given H3 index.
-
#to_string(h3_index) ⇒ String
Derives the hexadecimal string representation for a given H3 index.
-
#valid?(h3_index) ⇒ Boolean
Determine whether the given H3 index is valid.
Methods included from Bindings::Base
attach_predicate_function, extended
Instance Method Details
#base_cell(h3_index) ⇒ Integer
Derives the base cell number of the given H3 index
35 |
# File 'lib/h3/inspection.rb', line 35 attach_function :base_cell, :h3GetBaseCell, %i[h3_index], :int |
#class_3_resolution?(h3_index) ⇒ Boolean
Determine whether the given H3 index has a resolution with Class III orientation.
75 |
# File 'lib/h3/inspection.rb', line 75 attach_predicate_function :class_3_resolution?, :h3IsResClassIII, %i[h3_index], :bool |
#faces(h3_index) ⇒ Array<Integer>
Find all icosahedron faces intersected by a given H3 index.
127 128 129 130 131 132 133 |
# File 'lib/h3/inspection.rb', line 127 def faces(h3_index) max_faces = max_face_count(h3_index) out = FFI::MemoryPointer.new(:int, max_faces) Bindings::Private.h3_faces(h3_index, out) # The C function returns a sparse array whose holes are represented by -1. out.read_array_of_int(max_faces).reject(&:negative?).sort end |
#from_string(h3_string) ⇒ Integer
Derives the H3 index for a given hexadecimal string representation.
48 |
# File 'lib/h3/inspection.rb', line 48 attach_function :from_string, :stringToH3, %i[string], :h3_index |
#max_face_count(h3_index) ⇒ Integer
Returns the maximum number of icosahedron faces the given H3 index may intersect.
116 |
# File 'lib/h3/inspection.rb', line 116 attach_function :max_face_count, :maxFaceCount, %i[h3_index], :int |
#pentagon?(h3_index) ⇒ Boolean
Determine whether the given H3 index is a pentagon.
61 |
# File 'lib/h3/inspection.rb', line 61 attach_predicate_function :pentagon?, :h3IsPentagon, %i[h3_index], :bool |
#resolution(h3_index) ⇒ Integer
Derive the resolution of a given H3 index
22 |
# File 'lib/h3/inspection.rb', line 22 attach_function :resolution, :h3GetResolution, %i[h3_index], Resolution |
#to_string(h3_index) ⇒ String
Derives the hexadecimal string representation for a given H3 index.
99 100 101 102 103 |
# File 'lib/h3/inspection.rb', line 99 def to_string(h3_index) h3_str = FFI::MemoryPointer.new(:char, H3_TO_STR_BUF_SIZE) Bindings::Private.h3_to_string(h3_index, h3_str, H3_TO_STR_BUF_SIZE) h3_str.read_string end |
#valid?(h3_index) ⇒ Boolean
Determine whether the given H3 index is valid.
88 |
# File 'lib/h3/inspection.rb', line 88 attach_predicate_function :valid?, :h3IsValid, %i[h3_index], :bool |