H3_API

DGGS_H3

标签(空格分隔):室内定位

1、Distance

h3Distance

int h3Distance(H3Index origin, H3Index h3);

返回两个索引对应的网格cell单元的距离
若是查询距离失败,则返回负值

2、Hierarchical grid functions

h3ToParent

H3Index h3ToParent(H3Index h, int parentRes);

Returns the parent (coarser) index containing h.

h3ToChildren

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).

maxH3ToChildrenSize

int maxH3ToChildrenSize(H3Index h, int childRes);

Returns the size of the array needed by h3ToChildren for these inputs.

compact

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.

uncompact

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.

maxUncompactSize

int maxUncompactSize(const H3Index *compactedSet, const int numHexes, const int res)

Returns the size of the array needed by uncompact.
#3、 Indexing functions

filterinputoutputs
geoToH3lat/lonH3Index
h3ToGeoH3Indexcell center point in lat/lon
h3ToGeoBoundaryH3Indexcell boundary in lat/lon
h3ToComponentsH3Indexcomponents
kRingH3Indexsurrounding H3Index
hexRangeH3Indexsurrounding H3Index, in order

geoToH3

H3Index geoToH3(const GeoCoord *g, int res);

Indexes the location at the specified resolution.

Returns 0 on error.

h3ToGeo

void h3ToGeo(H3Index h3, GeoCoord *g);

Finds the centroid of the index.

  ##h3ToGeoBoundary
void h3ToGeoBoundary(H3Index h3, GeoBoundary *gp);

Finds the boundary of the index.
Unix Command Line Examples

  • 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

h3GetResolution

int h3GetResolution(H3Index h);

Returns the resolution of the index.

h3GetBaseCell

int h3GetBaseCell(H3Index h);

Returns the base cell number of the index.

stringToH3

H3Index stringToH3(const char *str);

Converts the string representation to H3Index (uint64_t) representation.

Returns 0 on error.

h3ToString

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.

h3IsValid

int h3IsValid(H3Index h);

Returns non-zero if this is a valid H3 index.

h3IsResClassIII

int h3IsResClassIII(H3Index h);

Returns non-zero if this index has a resolution with Class III orientation.

h3IsPentagon

int h3IsPentagon(H3Index h);

Returns non-zero if this index represents a pentagonal cell.
#5、 Miscellaneous H3 functions

degsToRads

double degsToRads(double degrees);

Converts degrees to radians.

radsToDegs

double radsToDegs(double radians);

Converts radians to degrees.

hexAreaKm2

double hexAreaKm2(int res);

Average hexagon area in square kilometers at the given resolution.

hexAreaM2

double hexAreaM2(int res);

Average hexagon area in square meters at the given resolution.

edgeLengthKm

double edgeLengthKm(int res);

Average hexagon edge length in kilometers at the given resolution.

edgeLengthM

double edgeLengthM(int res);

Average hexagon edge length in meters at the given resolution.

numHexagons

int64_t numHexagons(int res);

Number of unique H3 indexes at the given resolution.
#6、 Neighbor traversal functions

kRing

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.

maxKringSize

int maxKringSize(int k);

Maximum number of indices that result from the kRing algorithm with the given k.

kRingDistances

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.

hexRange

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.

hexRangeDistances

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.

hexRanges

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

hexRing

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

polyfill

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.

maxPolyfillSize

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.

h3SetToLinkedGeo

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.

destroyLinkedPolygon

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

h3IndexesAreNeighbors

int h3IndexesAreNeighbors(H3Index origin, H3Index destination);

Returns whether or not the provided H3Indexes are neighbors.

Returns 1 if the indexes are neighbors, 0 otherwise.

getH3UnidirectionalEdge

H3Index getH3UnidirectionalEdge(H3Index origin, H3Index destination);

Returns a unidirectional edge H3 index based on the provided origin and
destination.

Returns 0 on error.

h3UnidirectionalEdgeIsValid

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.

getOriginH3IndexFromUnidirectionalEdge

H3Index getOriginH3IndexFromUnidirectionalEdge(H3Index edge);

Returns the origin hexagon from the unidirectional edge H3Index.

getDestinationH3IndexFromUnidirectionalEdge

H3Index getDestinationH3IndexFromUnidirectionalEdge(H3Index edge);

Returns the destination hexagon from the unidirectional edge H3Index.

getH3IndexesFromUnidirectionalEdge

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.

getH3UnidirectionalEdgesFromHexagon

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.

getH3UnidirectionalEdgeBoundary

void getH3UnidirectionalEdgeBoundary(H3Index edge, GeoBoundary* gb);

Provides the coordinates defining the unidirectional edge.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值