h3 3.5.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95994576b5df069470128bda24d6768b3c8d5fe9ee61ebf0b5f4f16126f64208
4
- data.tar.gz: a439783870113f4101d00a3fb94c8f4fec978ddabc55410531aa3e0f3c787fdd
3
+ metadata.gz: fcd6c37e501f228912e6a851ff799d38cefd458b424e9c19ed5fc8a635feda9f
4
+ data.tar.gz: 9e969c1a07735bed4b498ecdb066f9dde27b5f1d27843f2c48636a8ee6f6fb46
5
5
  SHA512:
6
- metadata.gz: 6315cd5682f58cf7384b67fbf8dd4cba4eaa59ccbede04386a94d526b26d593dd0a92df2c4446dc5ff3a662622acbede640d63bae7345c64be0225b92c81d244
7
- data.tar.gz: 9b543348c2c66cc8a441ba42e27503d8ace2b83b6714b577e5531a1cb29cb28810a5e816b90adda4a344a2082ed6e4623a25f10b7126a648498fe200787b930e
6
+ metadata.gz: 33281c3298ba50a851674f6f1523a55c5683bddcfe32772cd7d95a6bf529db6690d20f47c1e9f9b4ff473f5f42283801b403b2620c14241a4e5d005b248dae86
7
+ data.tar.gz: cb3677482d3cd5f6cfb0bc63f2d9ebe7bc1c0a9409a354f6917f21fed6044e6b42e2ee2694208873fccef7be498d4034d992bc38d5a339f2691c5af99273f763
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  We track the MAJOR and MINOR version levels of Uber's H3 project (https://github.com/uber/h3) but maintain independent patch levels so we can make small fixes and non breaking changes.
8
8
 
