h3 3.6.0 → 3.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_ci.yml +30 -0
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +39 -0
  6. data/Gemfile.lock +6 -24
  7. data/LICENSE.md +1 -1
  8. data/README.md +2 -3
  9. data/ext/h3/src/.github/workflows/test-linux.yml +118 -0
  10. data/ext/h3/src/.github/workflows/test-macos.yml +42 -0
  11. data/ext/h3/src/.github/workflows/test-website.yml +32 -0
  12. data/ext/h3/src/.github/workflows/test-windows.yml +44 -0
  13. data/ext/h3/src/.gitignore +5 -0
  14. data/ext/h3/src/.travis.yml +20 -42
  15. data/ext/h3/src/CHANGELOG.md +57 -0
  16. data/ext/h3/src/CMakeLists.txt +135 -33
  17. data/ext/h3/src/CONTRIBUTING.md +1 -1
  18. data/ext/h3/src/README.md +61 -11
  19. data/ext/h3/src/RELEASE.md +3 -1
  20. data/ext/h3/src/VERSION +1 -1
  21. data/ext/h3/src/dev-docs/RFCs/rfc-template.md +21 -0
  22. data/ext/h3/src/dev-docs/RFCs/v4.0.0/error-handling-rfc.md +21 -0
  23. data/ext/h3/src/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md +276 -0
  24. data/ext/h3/src/dev-docs/RFCs/v4.0.0/overrideable-allocators-rfc.md +141 -0
  25. data/ext/h3/src/dev-docs/RFCs/v4.0.0/polyfill-modes-rfc.md +21 -0
  26. data/ext/h3/src/dev-docs/RFCs/v4.0.0/vertex-mode-rfc.md +50 -0
  27. data/ext/h3/src/dev-docs/build_windows.md +6 -1
  28. data/ext/h3/src/dev-docs/creating_bindings.md +3 -3
  29. data/ext/h3/src/dev-docs/custom_alloc.md +27 -0
  30. data/ext/h3/src/docs/{overview/mainpage.md → README.md} +2 -3
  31. data/ext/h3/src/docs/api/misc.md +76 -0
  32. data/ext/h3/src/docs/community/applications.md +1 -0
  33. data/ext/h3/src/docs/community/bindings.md +10 -0
  34. data/ext/h3/src/docs/community/tutorials.md +8 -3
  35. data/ext/h3/src/docs/core-library/coordsystems.md +5 -4
  36. data/ext/h3/src/docs/core-library/filters.md +8 -9
  37. data/ext/h3/src/docs/core-library/geoToH3desc.md +2 -3
  38. data/ext/h3/src/docs/core-library/h3ToGeoBoundaryDesc.md +4 -5
  39. data/ext/h3/src/docs/core-library/h3ToGeoDesc.md +3 -4
  40. data/ext/h3/src/docs/core-library/h3indexing.md +26 -17
  41. data/ext/h3/src/docs/core-library/overview.md +2 -3
  42. data/ext/h3/src/docs/core-library/restable.md +1 -2
  43. data/ext/h3/src/docs/core-library/usage.md +1 -2
  44. data/ext/h3/src/docs/table-of-contents.json +47 -0
  45. data/ext/h3/src/docs/{overview/usecases.md → usecases.md} +6 -11
  46. data/ext/h3/src/scripts/binding_functions.sh +1 -1
  47. data/ext/h3/src/scripts/coverage.sh.in +1 -1
  48. data/ext/h3/src/scripts/update_version.sh +2 -2
  49. data/ext/h3/src/src/apps/applib/include/args.h +1 -0
  50. data/ext/h3/src/src/apps/applib/include/test.h +1 -0
  51. data/ext/h3/src/src/apps/applib/include/utility.h +7 -1
  52. data/ext/h3/src/src/apps/applib/lib/args.c +2 -0
  53. data/ext/h3/src/src/apps/applib/lib/kml.c +2 -0
  54. data/ext/h3/src/src/apps/applib/lib/test.c +1 -0
  55. data/ext/h3/src/src/apps/applib/lib/utility.c +133 -2
  56. data/ext/h3/src/src/apps/benchmarks/benchmarkH3Api.c +1 -1
  57. data/ext/h3/src/{website/html.config.js → src/apps/benchmarks/benchmarkH3UniEdge.c} +15 -12
  58. data/ext/h3/src/src/apps/filters/h3ToComponents.c +1 -0
  59. data/ext/h3/src/src/apps/filters/h3ToGeo.c +1 -0
  60. data/ext/h3/src/src/apps/filters/h3ToGeoBoundary.c +1 -0
  61. data/ext/h3/src/src/apps/filters/h3ToLocalIj.c +1 -0
  62. data/ext/h3/src/src/apps/filters/hexRange.c +1 -0
  63. data/ext/h3/src/src/apps/filters/kRing.c +1 -0
  64. data/ext/h3/src/src/apps/filters/localIjToH3.c +1 -0
  65. data/ext/h3/src/src/apps/miscapps/generateFaceCenterPoint.c +1 -0
  66. data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +1 -0
  67. data/ext/h3/src/src/apps/miscapps/generatePentagonDirectionFaces.c +67 -0
  68. data/ext/h3/src/src/apps/miscapps/h3ToGeoBoundaryHier.c +1 -0
  69. data/ext/h3/src/src/apps/miscapps/h3ToGeoHier.c +1 -0
  70. data/ext/h3/src/src/apps/miscapps/h3ToHier.c +1 -0
  71. data/ext/h3/src/src/apps/testapps/mkRandGeo.c +1 -0
  72. data/ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c +1 -0
  73. data/ext/h3/src/src/apps/testapps/testBBox.c +1 -0
  74. data/ext/h3/src/src/apps/testapps/testBaseCells.c +15 -1
  75. data/ext/h3/src/src/apps/testapps/testCompact.c +109 -2
  76. data/ext/h3/src/src/apps/testapps/testCoordIj.c +1 -0
  77. data/ext/h3/src/src/apps/testapps/testGeoCoord.c +47 -8
  78. data/ext/h3/src/src/apps/testapps/testGeoToH3.c +1 -0
  79. data/ext/h3/src/src/apps/testapps/testH3Api.c +1 -0
  80. data/ext/h3/src/src/apps/testapps/testH3CellArea.c +47 -0
  81. data/ext/h3/src/src/apps/testapps/testH3CellAreaExhaustive.c +180 -0
  82. data/ext/h3/src/src/apps/testapps/testH3Distance.c +1 -0
  83. data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +1 -0
  84. data/ext/h3/src/src/apps/testapps/testH3GetFaces.c +1 -0
  85. data/ext/h3/src/src/apps/testapps/testH3Index.c +33 -3
  86. data/ext/h3/src/src/apps/testapps/testH3Line.c +1 -0
  87. data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +1 -0
  88. data/ext/h3/src/src/apps/testapps/testH3Memory.c +175 -0
  89. data/ext/h3/src/src/apps/testapps/testH3NeighborRotations.c +1 -0
  90. data/ext/h3/src/src/apps/testapps/testH3SetToLinkedGeo.c +1 -0
  91. data/ext/h3/src/src/apps/testapps/testH3SetToVertexGraph.c +1 -0
  92. data/ext/h3/src/src/apps/testapps/testH3ToCenterChild.c +1 -0
  93. data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +1 -0
  94. data/ext/h3/src/src/apps/testapps/testH3ToGeo.c +1 -0
  95. data/ext/h3/src/src/apps/testapps/testH3ToGeoBoundary.c +1 -0
  96. data/ext/h3/src/src/apps/testapps/testH3ToLocalIj.c +12 -6
  97. data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +1 -0
  98. data/ext/h3/src/src/apps/testapps/testH3ToParent.c +1 -0
  99. data/ext/h3/src/src/apps/testapps/testH3UniEdge.c +45 -16
  100. data/ext/h3/src/src/apps/testapps/testH3UniEdgeExhaustive.c +111 -0
  101. data/ext/h3/src/src/apps/testapps/testHexRanges.c +1 -0
  102. data/ext/h3/src/src/apps/testapps/testHexRing.c +1 -0
  103. data/ext/h3/src/src/apps/testapps/testKRing.c +19 -0
  104. data/ext/h3/src/src/apps/testapps/testLinkedGeo.c +1 -0
  105. data/ext/h3/src/src/apps/testapps/testMaxH3ToChildrenSize.c +1 -0
  106. data/ext/h3/src/src/apps/testapps/testPentagonIndexes.c +1 -0
  107. data/ext/h3/src/src/apps/testapps/testPolyfill.c +72 -9
  108. data/ext/h3/src/src/apps/testapps/testPolyfillReported.c +157 -0
  109. data/ext/h3/src/src/apps/testapps/testPolygon.c +27 -1
  110. data/ext/h3/src/src/apps/testapps/testVec2d.c +1 -0
  111. data/ext/h3/src/src/apps/testapps/testVec3d.c +1 -0
  112. data/ext/h3/src/src/apps/testapps/testVertex.c +66 -0
  113. data/ext/h3/src/src/apps/testapps/testVertexGraph.c +1 -0
  114. data/ext/h3/src/src/h3lib/include/algos.h +8 -0
  115. data/ext/h3/src/src/h3lib/include/alloc.h +40 -0
  116. data/ext/h3/src/src/h3lib/include/baseCells.h +4 -0
  117. data/ext/h3/src/src/h3lib/include/bbox.h +4 -1
  118. data/ext/h3/src/src/h3lib/include/faceijk.h +3 -2
  119. data/ext/h3/src/src/h3lib/include/geoCoord.h +2 -3
  120. data/ext/h3/src/src/h3lib/include/h3Index.h +37 -4
  121. data/ext/h3/src/src/h3lib/include/h3api.h.in +65 -17
  122. data/ext/h3/src/src/h3lib/include/linkedGeo.h +1 -0
  123. data/ext/h3/src/src/h3lib/include/polygon.h +1 -0
  124. data/ext/h3/src/src/h3lib/include/polygonAlgos.h +1 -0
  125. data/ext/h3/src/src/h3lib/include/vertex.h +44 -0
  126. data/ext/h3/src/src/h3lib/include/vertexGraph.h +1 -0
  127. data/ext/h3/src/src/h3lib/lib/algos.c +304 -76
  128. data/ext/h3/src/src/h3lib/lib/baseCells.c +26 -4
  129. data/ext/h3/src/src/h3lib/lib/bbox.c +56 -27
  130. data/ext/h3/src/src/h3lib/lib/coordijk.c +2 -0
  131. data/ext/h3/src/src/h3lib/lib/faceijk.c +32 -21
  132. data/ext/h3/src/src/h3lib/lib/geoCoord.c +162 -44
  133. data/ext/h3/src/src/h3lib/lib/h3Index.c +83 -42
  134. data/ext/h3/src/src/h3lib/lib/h3UniEdge.c +42 -57
  135. data/ext/h3/src/src/h3lib/lib/linkedGeo.c +20 -15
  136. data/ext/h3/src/src/h3lib/lib/localij.c +1 -1
  137. data/ext/h3/src/src/h3lib/lib/polygon.c +2 -0
  138. data/ext/h3/src/src/h3lib/lib/vec2d.c +1 -0
  139. data/ext/h3/src/src/h3lib/lib/vec3d.c +1 -0
  140. data/ext/h3/src/src/h3lib/lib/vertex.c +134 -0
  141. data/ext/h3/src/src/h3lib/lib/vertexGraph.c +8 -5
  142. data/ext/h3/src/website/.eslintignore +2 -0
  143. data/ext/h3/src/website/.gitignore +57 -0
  144. data/ext/h3/src/website/.nvmrc +1 -0
  145. data/ext/h3/src/website/README.md +8 -6
  146. data/ext/h3/src/website/gatsby-config.js +83 -0
  147. data/ext/h3/src/website/package.json +20 -12
  148. data/ext/h3/src/website/scripts/build-to-gh-pages.sh +7 -5
  149. data/ext/h3/src/website/src/.gitkeep +0 -0
  150. data/ext/h3/src/website/templates/documentation.jsx +129 -0
  151. data/ext/h3/src/website/yarn.lock +13723 -0
  152. data/h3.gemspec +2 -2
  153. data/lib/h3/bindings/base.rb +14 -4
  154. data/lib/h3/bindings/private.rb +12 -9
  155. data/lib/h3/hierarchy.rb +0 -18
  156. data/lib/h3/indexing.rb +0 -18
  157. data/lib/h3/inspection.rb +3 -59
  158. data/lib/h3/miscellaneous.rb +119 -14
  159. data/lib/h3/regions.rb +3 -0
  160. data/lib/h3/traversal.rb +0 -18
  161. data/lib/h3/unidirectional_edges.rb +5 -60
  162. data/lib/h3/version.rb +1 -1
  163. data/spec/geo_json_spec.rb +8 -0
  164. data/spec/miscellaneous_spec.rb +117 -0
  165. data/spec/{region_spec.rb → regions_spec.rb} +1 -1
  166. data/spec/spec_helper.rb +2 -2
  167. metadata +44 -36
  168. data/.travis.yml +0 -11
  169. data/ext/h3/src/.ycm_extra_conf.py +0 -92
  170. data/ext/h3/src/appveyor.yml +0 -50
  171. data/ext/h3/src/website/src/config.js +0 -46
  172. data/ext/h3/src/website/src/mdRoutes.js +0 -151
  173. data/ext/h3/src/website/src/styles/_variables.scss +0 -16
  174. data/ext/h3/src/website/src/styles/index.scss +0 -3
  175. data/ext/h3/src/website/static/index.html +0 -15
