Module: H3::UnidirectionalEdges

Extended by:
Bindings::Base
Included in:
H3
Defined in:
lib/h3/unidirectional_edges.rb

Overview

Unidirectional edge functions

Instance Method Summary collapse

Methods included from Bindings::Base

extended

Instance Method Details

#destination_from_unidirectional_edge(edge) ⇒ Integer

Derive destination H3 index from edge.

Examples:

Get destination index from edge

H3.destination_from_unidirectional_edge(1266218516299644927)
617700169961177087

Parameters:

  • edge (Integer)

    H3 edge index

Returns:

  • (Integer)

    H3 index



91
92
93
94
# File 'lib/h3/unidirectional_edges.rb', line 91

attach_function :destination_from_unidirectional_edge,
:getDestinationH3IndexFromUnidirectionalEdge,
%i[h3_index],
:h3_index

#h3_indexes_from_unidirectional_edge(edge) ⇒ Object

Deprecated.


133
134
135
# File 'lib/h3/unidirectional_edges.rb', line 133

def h3_indexes_from_unidirectional_edge(edge)
  origin_and_destination_from_unidirectional_edge(edge)
end

#h3_indexes_neighbors?(origin, destination) ⇒ Boolean

Deprecated.

Please use #neighbors? instead.

Returns:

  • (Boolean)


25
26
27
# File 'lib/h3/unidirectional_edges.rb', line 25

def h3_indexes_neighbors?(origin, destination)
  neighbors?(origin, destination)
end

#h3_unidirectional_edge(origin, destination) ⇒ Object

Deprecated.

Please use #unidirectional_edge instead.



74
75
76
# File 'lib/h3/unidirectional_edges.rb', line 74

def h3_unidirectional_edge(origin, destination)
  unidirectional_edge(origin, destination)
end

#h3_unidirectional_edge_boundary(edge) ⇒ Object

Deprecated.

Please use #unidirectional_edge_boundary instead.



193
194
195
# File 'lib/h3/unidirectional_edges.rb', line 193

def h3_unidirectional_edge_boundary(edge)
  unidirectional_edge_boundary(edge)
end

#h3_unidirectional_edge_valid?(h3_index) ⇒ Boolean

Deprecated.

Please use #unidirectional_edge_valid? instead.

Returns:

  • (Boolean)


50
51
52
# File 'lib/h3/unidirectional_edges.rb', line 50

def h3_unidirectional_edge_valid?(h3_index)
  unidirectional_edge_valid?(h3_index)
end

#h3_unidirectional_edges_from_hexagon(origin) ⇒ Object

Deprecated.


162
163
164
# File 'lib/h3/unidirectional_edges.rb', line 162

def h3_unidirectional_edges_from_hexagon(origin)
  unidirectional_edges_from_hexagon(origin)
end

#origin_and_destination_from_unidirectional_edge(edge) ⇒ Array<Integer>

Derive origin and destination H3 indexes from edge.

Returned in the form

[origin, destination]

Examples:

Get origin and destination indexes from edge

H3.origin_and_destination_from_unidirectional_edge(1266218516299644927)
[617700169958293503, 617700169961177087]

Parameters:

  • edge (Integer)

    H3 edge index

Returns:

  • (Array<Integer>)

    H3 index array.



125
126
127
128
129
130
# File 'lib/h3/unidirectional_edges.rb', line 125

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.

Examples:

Get origin index from edge

H3.origin_from_unidirectional_edge(1266218516299644927)
617700169958293503

Parameters:

  • edge (Integer)

    H3 edge index

Returns:

  • (Integer)

    H3 index



107
108
109
110
# File 'lib/h3/unidirectional_edges.rb', line 107

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.

Examples:

Derive the H3 edge index between two H3 indexes

H3.unidirectional_edge(617700169958293503, 617700169958031359)
1626506486489284607

Parameters:

  • origin (Integer)

    H3 index

  • destination (Integer)

    H3 index

Returns:

  • (Integer)

    H3 edge index



68
69
70
71
# File 'lib/h3/unidirectional_edges.rb', line 68

attach_function :unidirectional_edge,
:getH3UnidirectionalEdge,
%i[h3_index h3_index],
:h3_index

#unidirectional_edge_boundary(edge) ⇒ Array<Array<Float>>

Derive coordinates for edge boundary.

Examples:

H3.unidirectional_edge_boundary(612933930963697663)
[
  [68.92995788193981, 31.831280499087402], [69.39359648991828, 62.345344956509784],
  [76.163042830191, 94.14309010184775], [87.36469532319619, 145.5581976913368],
  [81.27137179020497, -34.75841798028461], [73.31022368544393, 0.32561035194326043]
]

Parameters:

  • edge (Integer)

    H3 edge index

Returns:

  • (Array<Array<Float>>)

    Edge boundary coordinates for a hexagon



184
185
186
187
188
189
190
# File 'lib/h3/unidirectional_edges.rb', line 184

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_edges_from_hexagon(origin) ⇒ Array<Integer>

Derive unidirectional edges for a H3 index.

Examples:

Get unidirectional indexes from hexagon

H3.unidirectional_edges_from_hexagon(612933930963697663)
[
  1261452277305049087, 1333509871342977023, 1405567465380904959,
  1477625059418832895, 1549682653456760831, 1621740247494688767
]

Parameters:

  • origin (Integer)

    H3 index

Returns:

  • (Array<Integer>)

    H3 index array.



154
155
156
157
158
159
# File 'lib/h3/unidirectional_edges.rb', line 154

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