h3 3.5.0 → 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 +45 -0
- data/Gemfile.lock +9 -7
- data/README.md +8 -8
- 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 +21 -32
- data/ext/h3/src/CHANGELOG.md +60 -0
- data/ext/h3/src/CMakeLists.txt +150 -33
- data/ext/h3/src/CONTRIBUTING.md +1 -1
- data/ext/h3/src/README.md +65 -16
- 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/hierarchy.md +8 -0
- data/ext/h3/src/docs/api/misc.md +94 -0
- data/ext/h3/src/docs/community/applications.md +1 -0
- data/ext/h3/src/docs/community/bindings.md +10 -0
- 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 +8 -4
- 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/generateBaseCellNeighbors.c +2 -2
- data/ext/h3/src/src/apps/miscapps/generateFaceCenterPoint.c +1 -0
- data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +1 -2
- 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 +121 -2
- data/ext/h3/src/src/apps/testapps/testCoordIj.c +1 -0
- data/ext/h3/src/src/apps/testapps/testGeoCoord.c +47 -8
- 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 +2 -50
- data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +84 -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 +2 -84
- data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +115 -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 +68 -0
- data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +15 -2
- 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 +24 -236
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +265 -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 +58 -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 +27 -1
- 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/constants.h +2 -0
- 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 +85 -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 +305 -80
- data/ext/h3/src/src/h3lib/lib/baseCells.c +26 -4
- data/ext/h3/src/src/h3lib/lib/bbox.c +56 -27
- data/ext/h3/src/src/h3lib/lib/coordijk.c +2 -0
- data/ext/h3/src/src/h3lib/lib/faceijk.c +35 -24
- data/ext/h3/src/src/h3lib/lib/geoCoord.c +162 -44
- data/ext/h3/src/src/h3lib/lib/h3Index.c +150 -46
- 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 +5 -5
- data/ext/h3/src/src/h3lib/lib/polygon.c +3 -2
- 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/h3.gemspec +1 -0
- data/lib/h3.rb +8 -23
- data/lib/h3/bindings/base.rb +15 -4
- data/lib/h3/bindings/private.rb +13 -9
- data/lib/h3/geo_json.rb +1 -1
- data/lib/h3/hierarchy.rb +24 -9
- data/lib/h3/indexing.rb +7 -7
- data/lib/h3/inspection.rb +22 -26
- data/lib/h3/miscellaneous.rb +157 -9
- data/lib/h3/regions.rb +3 -0
- data/lib/h3/traversal.rb +9 -9
- data/lib/h3/unidirectional_edges.rb +18 -18
- data/lib/h3/version.rb +1 -1
- data/spec/geo_json_spec.rb +8 -0
- data/spec/hierarchy_spec.rb +23 -13
- data/spec/indexing_spec.rb +15 -15
- data/spec/inspection_spec.rb +17 -17
- data/spec/miscellaneous_spec.rb +151 -6
- data/spec/{region_spec.rb → regions_spec.rb} +1 -1
- data/spec/traversal_spec.rb +6 -6
- data/spec/unidirectional_edges_spec.rb +18 -18
- metadata +55 -15
- data/ext/h3/src/.ycm_extra_conf.py +0 -92
- data/ext/h3/src/appveyor.yml +0 -50
- 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
- data/lib/h3/bindings.rb +0 -12
@@ -40,4 +40,12 @@ void h3SetToVertexGraph(const H3Index* h3Set, const int numHexes,
|
|
40
40
|
// Create a LinkedGeoPolygon from a vertex graph
|
41
41
|
void _vertexGraphToLinkedGeo(VertexGraph* graph, LinkedGeoPolygon* out);
|
42
42
|
|
43
|
+
// Internal function for polyfill that traces a geofence with hexagons of a
|
44
|
+
// specific size
|
45
|
+
int _getEdgeHexagons(const Geofence* geofence, int numHexagons, int res,
|
46
|
+
int* numSearchHexes, H3Index* search, H3Index* found);
|
47
|
+
|
48
|
+
// The polyfill algorithm. Separated out because it can theoretically fail
|
49
|
+
int _polyfillInternal(const GeoPolygon* geoPolygon, int res, H3Index* out);
|
50
|
+
|
43
51
|
#endif
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2020 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
|
+
/** @file alloc.h
|
17
|
+
* @brief Memory management functions
|
18
|
+
*
|
19
|
+
* This file contains macros and the necessary declarations to be able
|
20
|
+
* to point H3 at different memory management functions than the standard
|
21
|
+
* malloc/free/etc functions.
|
22
|
+
*/
|
23
|
+
|
24
|
+
#ifndef ALLOC_H
|
25
|
+
#define ALLOC_H
|
26
|
+
|
27
|
+
#include "h3api.h" // for TJOIN
|
28
|
+
|
29
|
+
#ifdef H3_ALLOC_PREFIX
|
30
|
+
#define H3_MEMORY(name) TJOIN(H3_ALLOC_PREFIX, name)
|
31
|
+
|
32
|
+
void* H3_MEMORY(malloc)(size_t size);
|
33
|
+
void* H3_MEMORY(calloc)(size_t num, size_t size);
|
34
|
+
void* H3_MEMORY(realloc)(void* ptr, size_t size);
|
35
|
+
void H3_MEMORY(free)(void* ptr);
|
36
|
+
#else
|
37
|
+
#define H3_MEMORY(name) name
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#endif
|
@@ -45,11 +45,15 @@ extern const BaseCellData baseCellData[NUM_BASE_CELLS];
|
|
45
45
|
/** Maximum input for any component to face-to-base-cell lookup functions */
|
46
46
|
#define MAX_FACE_COORD 2
|
47
47
|
|
48
|
+
/** Invalid number of rotations */
|
49
|
+
#define INVALID_ROTATIONS -1
|
50
|
+
|
48
51
|
// Internal functions
|
49
52
|
int _isBaseCellPentagon(int baseCell);
|
50
53
|
bool _isBaseCellPolarPentagon(int baseCell);
|
51
54
|
int _faceIjkToBaseCell(const FaceIJK* h);
|
52
55
|
int _faceIjkToBaseCellCCWrot60(const FaceIJK* h);
|
56
|
+
int _baseCellToCCWrot60(int baseCell, int face);
|
53
57
|
void _baseCellToFaceIjk(int baseCell, FaceIJK* h);
|
54
58
|
bool _baseCellIsCwOffset(int baseCell, int testFace);
|
55
59
|
int _getBaseCellNeighbor(int baseCell, Direction dir);
|
@@ -21,6 +21,7 @@
|
|
21
21
|
#define BBOX_H
|
22
22
|
|
23
23
|
#include <stdbool.h>
|
24
|
+
|
24
25
|
#include "geoCoord.h"
|
25
26
|
|
26
27
|
/** @struct BBox
|
@@ -37,6 +38,8 @@ bool bboxIsTransmeridian(const BBox* bbox);
|
|
37
38
|
void bboxCenter(const BBox* bbox, GeoCoord* center);
|
38
39
|
bool bboxContains(const BBox* bbox, const GeoCoord* point);
|
39
40
|
bool bboxEquals(const BBox* b1, const BBox* b2);
|
40
|
-
int
|
41
|
+
int bboxHexEstimate(const BBox* bbox, int res);
|
42
|
+
int lineHexEstimate(const GeoCoord* origin, const GeoCoord* destination,
|
43
|
+
int res);
|
41
44
|
|
42
45
|
#endif
|
@@ -75,9 +75,10 @@ typedef enum {
|
|
75
75
|
void _geoToFaceIjk(const GeoCoord* g, int res, FaceIJK* h);
|
76
76
|
void _geoToHex2d(const GeoCoord* g, int res, int* face, Vec2d* v);
|
77
77
|
void _faceIjkToGeo(const FaceIJK* h, int res, GeoCoord* g);
|
78
|
-
void _faceIjkToGeoBoundary(const FaceIJK* h, int res, int
|
78
|
+
void _faceIjkToGeoBoundary(const FaceIJK* h, int res, int start, int length,
|
79
79
|
GeoBoundary* g);
|
80
|
-
void _faceIjkPentToGeoBoundary(const FaceIJK* h, int res,
|
80
|
+
void _faceIjkPentToGeoBoundary(const FaceIJK* h, int res, int start, int length,
|
81
|
+
GeoBoundary* g);
|
81
82
|
void _faceIjkToVerts(FaceIJK* fijk, int* res, FaceIJK* fijkVerts);
|
82
83
|
void _faceIjkPentToVerts(FaceIJK* fijk, int* res, FaceIJK* fijkVerts);
|
83
84
|
void _hex2dToGeo(const Vec2d* v, int face, int res, int substrate, GeoCoord* g);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright 2016-
|
2
|
+
* Copyright 2016-2020 Uber Technologies, Inc.
|
3
3
|
*
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
* you may not use this file except in compliance with the License.
|
@@ -23,6 +23,7 @@
|
|
23
23
|
#include <stdbool.h>
|
24
24
|
#include <stdint.h>
|
25
25
|
#include <stdio.h>
|
26
|
+
|
26
27
|
#include "constants.h"
|
27
28
|
#include "h3api.h"
|
28
29
|
|
@@ -43,8 +44,6 @@ bool geoAlmostEqualThreshold(const GeoCoord* p1, const GeoCoord* p2,
|
|
43
44
|
|
44
45
|
double _posAngleRads(double rads);
|
45
46
|
void _setGeoRads(GeoCoord* p, double latRads, double lonRads);
|
46
|
-
double _geoDistRads(const GeoCoord* p1, const GeoCoord* p2);
|
47
|
-
double _geoDistKm(const GeoCoord* p1, const GeoCoord* p2);
|
48
47
|
double _geoAzimuthRads(const GeoCoord* p1, const GeoCoord* p2);
|
49
48
|
void _geoAzDistanceRads(const GeoCoord* p1, double az, double distance,
|
50
49
|
GeoCoord* p2);
|
@@ -46,6 +46,12 @@
|
|
46
46
|
/** The number of bits in a single H3 resolution digit. */
|
47
47
|
#define H3_PER_DIGIT_OFFSET 3
|
48
48
|
|
49
|
+
/** 1 in the highest bit, 0's everywhere else. */
|
50
|
+
#define H3_HIGH_BIT_MASK ((uint64_t)(1) << H3_MAX_OFFSET)
|
51
|
+
|
52
|
+
/** 0 in the highest bit, 1's everywhere else. */
|
53
|
+
#define H3_HIGH_BIT_MASK_NEGATIVE (~H3_HIGH_BIT_MASK)
|
54
|
+
|
49
55
|
/** 1's in the 4 mode bits, 0's everywhere else. */
|
50
56
|
#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
|
51
57
|
|
@@ -74,11 +80,27 @@
|
|
74
80
|
#define H3_DIGIT_MASK ((uint64_t)(7))
|
75
81
|
|
76
82
|
/** 0's in the 7 base cell bits, 1's everywhere else. */
|
77
|
-
#define H3_DIGIT_MASK_NEGATIVE (~
|
83
|
+
#define H3_DIGIT_MASK_NEGATIVE (~H3_DIGIT_MASK)
|
78
84
|
|
79
|
-
/**
|
85
|
+
/**
|
86
|
+
* H3 index with mode 0, res 0, base cell 0, and 7 for all index digits.
|
87
|
+
* Typically used to initialize the creation of an H3 cell index, which
|
88
|
+
* expects all direction digits to be 7 beyond the cell's resolution.
|
89
|
+
*/
|
80
90
|
#define H3_INIT (UINT64_C(35184372088831))
|
81
91
|
|
92
|
+
/**
|
93
|
+
* Gets the highest bit of the H3 index.
|
94
|
+
*/
|
95
|
+
#define H3_GET_HIGH_BIT(h3) ((int)((((h3)&H3_HIGH_BIT_MASK) >> H3_MAX_OFFSET)))
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Sets the highest bit of the h3 to v.
|
99
|
+
*/
|
100
|
+
#define H3_SET_HIGH_BIT(h3, v) \
|
101
|
+
(h3) = (((h3)&H3_HIGH_BIT_MASK_NEGATIVE) | \
|
102
|
+
(((uint64_t)(v)) << H3_MAX_OFFSET))
|
103
|
+
|
82
104
|
/**
|
83
105
|
* Gets the integer mode of h3.
|
84
106
|
*/
|
@@ -143,9 +165,19 @@
|
|
143
165
|
<< ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
|
144
166
|
|
145
167
|
/**
|
146
|
-
* Invalid index used to indicate an error from geoToH3 and related functions
|
168
|
+
* Invalid index used to indicate an error from geoToH3 and related functions
|
169
|
+
* or missing data in arrays of h3 indices. Analogous to NaN in floating point.
|
147
170
|
*/
|
148
|
-
#define
|
171
|
+
#define H3_NULL 0
|
172
|
+
|
173
|
+
/*
|
174
|
+
* Return codes for compact
|
175
|
+
*/
|
176
|
+
|
177
|
+
#define COMPACT_SUCCESS 0
|
178
|
+
#define COMPACT_LOOP_EXCEEDED -1
|
179
|
+
#define COMPACT_DUPLICATE -2
|
180
|
+
#define COMPACT_ALLOC_FAILED -3
|
149
181
|
|
150
182
|
void setH3Index(H3Index* h, int res, int baseCell, Direction initDigit);
|
151
183
|
int isResClassIII(int res);
|
@@ -153,6 +185,7 @@ int isResClassIII(int res);
|
|
153
185
|
// Internal functions
|
154
186
|
|
155
187
|
int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK* fijk);
|
188
|
+
void _h3ToFaceIjk(H3Index h, FaceIJK* fijk);
|
156
189
|
H3Index _faceIjkToH3(const FaceIJK* fijk, int res);
|
157
190
|
Direction _h3LeadingNonZeroDigit(H3Index h);
|
158
191
|
H3Index _h3RotatePent60ccw(H3Index h);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright 2016-
|
2
|
+
* Copyright 2016-2020 Uber Technologies, Inc.
|
3
3
|
*
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
* you may not use this file except in compliance with the License.
|
@@ -150,7 +150,7 @@ typedef struct {
|
|
150
150
|
* Functions for geoToH3
|
151
151
|
* @{
|
152
152
|
*/
|
153
|
-
/** @brief find the H3 index of the resolution res cell containing the lat/
|
153
|
+
/** @brief find the H3 index of the resolution res cell containing the lat/lng
|
154
154
|
*/
|
155
155
|
H3Index H3_EXPORT(geoToH3)(const GeoCoord *g, int res);
|
156
156
|
/** @} */
|
@@ -183,8 +183,7 @@ int H3_EXPORT(hexRange)(H3Index origin, int k, H3Index *out);
|
|
183
183
|
/** @} */
|
184
184
|
|
185
185
|
/** @brief hexagons neighbors in all directions, assuming no pentagons,
|
186
|
-
* reporting
|
187
|
-
* distance from origin */
|
186
|
+
* reporting distance from origin */
|
188
187
|
int H3_EXPORT(hexRangeDistances)(H3Index origin, int k, H3Index *out,
|
189
188
|
int *distances);
|
190
189
|
|
@@ -252,33 +251,77 @@ double H3_EXPORT(degsToRads)(double degrees);
|
|
252
251
|
double H3_EXPORT(radsToDegs)(double radians);
|
253
252
|
/** @} */
|
254
253
|
|
254
|
+
/** @defgroup pointDist pointDist
|
255
|
+
* Functions for pointDist
|
256
|
+
* @{
|
257
|
+
*/
|
258
|
+
/** @brief "great circle distance" between pairs of GeoCoord points in radians*/
|
259
|
+
double H3_EXPORT(pointDistRads)(const GeoCoord *a, const GeoCoord *b);
|
260
|
+
|
261
|
+
/** @brief "great circle distance" between pairs of GeoCoord points in
|
262
|
+
* kilometers*/
|
263
|
+
double H3_EXPORT(pointDistKm)(const GeoCoord *a, const GeoCoord *b);
|
264
|
+
|
265
|
+
/** @brief "great circle distance" between pairs of GeoCoord points in meters*/
|
266
|
+
double H3_EXPORT(pointDistM)(const GeoCoord *a, const GeoCoord *b);
|
267
|
+
/** @} */
|
268
|
+
|
255
269
|
/** @defgroup hexArea hexArea
|
256
270
|
* Functions for hexArea
|
257
271
|
* @{
|
258
272
|
*/
|
259
|
-
/** @brief hexagon area in square kilometers */
|
273
|
+
/** @brief average hexagon area in square kilometers (excludes pentagons) */
|
260
274
|
double H3_EXPORT(hexAreaKm2)(int res);
|
261
275
|
|
262
|
-
/** @brief hexagon area in square meters */
|
276
|
+
/** @brief average hexagon area in square meters (excludes pentagons) */
|
263
277
|
double H3_EXPORT(hexAreaM2)(int res);
|
264
278
|
/** @} */
|
265
279
|
|
280
|
+
/** @defgroup cellArea cellArea
|
281
|
+
* Functions for cellArea
|
282
|
+
* @{
|
283
|
+
*/
|
284
|
+
/** @brief exact area for a specific cell (hexagon or pentagon) in radians^2 */
|
285
|
+
double H3_EXPORT(cellAreaRads2)(H3Index h);
|
286
|
+
|
287
|
+
/** @brief exact area for a specific cell (hexagon or pentagon) in kilometers^2
|
288
|
+
*/
|
289
|
+
double H3_EXPORT(cellAreaKm2)(H3Index h);
|
290
|
+
|
291
|
+
/** @brief exact area for a specific cell (hexagon or pentagon) in meters^2 */
|
292
|
+
double H3_EXPORT(cellAreaM2)(H3Index h);
|
293
|
+
/** @} */
|
294
|
+
|
266
295
|
/** @defgroup edgeLength edgeLength
|
267
296
|
* Functions for edgeLength
|
268
297
|
* @{
|
269
298
|
*/
|
270
|
-
/** @brief hexagon edge length in kilometers */
|
299
|
+
/** @brief average hexagon edge length in kilometers (excludes pentagons) */
|
271
300
|
double H3_EXPORT(edgeLengthKm)(int res);
|
272
301
|
|
273
|
-
/** @brief hexagon edge length in meters */
|
302
|
+
/** @brief average hexagon edge length in meters (excludes pentagons) */
|
274
303
|
double H3_EXPORT(edgeLengthM)(int res);
|
275
304
|
/** @} */
|
276
305
|
|
306
|
+
/** @defgroup exactEdgeLength exactEdgeLength
|
307
|
+
* Functions for exactEdgeLength
|
308
|
+
* @{
|
309
|
+
*/
|
310
|
+
/** @brief exact length for a specific unidirectional edge in radians*/
|
311
|
+
double H3_EXPORT(exactEdgeLengthRads)(H3Index edge);
|
312
|
+
|
313
|
+
/** @brief exact length for a specific unidirectional edge in kilometers*/
|
314
|
+
double H3_EXPORT(exactEdgeLengthKm)(H3Index edge);
|
315
|
+
|
316
|
+
/** @brief exact length for a specific unidirectional edge in meters*/
|
317
|
+
double H3_EXPORT(exactEdgeLengthM)(H3Index edge);
|
318
|
+
/** @} */
|
319
|
+
|
277
320
|
/** @defgroup numHexagons numHexagons
|
278
321
|
* Functions for numHexagons
|
279
322
|
* @{
|
280
323
|
*/
|
281
|
-
/** @brief number of hexagons for a given resolution */
|
324
|
+
/** @brief number of cells (hexagons and pentagons) for a given resolution */
|
282
325
|
int64_t H3_EXPORT(numHexagons)(int res);
|
283
326
|
/** @} */
|
284
327
|
|
@@ -286,18 +329,30 @@ int64_t H3_EXPORT(numHexagons)(int res);
|
|
286
329
|
* Functions for getRes0Indexes
|
287
330
|
* @{
|
288
331
|
*/
|
289
|
-
/** @brief returns the number of resolution 0
|
332
|
+
/** @brief returns the number of resolution 0 cells (hexagons and pentagons) */
|
290
333
|
int H3_EXPORT(res0IndexCount)();
|
291
334
|
|
292
|
-
/** @brief provides all base cells */
|
335
|
+
/** @brief provides all base cells in H3Index format*/
|
293
336
|
void H3_EXPORT(getRes0Indexes)(H3Index *out);
|
294
337
|
/** @} */
|
295
338
|
|
339
|
+
/** @defgroup getPentagonIndexes getPentagonIndexes
|
340
|
+
* Functions for getPentagonIndexes
|
341
|
+
* @{
|
342
|
+
*/
|
343
|
+
/** @brief returns the number of pentagons per resolution */
|
344
|
+
int H3_EXPORT(pentagonIndexCount)();
|
345
|
+
|
346
|
+
/** @brief generates all pentagons at the specified resolution */
|
347
|
+
void H3_EXPORT(getPentagonIndexes)(int res, H3Index *out);
|
348
|
+
/** @} */
|
349
|
+
|
296
350
|
/** @defgroup h3GetResolution h3GetResolution
|
297
351
|
* Functions for h3GetResolution
|
298
352
|
* @{
|
299
353
|
*/
|
300
|
-
/** @brief returns the resolution of the provided
|
354
|
+
/** @brief returns the resolution of the provided H3 index
|
355
|
+
* Works on both cells and unidirectional edges. */
|
301
356
|
int H3_EXPORT(h3GetResolution)(H3Index h);
|
302
357
|
/** @} */
|
303
358
|
|
@@ -305,7 +360,10 @@ int H3_EXPORT(h3GetResolution)(H3Index h);
|
|
305
360
|
* Functions for h3GetBaseCell
|
306
361
|
* @{
|
307
362
|
*/
|
308
|
-
/** @brief returns the base cell of the provided
|
363
|
+
/** @brief returns the base cell "number" (0 to 121) of the provided H3 cell
|
364
|
+
*
|
365
|
+
* Note: Technically works on H3 edges, but will return base cell of the
|
366
|
+
* origin cell. */
|
309
367
|
int H3_EXPORT(h3GetBaseCell)(H3Index h);
|
310
368
|
/** @} */
|
311
369
|
|
@@ -329,7 +387,9 @@ void H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
|
|
329
387
|
* Functions for h3IsValid
|
330
388
|
* @{
|
331
389
|
*/
|
332
|
-
/** @brief confirms if an H3Index is valid
|
390
|
+
/** @brief confirms if an H3Index is a valid cell (hexagon or pentagon)
|
391
|
+
* In particular, returns 0 (False) for H3 unidirectional edges or invalid data
|
392
|
+
*/
|
333
393
|
int H3_EXPORT(h3IsValid)(H3Index h);
|
334
394
|
/** @} */
|
335
395
|
|
@@ -347,14 +407,22 @@ H3Index H3_EXPORT(h3ToParent)(H3Index h, int parentRes);
|
|
347
407
|
* @{
|
348
408
|
*/
|
349
409
|
/** @brief determines the maximum number of children (or grandchildren, etc)
|
350
|
-
* that
|
351
|
-
* could be returned for the given hexagon */
|
410
|
+
* that could be returned for the given hexagon */
|
352
411
|
int H3_EXPORT(maxH3ToChildrenSize)(H3Index h, int childRes);
|
353
412
|
|
354
413
|
/** @brief provides the children (or grandchildren, etc) of the given hexagon */
|
355
414
|
void H3_EXPORT(h3ToChildren)(H3Index h, int childRes, H3Index *children);
|
356
415
|
/** @} */
|
357
416
|
|
417
|
+
/** @defgroup h3ToCenterChild h3ToCenterChild
|
418
|
+
* Functions for h3ToCenterChild
|
419
|
+
* @{
|
420
|
+
*/
|
421
|
+
/** @brief returns the center child of the given hexagon at the specified
|
422
|
+
* resolution */
|
423
|
+
H3Index H3_EXPORT(h3ToCenterChild)(H3Index h, int childRes);
|
424
|
+
/** @} */
|
425
|
+
|
358
426
|
/** @defgroup compact compact
|
359
427
|
* Functions for compact
|
360
428
|
* @{
|
@@ -390,7 +458,7 @@ int H3_EXPORT(h3IsResClassIII)(H3Index h);
|
|
390
458
|
* Functions for h3IsPentagon
|
391
459
|
* @{
|
392
460
|
*/
|
393
|
-
/** @brief determines if
|
461
|
+
/** @brief determines if an H3 cell is a pentagon */
|
394
462
|
int H3_EXPORT(h3IsPentagon)(H3Index h);
|
395
463
|
/** @} */
|
396
464
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2020 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
|
+
/** @file vertex.h
|
17
|
+
* @brief Functions for working with cell vertexes.
|
18
|
+
*/
|
19
|
+
|
20
|
+
#ifndef H3VERTEX_H
|
21
|
+
#define H3VERTEX_H
|
22
|
+
|
23
|
+
#include "h3Index.h"
|
24
|
+
#include "faceijk.h"
|
25
|
+
|
26
|
+
/** @struct PentagonDirectionFaces
|
27
|
+
* @brief The faces in each axial direction of a given pentagon base cell
|
28
|
+
*/
|
29
|
+
typedef struct {
|
30
|
+
int baseCell; ///< base cell number
|
31
|
+
int faces[NUM_PENT_VERTS]; ///< face numbers for each axial direction,
|
32
|
+
/// in order, starting with J
|
33
|
+
} PentagonDirectionFaces;
|
34
|
+
|
35
|
+
/** Invalid vertex number */
|
36
|
+
#define INVALID_VERTEX_NUM -1
|
37
|
+
|
38
|
+
/** Max number of faces a base cell's descendants may appear on */
|
39
|
+
#define MAX_BASE_CELL_FACES 5
|
40
|
+
|
41
|
+
int vertexRotations(H3Index cell);
|
42
|
+
int vertexNumForDirection(const H3Index origin, const Direction direction);
|
43
|
+
|
44
|
+
#endif
|