@@ -15,12 +15,17 @@
15
15
  language: c
16
16
 
17
17
  os: linux
18
- dist: xenial
18
+ dist: bionic
19
19
 
20
20
  compiler:
21
21
  - gcc
22
22
  - clang
23
23
 
24
+ arch:
25
+ - arm64
26
+ - ppc64le
27
+ - s390x
28
+
24
29
  # Docs are built during the normal compile/test check.
25
30
  addons:
26
31
  apt:
@@ -30,49 +35,22 @@ addons:
30
35
 
31
36
  matrix:
32
37
  include:
33
- # Check that clang-format doesn't detect some files are not formatted.
34
- - env: NAME="Formatting check"
35
- compiler: clang
36
- addons:
37
- apt:
38
- sources:
39
- - llvm-toolchain-trusty-5.0
40
- packages:
41
- - clang-format-5.0
42
- script: make format && git diff --exit-code
43
- # Submit coverage report to Coveralls.io, also test that prefixing works.
44
- - env: NAME="Coverage report"
45
- compiler: gcc
46
- addons:
47
- apt:
48
- packages:
49
- - lcov
50
- install:
51
- - gem install coveralls-lcov
52
- before_script:
53
- - cmake -DCMAKE_BUILD_TYPE=Debug -DWARNINGS_AS_ERRORS=ON -DH3_PREFIX=testprefix_ .
54
- script:
55
- - make && make coverage
56
- after_success:
57
- - coveralls-lcov coverage.cleaned.info
58
- - env: NAME="Valgrind test"
59
- compiler: gcc
60
- addons:
61
- apt:
62
- packages:
63
- - valgrind
38
+ # Test building the website also - needed for FOSSA to pick up dependencies
39
+ # FOSSA is run here because the API key will not be present in Github Actions.
40
+ # Blocked on https://github.com/fossas/fossa-cli/issues/617
41
+ - name: "Website and FOSSA report"
42
+ arch: amd64
43
+ language: node_js
44
+ node_js: 10
45
+ install: []
64
46
  before_script:
