Module: H3::UnidirectionalEdges
Overview
Unidirectional edge functions
Instance Method Summary collapse
-
#destination_from_unidirectional_edge(edge) ⇒ Integer
Derive destination H3 index from edge.
-
#h3_indexes_from_unidirectional_edge(edge) ⇒ Array<Integer>
Derive origin and destination H3 indexes from edge.
-
#h3_indexes_neighbors?(origin, destination) ⇒ Boolean
Determine whether two H3 indexes are neighbors.
-
#h3_unidirectional_edge(origin, destination) ⇒ Integer
Derives the H3 index of the edge from the given H3 indexes.
-
#h3_unidirectional_edge_boundary(edge) ⇒ Array<Array<Float>>
Derive coordinates for edge boundary.
-
#h3_unidirectional_edge_valid?(h3_index) ⇒ Boolean
Determine whether the given H3 index represents an edge.
-
#h3_unidirectional_edges_from_hexagon(origin) ⇒ Array<Integer>
Derive unidirectional edges for a H3 index.
-
#origin_from_unidirectional_edge(edge) ⇒ Integer
Derive origin H3 index from edge.
Methods included from Bindings::Base
Instance Method Details
#destination_from_unidirectional_edge(edge) ⇒ Integer
Derive destination H3 index from edge.
66 67 68 69 |
# File 'lib/h3/unidirectional_edges.rb', line 66 attach_function :destination_from_unidirectional_edge, :getDestinationH3IndexFromUnidirectionalEdge, [ :h3_index ], :h3_index |
#h3_indexes_from_unidirectional_edge(edge) ⇒ Array<Integer>
Derive origin and destination H3 indexes from edge.
Returned in the form
[origin, destination]
100 101 102 103 104 105 |
# File 'lib/h3/unidirectional_edges.rb', line 100 def h3_indexes_from_unidirectional_edge(edge) max_hexagons = 2 origin_destination = FFI::MemoryPointer.new(:ulong_long, max_hexagons) Bindings::Private.h3_indexes_from_unidirectional_edge(edge, origin_destination) origin_destination.read_array_of_ulong_long(max_hexagons).reject(&:zero?) end |
#h3_indexes_neighbors?(origin, destination) ⇒ Boolean
Determine whether two H3 indexes are neighbors.
20 |
# File 'lib/h3/unidirectional_edges.rb', line 20 attach_function :h3_indexes_neighbors, :h3IndexesAreNeighbors, [ :h3_index, :h3_index ], :bool |
#h3_unidirectional_edge(origin, destination) ⇒ Integer
Derives the H3 index of the edge from the given H3 indexes.
50 51 52 53 |
# File 'lib/h3/unidirectional_edges.rb', line 50 attach_function :h3_unidirectional_edge, :getH3UnidirectionalEdge, [ :h3_index, :h3_index ], :h3_index |
#h3_unidirectional_edge_boundary(edge) ⇒ Array<Array<Float>>
Derive coordinates for edge boundary.
138 139 140 141 142 143 144 |
# File 'lib/h3/unidirectional_edges.rb', line 138 def h3_unidirectional_edge_boundary(edge) geo_boundary = Bindings::Structs::GeoBoundary.new Bindings::Private.h3_unidirectional_edge_boundary(edge, geo_boundary) geo_boundary[:verts].take(geo_boundary[:num_verts] * 2).map do |d| rads_to_degs(d) end.each_slice(2).to_a end |
#h3_unidirectional_edge_valid?(h3_index) ⇒ Boolean
Determine whether the given H3 index represents an edge.
33 34 35 36 |
# File 'lib/h3/unidirectional_edges.rb', line 33 attach_function :h3_unidirectional_edge_valid, :h3UnidirectionalEdgeIsValid, [ :h3_index ], :bool |
#h3_unidirectional_edges_from_hexagon(origin) ⇒ Array<Integer>
Derive unidirectional edges for a H3 index.
119 120 121 122 123 124 |
# File 'lib/h3/unidirectional_edges.rb', line 119 def h3_unidirectional_edges_from_hexagon(origin) max_edges = 6 edges = FFI::MemoryPointer.new(:ulong_long, max_edges) Bindings::Private.h3_unidirectional_edges_from_hexagon(origin, edges) edges.read_array_of_ulong_long(max_edges).reject(&:zero?) end |
#origin_from_unidirectional_edge(edge) ⇒ Integer
Derive origin H3 index from edge.
82 83 84 85 |
# File 'lib/h3/unidirectional_edges.rb', line 82 attach_function :origin_from_unidirectional_edge, :getOriginH3IndexFromUnidirectionalEdge, [ :h3_index ], :h3_index |