9
+ ## [3.5.1] - 2019-8-5
10
+ ### Changed
11
+ - Renamed 26 methods to be more idiomatic with Ruby conventions. The old names are deprecated until 2020 when they will be removed (#59).
12
+ - Added Zeitwerk as the code loader.
13
+
9
14
  ## [3.5.0] - 2019-7-25
10
15
  ### Added
11
16
  - `h3_faces` and `max_face_count` support (#56)
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- h3 (3.5.0)
4
+ h3 (3.5.1)
5
5
  ffi (~> 1.9)
6
6
  rgeo-geojson (~> 2.1)
7
+ zeitwerk (~> 2.1.9)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -16,10 +17,10 @@ GEM
16
17
  tins (~> 1.6)
17
18
  diff-lcs (1.3)
18
19
  docile (1.3.1)
19
- ffi (1.10.0)
20
+ ffi (1.11.1)
20
21
  json (2.1.0)
21
22
  rake (12.3.2)
22
- rgeo (2.0.0)
23
+ rgeo (2.0.1)
23
24
  rgeo-geojson (2.1.1)
24
25
  rgeo (>= 1.0.0)
25
26
  rspec (3.8.0)
@@ -44,7 +45,8 @@ GEM
44
45
  tins (~> 1.0)
45
46
  thor (0.19.4)
46
47
  tins (1.20.2)
47
- yard (0.9.16)
48
+ yard (0.9.20)
49
+ zeitwerk (2.1.9)
48
50
 
49
51
  PLATFORMS
50
52
  ruby
data/README.md CHANGED
@@ -11,15 +11,15 @@ Please consult [the H3 documentation](https://uber.github.io/h3/#/documentation/
11
11
 
12
12
  ## Supported H3 Versions
13
13
 
14
- The semantic versioning of this gem matches the versioning of the H3 C library. E.g. version `3.2.x` of this gem is targeted for version `3.2.y` of H3 C lib where `x` and `y` are independent patch levels.
14
+ The semantic versioning of this gem matches the versioning of the H3 C library. E.g. version `3.5.x` of this gem is targeted for version `3.5.y` of H3 C lib where `x` and `y` are independent patch levels.
15
15
 
16
16
  ## Naming Conventions
17
17
 
18
18
  We have changed camel-case method names to snake-case, as per the Ruby convention.
19
19
 
20
- In addition, some methods using the `get` verb have been renamed i.e. `getH3UnidirectionalEdgesFromHexagon` becomes `h3_unidirectional_edges_from_hexagon`.
20
+ In addition, some methods using the `get` verb have been renamed i.e. `getH3UnidirectionalEdgesFromHexagon` becomes `unidirectional_edges_from_hexagon`.
21
21
 
22
- We have also suffixed predicate methods with a question mark, as per the Ruby convention, and removed `is` from the name i.e. `h3IsPentagon` becomes `h3_pentagon?`
22
+ We have also suffixed predicate methods with a question mark, as per the Ruby convention, and removed `h3Is` from the name i.e. `h3IsPentagon` becomes `pentagon?`
23
23
 
24
24
  ## Getting Started
25
25
 
@@ -53,13 +53,13 @@ require "h3"
53
53
  Call H3 functions via the `H3` namespace
54
54
 
55
55
  ```ruby
56
- H3.geo_to_h3([53.959130, -1.079230], 8).to_s(16)
56
+ H3.from_geo_coordinates([53.959130, -1.079230], 8).to_s(16)
57
57
  => "8819429a9dfffff"
58
- H3.h3_valid?("8819429a9dfffff".to_i(16))
58
+ H3.valid?("8819429a9dfffff".to_i(16))
59
59
  => true
60
- H3.h3_pentagon?("8819429a9dfffff".to_i(16))
60
+ H3.pentagon?("8819429a9dfffff".to_i(16))
61
61
  => false
62
- H3.h3_to_geo_boundary("8819429a9dfffff".to_i(16))
62
+ H3.to_boundary("8819429a9dfffff".to_i(16))
63
63
  => [[53.962987505331384, -1.079984346847996], [53.9618315234061, -1.0870313428985856], [53.95744798515881, -1.0882421079017874], [53.95422067486053, -1.082406760751464], [53.955376670617454, -1.0753609232787642], [53.95975996282198, -1.074149274503605]]
64
64
  ```
65
65
 
data/h3.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.add_runtime_dependency "ffi", "~> 1.9"
16
16
  spec.add_runtime_dependency "rgeo-geojson", "~> 2.1"
17
+ spec.add_runtime_dependency "zeitwerk", "~> 2.1.9"
17
18
 
18
19
  spec.add_development_dependency "coveralls", "~> 0.8"
19
20
  spec.add_development_dependency "rake", "~> 12.3"
data/lib/h3.rb CHANGED
@@ -1,15 +1,8 @@
1
1
  require "ffi"
2
2
  require "rgeo/geo_json"
3
+ require "zeitwerk"
3
4
 
4
- require "h3/bindings"
5
- require "h3/geo_json"
6
- require "h3/hierarchy"
7
- require "h3/indexing"
8
- require "h3/inspection"
9
- require "h3/miscellaneous"
10
- require "h3/regions"
11
- require "h3/traversal"
12
- require "h3/unidirectional_edges"
5
+ Zeitwerk::Loader.for_gem.setup
13
6
 
14
7
  # The main H3 namespace.
15
8
  #
@@ -17,7 +10,7 @@ require "h3/unidirectional_edges"
17
10
  #
18
11
  # @see https://uber.github.io/h3/#/documentation/overview/introduction
19
12
  module H3
20
- extend GeoJSON
13
+ extend GeoJson
21
14
  extend Hierarchy
22
15
  extend Miscellaneous
23
16
  extend Indexing
@@ -26,17 +19,9 @@ module H3
26
19
  extend Traversal
27
20
  extend UnidirectionalEdges
28
21
 
29
- PREDICATES = %i[h3_indexes_neighbors h3_pentagon h3_res_class_3
30
- h3_unidirectional_edge_valid h3_valid].freeze
31
- private_constant :PREDICATES
32
-
33
- class << self
34
- # FFI's attach_function doesn't allow method names ending with a
35
- # question mark. This works around the issue by dynamically
36
- # renaming those methods afterwards.
37
- PREDICATES.each do |predicate|
38
- alias_method "#{predicate}?", predicate
39
- undef_method predicate
40
- end
41
- end
22
+ # Internal bindings related modules and classes.
23
+ #
24
+ # These are intended to be used by the library's public methods
25
+ # and not to be used directly by client code.
26
+ module Bindings; end
42
27
  end
@@ -7,6 +7,7 @@ module H3
7
7
  def self.extended(base)
8
8
  lib_path = File.expand_path(__dir__ + "/../../../ext/h3/src/lib")
9
9
  base.extend FFI::Library
10
+ base.extend Gem::Deprecate
10
11
  base.include Structs
11
12
  base.include Types
12
13
  base.ffi_lib ["#{lib_path}/libh3.dylib", "#{lib_path}/libh3.so"]
data/lib/h3/geo_json.rb CHANGED
@@ -27,7 +27,7 @@ module H3
27
27
  #
28
28
  # @see http://geojson.io geojson.io - A tool to see GeoJSON data rendered on a world map.
29
29
  # @see https://tools.ietf.org/html/rfc7946 The GeoJSON RFC standard.
30
- module GeoJSON
30
+ module GeoJson
31
31
  # Convert a GeoJSON document to a nested array of coordinates.
32
32
  #
33
33
  # @param [String] input The GeoJSON document. This can be a feature collection, feature,
data/lib/h3/hierarchy.rb CHANGED
@@ -5,7 +5,7 @@ module H3
5
5
  module Hierarchy
6
6
  extend H3::Bindings::Base
7
7
 
8
- # @!method h3_to_parent(h3_index, parent_resolution)
8
+ # @!method parent(h3_index, parent_resolution)
9
9
  #
10
10
  # Derive the parent hexagon which contains the hexagon at the given H3 index.
11
11
  #
@@ -13,13 +13,19 @@ module H3
13
13
  # @param [Integer] parent_resoluton The desired resolution of the parent hexagon.
14
14
  #
15
15
  # @example Find the parent hexagon for a H3 index.
16
- # H3.h3_to_parent(613196570357137407, 6)
16
+ # H3.parent(613196570357137407, 6)
17
17
  # 604189371209351167
18
18
  #
19
19
  # @return [Integer] H3 index of parent hexagon.
20
- attach_function :h3_to_parent, :h3ToParent, [:h3_index, Resolution], :h3_index
20
+ attach_function :parent, :h3ToParent, [:h3_index, Resolution], :h3_index
21
21
 
22
- # @!method max_h3_to_children_size(h3_index, child_resolution)
22
+ # @deprecated Please use {#parent} instead.
23
+ def h3_to_parent(h3_index, resolution)
24
+ parent(h3_index, resolution)
25
+ end
26
+ deprecate :h3_to_parent, :parent, 2020, 1
27
+
28
+ # @!method max_children(h3_index, child_resolution)
23
29
  #
24
30
  # Derive maximum number of child hexagons possible at given resolution.
25
31
  #
@@ -27,11 +33,17 @@ module H3
27
33
  # @param [Integer] child_resoluton The desired resolution of the child hexagons.
28
34
  #
29
35
  # @example Derive maximum number of child hexagons.
30
- # H3.max_h3_to_children_size(613196570357137407, 10)
36
+ # H3.max_children(613196570357137407, 10)
31
37
  # 49
32
38
  #
33
39
  # @return [Integer] Maximum number of child hexagons possible at given resolution.
34
- attach_function :max_h3_to_children_size, :maxH3ToChildrenSize, [:h3_index, Resolution], :int
40
+ attach_function :max_children, :maxH3ToChildrenSize, [:h3_index, Resolution], :int
41
+
42
+ # @deprecated Please use {#max_children} instead.
43
+ def max_h3_to_children_size(h3_index, resolution)
44
+ max_children(h3_index, resolution)
45
+ end
46
+ deprecate :max_h3_to_children_size, :max_children, 2020, 1
35
47
 
36
48
  # Derive child hexagons contained within the hexagon at the given H3 index.
37
49
  #
@@ -39,20 +51,26 @@ module H3
39
51
  # @param [Integer] child_resolution The desired resolution of hexagons returned.
40
52
  #
41
53
  # @example Find the child hexagons for a H3 index.
42
- # H3.h3_to_children(613196570357137407, 9)
54
+ # H3.children(613196570357137407, 9)
43
55
  # [
44
56
  # 617700169982672895, 617700169982935039, 617700169983197183, 617700169983459327,
45
57
  # 617700169983721471, 617700169983983615, 617700169984245759
46
58
  # ]
47
59
  #
48
60
  # @return [Array<Integer>] H3 indexes of child hexagons.
49
- def h3_to_children(h3_index, child_resolution)
50
- max_children = max_h3_to_children_size(h3_index, child_resolution)
61
+ def children(h3_index, child_resolution)
62
+ max_children = max_children(h3_index, child_resolution)
51
63
  out = H3Indexes.of_size(max_children)
52
64
  Bindings::Private.h3_to_children(h3_index, child_resolution, out)
53
65
  out.read
54
66
  end
55
67
 
68
+ # @deprecated Please use {#children} instead.
69
+ def h3_to_children(h3_index, resolution)
70
+ children(h3_index, resolution)
71
+ end
72
+ deprecate :h3_to_children, :children, 2020, 1
73
+
56
74
  # Find the maximum uncompacted size of the given set of H3 indexes.
57
75
  #
58
76
  # @param [Array<Integer>] compacted_set An array of valid H3 indexes.
data/lib/h3/indexing.rb CHANGED
@@ -7,20 +7,20 @@ module H3
7
7
  #
8
8
  # @see https://uber.github.io/h3/#/documentation/api-reference/indexing
9
9
  module Indexing
10
- include Bindings::Structs
10
+ extend H3::Bindings::Base
11
11
  # Derive H3 index for the given set of coordinates.
12
12
  #
13
13
  # @param [Array<Integer>] coords A coordinate pair.
14
14
  # @param [Integer] resolution The desired resolution of the H3 index.
15
15
  #
16
16
  # @example Derive the H3 index for the given coordinates.
17
- # H3.geo_to_h3([52.24630137198303, -1.7358398437499998], 9)
17
+ # H3.from_geo_coordinates([52.24630137198303, -1.7358398437499998], 9)
18
18
  # 617439284584775679
19
19
  #
20
20
  # @raise [ArgumentError] If coordinates are invalid.
21
21
  #
22
22
  # @return [Integer] H3 index.
23
- def geo_to_h3(coords, resolution)
23
+ def from_geo_coordinates(coords, resolution)
24
24
  raise ArgumentError unless coords.is_a?(Array) && coords.count == 2
25
25
 
26
26
  lat, lon = coords
@@ -35,6 +35,12 @@ module H3
35
35
  Bindings::Private.geo_to_h3(coords, resolution)
36
36
  end
37
37
 
38
+ # @deprecated Please use {#from_geo_coordinates} instead.
39
+ def geo_to_h3(coords, resolution)
40
+ from_geo_coordinates(coords, resolution)
41
+ end
42
+ deprecate :geo_to_h3, :from_geo_coordinates, 2020, 1
43
+
38
44
  # Derive coordinates for a given H3 index.
39
45
  #
40
46
  # The coordinates map to the centre of the hexagon at the given index.
@@ -42,16 +48,22 @@ module H3
42
48
  # @param [Integer] h3_index A valid H3 index.
43
49
  #
44
50
  # @example Derive the central coordinates for the given H3 index.
45
- # H3.h3_to_geo(617439284584775679)
51
+ # H3.to_geo_coordinates(617439284584775679)
46
52
  # [52.245519061399506, -1.7363137757391423]
47
53
  #
48
54
  # @return [Array<Integer>] A coordinate pair.
49
- def h3_to_geo(h3_index)
55
+ def to_geo_coordinates(h3_index)
50
56
  coords = GeoCoord.new
51
57
  Bindings::Private.h3_to_geo(h3_index, coords)
52
58
  [rads_to_degs(coords[:lat]), rads_to_degs(coords[:lon])]
53
59
  end
54
60
 
61
+ # @deprecated Please use {#to_geo_coordinates} instead.
62
+ def h3_to_geo(h3_index)
63
+ to_geo_coordinates(h3_index)
64
+ end
65
+ deprecate :h3_to_geo, :to_geo_coordinates, 2020, 1
66
+
55
67
  # Derive the geographical boundary as coordinates for a given H3 index.
56
68
  #
57
69
  # This will be a set of 6 coordinate pairs matching the vertexes of the
@@ -62,7 +74,7 @@ module H3
62
74
  # @param [Integer] h3_index A valid H3 index.
63
75
  #
64
76
  # @example Derive the geographical boundary for the given H3 index.
65
- # H3.h3_to_geo_boundary(617439284584775679)
77
+ # H3.to_boundary(617439284584775679)
66
78
  # [
67
79
  # [52.247260929171055, -1.736809158397472], [52.24625850761068, -1.7389279144996015],
68
80
  # [52.244516619273476, -1.7384324668792375], [52.243777169245725, -1.7358184256304658],
@@ -70,12 +82,18 @@ module H3
70
82
  # ]
71
83
  #
72
84
  # @return [Array<Array<Integer>>] An array of six coordinate pairs.
73
- def h3_to_geo_boundary(h3_index)
85
+ def to_boundary(h3_index)
74
86
  geo_boundary = GeoBoundary.new
75
87
  Bindings::Private.h3_to_geo_boundary(h3_index, geo_boundary)
76
88
  geo_boundary[:verts].take(geo_boundary[:num_verts]).map do |d|
77
89
  [rads_to_degs(d[:lat]), rads_to_degs(d[:lon])]
78
90
  end
79
91
  end
92
+
93
+ # @deprecated Please use {#to_boundary} instead.
94
+ def h3_to_geo_boundary(h3_index)
95
+ to_boundary(h3_index)
96
+ end
97
+ deprecate :h3_to_geo_boundary, :to_boundary, 2020, 1
80
98
  end
81
99
  end
data/lib/h3/inspection.rb CHANGED
@@ -8,59 +8,85 @@ module H3
8
8
  H3_TO_STR_BUF_SIZE = 17
9
9
  private_constant :H3_TO_STR_BUF_SIZE
10
10
 
11
- # @!method h3_resolution(h3_index)
11
+ # @!method resolution(h3_index)
12
12
  #
13
13
  # Derive the resolution of a given H3 index
14
14
  #
15
15
  # @param [Integer] h3_index A valid H3 index
16
16
  #
17
17
  # @example Derive the resolution of a H3 index
18
- # H3.h3_resolution(617700440100569087)
18
+ # H3.resolution(617700440100569087)
19
19
  # 9
20
20
  #
21
21
  # @return [Integer] Resolution of H3 index
22
- attach_function :h3_resolution, :h3GetResolution, %i[h3_index], Resolution
22
+ attach_function :resolution, :h3GetResolution, %i[h3_index], Resolution
23
23
 
24
- # @!method h3_base_cell(h3_index)
24
+ # @deprecated Please use {#resolution} instead.
25
+ def h3_resolution(h3_index)
26
+ resolution(h3_index)
27
+ end
28
+ deprecate :h3_resolution, :resolution, 2020, 1
29
+
30
+ # @!method base_cell(h3_index)
25
31
  #
26
32
  # Derives the base cell number of the given H3 index
27
33
  #
28
34
  # @param [Integer] h3_index A valid H3 index
29
35
  #
30
36
  # @example Derive the base cell number of a H3 index
31
- # H3.h3_base_cell(617700440100569087)
37
+ # H3.base_cell(617700440100569087)
32
38
  # 20
33
39
  #
34
40
  # @return [Integer] Base cell number
35
- attach_function :h3_base_cell, :h3GetBaseCell, %i[h3_index], :int
41
+ attach_function :base_cell, :h3GetBaseCell, %i[h3_index], :int
42
+
43
+ # @deprecated Please use {#base_cell} instead.
44
+ def h3_base_cell(h3_index)
45
+ base_cell(h3_index)
46
+ end
47
+ deprecate :h3_base_cell, :base_cell, 2020, 1
36
48
 
37
- # @!method string_to_h3(h3_string)
49
+ # @!method from_string(h3_string)
38
50
  #
39
51
  # Derives the H3 index for a given hexadecimal string representation.
40
52
  #
41
53
  # @param [String] h3_string A H3 index in hexadecimal form.
42
54
  #
43
55
  # @example Derive the H3 index from the given hexadecimal form.
44
- # H3.string_to_h3("8928308280fffff")
56
+ # H3.from_string("8928308280fffff")
45
57
  # 617700169958293503
46
58
  #
47
59
  # @return [Integer] H3 index
48
- attach_function :string_to_h3, :stringToH3, %i[string], :h3_index
60
+ attach_function :from_string, :stringToH3, %i[string], :h3_index
61
+
62
+ # @deprecated Please use {#from_string} instead.
63
+ def string_to_h3(string)
64
+ from_string(string)
65
+ end
66
+ deprecate :string_to_h3, :from_string, 2020, 1
49
67
 
50
- # @!method h3_pentagon?(h3_index)
68
+ # @!method pentagon?(h3_index)
51
69
  #
52
70
  # Determine whether the given H3 index is a pentagon.
53
71
  #
54
72
  # @param [Integer] h3_index A valid H3 index.
55
73
  #
56
74
  # @example Check if H3 index is a pentagon
57
- # H3.h3_pentagon?(585961082523222015)
75
+ # H3.pentagon?(585961082523222015)
58
76
  # true
59
77
  #
60
78
  # @return [Boolean] True if the H3 index is a pentagon.
61
- attach_function :h3_pentagon, :h3IsPentagon, %i[h3_index], :bool
79
+ attach_function :pentagon, :h3IsPentagon, %i[h3_index], :bool
80
+ alias_method :pentagon?, :pentagon
81
+ undef_method :pentagon
62
82
 
63
- # @!method h3_res_class_3?(h3_index)
83
+ # @deprecated Please use {#pentagon?} instead.
84
+ def h3_pentagon?(h3_index)
85
+ pentagon?(h3_index)
86
+ end
87
+ deprecate :h3_pentagon?, :pentagon?, 2020, 1
88
+
89
+ # @!method class_3_resolution?(h3_index)
64
90
  #
65
91
  # Determine whether the given H3 index has a resolution with
66
92
  # Class III orientation.
@@ -68,40 +94,62 @@ module H3
68
94
  # @param [Integer] h3_index A valid H3 index.
69
95
  #
70
96
  # @example Check if H3 index has a class III resolution.
71
- # H3.h3_res_class_3?(599686042433355775)
97
+ # H3.class_3_resolution?(599686042433355775)
72
98
  # true
73
99
  #
74
100
  # @return [Boolean] True if the H3 index has a class III resolution.
75
- attach_function :h3_res_class_3, :h3IsResClassIII, %i[h3_index], :bool
101
+ attach_function :class_3_resolution, :h3IsResClassIII, %i[h3_index], :bool
102
+ alias_method :class_3_resolution?, :class_3_resolution
103
+ undef_method :class_3_resolution
76
104
 
77
- # @!method h3_valid?(h3_index)
105
+ # @deprecated Please use {#class_3_resolution?} instead.
106
+ def h3_res_class_3?(h3_index)
107
+ class_3_resolution?(h3_index)
108
+ end
109
+ deprecate :h3_res_class_3?, :class_3_resolution?, 2020, 1
110
+
111
+ # @!method valid?(h3_index)
78
112
  #
79
113
  # Determine whether the given H3 index is valid.
80
114
  #
81
115
  # @param [Integer] h3_index A H3 index.
82
116
  #
83
117
  # @example Check if H3 index is valid
84
- # H3.h3_valid?(599686042433355775)
118
+ # H3.valid?(599686042433355775)
85
119
  # true
86
120
  #
87
121
  # @return [Boolean] True if the H3 index is valid.
88
- attach_function :h3_valid, :h3IsValid, %i[h3_index], :bool
122
+ attach_function :valid, :h3IsValid, %i[h3_index], :bool
123
+ alias_method :valid?, :valid
124
+ undef_method :valid
125
+
126
+ # @deprecated Please use {#valid?} instead.
127
+ def h3_valid?(h3_index)
128
+ valid?(h3_index)
129
+ end
130
+ deprecate :h3_valid?, :valid?, 2020, 1
89
131
 
90
132
  # Derives the hexadecimal string representation for a given H3 index.
91
133
  #
92
134
  # @param [Integer] h3_index A valid H3 index.
93
135
  #
94
136
  # @example Derive the given hexadecimal form for the H3 index
95
- # H3.h3_to_string(617700169958293503)
137
+ # H3.to_string(617700169958293503)
96
138
  # "89283470dcbffff"
97
139
  #
98
140
  # @return [String] H3 index in hexadecimal form.
99
- def h3_to_string(h3_index)
141
+ def to_string(h3_index)
100
142
  h3_str = FFI::MemoryPointer.new(:char, H3_TO_STR_BUF_SIZE)
101
143
  Bindings::Private.h3_to_string(h3_index, h3_str, H3_TO_STR_BUF_SIZE)
102
144
  h3_str.read_string
103
145
  end
104
146
 
147
+ # @deprecated Please use {#to_string} instead.
148
+ def h3_to_string(h3_index)
149
+ to_string(h3_index)
150
+ end
151
+ deprecate :h3_to_string, :to_strings, 2020, 1
152
+
105
153
  # @!method max_face_count(h3_index)
106
154
  #
107
155
  # Returns the maximum number of icosahedron faces the given H3 index may intersect.
@@ -115,25 +163,29 @@ module H3
115
163
  # @return [Integer] Maximum possible number of faces
116
164
  attach_function :max_face_count, :maxFaceCount, %i[h3_index], :int
117
165
 
118
- # void h3GetFaces(H3Index h, int* out);
119
-
120
- # @!method h3_faces(h3_index)
166
+ # @!method faces(h3_index)
121
167
  #
122
168
  # Find all icosahedron faces intersected by a given H3 index.
123
169
  #
124
170
  # @param [Integer] h3_index A H3 index.
125
171
  #
126
172
  # @example Find icosahedron faces for given index
127
- # H3.h3_faces(585961082523222015)
173
+ # H3.faces(585961082523222015)
128
174
  # [1, 2, 6, 7, 11]
129
175
  #
130
176
  # @return [Array<Integer>] Faces. Faces are represented as integers from 0-19, inclusive.
131
- def h3_faces(h3_index)
177
+ def faces(h3_index)
132
178
  max_faces = max_face_count(h3_index)
133
179
  out = FFI::MemoryPointer.new(:int, max_faces)
134
180
  Bindings::Private.h3_faces(h3_index, out)
135
181
  # The C function returns a sparse array whose holes are represented by -1.
136
182
  out.read_array_of_int(max_faces).reject(&:negative?).sort
137
183
  end
184
+
185
+ # @deprecated Please use {#faces} instead.
186
+ def h3_faces(h3_index)
187
+ faces(h3_index)
188
+ end
189
+ deprecate :h3_faces, :faces, 2020, 1
138
190
  end
139
191
  end