Module: H3::Miscellaneous
Overview
Miscellaneous functions.
Instance Method Summary collapse
-
#base_cell_count ⇒ Integer
Returns the number of resolution 0 hexagons (base cells).
-
#base_cells ⇒ Array<Integer>
Returns all resolution 0 hexagons (base cells).
-
#cell_area_km2 ⇒ Double
Area of a given cell expressed in km squared.
-
#cell_area_m2 ⇒ Double
Area of a given cell expressed in metres squared.
-
#cell_area_rads2 ⇒ Double
Area of a given cell expressed in radians squared.
-
#degs_to_rads(degs) ⇒ Float
Convert a number expressed in degrees to its equivalent in radians.
-
#edge_length_km(resolution) ⇒ Float
Derive the length of a hexagon edge in kilometres at the given resolution.
-
#edge_length_m(resolution) ⇒ Float
Derive the length of a hexagon edge in metres at the given resolution.
-
#exact_edge_length_km ⇒ Double
Exact length of edge in kilometres.
-
#exact_edge_length_m ⇒ Double
Exact length of edge in metres.
-
#exact_edge_length_rads ⇒ Double
Exact length of edge in rads.
-
#hex_area_km2(resolution) ⇒ Float
Average hexagon area in square kilometres at the given resolution.
-
#hex_area_m2(resolution) ⇒ Float
Average hexagon area in square metres at the given resolution.
-
#hexagon_count(resolution) ⇒ Integer
Number of unique H3 indexes at the given resolution.
-
#pentagon_count ⇒ Integer
Number of pentagon H3 indexes per resolution.
-
#pentagons(resolution) ⇒ Array<Integer>
Returns all pentagon indexes at the given resolution.
-
#point_distance_km(origin, destination) ⇒ Double
Returns the kilometres distance between two points.
-
#point_distance_m(origin, destination) ⇒ Double
Returns the metre distance between two points.
-
#point_distance_rads(origin, destination) ⇒ Double
Returns the radians distance between two points.
-
#rads_to_degs(rads) ⇒ Float
Convert a number expressed in radians to its equivalent in degrees.
Methods included from Bindings::Base
attach_predicate_function, extended
Instance Method Details
#base_cell_count ⇒ Integer
Returns the number of resolution 0 hexagons (base cells).
108 |
# File 'lib/h3/miscellaneous.rb', line 108 attach_function :base_cell_count, :res0IndexCount, [], :int |
#base_cells ⇒ Array<Integer>
Returns all resolution 0 hexagons (base cells).
228 229 230 231 232 |
# File 'lib/h3/miscellaneous.rb', line 228 def base_cells out = H3Indexes.of_size(base_cell_count) Bindings::Private.res_0_indexes(out) out.read end |
#cell_area_km2 ⇒ Double
Area of a given cell expressed in km squared
142 |
# File 'lib/h3/miscellaneous.rb', line 142 attach_function :cell_area_km2, :cellAreaKm2, %i[h3_index], :double |
#cell_area_m2 ⇒ Double
Area of a given cell expressed in metres squared
153 |
# File 'lib/h3/miscellaneous.rb', line 153 attach_function :cell_area_m2, :cellAreaM2, %i[h3_index], :double |
#cell_area_rads2 ⇒ Double
Area of a given cell expressed in radians squared
131 |
# File 'lib/h3/miscellaneous.rb', line 131 attach_function :cell_area_rads2, :cellAreaRads2, %i[h3_index], :double |
#degs_to_rads(degs) ⇒ Float
Convert a number expressed in degrees to its equivalent in radians.
19 |
# File 'lib/h3/miscellaneous.rb', line 19 attach_function :degs_to_rads, :degsToRads, %i[double], :double |
#edge_length_km(resolution) ⇒ Float
Derive the length of a hexagon edge in kilometres at the given resolution.
32 |
# File 'lib/h3/miscellaneous.rb', line 32 attach_function :edge_length_km, :edgeLengthKm, [Resolution], :double |
#edge_length_m(resolution) ⇒ Float
Derive the length of a hexagon edge in metres at the given resolution.
45 |
# File 'lib/h3/miscellaneous.rb', line 45 attach_function :edge_length_m, :edgeLengthM, [Resolution], :double |
#exact_edge_length_km ⇒ Double
Exact length of edge in kilometres
175 |
# File 'lib/h3/miscellaneous.rb', line 175 attach_function :exact_edge_length_km, :exactEdgeLengthKm, %i[h3_index], :double |
#exact_edge_length_m ⇒ Double
Exact length of edge in metres
186 |
# File 'lib/h3/miscellaneous.rb', line 186 attach_function :exact_edge_length_m, :exactEdgeLengthM, %i[h3_index], :double |
#exact_edge_length_rads ⇒ Double
Exact length of edge in rads
164 |
# File 'lib/h3/miscellaneous.rb', line 164 attach_function :exact_edge_length_rads, :exactEdgeLengthRads, %i[h3_index], :double |
#hex_area_km2(resolution) ⇒ Float
Average hexagon area in square kilometres at the given resolution.
58 |
# File 'lib/h3/miscellaneous.rb', line 58 attach_function :hex_area_km2, :hexAreaKm2, [Resolution], :double |
#hex_area_m2(resolution) ⇒ Float
Average hexagon area in square metres at the given resolution.
71 |
# File 'lib/h3/miscellaneous.rb', line 71 attach_function :hex_area_m2, :hexAreaM2, [Resolution], :double |
#hexagon_count(resolution) ⇒ Integer
Number of unique H3 indexes at the given resolution.
84 |
# File 'lib/h3/miscellaneous.rb', line 84 attach_function :hexagon_count, :numHexagons, [Resolution], :ulong_long |
#pentagon_count ⇒ Integer
Number of pentagon H3 indexes per resolution. This is always 12, but provided as a convenience.
120 |
# File 'lib/h3/miscellaneous.rb', line 120 attach_function :pentagon_count, :pentagonIndexCount, [], :int |
#pentagons(resolution) ⇒ Array<Integer>
Returns all pentagon indexes at the given resolution.
241 242 243 244 245 |
# File 'lib/h3/miscellaneous.rb', line 241 def pentagons(resolution) out = H3Indexes.of_size(pentagon_count) Bindings::Private.get_pentagon_indexes(resolution, out) out.read end |
#point_distance_km(origin, destination) ⇒ Double
Returns the kilometres distance between two points.
206 207 208 |
# File 'lib/h3/miscellaneous.rb', line 206 def point_distance_km(origin, destination) Bindings::Private.point_distance_km(*build_geocoords(origin, destination)) end |
#point_distance_m(origin, destination) ⇒ Double
Returns the metre distance between two points.
217 218 219 |
# File 'lib/h3/miscellaneous.rb', line 217 def point_distance_m(origin, destination) Bindings::Private.point_distance_m(*build_geocoords(origin, destination)) end |
#point_distance_rads(origin, destination) ⇒ Double
Returns the radians distance between two points.
195 196 197 |
# File 'lib/h3/miscellaneous.rb', line 195 def point_distance_rads(origin, destination) Bindings::Private.point_distance_rads(*build_geocoords(origin, destination)) end |
#rads_to_degs(rads) ⇒ Float
Convert a number expressed in radians to its equivalent in degrees.
97 |
# File 'lib/h3/miscellaneous.rb', line 97 attach_function :rads_to_degs, :radsToDegs, %i[double], :double |