h3 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b543bf69e0292e3239876450fab54a28eb0d7b7161f103901fec977ec91562a
4
- data.tar.gz: 137338d6adf3954e0e6dd41e00b06f86c4b87a6cc68a4cdfc1df587f28992e5b
3
+ metadata.gz: 4b2531121ded47b5f0d9d2b5f5a6a335f7fd2f0fb10b3662a27d53299337742c
4
+ data.tar.gz: 3ba64616a8906422668fa9db3f17da9805dcfe7ff57fec8ccc32af750266dd56
5
5
  SHA512:
6
- metadata.gz: 4ae519dd48bf7f004dd63f612d8427464b1a4c41b55d894ef10df6c5883b038e128d04a25e7f8f5cbd87bb1a37d5dd53a84e4692bb202f5d0d7fb79a217c244a
7
- data.tar.gz: 82a2a186ba5e43d751bb02af0b62435f83acca88786d3789deec48eb4e43cf6aa34668b97a3c8cc74ec47e57f16fa2e01b62b098068c4ca20104deab8d980ee1
6
+ metadata.gz: 7a135032876835619d79ebef8160bbb55115058a001dae8e3bcd90091c3ff140cbb2808fa44e98af2761dccd7b2adbb7344c154796732d69ce3bd9365fd3fb84
7
+ data.tar.gz: 624c367307b48be1274f5a92ce600fa2f110ace2d1d8ef97285cec9e0f9fe66d08c8bf3f34a09c9968aa566b0f0158601a90127f3aa2ec201bb8923107854205
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,14 @@
1
+ # Contributing to the H3 Ruby project
2
+
3
+ Pull requests and Github issues are welcome!
4
+
5
+ ## Pull requests
6
+
7
+ * Please include tests that show the bug is fixed or feature works as intended.
8
+ * Please add a description of your change to the [changelog](./CHANGELOG.md).
9
+ * Please open issues to discuss large features or changes which would break compatibility, before submitting pull requests.
10
+ * Please keep code coverage at 100%.
11
+
12
+ ## Other ways to contribute
13
+
14
+ * Writing and updating documentation. This is written in [YARD](https://yardoc.org/) format and [hosted on RubyDoc](https://www.rubydoc.info/github/StuartApp/h3_ruby/master/H3).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- h3 (3.2.0)
4
+ h3 (3.4.0)
5
5
  ffi (~> 1.9)
6
6
  rgeo-geojson (~> 2.1)
7
7
 
@@ -16,7 +16,7 @@ GEM
16
16
  tins (~> 1.6)
17
17
  diff-lcs (1.3)
18
18
  docile (1.3.1)
19
- ffi (1.9.25)
19
+ ffi (1.10.0)
20
20
  json (2.1.0)
21
21
  rake (12.3.2)
22
22
  rgeo (2.0.0)
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Stuart Delivery
3
+ Copyright (c) 2018-2019 Stuart Delivery
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -88,4 +88,4 @@ Be aware that errors may be encountered if you have a locally cached H3 binary t
88
88
 
89
89
  ## Contributing
90
90
 
91
- Pull requests and issues are welcome!
91
+ Pull requests and issues are welcome! Please read [the Contributing Guide](./CONTRIBUTING.md) for more info.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ RSpec::Core::RakeTask.new(:spec)
3
3
 
4
4
  desc "Build H3 C library"
5
5
  task :build do
6
- unless File.exists?("ext/h3/src/Makefile")
6
+ unless File.exist?("ext/h3/src/Makefile")
7
7
  `git submodule update --init --recursive`
8
8
  print "Building h3..."
9
9
  `cd ext/h3; make > /dev/null 2>&1`
@@ -13,15 +13,15 @@ end
13
13
 
14
14
  desc "Remove compiled H3 library"
15
15
  task :clean do
16
- File.delete("ext/h3/src/Makefile") if File.exists?("ext/h3/src/Makefile")
17
- FileUtils.remove_dir("ext/h3/src/bin") if Dir.exists?("ext/h3/src/bin")
18
- FileUtils.remove_dir("ext/h3/src/generated") if Dir.exists?("ext/h3/src/generated")
19
- FileUtils.remove_dir("ext/h3/src/lib") if Dir.exists?("ext/h3/src/lib")
16
+ File.delete("ext/h3/src/Makefile") if File.exist?("ext/h3/src/Makefile")
17
+ FileUtils.remove_dir("ext/h3/src/bin") if Dir.exist?("ext/h3/src/bin")
18
+ FileUtils.remove_dir("ext/h3/src/generated") if Dir.exist?("ext/h3/src/generated")
19
+ FileUtils.remove_dir("ext/h3/src/lib") if Dir.exist?("ext/h3/src/lib")
20
20
  end
21
21
 
22
22
  task spec: :build
23
23
 
24
24
  desc "Recompile the H3 C library"
25
- task rebuild: [:clean, :build]
25
+ task rebuild: %i[clean build]
26
26
 
27
27
  task default: :spec
@@ -96,3 +96,6 @@ binding-functions
96
96
  # These KML files are generated by `make kml`
97
97
  KML/res*cells.kml
98
98
  KML/res*centers.kml
99
+
100
+ # Generated files
101
+ src/h3lib/include/h3api.h
@@ -3,10 +3,15 @@ All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  The public API of this library consists of the functions declared in file
6
- [h3api.h](./src/h3lib/include/h3api.h).
6
+ [h3api.h.in](./src/h3lib/include/h3api.h.in).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.4.0] - 2019-01-23
11
+ ### Added
12
+ - `getRes0Indexes` function for getting all base cells, and helper function `res0IndexCount` (#174)
13
+ - Include defined constants for current library version (#173)
14
+
10
15
  ## [3.3.0] - 2018-12-25
11
16
  ### Added
12
17
  - `h3Line` and `h3LineSize` functions for getting the line of indexes between some start and end (inclusive) (#165)
@@ -45,6 +45,10 @@ endif()
45
45
  file(READ VERSION H3_VERSION LIMIT_COUNT 1)
46
46
  # Clean any newlines
47
47
  string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}")
48
+ string(REPLACE "." ";" H3_VERSION_LIST "${H3_VERSION}")
49
+ list(GET H3_VERSION_LIST 0 H3_VERSION_MAJOR)
50
+ list(GET H3_VERSION_LIST 1 H3_VERSION_MINOR)
51
+ list(GET H3_VERSION_LIST 2 H3_VERSION_PATCH)
48
52
  set(H3_SOVERSION 1)
49
53
 
50
54
  project(h3 LANGUAGES C VERSION ${H3_VERSION})
@@ -99,7 +103,6 @@ set(LIB_SOURCE_FILES
99
103
  src/h3lib/include/constants.h
100
104
  src/h3lib/include/coordijk.h
101
105
  src/h3lib/include/algos.h
102
- src/h3lib/include/h3api.h
103
106
  src/h3lib/include/stackAlloc.h
104
107
  src/h3lib/lib/algos.c
105
108
  src/h3lib/lib/coordijk.c
@@ -184,8 +187,12 @@ set(OTHER_SOURCE_FILES
184
187
  set(ALL_SOURCE_FILES
185
188
  ${LIB_SOURCE_FILES} ${APP_SOURCE_FILES} ${OTHER_SOURCE_FILES})
186
189
 
190
+ set(UNCONFIGURED_API_HEADER src/h3lib/include/h3api.h.in)
191
+ set(CONFIGURED_API_HEADER src/h3lib/include/h3api.h)
192
+ configure_file(${UNCONFIGURED_API_HEADER} ${CONFIGURED_API_HEADER})
193
+
187
194
  # Build the H3 library
188
- add_library(h3 ${LIB_SOURCE_FILES})
195
+ add_library(h3 ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER})
189
196
 
190
197
  target_compile_options(h3 PRIVATE ${H3_COMPILE_FLAGS})
191
198
  target_link_libraries(h3 PRIVATE ${H3_LINK_FLAGS})
@@ -207,7 +214,8 @@ if(have_vla)
207
214
  target_compile_definitions(h3 PUBLIC H3_HAVE_VLA)
208
215
  endif()
209
216
  target_include_directories(h3 PUBLIC
210
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/h3lib/include>)
217
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/h3lib/include>
218
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/include>)
211
219
 
212
220
  # Automatic code formatting
213
221
  find_program(CLANG_FORMAT_PATH clang-format)
@@ -222,6 +230,7 @@ if(ENABLE_FORMAT)
222
230
  -i
223
231
  ${ALL_SOURCE_FILES}
224
232
  ${EXAMPLE_SOURCE_FILES}
233
+ ${UNCONFIGURED_API_HEADER}
225
234
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
226
235
  COMMENT "Formatting sources"
227
236
  )
@@ -278,6 +287,12 @@ else()
278
287
  )
