标签(空格分隔):室内定位
int h3Distance(H3Index origin, H3Index h3);
返回两个索引对应的网格cell单元的距离
若是查询距离失败,则返回负值
H3Index h3ToParent(H3Index h, int parentRes);
Returns the parent (coarser) index containing h
.
void h3ToChildren(H3Index h, int childRes, H3Index *children);
Populates children
with the indexes contained by h
at resolution childRes
. children
must be an array of at least size maxH3ToChildrenSize(h, childRes)
.
int maxH3ToChildrenSize(H3Index h, int childRes);
Returns the size of the array needed by h3ToChildren
for these inputs.
int compact(const H3Index *h3Set, H3Index *compactedSet, const int numHexes);
Compacts the set h3Set
of indexes as best as possible, into the array compactedSet
. compactedSet
must be at least the size of h3Set
in case the set cannot be compacted.
Returns 0 on success.
int uncompact(const H3Index *compactedSet, const int numHexes, H3Index *h3Set, const int maxHexes, const int res);
Uncompacts the set compactedSet
of indexes to the resolution res
. h3Set
must be at least of size maxUncompactSize(compactedSet, numHexes, res)
.
Returns 0 on success.
int maxUncompactSize(const H3Index *compactedSet, const int numHexes, const int res)
Returns the size of the array needed by uncompact
.
#3、 Indexing functions
filter | input | outputs |
---|---|---|
geoToH3 | lat/lon | H3Index |
h3ToGeo | H3Index | cell center point in lat/lon |
h3ToGeoBoundary | H3Index | cell boundary in lat/lon |
h3ToComponents | H3Index | components |
kRing | H3Index | surrounding H3Index |
hexRange | H3Index | surrounding H3Index , in order |
H3Index geoToH3(const GeoCoord *g, int res);
Indexes the location at the specified resolution.
Returns 0 on error.
void h3ToGeo(H3Index h3, GeoCoord *g);
Finds the centroid of the index.
##h3ToGeoBoundary
void h3ToGeoBoundary(H3Index h3, GeoBoundary *gp);
find the index for coordinates at resolution 5
echo 40.689167 -74.044444 | geoToH3 5
output the cell center point for H3Index
845ad1bffffffff
echo 845ad1bffffffff | h3ToGeo
output the cell boundary for H3Index
845ad1bffffffff
echo 845ad1bffffffff | h3ToGeoBoundary
find the components for the H3Index
845ad1bffffffff
echo 845ad1bffffffff | h3ToComponents
output all indexes within distance 1 of the H3Index
845ad1bffffffff
echo 845ad1bffffffff | kRing 1
output all hexagon indexes within distance 2 of the H3Index
845ad1bffffffff
echo 845ad1bffffffff | hexRange 2
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.
#4、 Index inspection functions
int h3GetResolution(H3Index h);
Returns the resolution of the index.
int h3GetBaseCell(H3Index h);
Returns the base cell number of the index.
H3Index stringToH3(const char *str);
Converts the string representation to H3Index
(uint64_t
) representation.
Returns 0 on error.
void h3ToString(H3Index h, char *str, size_t sz);
Converts the H3Index
representation of the index to the string representation. str
must be at least of length 17.
int h3IsValid(H3Index h);
Returns non-zero if this is a valid H3 index.
int h3IsResClassIII(H3Index h);
Returns non-zero if this index has a resolution with Class III orientation.
int h3IsPentagon(H3Index h);
Returns non-zero if this index represents a pentagonal cell.
#5、 Miscellaneous H3 functions
double degsToRads(double degrees);
Converts degrees to radians.
double radsToDegs(double radians);
Converts radians to degrees.
double hexAreaKm2(int res);
Average hexagon area in square kilometers at the given resolution.
double hexAreaM2(int res);
Average hexagon area in square meters at the given resolution.
double edgeLengthKm(int res);
Average hexagon edge length in kilometers at the given resolution.
double edgeLengthM(int res);
Average hexagon edge length in meters at the given resolution.
int64_t numHexagons(int res);
Number of unique H3 indexes at the given resolution.
#6、 Neighbor traversal functions
void kRing(H3Index origin, int k, H3Index* out);
k-rings produces indices within k distance of the origin index.
k-ring 0 is defined as the origin index, k-ring 1 is defined as k-ring 0 and
all neighboring indices, and so on.
Output is placed in the provided array in no particular order. Elements of
the output array may be left zero, as can happen when crossing a pentagon.
int maxKringSize(int k);
Maximum number of indices that result from the kRing algorithm with the given k.
void kRingDistances(H3Index origin, int k, H3Index* out, int* distances);
k-rings produces indices within k distance of the origin index.
k-ring 0 is defined as the origin index, k-ring 1 is defined as k-ring 0 and
all neighboring indices, and so on.
Output is placed in the provided array in no particular order. Elements of
the output array may be left zero, as can happen when crossing a pentagon.
int hexRange(H3Index origin, int k, H3Index* out);
hexRange produces indexes within k distance of the origin index.
Output behavior is undefined when one of the indexes returned by this
function is a pentagon or is in the pentagon distortion area.
k-ring 0 is defined as the origin index, k-ring 1 is defined as k-ring 0 and
all neighboring indexes, and so on.
Output is placed in the provided array in order of increasing distance from
the origin.
Returns 0 if no pentagonal distortion is encountered.
int hexRangeDistances(H3Index origin, int k, H3Index* out, int* distances);
hexRange produces indexes within k distance of the origin index.
Output behavior is undefined when one of the indexes returned by this
function is a pentagon or is in the pentagon distortion area.
k-ring 0 is defined as the origin index, k-ring 1 is defined as k-ring 0 and
all neighboring indexes, and so on.
Output is placed in the provided array in order of increasing distance from
the origin. The distances in hexagons is placed in the distances array at
the same offset.
Returns 0 if no pentagonal distortion is encountered.
int hexRanges(H3Index* h3Set, int length, int k, H3Index* out);
hexRanges takes an array of input hex IDs and a max k-ring and returns an
array of hexagon IDs sorted first by the original hex IDs and then by the
k-ring (0 to max), with no guaranteed sorting within each k-ring group.
Returns 0 if no pentagonal distortion was encountered. Otherwise, output
is undefined
int hexRing(H3Index origin, int k, H3Index* out);
Produces the hollow hexagonal ring centered at origin with sides of length k.
Returns 0 if no pentagonal distortion was encountered.
#7、 Region functions
void polyfill(const GeoPolygon* geoPolygon, int res, H3Index* out);
polyfill takes a given GeoJSON-like data structure and preallocated,
zeroed memory, and fills it with the hexagons that are contained by
the GeoJSON-like data structure.
The current implementation is very primitive and slow, but correct,
performing a point-in-poly operation on every hexagon in a k-ring defined
around the given geofence.
int maxPolyfillSize(const GeoPolygon* geoPolygon, int res);
maxPolyfillSize returns the number of hexagons to allocate space for when
performing a polyfill on the given GeoJSON-like data structure.
void h3SetToLinkedGeo(const H3Index* h3Set, const int numHexes, LinkedGeoPolygon* out);
Create a LinkedGeoPolygon describing the outline(s) of a set of hexagons.
It is the responsibility of the caller to call destroyLinkedPolygon on the
populated linked geo structure, or the memory for that structure will
not be freed.
It is expected that all hexagons in the set will have the same resolution.
Using different resolution hexagons is not recommended.
At present, if the set of hexagons is not contiguous, this function
will return a single polygon with multiple outer loops. The correct GeoJSON
output should only have one outer loop per polygon. It appears that most
GeoJSON consumers are fine with the first input format, but it’s less correct
than the second format. The function may be updated to produce
multiple polygons in the future.
void destroyLinkedPolygon(LinkedGeoPolygon* polygon);
Free all allocated memory for a linked geo structure. The caller is
responsible for freeing memory allocated to input polygon struct.
#8、 Unidirectional edge functions
int h3IndexesAreNeighbors(H3Index origin, H3Index destination);
Returns whether or not the provided H3Indexes are neighbors.
Returns 1 if the indexes are neighbors, 0 otherwise.
H3Index getH3UnidirectionalEdge(H3Index origin, H3Index destination);
Returns a unidirectional edge H3 index based on the provided origin and
destination.
Returns 0 on error.
int h3UnidirectionalEdgeIsValid(H3Index edge);
Determines if the provided H3Index is a valid unidirectional edge index.
Returns 1 if it is a unidirectional edge H3Index, otherwise 0.
H3Index getOriginH3IndexFromUnidirectionalEdge(H3Index edge);
Returns the origin hexagon from the unidirectional edge H3Index.
H3Index getDestinationH3IndexFromUnidirectionalEdge(H3Index edge);
Returns the destination hexagon from the unidirectional edge H3Index.
void getH3IndexesFromUnidirectionalEdge(H3Index edge, H3Index* originDestination);
Returns the origin, destination pair of hexagon IDs for the given edge ID, which are placed at originDestination[0]
and
originDestination[1]
respectively.
void getH3UnidirectionalEdgesFromHexagon(H3Index origin, H3Index* edges);
Provides all of the unidirectional edges from the current H3Index. edges
must be of length 6,
and the number of undirectional edges placed in the array may be less than 6.
void getH3UnidirectionalEdgeBoundary(H3Index edge, GeoBoundary* gb);
Provides the coordinates defining the unidirectional edge.