lib/h3/traversal.rb in h3-3.5.0 vs lib/h3/traversal.rb in h3-3.5.1
- old
+ new
@@ -16,25 +16,31 @@
# 91
#
# @return [Integer] Maximum k-ring size.
attach_function :max_kring_size, :maxKringSize, %i[k_distance], :int
- # @!method h3_distance(origin, h3_index)
+ # @!method distance(origin, h3_index)
#
# Derive the distance between two H3 indexes.
#
# @param [Integer] origin Origin H3 index
# @param [Integer] h3_index H3 index
#
# @example Derive the distance between two H3 indexes.
- # H3.h3_distance(617700169983721471, 617700169959866367)
+ # H3.distance(617700169983721471, 617700169959866367)
# 5
#
# @return [Integer] Distance between indexes.
- attach_function :h3_distance, :h3Distance, %i[h3_index h3_index], :k_distance
+ attach_function :distance, :h3Distance, %i[h3_index h3_index], :k_distance
- # @!method h3_line_size(origin, destination)
+ # @deprecated Please use {#distance} instead.
+ def h3_distance(origin, destination)
+ distance(origin, destination)
+ end
+ deprecate :h3_distance, :distance, 2020, 1
+
+ # @!method line_size(origin, destination)
#
# Derive the number of hexagons present in a line between two H3 indexes.
#
# This value is simply `h3_distance(origin, destination) + 1` when a line is computable.
#
@@ -43,16 +49,22 @@
#
# @param [Integer] origin Origin H3 index
# @param [Integer] destination H3 index
#
# @example Derive the number of hexagons present in a line between two H3 indexes.
- # H3.h3_line_size(617700169983721471, 617700169959866367)
+ # H3.line_size(617700169983721471, 617700169959866367)
# 6
#
# @return [Integer] Number of hexagons found between indexes.
- attach_function :h3_line_size, :h3LineSize, %i[h3_index h3_index], :int
+ attach_function :line_size, :h3LineSize, %i[h3_index h3_index], :int
+ # @deprecated Please use {#line_size} instead.
+ def h3_line_size(origin, destination)
+ line_size(origin, destination)
+ end
+ deprecate :h3_line_size, :line_size, 2020, 1
+
# Derives H3 indexes within k distance of the origin H3 index.
#
# Similar to {k_ring}, except that an error is raised when one of the indexes
# returned is a pentagon or is in the pentagon distortion area.
#
@@ -286,25 +298,31 @@
#
# @param [Integer] origin Origin H3 index.
# @param [Integer] destination Destination H3 index.
#
# @example Derive the indexes found in a line.
- # H3.h3_line(617700169983721471, 617700169959866367)
+ # H3.line(617700169983721471, 617700169959866367)
# [
# 617700169983721471, 617700169984245759, 617700169988177919,
# 617700169986867199, 617700169987391487, 617700169959866367
# ]
#
# @raise [ArgumentError] Could not compute line
#
# @return [Array<Integer>] H3 indexes
- def h3_line(origin, destination)
- max_hexagons = h3_line_size(origin, destination)
+ def line(origin, destination)
+ max_hexagons = line_size(origin, destination)
hexagons = H3Indexes.of_size(max_hexagons)
res = Bindings::Private.h3_line(origin, destination, hexagons)
raise(ArgumentError, "Could not compute line") if res.negative?
hexagons.read
end
+
+ # @deprecated Please use {#line} instead.
+ def h3_line(origin, destination)
+ line(origin, destination)
+ end
+ deprecate :h3_line, :line, 2020, 1
private
def k_rings_for_hex_range(indexes, k)
0.upto(k).map do |j|