279
288
  endif()
280
289
 
290
+ # Website publishing
291
+ add_custom_target(publish-website
292
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/publish_website.sh
293
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
294
+ )
295
+
281
296
  # Link all executables against H3
282
297
  macro(add_h3_executable name)
283
298
  # invoke built-in add_executable
@@ -470,6 +485,7 @@ if(BUILD_TESTING)
470
485
  add_h3_test(testH3Distance src/apps/testapps/testH3Distance.c)
471
486
  add_h3_test(testH3Line src/apps/testapps/testH3Line.c)
472
487
  add_h3_test(testCoordIj src/apps/testapps/testCoordIj.c)
488
+ add_h3_test(testBaseCells src/apps/testapps/testBaseCells.c)
473
489
 
474
490
  add_h3_test_with_arg(testH3NeighborRotations src/apps/testapps/testH3NeighborRotations.c 0)
475
491
  add_h3_test_with_arg(testH3NeighborRotations src/apps/testapps/testH3NeighborRotations.c 1)
@@ -552,7 +568,7 @@ install(
552
568
  # * src/h3lib/include/h3api.h -> <prefix>/include/h3/h3api.h
553
569
  # Only the h3api.h header is needed by applications using H3.
554
570
  install(
555
- FILES src/h3lib/include/h3api.h
571
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/include/h3api.h"
556
572
  DESTINATION "${include_install_dir}/h3"
557
573
  )
558
574
 
@@ -7,3 +7,6 @@
7
7
  2. Create a release "Release X.Y.Z" on Github
8
8
  * Create Tag `vX.Y.Z`
9
9
  * Copy CHANGELOG.md into the release notes
10
+
11
+ 3. Publish the website to display the latest docs
12
+ * `make publish-website`
data/ext/h3/src/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.4.0
@@ -34,6 +34,7 @@ As a C library, bindings can be made to call H3 functions from different program
34
34
  ## PostgreSQL
35
35
 
36
36
  - [dlr-eoc/pgh3](https://github.com/dlr-eoc/pgh3)
37
+ - [bytesandbrains/h3-pg](https://github.com/bytesandbrains/h3-pg)
37
38
 
38
39
  ## Python
39
40
 
@@ -0,0 +1,29 @@
1
+ #!/bin/sh
2
+ # Copyright 2019 Uber Technologies, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # This script builds the current version of the H3 documentation website
17
+ # and pushes it to production. This assumes that you have set the remote
18
+ # for gh-pages to the upstream (i.e. uber/h3) remote.
19
+
20
+ git checkout gh-pages
21
+ git pull
22
+ git checkout master
23
+ pushd website
24
+ ./scripts/build-to-gh-pages.sh
25
+ git push
26
+ git checkout master
27
+ popd
28
+
29
+
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright 2017-2019 Uber Technologies, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include <stdlib.h>
18
+ #include "h3api.h"
19
+ #include "test.h"
20
+
21
+ SUITE(baseCells) {
22
+ TEST(getRes0Indexes) {
23
+ int count = H3_EXPORT(res0IndexCount)();
24
+ H3Index* indexes = malloc(count * sizeof(H3Index));
25
+ H3_EXPORT(getRes0Indexes)(indexes);
26
+ t_assert(indexes[0] == 0x8001fffffffffff, "correct first basecell");
27
+ t_assert(indexes[121] == 0x80f3fffffffffff, "correct last basecell");
28
+ free(indexes);
29
+ }
30
+ }
@@ -78,4 +78,10 @@ SUITE(h3Api) {
78
78
  setGeoDegs(&boundary.verts[6], 18.043007860, -66.27669118199998);
79
79
  t_assertBoundary(h3, &boundary);
80
80
  }
81
+
82
+ TEST(version) {
83
+ t_assert(H3_VERSION_MAJOR >= 0, "major version is set");
84
+ t_assert(H3_VERSION_MINOR >= 0, "minor version is set");
85
+ t_assert(H3_VERSION_PATCH >= 0, "patch version is set");
86
+ }
81
87
  }
@@ -54,6 +54,13 @@ extern "C" {
54
54
  /** @brief the H3Index fits within a 64-bit unsigned integer */
55
55
  typedef uint64_t H3Index;
56
56
 
57
+ /* library version numbers generated from VERSION file */
58
+ // clang-format off
59
+ #define H3_VERSION_MAJOR @H3_VERSION_MAJOR@
60
+ #define H3_VERSION_MINOR @H3_VERSION_MINOR@
61
+ #define H3_VERSION_PATCH @H3_VERSION_PATCH@
62
+ // clang-format on
63
+
57
64
  /** Maximum number of cell boundary vertices; worst case is pentagon:
58
65
  * 5 original verts + 5 edge crossings
59
66
  */
@@ -275,6 +282,17 @@ double H3_EXPORT(edgeLengthM)(int res);
275
282
  int64_t H3_EXPORT(numHexagons)(int res);
276
283
  /** @} */
277
284
 
285
+ /** @defgroup getRes0Indexes getRes0Indexes
286
+ * Functions for getRes0Indexes
287
+ * @{
288
+ */
289
+ /** @brief returns the number of resolution 0 indexes */
290
+ int H3_EXPORT(res0IndexCount)();
291
+
292
+ /** @brief provides all base cells */
293
+ void H3_EXPORT(getRes0Indexes)(H3Index *out);
294
+ /** @} */
295
+
278
296
  /** @defgroup h3GetResolution h3GetResolution
279
297
  * Functions for h3GetResolution
280
298
  * @{
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  #include "baseCells.h"
21
+ #include "h3Index.h"
21
22
 
22
23
  /** @struct BaseCellOrient
23
24
  * @brief base cell at a given ijk and required rotations into its system
@@ -886,3 +887,25 @@ Direction _getBaseCellDirection(int originBaseCell, int neighboringBaseCell) {
886
887
  }
887
888
  return INVALID_DIGIT;
888
889
  }
890
+
891
+ /**
892
+ * res0IndexCount returns the number of resolution 0 indexes
893
+ *
894
+ * @return int count of resolution 0 indexes
895
+ */
896
+ int H3_EXPORT(res0IndexCount)() { return NUM_BASE_CELLS; }
897
+
898
+ /**
899
+ * getRes0Indexes generates all base cells storing them into the provided
900
+ * memory pointer. Buffer must be of size NUM_BASE_CELLS * sizeof(H3Index).
901
+ *
902
+ * @param out H3Index* the memory to store the resulting base cells in
903
+ */
904
+ void H3_EXPORT(getRes0Indexes)(H3Index* out) {
905
+ for (int bc = 0; bc < NUM_BASE_CELLS; bc++) {
906
+ H3Index baseCell = H3_INIT;
907
+ H3_SET_MODE(baseCell, H3_HEXAGON_MODE);
908
+ H3_SET_BASE_CELL(baseCell, bc);
909
+ out[bc] = baseCell;
910
+ }
911
+ }
@@ -17,21 +17,8 @@ npm start
17
17
 
18
18
  ## Updating the H3 Website
19
19
 
20
- From `./website`:
20
+ Make sure your `gh-pages` branch has its remote set to the upstream repo, then
21
21
 
22
- Make sure your `gh-pages` branch is up to date with the upstream repo:
23
22
  ```
24
- git checkout gh-pages
25
- git pull upstream gh-pages
26
- ```
27
-
28
- Switch back to `master` and run the build:
29
- ```
30
- git checkout master
31
- ./scripts/build-to-gh-pages.sh
32
- ```
33
-
34
- You're now on branch `gh-pages` again. Push changes to the live site:
35
- ```
36
- git push upstream gh-pages:gh-pages
23
+ make publish-website
37
24
  ```
data/h3.gemspec CHANGED
@@ -15,10 +15,10 @@ Gem::Specification.new do |spec|
15
15
  spec.add_runtime_dependency "ffi", "~> 1.9"
16
16
  spec.add_runtime_dependency "rgeo-geojson", "~> 2.1"
17
17
 
18
+ spec.add_development_dependency "coveralls", "~> 0.8"
18
19
  spec.add_development_dependency "rake", "~> 12.3"
19
20
  spec.add_development_dependency "rspec", "~> 3.8"
20
21
  spec.add_development_dependency "yard", "~> 0.9"
21
- spec.add_development_dependency "coveralls", "~> 0.8"
22
22
 
23
23
  spec.extensions << "ext/h3/extconf.rb"
24
24
  end
data/lib/h3.rb CHANGED
@@ -17,22 +17,23 @@ require "h3/unidirectional_edges"
17
17
  #
18
18
  # @see https://uber.github.io/h3/#/documentation/overview/introduction
19
19
  module H3
20
- class << self
21
- include GeoJSON
22
- include Hierarchy
23
- include Miscellaneous
24
- include Indexing
25
- include Inspection
26
- include Regions
27
- include Traversal
28
- include UnidirectionalEdges
20
+ extend GeoJSON
21
+ extend Hierarchy
22
+ extend Miscellaneous
23
+ extend Indexing
24
+ extend Inspection
25
+ extend Regions
26
+ extend Traversal
27
+ extend UnidirectionalEdges
28
+
29
+ PREDICATES = %i[h3_indexes_neighbors h3_pentagon h3_res_class_3
30
+ h3_unidirectional_edge_valid h3_valid].freeze
31
+ private_constant :PREDICATES
29
32
 
33
+ class << self
30
34
  # FFI's attach_function doesn't allow method names ending with a
31
35
  # question mark. This works around the issue by dynamically
32
36
  # renaming those methods afterwards.
33
- PREDICATES = %i[h3_indexes_neighbors h3_pentagon h3_res_class_3
34
- h3_unidirectional_edge_valid h3_valid].freeze
35
- private_constant :PREDICATES
36
37
  PREDICATES.each do |predicate|
37
38
  alias_method "#{predicate}?", predicate
38
39
  undef_method predicate
@@ -8,6 +8,7 @@ module H3
8
8
  extend H3::Bindings::Base
9
9
 
10
10
  attach_function :compact, [H3IndexesIn, H3IndexesOut, :size], :bool
11
+ attach_function :destroy_linked_polygon, :destroyLinkedPolygon, [LinkedGeoPolygon], :void
11
12
  attach_function :geo_to_h3, :geoToH3, [GeoCoord, Resolution], :h3_index
12
13
  attach_function :h3_indexes_from_unidirectional_edge,
13
14
  :getH3IndexesFromUnidirectionalEdge,
@@ -34,7 +35,10 @@ module H3
34
35
  attach_function :hex_range_distances,
35
36
  :hexRangeDistances,
36
37
  [:h3_index, :k_distance, H3IndexesOut, :output_buffer], :bool
37
- attach_function :hex_ranges, :hexRanges, [H3IndexesIn, :size, :k_distance, H3IndexesOut], :bool
38
+ attach_function :hex_ranges,
39
+ :hexRanges,
40
+ [H3IndexesIn, :size, :k_distance, H3IndexesOut],
41
+ :bool
38
42
  attach_function :hex_ring, :hexRing, [:h3_index, :k_distance, H3IndexesOut], :bool
39
43
  attach_function :k_ring, :kRing, [:h3_index, :k_distance, H3IndexesOut], :void
40
44
  attach_function :k_ring_distances,
@@ -46,7 +50,8 @@ module H3
46
50
  [GeoPolygon, Resolution],
47
51
  :int
48
52
  attach_function :max_uncompact_size, :maxUncompactSize, [H3IndexesIn, :size, Resolution], :int
49
- attach_function :polyfill, [GeoPolygon.by_ref, Resolution, H3IndexesOut], :void
53
+ attach_function :polyfill, [GeoPolygon, Resolution, H3IndexesOut], :void
54
+ attach_function :res_0_indexes, :getRes0Indexes, [H3IndexesOut], :void
50
55
  attach_function :uncompact, [H3IndexesIn, :size, H3IndexesOut, :size, Resolution], :bool
51
56
  end
52
57
  end
@@ -21,7 +21,7 @@ module H3
21
21
  private
22
22
 
23
23
  def failure
24
- raise ArgumentError,
24
+ raise ArgumentError,
25
25
  "resolution must be between #{RES_RANGE.first} and #{RES_RANGE.last}"
26
26
  end
27
27
  end
@@ -35,10 +35,10 @@ module H3
35
35
  h3_set_in.ptr
36
36
  end
37
37
 
38
- attr_reader :ptr, :size
38
+ attr_reader :size
39
39
 
40
40
  def initialize(set)
41
- @size = set.size
41
+ @size = set.size
42
42
  ptr.write_array_of_ulong_long(set)
43
43
  end
44
44
 
data/lib/h3/hierarchy.rb CHANGED
@@ -139,7 +139,6 @@ module H3
139
139
  def uncompact(compacted_set, resolution)
140
140
  max_size = max_uncompact_size(compacted_set, resolution)
141
141
 
142
- failure = false
143
142
  out = H3Indexes.of_size(max_size)
144
143
  h3_set = H3Indexes.with_contents(compacted_set)
145
144
  failure = Bindings::Private.uncompact(h3_set, compacted_set.size, out, max_size, resolution)
@@ -95,5 +95,29 @@ module H3
95
95
  #
96
96
  # @return [Float] Value expressed in degrees.
97
97
  attach_function :rads_to_degs, :radsToDegs, %i[double], :double
98
+
99
+ # @!method res_0_index_count
100
+ #
101
+ # Returns the number of resolution 0 hexagons (base cells).
102
+ #
103
+ # @example Return the number of base cells
104
+ # H3.res_0_index_count
105
+ # 122
106
+ #
107
+ # @return [Integer] The number of resolution 0 hexagons (base cells).
108
+ attach_function :res_0_index_count, :res0IndexCount, [], :int
109
+
110
+ # Returns all resolution 0 hexagons (base cells).
111
+ #
112
+ # @example Return all base cells.
113
+ # H3.res_0_indexes
114
+ # [576495936675512319, 576531121047601151, ..., 580753245698260991]
115
+ #
116
+ # @return [Array<Integer>] All resolution 0 hexagons (base cells).
117
+ def res_0_indexes
118
+ out = H3Indexes.of_size(res_0_index_count)
119
+ Bindings::Private.res_0_indexes(out)
120
+ out.read
121
+ end
98
122
  end
99
123
  end
data/lib/h3/regions.rb CHANGED
@@ -142,6 +142,8 @@ module H3
142
142
  Bindings::Private.h3_set_to_linked_geo(h3_set, h3_indexes.size, linked_geo_polygon)
143
143
 
144
144
  extract_linked_geo_polygon(linked_geo_polygon).first
145
+ ensure
146
+ Bindings::Private.destroy_linked_polygon(linked_geo_polygon)
145
147
  end
146
148
 
147
149
  private
data/lib/h3/traversal.rb CHANGED
@@ -38,7 +38,7 @@ module H3
38
38
  #
39
39
  # This value is simply `h3_distance(origin, destination) + 1` when a line is computable.
40
40
  #
41
- # Returns a negative number if a line cannot be computed e.g.
41
+ # Returns a negative number if a line cannot be computed e.g.
42
42
  # a pentagon was encountered, or the hexagons are too far apart.
43
43
  #
44
44
  # @param [Integer] origin Origin H3 index
data/lib/h3/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module H3
2
- VERSION = "3.3.1".freeze
2
+ VERSION = "3.4.0".freeze
3
3
  end
@@ -72,4 +72,13 @@ RSpec.describe H3 do
72
72
 
73
73
  it { is_expected.to eq(result) }
74
74
  end
75
+
76
+ describe ".res_0_indexes" do
77
+ let(:count) { 122 }
78
+ subject(:res_0_indexes) { H3.res_0_indexes }
79
+
80
+ it "has 122 base cells" do
81
+ expect(res_0_indexes.count).to eq(count)
82
+ end
83
+ end
75
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lachlan Laycock
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-04 00:00:00.000000000 Z
12
+ date: 2019-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -40,61 +40,61 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.1'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: coveralls
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '12.3'
48
+ version: '0.8'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '12.3'
55
+ version: '0.8'
56
56
  - !ruby/object:Gem::Dependency
57
- name: rspec
57
+ name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '3.8'
62
+ version: '12.3'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '3.8'
69
+ version: '12.3'
70
70
  - !ruby/object:Gem::Dependency
71
- name: yard
71
+ name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.9'
76
+ version: '3.8'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '0.9'
83
+ version: '3.8'
84
84
  - !ruby/object:Gem::Dependency
85
- name: coveralls
85
+ name: yard
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '0.8'
90
+ version: '0.9'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '0.8'
97
+ version: '0.9'
98
98
  description:
99
99
  email: l.laycock@stuart.com
100
100
  executables: []
@@ -109,6 +109,7 @@ files:
109
109
  - ".rubocop.yml"
110
110
  - ".travis.yml"
111
111
  - CHANGELOG.md
112
+ - CONTRIBUTING.md
112
113
  - Gemfile
113
114
  - Gemfile.lock
114
115
  - LICENSE.md
@@ -171,6 +172,7 @@ files:
171
172
  - ext/h3/src/scripts/binding_functions.ps1
172
173
  - ext/h3/src/scripts/binding_functions.sh
173
174
  - ext/h3/src/scripts/coverage.sh.in
175
+ - ext/h3/src/scripts/publish_website.sh
174
176
  - ext/h3/src/src/apps/applib/include/benchmark.h
175
177
  - ext/h3/src/src/apps/applib/include/kml.h
176
178
  - ext/h3/src/src/apps/applib/include/test.h
@@ -201,6 +203,7 @@ files:
201
203
  - ext/h3/src/src/apps/testapps/mkRandGeo.c
202
204
  - ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c
203
205
  - ext/h3/src/src/apps/testapps/testBBox.c
206
+ - ext/h3/src/src/apps/testapps/testBaseCells.c
204
207
  - ext/h3/src/src/apps/testapps/testCompact.c
205
208
  - ext/h3/src/src/apps/testapps/testCoordIj.c
206
209
  - ext/h3/src/src/apps/testapps/testGeoCoord.c
@@ -237,7 +240,7 @@ files:
237
240
  - ext/h3/src/src/h3lib/include/geoCoord.h
238
241
  - ext/h3/src/src/h3lib/include/h3Index.h
239
242
  - ext/h3/src/src/h3lib/include/h3UniEdge.h
240
- - ext/h3/src/src/h3lib/include/h3api.h
243
+ - ext/h3/src/src/h3lib/include/h3api.h.in
241
244
  - ext/h3/src/src/h3lib/include/linkedGeo.h
242
245
  - ext/h3/src/src/h3lib/include/localij.h
243
246
  - ext/h3/src/src/h3lib/include/mathExtensions.h