Module: H3::UnidirectionalEdges
Overview
Unidirectional edge functions
Instance Method Summary collapse
-
#destination_from_unidirectional_edge(edge) ⇒ Integer
Derive destination H3 index from edge.
-
#neighbors?(origin, destination) ⇒ Boolean
Determine whether two H3 indexes are neighbors.
-
#origin_and_destination_from_unidirectional_edge(edge) ⇒ Array<Integer>
Derive origin and destination H3 indexes from edge.
-
#origin_from_unidirectional_edge(edge) ⇒ Integer
Derive origin H3 index from edge.
-
#unidirectional_edge(origin, destination) ⇒ Integer
Derives the H3 index of the edge from the given H3 indexes.
-
#unidirectional_edge_boundary(edge) ⇒ Array<Array<Float>>
Derive coordinates for edge boundary.
-
#unidirectional_edge_valid?(h3_index) ⇒ Boolean
Determine whether the given H3 index represents an edge.
-
#unidirectional_edges_from_hexagon(origin) ⇒ Array<Integer>
Derive unidirectional edges for a H3 index.
Methods included from Bindings::Base
attach_predicate_function, extended
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, %i[h3_index], :h3_index |
#neighbors?(origin, destination) ⇒ Boolean
Determine whether two H3 indexes are neighbors.
20 |
# File 'lib/h3/unidirectional_edges.rb', line 20 attach_predicate_function :neighbors?, :h3IndexesAreNeighbors, %i[h3_index h3_index], :bool |
#origin_and_destination_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 origin_and_destination_from_unidirectional_edge(edge) max_hexagons = 2 out = H3Indexes.of_size(max_hexagons) Bindings::Private.h3_indexes_from_unidirectional_edge(edge, out) out.read 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, %i[h3_index], :h3_index |
#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 :unidirectional_edge, :getH3UnidirectionalEdge, %i[h3_index h3_index], :h3_index |
#unidirectional_edge_boundary(edge) ⇒ Array<Array<Float>>
Derive coordinates for edge boundary.
139 140 141 142 143 144 145 |
# File 'lib/h3/unidirectional_edges.rb', line 139 def unidirectional_edge_boundary(edge) geo_boundary = GeoBoundary.new Bindings::Private.h3_unidirectional_edge_boundary(edge, geo_boundary) geo_boundary[:verts].take(geo_boundary[:num_verts]).map do |d| [rads_to_degs(d[:lat]), rads_to_degs(d[:lon])] end end |
#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_predicate_function :unidirectional_edge_valid?, :h3UnidirectionalEdgeIsValid, %i[h3_index], :bool |
#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 unidirectional_edges_from_hexagon(origin) max_edges = 6 out = H3Indexes.of_size(max_edges) Bindings::Private.h3_unidirectional_edges_from_hexagon(origin, out) out.read end |