65
- - cmake -DCMAKE_BUILD_TYPE=Debug -DWRAP_VALGRIND=ON .
66
- script:
67
- - make
68
- - CTEST_OUTPUT_ON_FAILURE=1 make test-fast
69
- - env: NAME="Mac OSX (Xcode 8)"
70
- os: osx
71
- - env: NAME="binding-functions target"
47
+ - "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash"
72
48
  script:
73
- - make binding-functions
74
- # Check that the file exists and has contents
75
- - test -s binding-functions
49
+ - cd website
50
+ - yarn
51
+ - yarn build
52
+ - cd ..
53
+ - 'if [ -n "$FOSSA_API_KEY" ]; then fossa; fi'
76
54
 
77
55
  # Configure the build script, out of source.
78
56
  before_script:
@@ -7,6 +7,63 @@ The public API of this library consists of the functions declared in file
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.7.2] - 2021-07-15
11
+ ### Fixed
12
+ - `gridDisk` of invalid indexes should not crash. (#498)
13
+
14
+ ## [3.7.1] - 2020-10-05
15
+ ### Fixed
16
+ - Finding invalid edge boundaries should not crash. (#399)
17
+ - Build fixes for FreeBSD. (#397)
18
+
19
+ ## [3.7.0] - 2020-09-28
20
+ ### Added
21
+ - Area and haversine distance functions (#377):
22
+ - `cellAreaRads2`
23
+ - `cellAreaKm2`
24
+ - `cellAreaM2`
25
+ - `pointDistRads`
26
+ - `pointDistKm`
27
+ - `pointDistM`
28
+ - `exactEdgeLengthRads`
29
+ - `exactEdgeLengthKm`
30
+ - `exactEdgeLengthM`
31
+ - Refactor `getH3UnidirectionalEdgeBoundary` for accuracy at small resolutions. (#391)
32
+ - Speeds up `getH3UnidirectionalEdgeBoundary` by about 3x.
33
+ - Implement core logic for future vertex mode.
34
+ ### Fixed
35
+ - Fixed building the library with custom memory allocation functions on Mac OSX. (#362)
36
+ - The installed H3 CMake target should have include directories specified. (#381)
37
+ ### Changed
38
+ - Tests now use `bash` on Windows. (#381)
39
+
40
+ ## [3.6.4] - 2020-06-19
41
+ ### Added
42
+ - `H3_MEMORY_PREFIX` CMake option for replacing the memory management functions used in H3. (#317)
43
+ - Support for building Debian packages of H3. (#352)
44
+ ### Fixed
45
+ - Removed duplicate include statements. (#333)
46
+ - Fixed macro `H3_DIGIT_MASK_NEGATIVE`. (#329)
47
+ ## Changed
48
+ - Again implement new `polyfill` algorithm. (#313)
49
+
50
+ ## [3.6.3] - 2020-01-21
51
+ ### Fixed
52
+ - `compact` detects and fails on cases with duplicated input indexes. (#299)
53
+ ### Changed
54
+ - `h3IsValid` returns false for indexes that have non-zero reserved bits. (#300)
55
+ - `h3IsValid` and `h3UnidirectionalEdgeIsValid` return false for indexes with the high bit set. (#300)
56
+
57
+ ## [3.6.2] - 2019-12-9
58
+ - Revert new `polyfill` algorithm until reported issues are fixed. (#293)
59
+
60
+ ## [3.6.1] - 2019-11-11
61
+ ### Fixed
62
+ - `compact` handles zero length input correctly. (#278)
63
+ - `bboxHexRadius` scaling factor adjusted to guarantee containment for `polyfill`. (#279)
64
+ - `polyfill` new algorithm for up to 3x perf boost. (#282)
65
+ - Fix CMake targets for KML generation. (#285)
66
+
10
67
  ## [3.6.0] - 2019-08-12
11
68
  ### Added
12
69
  - `h3ToCenterChild` function to find center child at given resolution (#267)
@@ -1,4 +1,4 @@
1
- # Copyright 2017-2019 Uber Technologies, Inc.
1
+ # Copyright 2017-2020 Uber Technologies, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
15
15
  cmake_minimum_required(VERSION 3.1)
16
16
 
17
17
  set(H3_PREFIX "" CACHE STRING "Prefix for exported symbols")
18
+ set(H3_ALLOC_PREFIX "" CACHE STRING "Prefix for allocation functions")
18
19
 
19
20
  # Needed due to CMP0042
20
21
  set(CMAKE_MACOSX_RPATH 1)
@@ -34,7 +35,8 @@ option(BUILD_FILTERS "Build filter applications." ON)
34
35
  option(BUILD_GENERATORS "Build code generation applications." ON)
35
36
 
36
37
  if(WIN32)
37
- set(SHELL PowerShell -Command)
38
+ # Use bash (usually from Git for Windows) for piping results
39
+ set(SHELL bash -c)
38
40
 
39
41
  set(EXECUTABLE_OUTPUT_PATH bin)
40
42
  set(LIBRARY_OUTPUT_PATH bin)
@@ -107,6 +109,7 @@ set(LIB_SOURCE_FILES
107
109
  src/h3lib/lib/h3Index.c
108
110
  src/h3lib/lib/vec2d.c
109
111
  src/h3lib/lib/vec3d.c
112
+ src/h3lib/lib/vertex.c
110
113
  src/h3lib/lib/linkedGeo.c
111
114
  src/h3lib/lib/localij.c
112
115
  src/h3lib/lib/geoCoord.c
@@ -143,6 +146,7 @@ set(OTHER_SOURCE_FILES
143
146
  src/apps/testapps/testVertexGraph.c
144
147
  src/apps/testapps/testCompact.c
145
148
  src/apps/testapps/testPolyfill.c
149
+ src/apps/testapps/testPolyfillReported.c
146
150
  src/apps/testapps/testPentagonIndexes.c
147
151
  src/apps/testapps/testKRing.c
148
152
  src/apps/testapps/testH3ToGeoBoundary.c
@@ -161,10 +165,12 @@ set(OTHER_SOURCE_FILES
161
165
  src/apps/testapps/testHexRing.c
162
166
  src/apps/testapps/testH3SetToVertexGraph.c
163
167
  src/apps/testapps/testBBox.c
168
+ src/apps/testapps/testVertex.c
164
169
  src/apps/testapps/testPolygon.c
165
170
  src/apps/testapps/testVec2d.c
166
171
  src/apps/testapps/testVec3d.c
167
172
  src/apps/testapps/testH3UniEdge.c
173
+ src/apps/testapps/testH3UniEdgeExhaustive.c
168
174
  src/apps/testapps/testLinkedGeo.c
169
175
  src/apps/testapps/mkRandGeo.c
170
176
  src/apps/testapps/testH3Api.c
@@ -175,11 +181,15 @@ set(OTHER_SOURCE_FILES
175
181
  src/apps/testapps/testH3DistanceExhaustive.c
176
182
  src/apps/testapps/testH3Line.c
177
183
  src/apps/testapps/testH3LineExhaustive.c
184
+ src/apps/testapps/testH3CellArea.c
185
+ src/apps/testapps/testH3CellAreaExhaustive.c
178
186
  src/apps/testapps/testCoordIj.c
179
187
  src/apps/testapps/testCoordIjk.c
188
+ src/apps/testapps/testH3Memory.c
180
189
  src/apps/miscapps/h3ToGeoBoundaryHier.c
181
190
  src/apps/miscapps/h3ToGeoHier.c
182
191
  src/apps/miscapps/generateBaseCellNeighbors.c
192
+ src/apps/miscapps/generatePentagonDirectionFaces.c
183
193
  src/apps/miscapps/generateNumHexagons.c
184
194
  src/apps/miscapps/generateFaceCenterPoint.c
185
195
  src/apps/miscapps/h3ToHier.c
@@ -188,6 +198,7 @@ set(OTHER_SOURCE_FILES
188
198
  src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c
189
199
  src/apps/benchmarks/benchmarkKRing.c
190
200
  src/apps/benchmarks/benchmarkH3Line.c
201
+ src/apps/benchmarks/benchmarkH3UniEdge.c
191
202
  src/apps/benchmarks/benchmarkH3Api.c)
192
203
 
193
204
  set(ALL_SOURCE_FILES
@@ -197,36 +208,55 @@ set(UNCONFIGURED_API_HEADER src/h3lib/include/h3api.h.in)
197
208
  set(CONFIGURED_API_HEADER src/h3lib/include/h3api.h)
198
209
  configure_file(${UNCONFIGURED_API_HEADER} ${CONFIGURED_API_HEADER})
199
210
 
200
- set(INSTALL_TARGETS h3)
211
+ set(INSTALL_TARGETS)
201
212
 
202
- # Build the H3 library
203
- add_library(h3 ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER})
213
+ function(add_h3_library name h3_alloc_prefix_override)
214
+ add_library(${name} ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER})
204
215
 
205
- target_compile_options(h3 PRIVATE ${H3_COMPILE_FLAGS})
206
- target_link_libraries(h3 PRIVATE ${H3_LINK_FLAGS})
216
+ target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS})
217
+ target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS})
207
218
 
208
- find_library(M_LIB m)
209
- if(M_LIB)
210
- target_link_libraries(h3 PUBLIC ${M_LIB})
211
- endif()
219
+ find_library(M_LIB m)
220
+ if(M_LIB)
221
+ target_link_libraries(${name} PUBLIC ${M_LIB})
222
+ endif()
212
223
 
213
- if(BUILD_SHARED_LIBS)
214
- set_target_properties(h3 PROPERTIES SOVERSION ${H3_SOVERSION})
215
- endif()
224
+ if(BUILD_SHARED_LIBS)
225
+ set_target_properties(${name} PROPERTIES SOVERSION ${H3_SOVERSION})
226
+ endif()
216
227
 
217
- target_compile_definitions(h3 PUBLIC H3_PREFIX=${H3_PREFIX})
218
- if(have_alloca)
219
- target_compile_definitions(h3 PUBLIC H3_HAVE_ALLOCA)
220
- endif()
221
- if(have_vla)
222
- target_compile_definitions(h3 PUBLIC H3_HAVE_VLA)
223
- endif()
224
- target_include_directories(h3 PUBLIC
225
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/h3lib/include>
226
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/include>)
228
+ target_compile_definitions(${name} PUBLIC H3_PREFIX=${H3_PREFIX})
229
+ set(has_alloc_prefix NO)
230
+ if(h3_alloc_prefix_override)
231
+ set(has_alloc_prefix YES)
232
+ target_compile_definitions(${name} PUBLIC H3_ALLOC_PREFIX=${h3_alloc_prefix_override})
233
+ elseif(H3_ALLOC_PREFIX)
234
+ set(has_alloc_prefix YES)
235
+ target_compile_definitions(${name} PUBLIC H3_ALLOC_PREFIX=${H3_ALLOC_PREFIX})
236
+ endif()
237
+ # Mac OSX defaults to not looking up undefined symbols dynamically,
238
+ # so enable that explicitly.
239
+ if(has_alloc_prefix AND APPLE)
240
+ target_link_libraries(${name} PRIVATE "-undefined dynamic_lookup")
241
+ endif()
242
+
243
+ if(have_alloca)
244
+ target_compile_definitions(${name} PUBLIC H3_HAVE_ALLOCA)
245
+ endif()
246
+ if(have_vla)
247
+ target_compile_definitions(${name} PUBLIC H3_HAVE_VLA)
248
+ endif()
249
+ target_include_directories(${name} PUBLIC
250
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/h3lib/include>
251
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/include>)
252
+ endfunction()
253
+
254
+ # Build the H3 library
255
+ add_h3_library(h3 "")
227
256
 
228
257
  # Automatic code formatting
229
- find_program(CLANG_FORMAT_PATH clang-format)
258
+ # Give preference to clang-format-9
259
+ find_program(CLANG_FORMAT_PATH NAMES clang-format-9 clang-format)
230
260
  cmake_dependent_option(
231
261
  ENABLE_FORMAT "Enable running clang-format before compiling" ON
232
262
  "CLANG_FORMAT_PATH" OFF)
@@ -349,11 +379,11 @@ if(BUILD_FILTERS)
349
379
  set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "KML/res${resolution}cells.kml")
350
380
  set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "KML/res${resolution}centers.kml")
351
381
  add_custom_target(kml_cells_${resolution}
352
- COMMAND ${SHELL} "$<TARGET_FILE:h3ToHier> ${resolution} | $<TARGET_FILE:h3ToGeoBoundary> 1 res${resolution}cells.kml \"Res ${resolution} Cells\" > KML/res${resolution}cells.kml"
382
+ COMMAND ${SHELL} "$<TARGET_FILE:h3ToHier> -r ${resolution} | $<TARGET_FILE:h3ToGeoBoundary> --kml --kml-name res${resolution}cells.kml --kml-description \"Res ${resolution} Cells\" > KML/res${resolution}cells.kml"
353
383
  VERBATIM
354
384
  DEPENDS create-kml-dir)
355
385
  add_custom_target(kml_centers_${resolution}
356
- COMMAND ${SHELL} "$<TARGET_FILE:h3ToHier> ${resolution} | $<TARGET_FILE:h3ToGeo> 1 res${resolution}centers.kml \"Res ${resolution} Centers\" > KML/res${resolution}centers.kml"
386
+ COMMAND ${SHELL} "$<TARGET_FILE:h3ToHier> -r ${resolution} | $<TARGET_FILE:h3ToGeo> --kml --kml-name res${resolution}centers.kml --kml-description \"Res ${resolution} Centers\" > KML/res${resolution}centers.kml"
357
387
  VERBATIM
358
388
  DEPENDS create-kml-dir)
359
389
  add_dependencies(kml
@@ -365,6 +395,7 @@ endif()
365
395
  if(BUILD_GENERATORS)
366
396
  # Code generation
367
397
  add_h3_executable(generateBaseCellNeighbors src/apps/miscapps/generateBaseCellNeighbors.c ${APP_SOURCE_FILES})
398
+ add_h3_executable(generatePentagonDirectionFaces src/apps/miscapps/generatePentagonDirectionFaces.c ${APP_SOURCE_FILES})
368
399
  add_h3_executable(generateNumHexagons src/apps/miscapps/generateNumHexagons.c ${APP_SOURCE_FILES})
369
400
  add_h3_executable(generateFaceCenterPoint src/apps/miscapps/generateFaceCenterPoint.c ${APP_SOURCE_FILES})
370
401
 
@@ -398,6 +429,37 @@ if(BUILD_TESTING)
398
429
  )
399
430
  endif()
400
431
 
432
+ add_h3_library(h3WithTestAllocators test_prefix_)
433
+
434
+ macro(add_h3_memory_test name srcfile)
435
+ # Like other test code, but these need to be linked against
436
+ # a different copy of the H3 library which has known intercepted
437
+ # allocator functions.
438
+ add_executable(${ARGV} ${APP_SOURCE_FILES})
439
+
440
+ if(TARGET ${name})
441
+ target_link_libraries(${name} PUBLIC h3WithTestAllocators)
442
+ target_include_directories(${name} PUBLIC
443
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/apps/applib/include>)
444
+ target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS})
445
+ target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS})
446
+ endif()
447
+
448
+ math(EXPR test_number "${test_number}+1")
449
+
450
+ add_test(NAME ${name}_test${test_number} COMMAND ${TEST_WRAPPER} "$<TARGET_FILE:${name}>")
451
+
452
+ if(ENABLE_COVERAGE)
453
+ add_custom_target(${name}_coverage${test_number}
454
+ COMMAND ${name} > /dev/null
455
+ COMMENT "Running ${name}_coverage${test_number}"
456
+ )
457
+
458
+ add_dependencies(coverage ${name}_coverage${test_number})
459
+ add_dependencies(${name}_coverage${test_number} clean-coverage)
460
+ endif()
461
+ endmacro()
462
+
401
463
  macro(add_h3_test_common name srcfile)
402
464
  # need to actually make the test target
403
465
  if(NOT TARGET ${name})
@@ -425,11 +487,7 @@ if(BUILD_TESTING)
425
487
  macro(add_h3_test_with_file name srcfile argfile)
426
488
  add_h3_test_common(${name} ${srcfile})
427
489
  # add a special command (so we don't need to read the test file from the test program)
428
- if(WIN32)
429
- set(dump_command "Get-Content")
430
- else()
431
- set(dump_command "cat")
432
- endif()
490
+ set(dump_command "cat")
433
491
 
434
492
  add_test(NAME ${name}_test${test_number}
435
493
  COMMAND ${SHELL} "${dump_command} ${argfile} | ${TEST_WRAPPER_STR} $<TARGET_FILE:${name}>")
@@ -470,7 +528,6 @@ if(BUILD_TESTING)
470
528
  endmacro()
471
529
 
472
530
  # Add each individual test
473
-
474
531
  file(GLOB all_centers tests/inputfiles/bc*centers.txt)
475
532
  foreach(file ${all_centers})
476
533
  add_h3_test_with_file(testH3ToGeo src/apps/testapps/testH3ToGeo.c ${file})
@@ -506,16 +563,19 @@ if(BUILD_TESTING)
506
563
  add_h3_test(testH3SetToVertexGraph src/apps/testapps/testH3SetToVertexGraph.c)
507
564
  add_h3_test(testLinkedGeo src/apps/testapps/testLinkedGeo.c)
508
565
  add_h3_test(testPolyfill src/apps/testapps/testPolyfill.c)
566
+ add_h3_test(testPolyfillReported src/apps/testapps/testPolyfillReported.c)
509
567
  add_h3_test(testVertexGraph src/apps/testapps/testVertexGraph.c)
510
568
  add_h3_test(testH3UniEdge src/apps/testapps/testH3UniEdge.c)
511
569
  add_h3_test(testGeoCoord src/apps/testapps/testGeoCoord.c)
512
570
  add_h3_test(testBBox src/apps/testapps/testBBox.c)
571
+ add_h3_test(testVertex src/apps/testapps/testVertex.c)
513
572
  add_h3_test(testPolygon src/apps/testapps/testPolygon.c)
514
573
  add_h3_test(testVec2d src/apps/testapps/testVec2d.c)
515
574
  add_h3_test(testVec3d src/apps/testapps/testVec3d.c)
516
575
  add_h3_test(testH3ToLocalIj src/apps/testapps/testH3ToLocalIj.c)
517
576
  add_h3_test(testH3Distance src/apps/testapps/testH3Distance.c)
518
577
  add_h3_test(testH3Line src/apps/testapps/testH3Line.c)
578
+ add_h3_test(testH3CellArea src/apps/testapps/testH3CellArea.c)
519
579
  add_h3_test(testCoordIj src/apps/testapps/testCoordIj.c)
520
580
  add_h3_test(testCoordIjk src/apps/testapps/testCoordIjk.c)
521
581
  add_h3_test(testBaseCells src/apps/testapps/testBaseCells.c)
@@ -527,9 +587,13 @@ if(BUILD_TESTING)
527
587
 
528
588
  # The "Exhaustive" part of the test name is used by the test-fast to exclude these files.
529
589
  # test-fast exists so that Travis CI can run Valgrind on tests without taking a very long time.
590
+ add_h3_test(testH3UniEdgeExhaustive src/apps/testapps/testH3UniEdgeExhaustive.c)
530
591
  add_h3_test(testH3ToLocalIjExhaustive src/apps/testapps/testH3ToLocalIjExhaustive.c)
531
592
  add_h3_test(testH3LineExhaustive src/apps/testapps/testH3LineExhaustive.c)
532
593
  add_h3_test(testH3DistanceExhaustive src/apps/testapps/testH3DistanceExhaustive.c)
594
+ add_h3_test(testH3CellAreaExhaustive src/apps/testapps/testH3CellAreaExhaustive.c)
595
+
596
+ add_h3_memory_test(testH3Memory src/apps/testapps/testH3Memory.c)
533
597
 
534
598
  add_custom_target(test-fast COMMAND ctest -E Exhaustive)
535
599
  endif()
@@ -547,6 +611,7 @@ if(BUILD_BENCHMARKS)
547
611
  add_h3_benchmark(benchmarkH3Api src/apps/benchmarks/benchmarkH3Api.c)
548
612
  add_h3_benchmark(benchmarkKRing src/apps/benchmarks/benchmarkKRing.c)
549
613
  add_h3_benchmark(benchmarkH3Line src/apps/benchmarks/benchmarkH3Line.c)
614
+ add_h3_benchmark(benchmarkH3UniEdge src/apps/benchmarks/benchmarkH3UniEdge.c)
550
615
  add_h3_benchmark(benchmarkH3SetToLinkedGeo src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c)
551
616
  add_h3_benchmark(benchmarkPolyfill src/apps/benchmarks/benchmarkPolyfill.c)
552
617
  add_h3_benchmark(benchmarkPolygon src/apps/benchmarks/benchmarkPolygon.c)
@@ -569,6 +634,10 @@ set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
569
634
  set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
570
635
  set(namespace "${PROJECT_NAME}::")
571
636
 
637
+ # TODO: Unclear why this is needed to get the libh3 Debian package to build correctly
638
+ # with shared libraries.
639
+ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "libh3")
640
+
572
641
  # Include module with fuction 'write_basic_package_version_file'
573
642
  include(CMakePackageConfigHelpers)
574
643
 
@@ -597,6 +666,14 @@ configure_package_config_file(
597
666
  install(
598
667
  TARGETS ${INSTALL_TARGETS}
599
668
  EXPORT "${TARGETS_EXPORT_NAME}"
669
+ RUNTIME DESTINATION "bin"
670
+ COMPONENT h3
671
+ )
672
+
673
+ install(
674
+ TARGETS h3
675
+ EXPORT "${TARGETS_EXPORT_NAME}"
676
+ COMPONENT libh3
600
677
  LIBRARY DESTINATION "lib"
601
678
  ARCHIVE DESTINATION "lib"
602
679
  RUNTIME DESTINATION "bin"
@@ -609,6 +686,7 @@ install(
609
686
  install(
610
687
  FILES "${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/include/h3api.h"
611
688
  DESTINATION "${include_install_dir}/h3"
689
+ COMPONENT libh3-dev
612
690
  )
613
691
 
614
692
  # Config
@@ -617,6 +695,7 @@ install(
617
695
  install(
618
696
  FILES "${project_config}" "${version_config}"
619
697
  DESTINATION "${config_install_dir}"
698
+ COMPONENT libh3-dev
620
699
  )
621
700
 
622
701
  # Config
@@ -625,4 +704,27 @@ install(
625
704
  EXPORT "${TARGETS_EXPORT_NAME}"
626
705
  NAMESPACE "${namespace}"
627
706
  DESTINATION "${config_install_dir}"
707
+ COMPONENT libh3-dev
628
708
  )
709
+
710
+ # Debian package build
711
+ set(CPACK_DEB_COMPONENT_INSTALL 1)
712
+ set(CPACK_GENERATOR "DEB")
713
+ set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
714
+ # set(CPACK_DEBIAN_PACKAGE_MAINTAINER "TEST PACKAGE") # Required
715
+ set(CPACK_PACKAGE_HOMEPAGE_URL "https://www.h3geo.org")
716
+ set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
717
+ set(CPACK_DEBIAN_LIBH3_PACKAGE_DEPENDS "libc6 (>= 2.27)")
718
+ set(CPACK_DEBIAN_LIBH3-DEV_PACKAGE_DEPENDS "libh3 (= ${H3_VERSION})")
719
+ set(CPACK_DEBIAN_H3_PACKAGE_DEPENDS "libc6 (>= 2.27), libh3 (= ${H3_VERSION})")
720
+ set(CPACK_DEBIAN_LIBH3_DESCRIPTION "Library files for the H3 hexagonal discrete global grid system.")
721
+ set(CPACK_DEBIAN_LIBH3-DEV_DESCRIPTION "Development files and headers for the H3 hexagonal discrete global grid system.")
722
+ set(CPACK_DEBIAN_H3_DESCRIPTION "UNIX style filter (command line) tools for the H3 hexagonal discrete global grid system.")
723
+ set(CPACK_DEBIAN_LIBH3_PACKAGE_NAME "libh3")
724
+ set(CPACK_DEBIAN_LIBH3-DEV_PACKAGE_NAME "libh3-dev")
725
+ set(CPACK_DEBIAN_H3_PACKAGE_NAME "h3")
726
+ set(CPACK_DEBIAN_LIBH3_PACKAGE_SECTION "libs")
727
+ set(CPACK_DEBIAN_LIBH3-DEV_PACKAGE_SECTION "libdevel")
728
+ set(CPACK_DEBIAN_H3_PACKAGE_SECTION "science")
729
+
730
+ include(CPack)