h3 3.6.2 → 3.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +6 -6
- data/README.md +1 -1
- data/ext/h3/src/.github/workflows/test-linux.yml +118 -0
- data/ext/h3/src/.github/workflows/test-macos.yml +42 -0
- data/ext/h3/src/.github/workflows/test-website.yml +32 -0
- data/ext/h3/src/.github/workflows/test-windows.yml +44 -0
- data/ext/h3/src/.gitignore +5 -0
- data/ext/h3/src/.travis.yml +16 -46
- data/ext/h3/src/CHANGELOG.md +43 -0
- data/ext/h3/src/CMakeLists.txt +133 -33
- data/ext/h3/src/CONTRIBUTING.md +1 -1
- data/ext/h3/src/README.md +60 -10
- data/ext/h3/src/RELEASE.md +3 -1
- data/ext/h3/src/VERSION +1 -1
- data/ext/h3/src/dev-docs/RFCs/rfc-template.md +21 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/error-handling-rfc.md +21 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md +276 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/overrideable-allocators-rfc.md +141 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/polyfill-modes-rfc.md +21 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/vertex-mode-rfc.md +50 -0
- data/ext/h3/src/dev-docs/build_windows.md +6 -1
- data/ext/h3/src/dev-docs/creating_bindings.md +3 -3
- data/ext/h3/src/dev-docs/custom_alloc.md +27 -0
- data/ext/h3/src/docs/{overview/mainpage.md → README.md} +2 -3
- data/ext/h3/src/docs/api/misc.md +76 -0
- data/ext/h3/src/docs/community/applications.md +1 -0
- data/ext/h3/src/docs/community/bindings.md +7 -1
- data/ext/h3/src/docs/community/tutorials.md +8 -3
- data/ext/h3/src/docs/core-library/coordsystems.md +5 -4
- data/ext/h3/src/docs/core-library/filters.md +8 -9
- data/ext/h3/src/docs/core-library/geoToH3desc.md +2 -3
- data/ext/h3/src/docs/core-library/h3ToGeoBoundaryDesc.md +4 -5
- data/ext/h3/src/docs/core-library/h3ToGeoDesc.md +3 -4
- data/ext/h3/src/docs/core-library/h3indexing.md +26 -17
- data/ext/h3/src/docs/core-library/overview.md +2 -3
- data/ext/h3/src/docs/core-library/restable.md +1 -2
- data/ext/h3/src/docs/core-library/usage.md +1 -2
- data/ext/h3/src/docs/table-of-contents.json +47 -0
- data/ext/h3/src/docs/{overview/usecases.md → usecases.md} +6 -11
- data/ext/h3/src/scripts/binding_functions.sh +1 -1
- data/ext/h3/src/scripts/coverage.sh.in +1 -1
- data/ext/h3/src/scripts/update_version.sh +2 -2
- data/ext/h3/src/src/apps/applib/include/args.h +1 -0
- data/ext/h3/src/src/apps/applib/include/test.h +1 -0
- data/ext/h3/src/src/apps/applib/include/utility.h +7 -1
- data/ext/h3/src/src/apps/applib/lib/args.c +2 -0
- data/ext/h3/src/src/apps/applib/lib/kml.c +2 -0
- data/ext/h3/src/src/apps/applib/lib/test.c +1 -0
- data/ext/h3/src/src/apps/applib/lib/utility.c +133 -2
- data/ext/h3/src/src/apps/benchmarks/benchmarkH3Api.c +1 -1
- data/ext/h3/src/{website/html.config.js → src/apps/benchmarks/benchmarkH3UniEdge.c} +15 -12
- data/ext/h3/src/src/apps/filters/h3ToComponents.c +1 -0
- data/ext/h3/src/src/apps/filters/h3ToGeo.c +1 -0
- data/ext/h3/src/src/apps/filters/h3ToGeoBoundary.c +1 -0
- data/ext/h3/src/src/apps/filters/h3ToLocalIj.c +1 -0
- data/ext/h3/src/src/apps/filters/hexRange.c +1 -0
- data/ext/h3/src/src/apps/filters/kRing.c +1 -0
- data/ext/h3/src/src/apps/filters/localIjToH3.c +1 -0
- data/ext/h3/src/src/apps/miscapps/generateFaceCenterPoint.c +1 -0
- data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +1 -0
- data/ext/h3/src/src/apps/miscapps/generatePentagonDirectionFaces.c +67 -0
- data/ext/h3/src/src/apps/miscapps/h3ToGeoBoundaryHier.c +1 -0
- data/ext/h3/src/src/apps/miscapps/h3ToGeoHier.c +1 -0
- data/ext/h3/src/src/apps/miscapps/h3ToHier.c +1 -0
- data/ext/h3/src/src/apps/testapps/mkRandGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c +1 -0
- data/ext/h3/src/src/apps/testapps/testBBox.c +1 -0
- data/ext/h3/src/src/apps/testapps/testBaseCells.c +15 -1
- data/ext/h3/src/src/apps/testapps/testCompact.c +75 -0
- data/ext/h3/src/src/apps/testapps/testCoordIj.c +1 -0
- data/ext/h3/src/src/apps/testapps/testGeoCoord.c +40 -13
- data/ext/h3/src/src/apps/testapps/testGeoToH3.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3Api.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3CellArea.c +47 -0
- data/ext/h3/src/src/apps/testapps/testH3CellAreaExhaustive.c +180 -0
- data/ext/h3/src/src/apps/testapps/testH3Distance.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3GetFaces.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3Index.c +33 -3
- data/ext/h3/src/src/apps/testapps/testH3Line.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3Memory.c +175 -0
- data/ext/h3/src/src/apps/testapps/testH3NeighborRotations.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3SetToLinkedGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3SetToVertexGraph.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToCenterChild.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToGeoBoundary.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIj.c +9 -5
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToParent.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3UniEdge.c +45 -16
- data/ext/h3/src/src/apps/testapps/testH3UniEdgeExhaustive.c +111 -0
- data/ext/h3/src/src/apps/testapps/testHexRanges.c +1 -0
- data/ext/h3/src/src/apps/testapps/testHexRing.c +1 -0
- data/ext/h3/src/src/apps/testapps/testKRing.c +1 -0
- data/ext/h3/src/src/apps/testapps/testLinkedGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/testMaxH3ToChildrenSize.c +1 -0
- data/ext/h3/src/src/apps/testapps/testPentagonIndexes.c +1 -0
- data/ext/h3/src/src/apps/testapps/testPolyfill.c +72 -9
- data/ext/h3/src/src/apps/testapps/testPolyfillReported.c +157 -0
- data/ext/h3/src/src/apps/testapps/testPolygon.c +1 -0
- data/ext/h3/src/src/apps/testapps/testVec2d.c +1 -0
- data/ext/h3/src/src/apps/testapps/testVec3d.c +1 -0
- data/ext/h3/src/src/apps/testapps/testVertex.c +66 -0
- data/ext/h3/src/src/apps/testapps/testVertexGraph.c +1 -0
- data/ext/h3/src/src/h3lib/include/algos.h +8 -0
- data/ext/h3/src/src/h3lib/include/alloc.h +40 -0
- data/ext/h3/src/src/h3lib/include/baseCells.h +4 -0
- data/ext/h3/src/src/h3lib/include/bbox.h +4 -1
- data/ext/h3/src/src/h3lib/include/faceijk.h +3 -2
- data/ext/h3/src/src/h3lib/include/geoCoord.h +2 -3
- data/ext/h3/src/src/h3lib/include/h3Index.h +37 -4
- data/ext/h3/src/src/h3lib/include/h3api.h.in +65 -17
- data/ext/h3/src/src/h3lib/include/linkedGeo.h +1 -0
- data/ext/h3/src/src/h3lib/include/polygon.h +1 -0
- data/ext/h3/src/src/h3lib/include/polygonAlgos.h +1 -0
- data/ext/h3/src/src/h3lib/include/vertex.h +44 -0
- data/ext/h3/src/src/h3lib/include/vertexGraph.h +1 -0
- data/ext/h3/src/src/h3lib/lib/algos.c +300 -75
- data/ext/h3/src/src/h3lib/lib/baseCells.c +26 -4
- data/ext/h3/src/src/h3lib/lib/bbox.c +56 -31
- data/ext/h3/src/src/h3lib/lib/coordijk.c +2 -0
- data/ext/h3/src/src/h3lib/lib/faceijk.c +32 -21
- data/ext/h3/src/src/h3lib/lib/geoCoord.c +162 -44
- data/ext/h3/src/src/h3lib/lib/h3Index.c +81 -43
- data/ext/h3/src/src/h3lib/lib/h3UniEdge.c +42 -57
- data/ext/h3/src/src/h3lib/lib/linkedGeo.c +20 -15
- data/ext/h3/src/src/h3lib/lib/localij.c +1 -1
- data/ext/h3/src/src/h3lib/lib/polygon.c +2 -0
- data/ext/h3/src/src/h3lib/lib/vec2d.c +1 -0
- data/ext/h3/src/src/h3lib/lib/vec3d.c +1 -0
- data/ext/h3/src/src/h3lib/lib/vertex.c +134 -0
- data/ext/h3/src/src/h3lib/lib/vertexGraph.c +8 -5
- data/ext/h3/src/website/.eslintignore +2 -0
- data/ext/h3/src/website/.gitignore +57 -0
- data/ext/h3/src/website/.nvmrc +1 -0
- data/ext/h3/src/website/README.md +8 -6
- data/ext/h3/src/website/gatsby-config.js +83 -0
- data/ext/h3/src/website/package.json +20 -12
- data/ext/h3/src/website/scripts/build-to-gh-pages.sh +7 -5
- data/ext/h3/src/website/src/.gitkeep +0 -0
- data/ext/h3/src/website/templates/documentation.jsx +129 -0
- data/ext/h3/src/website/yarn.lock +13723 -0
- data/lib/h3/bindings/private.rb +3 -0
- data/lib/h3/miscellaneous.rb +123 -0
- data/lib/h3/version.rb +1 -1
- data/spec/miscellaneous_spec.rb +117 -0
- data/spec/regions_spec.rb +1 -1
- metadata +35 -14
- data/ext/h3/src/.ycm_extra_conf.py +0 -92
- data/ext/h3/src/appveyor.yml +0 -50
- data/ext/h3/src/src/apps/testapps/testPolyfill_GH136.c +0 -58
- data/ext/h3/src/website/src/config.js +0 -46
- data/ext/h3/src/website/src/mdRoutes.js +0 -151
- data/ext/h3/src/website/src/styles/_variables.scss +0 -16
- data/ext/h3/src/website/src/styles/index.scss +0 -3
- data/ext/h3/src/website/static/index.html +0 -15
@@ -0,0 +1,21 @@
|
|
1
|
+
# RFC: Polyfill modes
|
2
|
+
|
3
|
+
* **Authors**: -
|
4
|
+
* **Date**: -
|
5
|
+
* **Status**: Draft
|
6
|
+
|
7
|
+
## Abstract
|
8
|
+
|
9
|
+
Our current polyfill algorithm allocates cells to polygons based on whether the center of the cell falls within the polygon, using Cartesian geometry. This proposal outlines options for expanding the polyfill algorithm to allow for different containment modes (e.g. wholly contained cells, intersecting cells) and spherical geometry.
|
10
|
+
|
11
|
+
## Motivation
|
12
|
+
|
13
|
+
*Why is this important?*
|
14
|
+
|
15
|
+
## Approaches
|
16
|
+
|
17
|
+
*What are the various options to address this issue?*
|
18
|
+
|
19
|
+
## Proposal
|
20
|
+
|
21
|
+
*What is the recommended approach?*
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# RFC: Vertex mode
|
2
|
+
|
3
|
+
* **Authors**: Nick Rabinowitz
|
4
|
+
* **Date**: -
|
5
|
+
* **Status**: Draft
|
6
|
+
|
7
|
+
## Abstract
|
8
|
+
|
9
|
+
This proposal would add a new H3 index mode, Vertex Mode, to provide a canonical id for a vertex in a cell boundary. Each vertex shared by 3 adjacent cells would be represented by a single index.
|
10
|
+
|
11
|
+
## Motivation
|
12
|
+
|
13
|
+
The advantages of this approach:
|
14
|
+
|
15
|
+
* Shared vertices can be compared between hexagons with a strict equality check
|
16
|
+
* Vertices can be represented and stored without the trig calls required to produce a lat/lon point
|
17
|
+
* Vertex to lat/lon can be guaranteed to return the same result across different cells that share the vertex
|
18
|
+
|
19
|
+
At a minimum, this should open up significant performance and correctness gains in `h3SetToLinkedGeo` and `directedEdgeToBoundary`, and there are likely other uses as well.
|
20
|
+
|
21
|
+
## Approaches
|
22
|
+
|
23
|
+
The proposed approach below is fairly straightforward. The main questions are:
|
24
|
+
|
25
|
+
* Whether to have one vertex mode, `H3_VERTEX_MODE`, representing the 5 or 6 topological vertices of each cell, or whether to additionally offer a second vertex mode, `H3_ICOSAEDGE_VERTEX_MODE`, to represent distortion vertices shared by two cells whose edge crosses an edge of the icosahedron.
|
26
|
+
|
27
|
+
* If we have two different modes, which functions return both types, in order, and which functions return only one type.
|
28
|
+
|
29
|
+
These two modes are largely orthogonal, and it would be possible to implement only `H3_VERTEX_MODE` first without considering `H3_ICOSAEDGE_VERTEX_MODE`. This simplifies the implementation and keeps the new mode wholly in the topological space, without considering the geometric issues posed by the distortion vertices. However this may make it harder or more expensive to implement transformations from sets of vertices to the geometry of a polygon or edge.
|
30
|
+
|
31
|
+
## Proposal
|
32
|
+
|
33
|
+
### Format of the index
|
34
|
+
|
35
|
+
* The H3 index of the "owner" cell. The owner would be one of the cells that share the vertex (see below).
|
36
|
+
* The mode set to `H3_VERTEX_MODE`
|
37
|
+
* The reserved bits used to identify the index (0-6) of the vertex on the owner cell, using the index order used by `cellToBoundary`
|
38
|
+
|
39
|
+
### Choice of owner
|
40
|
+
|
41
|
+
Proposed simple algorithm for determining ownership:
|
42
|
+
|
43
|
+
* Find all three neighbors that share a vertex
|
44
|
+
* Use the one with the numerically lowest index as the owner
|
45
|
+
|
46
|
+
### New library functions
|
47
|
+
|
48
|
+
* `void getCellVertexes(H3Index cell, H3Vertex *vertices)`
|
49
|
+
* `H3Vertex getCellVertex(H3Index cell, int vertIndex)`
|
50
|
+
* `GeoCoord vertexToGeoPoint(H3Vertex vertex)`
|
@@ -10,9 +10,14 @@ cd build
|
|
10
10
|
cmake ..
|
11
11
|
```
|
12
12
|
|
13
|
-
You can now open `h3.sln` and build the `ALL_BUILD` project to build the H3 library, filter applications, and tests.
|
13
|
+
You can now open `h3.sln` and build the `ALL_BUILD` project to build the H3 library, filter applications, and tests. From the command line:
|
14
14
|
|
15
15
|
```
|
16
16
|
msbuild ALL_BUILD.vcxproj
|
17
|
+
```
|
18
|
+
|
19
|
+
Tests can be run by building the `RUN_TESTS` project. Tests require `bash` be available, which is usually supplied by Git for Windows. From the command line:
|
20
|
+
|
21
|
+
```
|
17
22
|
msbuild RUN_TESTS.vcxproj
|
18
23
|
```
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
H3 is a C library, in part to make it simpler to create bindings for different programming languages. Each language usually has its own way to bind to C functions, but this document can serve as a starting point and list of tips.
|
4
4
|
|
5
|
-
There may already be [H3 bindings](https://
|
5
|
+
There may already be [H3 bindings](https://h3geo.org/docs/community/bindings) available for your language of choice.
|
6
6
|
|
7
7
|
## Function naming
|
8
8
|
|
9
9
|
The `make binding-functions` target produces a file `binding-functions` containing a list of function in the H3 public API, one per line. You can use this as part of your build process to check how much of the H3 public API your bindings expose. This list does not include memory management functions that are needed to allocate arrays to be passed to the H3 API.
|
10
10
|
|
11
|
-
Keeping similar names and purposes for functions can make it easier for your users to use the H3 [API Reference](https://
|
11
|
+
Keeping similar names and purposes for functions can make it easier for your users to use the H3 [API Reference](https://h3geo.org/docs/api/indexing).
|
12
12
|
|
13
13
|
## Community
|
14
14
|
|
@@ -16,7 +16,7 @@ When ready, make a [pull request](https://github.com/uber/h3/edit/master/docs/co
|
|
16
16
|
|
17
17
|
## Documentation
|
18
18
|
|
19
|
-
To be included in the H3 [API reference](https://
|
19
|
+
To be included in the H3 [API reference](https://h3geo.org/docs/api/indexing), your binding should:
|
20
20
|
|
21
21
|
* Be reasonably up to date with uber/h3.
|
22
22
|
* Include bindings for the relevant functions in the output of `make binding-functions`. For example, `stringToH3` may not be necessary if your bindings only supports string H3 indexes.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Custom Memory Allocators
|
2
|
+
|
3
|
+
H3 supports replacing the memory management functions (`malloc`, `calloc`, `realloc`, `free`) used by the library at build time. This can be used to integrate H3 within a managed framework.
|
4
|
+
|
5
|
+
When using custom memory allocators, H3 prefixes the names of memory allocation functions with the string you specify. The application linking H3 must have the prefixed replacement functions defined.
|
6
|
+
|
7
|
+
When building H3, specify the `H3_ALLOC_PREFIX` option to your prefix of choice, as below:
|
8
|
+
|
9
|
+
```
|
10
|
+
cmake -DH3_ALLOC_PREFIX=my_prefix_ .
|
11
|
+
```
|
12
|
+
|
13
|
+
Then, in your application using H3, implement the following functions (replacing `my_prefix_` with the prefix you chose above):
|
14
|
+
|
15
|
+
```
|
16
|
+
void* my_prefix_malloc(size_t size);
|
17
|
+
void* my_prefix_calloc(size_t num, size_t size);
|
18
|
+
void* my_prefix_realloc(void* ptr, size_t size);
|
19
|
+
void my_prefix_free(void* ptr);
|
20
|
+
```
|
21
|
+
|
22
|
+
Link to H3 as you would have without the custom allocators. The custom allocators will be used for allocating heap memory in H3.
|
23
|
+
|
24
|
+
## Notes/Caveats
|
25
|
+
|
26
|
+
* There are a few algorithms like `kRing` that still use the call stack to recurse and could run out of memory that way.
|
27
|
+
* H3 does not currently use `realloc`.
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
---
|
1
|
+
# Introduction
|
3
2
|
|
4
3
|
The **H3** geospatial indexing system is a multi-precision hexagonal tiling of the sphere indexed with hierarchical linear indexes. The **H3 Core Library** provides functions for converting between latitude/longitude coordinates and **H3** geospatial indexes. Specifically, the major library entry point functions (defined in `h3api.h`) provide the functionality:
|
5
4
|
|
@@ -8,4 +7,4 @@ The **H3** geospatial indexing system is a multi-precision hexagonal tiling of t
|
|
8
7
|
* given an **H3** index, determine the cell boundary in latitude/longitude coordinates
|
9
8
|
* and more.
|
10
9
|
|
11
|
-
The **H3 Core Library** is written entirely in *C*.
|
10
|
+
The **H3 Core Library** is written entirely in *C*. [Bindings for other languages](/docs/community/bindings) are available.
|
data/ext/h3/src/docs/api/misc.md
CHANGED
@@ -34,6 +34,30 @@ double hexAreaM2(int res);
|
|
34
34
|
|
35
35
|
Average hexagon area in square meters at the given resolution.
|
36
36
|
|
37
|
+
## cellAreaKm2
|
38
|
+
|
39
|
+
```
|
40
|
+
double cellAreaKm2(H3Index h);
|
41
|
+
```
|
42
|
+
|
43
|
+
Exact area of specific cell in square kilometers.
|
44
|
+
|
45
|
+
## cellAreaM2
|
46
|
+
|
47
|
+
```
|
48
|
+
double cellAreaM2(H3Index h);
|
49
|
+
```
|
50
|
+
|
51
|
+
Exact area of specific cell in square meters.
|
52
|
+
|
53
|
+
## cellAreaRads2
|
54
|
+
|
55
|
+
```
|
56
|
+
double cellAreaRads2(H3Index h);
|
57
|
+
```
|
58
|
+
|
59
|
+
Exact area of specific cell in square radians.
|
60
|
+
|
37
61
|
## edgeLengthKm
|
38
62
|
|
39
63
|
```
|
@@ -50,6 +74,31 @@ double edgeLengthM(int res);
|
|
50
74
|
|
51
75
|
Average hexagon edge length in meters at the given resolution.
|
52
76
|
|
77
|
+
|
78
|
+
## exactEdgeLengthKm
|
79
|
+
|
80
|
+
```
|
81
|
+
double exactEdgeLengthKm(H3Index edge);
|
82
|
+
```
|
83
|
+
|
84
|
+
Exact edge length of specific unidirectional edge in kilometers.
|
85
|
+
|
86
|
+
## exactEdgeLengthM
|
87
|
+
|
88
|
+
```
|
89
|
+
double exactEdgeLengthM(H3Index edge);
|
90
|
+
```
|
91
|
+
|
92
|
+
Exact edge length of specific unidirectional edge in meters.
|
93
|
+
|
94
|
+
## exactEdgeLengthRads
|
95
|
+
|
96
|
+
```
|
97
|
+
double exactEdgeLengthRads(H3Index edge);
|
98
|
+
```
|
99
|
+
|
100
|
+
Exact edge length of specific unidirectional edge in radians.
|
101
|
+
|
53
102
|
## numHexagons
|
54
103
|
|
55
104
|
```
|
@@ -91,3 +140,30 @@ int pentagonIndexCount();
|
|
91
140
|
```
|
92
141
|
|
93
142
|
Number of pentagon **H3** indexes per resolution. This is always 12, but provided as a convenience.
|
143
|
+
|
144
|
+
## pointDistKm
|
145
|
+
|
146
|
+
```
|
147
|
+
double pointDistKm(const GeoCoord *a, const GeoCoord *b);
|
148
|
+
```
|
149
|
+
|
150
|
+
Gives the "great circle" or "haversine" distance between pairs of
|
151
|
+
GeoCoord points (lat/lng pairs) in kilometers.
|
152
|
+
|
153
|
+
## pointDistM
|
154
|
+
|
155
|
+
```
|
156
|
+
double pointDistM(const GeoCoord *a, const GeoCoord *b);
|
157
|
+
```
|
158
|
+
|
159
|
+
Gives the "great circle" or "haversine" distance between pairs of
|
160
|
+
GeoCoord points (lat/lng pairs) in meters.
|
161
|
+
|
162
|
+
## pointDistRads
|
163
|
+
|
164
|
+
```
|
165
|
+
double pointDistRads(const GeoCoord *a, const GeoCoord *b);
|
166
|
+
```
|
167
|
+
|
168
|
+
Gives the "great circle" or "haversine" distance between pairs of
|
169
|
+
GeoCoord points (lat/lng pairs) in radians.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
As a C library, bindings can be made to call H3 functions from different programming languages. This page lists different bindings currently available. Contributions to this list are welcome, please feel free to open a [pull request](https://github.com/uber/h3/tree/master/docs/community/bindings.md).
|
4
4
|
|
5
5
|
## BigQuery
|
6
|
-
|
6
|
+
|
7
7
|
- [cartodb/bigquery-jslibs](https://github.com/CartoDB/bigquery-jslibs)
|
8
8
|
|
9
9
|
## C#
|
@@ -34,6 +34,7 @@ As a C library, bindings can be made to call H3 functions from different program
|
|
34
34
|
|
35
35
|
- [uber/h3-js](https://github.com/uber/h3-js)
|
36
36
|
- [dfellis/h3-node](https://github.com/dfellis/h3-node)
|
37
|
+
- [realPrimoh/h3-reactnative](https://github.com/realPrimoh/h3-reactnative)
|
37
38
|
|
38
39
|
## Julia
|
39
40
|
|
@@ -64,3 +65,8 @@ As a C library, bindings can be made to call H3 functions from different program
|
|
64
65
|
## Ruby
|
65
66
|
|
66
67
|
- [StuartApp/h3_ruby](https://github.com/StuartApp/h3_ruby)
|
68
|
+
|
69
|
+
## Rust
|
70
|
+
|
71
|
+
- [rustyconover/libh3-sys](https://github.com/rustyconover/libh3-sys)
|
72
|
+
- [rustyconover/libh3](https://github.com/rustyconover/libh3)
|
@@ -1,7 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Learning Resources
|
2
2
|
|
3
3
|
This page lists further learning materials and code walkthroughs for the H3 library and bindings. Contributions to this list are welcome, please feel free to open a [pull request](https://github.com/uber/h3/tree/master/docs/community/tutorials.md).
|
4
4
|
|
5
|
+
## Community
|
6
|
+
|
7
|
+
- [H3 Slack workspace](https://join.slack.com/t/h3-core/shared_invite/zt-g6u5r1hf-W_~uVJmfeiWtMQuBGc1NNg)
|
8
|
+
|
5
9
|
## Videos
|
6
10
|
|
7
11
|
- [Introduction to H3](https://www.youtube.com/watch?v=wDuKeUkNLkQ) (June 2019)
|
@@ -24,5 +28,6 @@ This page lists further learning materials and code walkthroughs for the H3 libr
|
|
24
28
|
|
25
29
|
## Python
|
26
30
|
|
27
|
-
- [Usage (IPython Notebook)](https://github.com/uber/h3-py/blob/master/
|
28
|
-
- [Unified Data Layers (IPython Notebook)](https://github.com/uber/h3-py/blob/master/
|
31
|
+
- [Usage (IPython Notebook)](https://github.com/uber/h3-py-notebooks/blob/master/notebooks/usage.ipynb)
|
32
|
+
- [Unified Data Layers (IPython Notebook)](https://github.com/uber/h3-py-notebooks/blob/master/notebooks/unified_data_layers.ipynb)
|
33
|
+
- [H3 API examples on Urban Analytics(IPython Notebook)](https://github.com/uber/h3-py-notebooks/blob/master/notebooks/urban_analytics.ipynb)
|
@@ -1,5 +1,6 @@
|
|
1
|
-
Coordinate
|
2
|
-
|
1
|
+
# Coordinate systems
|
2
|
+
|
3
|
+
The **H3 Core Library** uses the following coordinate systems internally.
|
3
4
|
|
4
5
|
IJK Coordinates
|
5
6
|
---
|
@@ -9,7 +10,7 @@ Discrete hexagon planar grid systems naturally have 3 coordinate axes spaced 120
|
|
9
10
|
Using an *ijk* coordinate system to address hexagon grid cells provides multiple valid addresses for each cell. *Normalizing* an *ijk* address (function `_ijkNormalize`) creates a unique address consisting of the minimal positive *ijk* components; this always results in at most two non-zero components.
|
10
11
|
|
11
12
|
<div align="center">
|
12
|
-
<img height="300" src="images/ijkp.png" />
|
13
|
+
<img height="300" src="/images/ijkp.png" />
|
13
14
|
</div>
|
14
15
|
|
15
16
|
FaceIJK Coordinates
|
@@ -20,7 +21,7 @@ The **H3 Core Library** centers an *ijk* coordinate system on each face of the i
|
|
20
21
|
Each grid resolution is rotated ~19.1° relative to the next coarser resolution. The rotation alternates between counterclockwise and clockwise at each successive resolution, so that each resolution will have one of two possible orientations: *Class II* or *Class III* (using a terminology coined by R. Buckminster Fuller). The base cells, which make up resolution 0, are *Class II*.
|
21
22
|
|
22
23
|
<div align="center">
|
23
|
-
<img height="300" src="images/classII.III.png" />
|
24
|
+
<img height="300" src="/images/classII.III.png" />
|
24
25
|
</div>
|
25
26
|
|
26
27
|
Hex2d Coordinates
|
@@ -1,11 +1,10 @@
|
|
1
|
-
Unix-style Filters for
|
2
|
-
---
|
1
|
+
# Unix-style Filters for H3
|
3
2
|
|
4
3
|
The directory `src/apps/filters` contains unix-style stdin/stdout filters that perform conversions between integer **H3** indexes and other useful types. It currently contains the filters listed in the table below. See the header comments in each application source code file for more information.
|
5
4
|
|
6
5
|
Filters are experimental and are not part of the semantic version of the H3 library.
|
7
6
|
|
8
|
-
All latitude/longitude coordinates are in decimal degrees. See the
|
7
|
+
All latitude/longitude coordinates are in decimal degrees. See the [**H3** Index Representations](/docs/core-library/h3indexing) page for information on the integer `H3Index`.
|
9
8
|
|
10
9
|
|
11
10
|
| filter | input | outputs
|
@@ -22,26 +21,26 @@ Unix Command Line Examples
|
|
22
21
|
|
23
22
|
* find the index for coordinates at resolution 5
|
24
23
|
|
25
|
-
`
|
24
|
+
`geoToH3 --resolution 5 --latitude 40.689167 --longitude -74.044444`
|
26
25
|
|
27
26
|
* output the cell center point for `H3Index` 845ad1bffffffff
|
28
27
|
|
29
|
-
`
|
28
|
+
`h3ToGeo --index 845ad1bffffffff`
|
30
29
|
|
31
30
|
* output the cell boundary for `H3Index` 845ad1bffffffff
|
32
31
|
|
33
|
-
`
|
32
|
+
`h3ToGeoBoundary --index 845ad1bffffffff`
|
34
33
|
|
35
34
|
* find the components for the `H3Index` 845ad1bffffffff
|
36
35
|
|
37
|
-
`
|
36
|
+
`h3ToComponents --index 845ad1bffffffff`
|
38
37
|
|
39
38
|
* output all indexes within distance 1 of the `H3Index` 845ad1bffffffff
|
40
39
|
|
41
|
-
`
|
40
|
+
`kRing -k 1 --origin 845ad1bffffffff`
|
42
41
|
|
43
42
|
* output all hexagon indexes within distance 2 of the `H3Index` 845ad1bffffffff
|
44
43
|
|
45
|
-
`
|
44
|
+
`hexRange -k 2 --origin 845ad1bffffffff`
|
46
45
|
|
47
46
|
Note that the filters `h3ToGeo` and `h3ToGeoBoundary` take optional arguments that allow them to generate `kml` output. See the header comments in the corresponding source code files for details.
|
@@ -1,9 +1,8 @@
|
|
1
|
-
Conversion from latitude/longitude to containing H3 cell index
|
2
|
-
---
|
1
|
+
# Conversion from latitude/longitude to containing H3 cell index
|
3
2
|
|
4
3
|
This operation is performed by function `geoToH3`. See the comments in the function for more detail.
|
5
4
|
|
6
|
-
The conversion is performed as a series of coordinate system conversions described below. See the page
|
5
|
+
The conversion is performed as a series of coordinate system conversions described below. See the page [Coordinate Systems used by the **H3 Core Library**](/docs/core-library/coordsystems) for more information on each of these coordinate systems.
|
7
6
|
|
8
7
|
1. The input latitude/longitude coordinate is first converted into the containing icosahedron face and a *Hex2d* coordinate on that face using function `_geoToHex2d`, which determines the correct face and then performs a face-centered gnomonic projection into face-centered polar coordinates. These polar coordinates are then scaled appropriately to a *Hex2d* coordinate on the input grid resolution *r*.
|
9
8
|
2. The *Hex2d* coordinate is converted into resolution *r* normalized *ijk* coordinates using function `_hex2dToCoordIJK`.
|
@@ -1,15 +1,14 @@
|
|
1
|
-
Generate the cell boundary in latitude/longitude coordinates of an H3Index cell
|
2
|
-
---
|
1
|
+
# Generate the cell boundary in latitude/longitude coordinates of an H3Index cell
|
3
2
|
|
4
3
|
This operation is performed by function `h3ToGeoBoundary`. See the comments in the function source code for more detail.
|
5
4
|
|
6
|
-
The conversion is performed as a series of coordinate system conversions described below. See the page
|
5
|
+
The conversion is performed as a series of coordinate system conversions described below. See the page [Coordinate Systems used by the **H3 Core Library**](/docs/core-library/coordsystems) for more information on each of these coordinate systems.
|
7
6
|
|
8
7
|
* We note that the cell vertices are the center points of cells in an aperture 3 grid one resolution finer than the cell resolution, which we term a *substrate* grid. We precalculate the substrate *ijk* coordinates of a cell with *ijk* coordinates (0,0,0), adding additional aperture 3 and aperture 7 (if required, by Class III cell grid) substrate grid resolutions as required to transform the vertex coordinates into a Class II substrate grid.
|
9
8
|
|
10
9
|
<div align="center">
|
11
|
-
<img height="300" src="images/substrate3.png" />
|
10
|
+
<img height="300" src="/images/substrate3.png" />
|
12
11
|
</div>
|
13
12
|
|
14
|
-
* The function `_faceIjkToGeoBoundary` calculates the *ijk* coordinates of the cell center point in the appropriate substrate grid (determined in the last step), and each of the substrate vertices is translated using the cell center point *ijk*. Each vertex *ijk* is then transformed onto the appropriate face and *Hex2d* coordinate system using the approach taken in
|
13
|
+
* The function `_faceIjkToGeoBoundary` calculates the *ijk* coordinates of the cell center point in the appropriate substrate grid (determined in the last step), and each of the substrate vertices is translated using the cell center point *ijk*. Each vertex *ijk* is then transformed onto the appropriate face and *Hex2d* coordinate system using the approach taken in [finding a cell center point](/docs/core-library/h3ToGeoDesc). If adjacent vertices lie on different icosahedron faces a point is introduced at the intersection of the cell edge and icosahedron face edge.
|
15
14
|
* The *Hex2d* coordinates are then converted to latitude/longitude using `_hex2dToGeo`.
|
@@ -1,9 +1,8 @@
|
|
1
|
-
Determine the latitude/longitude coordinates of the center point of an H3Index cell
|
2
|
-
---
|
1
|
+
# Determine the latitude/longitude coordinates of the center point of an H3Index cell
|
3
2
|
|
4
3
|
This operation is performed by function `h3ToGeo`. See the comments in the function source code for more detail.
|
5
4
|
|
6
|
-
The conversion is performed as a series of coordinate system conversions described below. See the page
|
5
|
+
The conversion is performed as a series of coordinate system conversions described below. See the page [Coordinate Systems used by the **H3 Core Library**](/docs/core-library/coordsystems) for more information on each of these coordinate systems.
|
7
6
|
|
8
7
|
* The function `_h3ToFaceIjk` then converts the **H3** index to the appropriate icosahedron face number and normalized *ijk* coordinate's on that face's coordinate system as follows:
|
9
8
|
* We start by assuming that the cell center point falls on the same icosahedron face as its base cell.
|
@@ -11,7 +10,7 @@ The conversion is performed as a series of coordinate system conversions describ
|
|
11
10
|
We determine whether an overage exists by taking the sum of the *ijk* components, and if there is an overage the positive *ijk* components indicate which adjacent face the cell center lies on. A lookup operation is then performed to find the appropriate rotation and translation to transform the *ijk* coordinates into the adjacent face-centered *ijk* system.
|
12
11
|
|
13
12
|
<div align="center">
|
14
|
-
<img height="300" src="images/triEdge.png" />
|
13
|
+
<img height="300" src="/images/triEdge.png" />
|
15
14
|
</div>
|
16
15
|
|
17
16
|
* The face-centered *ijk* coordinates are then converted into corresponding *Hex2d* coordinates using the function `_ijkToHex2d`.
|
@@ -1,45 +1,54 @@
|
|
1
|
-
H3 Index Representations
|
2
|
-
---
|
1
|
+
# H3 Index Representations
|
3
2
|
|
4
|
-
Introduction
|
5
|
-
---
|
3
|
+
## Introduction
|
6
4
|
|
7
5
|
The **H3** system assigns a unique hierarchical index to each cell. The **H3** index of a resolution *r* cell begins with the appropriate resolution 0 base cell number. This is followed by a sequence of *r* digits 0-6, where each *i*<sup>th</sup> digit *d*<sub>i</sub> specifies one of the 7 cells centered on the cell indicated by the coarser resolution digits *d*<sub>1</sub> through *d*<sub>i-1</sub>. A local hexagon coordinate system is assigned to each of the resolution 0 base cells and is used to orient all hierarchical indexing child cells of that base cell. The assignment of digits 0-6 at each resolution uses a *Central Place Indexing* arrangement (see [Sahr, 2014](http://webpages.sou.edu/~sahrk/sqspc/pubs/autocarto14.pdf)). In the case of the 12 pentagonal cells the indexing hierarchy produced by sub-digit 1 is removed at all resolutions.
|
8
6
|
|
9
7
|
Child hexagons are linearly smaller than their parent hexagons.
|
10
8
|
|
11
9
|
<div align="center">
|
12
|
-
<img height="300" src="images/cpidigits.png" />
|
10
|
+
<img height="300" src="/images/cpidigits.png" />
|
13
11
|
</div>
|
14
12
|
|
15
13
|
|
16
|
-
H3Index Representation
|
17
|
-
---
|
14
|
+
## H3Index Representation
|
18
15
|
|
19
|
-
The **H3Index** is the integer representation of an **H3** index, which can be placed into multiple modes to indicate the
|
16
|
+
The **H3Index** is the integer representation of an **H3** index, which can be placed into multiple modes to indicate the concept being indexed.
|
20
17
|
|
21
|
-
|
18
|
+
* Mode 1 is an **H3** Cell (Hexagon/Pentagon) index.
|
19
|
+
* Mode 2 is an **H3** Unidirectional Edge (Cell A -> Cell B) index.
|
20
|
+
* Mode 3 is planned to be a bidirectional edge (Cell A <-> Cell B).
|
21
|
+
* Mode 0 is reserved and indicates an invalid **H3** index.
|
22
|
+
* This mode remains, partially, for backwards compatibility with an older version of H3.
|
22
23
|
|
24
|
+
Mode 0 contains a special index, `H3_NULL`, which is unique: it is bit-equivalent to `0`.
|
25
|
+
This index indicates, *specifically*, an invalid, missing, or uninitialized **H3** index;
|
26
|
+
it is analogous to `NaN` in floating point.
|
27
|
+
It should be used instead of an arbitrary Mode 0 index, due to its uniqueness and easy identifiability.
|
28
|
+
|
29
|
+
The components of the **H3** cell index (mode 1) are packed into a 64-bit integer in order, highest bit first, as follows:
|
30
|
+
|
31
|
+
* 1 bit reserved and set to 0,
|
23
32
|
* 4 bits to indicate the index mode,
|
24
|
-
* 3 bits reserved,
|
33
|
+
* 3 bits reserved and set to 0,
|
25
34
|
* 4 bits to indicate the cell resolution 0-15,
|
26
35
|
* 7 bits to indicate the base cell 0-121, and
|
27
|
-
* 3 bits to indicate each subsequent digit 0-6 from resolution 1 up to the resolution of the cell (45 bits total
|
36
|
+
* 3 bits to indicate each subsequent digit 0-6 from resolution 1 up to the resolution of the cell (45 bits total are reserved for resolutions 1-15)
|
28
37
|
|
29
|
-
The components of the **H3** unidirectional edge index (mode 2) are packed into
|
38
|
+
The components of the **H3** unidirectional edge index (mode 2) are packed into a 64-bit integer in order, highest bit first, as follows:
|
30
39
|
|
40
|
+
* 1 bit reserved and set to 0,
|
31
41
|
* 4 bits to indicate the index mode,
|
32
42
|
* 3 bits to indicate the edge 1-6 of the cell to traverse,
|
33
43
|
* 4 bits to indicate the cell resolution 0-15,
|
34
44
|
* 7 bits to indicate the base cell 0-121, and
|
35
|
-
* 3 bits to indicate each subsequent digit 0-6 from resolution 1 up to the resolution of the cell (45 bits total
|
45
|
+
* 3 bits to indicate each subsequent digit 0-6 from resolution 1 up to the resolution of the cell (45 bits total are reserved for resolutions 1-15)
|
36
46
|
|
37
|
-
The canonical string representation of an **H3Index** is the hexadecimal representation of the integer.
|
47
|
+
The canonical string representation of an **H3Index** is the hexadecimal representation of the integer, using lowercase letters. The string representation is variable length (no zero padding) and is not prefixed or suffixed.
|
38
48
|
|
39
49
|
The three bits for each unused digit are set to 7.
|
40
50
|
|
41
|
-
Bit layout of H3Index
|
42
|
-
---
|
51
|
+
## Bit layout of H3Index
|
43
52
|
|
44
53
|
The layout of an **H3Index** is shown below in table form. The interpretation of the "Reserved/edge" field differs depending on the mode of the index.
|
45
54
|
|
@@ -65,7 +74,7 @@ The layout of an **H3Index** is shown below in table form. The interpretation of
|
|
65
74
|
</tr>
|
66
75
|
<tr>
|
67
76
|
<th>0x30</th>
|
68
|
-
<td
|
77
|
+
<td>Reserved</td>
|
69
78
|
<td colspan="4">Mode</td>
|
70
79
|
<td colspan="3">Reserved/edge</td>
|
71
80
|
<td colspan="4">Resolution</td>
|