|
5 년 전 | |
---|---|---|
.. | ||
uber-h3 @ 6af4914752 | 582671b180 HPCC-21250 Uber H3 geospatial plugin | 6 년 전 |
CMakeLists.txt | 582671b180 HPCC-21250 Uber H3 geospatial plugin | 6 년 전 |
README.md | 7835681c6c HPCC-22215 Add ECLIndex representation to H3 plugin | 6 년 전 |
h3.cpp | 9c8f35a83d HPCC-22933 H3 plugin issue | 5 년 전 |
h3.hpp | 582671b180 HPCC-21250 Uber H3 geospatial plugin | 6 년 전 |
lib_h3.ecllib | 7835681c6c HPCC-22215 Add ECLIndex representation to H3 plugin | 6 년 전 |
This plugin exposes a hexagonal hierarchical geospatial indexing system to ECL. It is a wrapper around Uber's H3 library:
The h3 plugin has a dependency on https://github.com/uber/h3 which has been added to the HPCC-Platform repository as a git submodule. To install:
git submodule update --init --recursive
Import the h3 plugin library and calculate a H3 index at the specified lat/long and at maximum resolution (15):
IMPORT h3 from lib_h3;
h3_index := h3.index(40.689167, -74.044444, 15);
EXPORT h3_index_t := UNSIGNED8;
EXPORT h3_degrees_t := REAL8;
EXPORT h3_rads_t := REAL8;
EXPORT h3_resolution_t := UNSIGNED4;
EXPORT h3_point_t := RECORD
h3_degrees_t lat;
h3_degrees_t lon;
END;
h3_index_t index(CONST h3_degrees_t lat, CONST h3_degrees_t lng, CONST h3_resolution_t resolution)
Indexes the location at the specified lat
, lng
and resolution
(0->15).
Returns 0 on error.
DATASET(h3_point_t) center(CONST h3_index_t idx) : cpp,action,context,fold,entrypoint='center';
Calculates the centroid of the idx
and returns the latitude / longitude as a 1 row dataset.
DATASET(h3_point_t) boundary(CONST h3_index_t idx) : cpp,action,context,fold,entrypoint='boundary';
Calculates the center and boundary (hexagon) of the idx
and returns them as 5 or 6 row dataset.
h3_resolution_t resolution(CONST h3_index_t idx)
Returns the resolution of the idx
.
UNSIGNED4 baseCell(CONST h3_index_t idx)
Returns the base cell number of the idx
.
STRING toString(CONST h3_index_t idx)
Converts the H3Index representation of idx
to the string representation.
h3_index_t fromString(CONST VARSTRING strIdx) : cpp,action,context,fold,entrypoint='fromString';
Converts the string representation of strIdx
to the H3Index representation.
Returns 0 on error.
BOOLEAN isValid(CONST h3_index_t idx)
Returns TRUE if this is a valid H3 idx
.
SET OF h3_index_t kRing(CONST h3_index_t idx, CONST INTEGER4 k)
k-rings produces indices within k
distance of the origin idx
.
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 returned SET in no particular order.
SET OF h3_index_t hexRing(CONST h3_index_t idx, CONST UNSIGNED4 k)
Produces the hollow hexagonal ring centered at idx
with distance of k
.
SIGNED4 distance(CONST h3_index_t fromIdx, CONST h3_index_t toIdx)
Returns the distance in grid cells between fromIdx
and toIdx
.
Returns a negative number if finding the distance failed. Finding the distance can fail because the two indexes are not comparable (different resolutions), too far apart, or are separated by pentagonal distortion. This is the same set of limitations as the local IJ coordinate space functions.
h3_index_t parent(CONST h3_index_t idx, CONST h3_resolution_t resolution)
Returns the parent (coarser) index containing idx
at resolution resolution
.
SET OF h3_index_t children(CONST h3_index_t idx, CONST h3_resolution_t resolution)
Returns children
with the indexes contained by idx
at resolution resolution
.
SET OF h3_index_t compact(CONST SET OF h3_index_t indexes)
Compacts the set indexes
as best as possible, and returns the compacted set.
SET OF h3_index_t uncompact(CONST SET OF h3_index_t indexes, CONST h3_resolution_t resolution)
Uncompacts the compacted set of indexes
to the resolution resolution
and returns the uncompacted set.
SET OF h3_index_t polyfill(CONST LINKCOUNTED DATASET(h3_point_t) boundary, CONST h3_resolution_t resolution)
polyfill takes an array of lat/long representing a polygon (open ended) and returns a dataset of hexagons that are contained by the polygon.
h3_rads_t degsToRads(CONST h3_degrees_t degrees)
Converts degrees
to radians.
h3_degrees_t radsToDegs(CONST h3_rads_t radians)
Converts radians
to degrees.
REAL8 hexAreaKm2(CONST h3_resolution_t resolution)
Average hexagon area in square kilometers at the given resolution
.
REAL8 hexAreaM2(CONST h3_resolution_t resolution)
Average hexagon area in square meters at the given resolution
.
UNSIGNED8 numHexagons(CONST h3_resolution_t resolution)
Number of unique H3 indexes at the given resolution
.
The following functions provide an ECL friendly representation of the h3 index. Specifically, it is a STRING16
format where each character represents a finer precision coordinate location (one character per resolution). This allows for quick equality and parentage checking using string slicing techniques.
STRING16 ECLIndex(CONST h3_degrees_t lat, CONST h3_degrees_t lng, CONST h3_resolution_t resolution)
Indexes the location at the specified lat
, lng
and resolution
(0->15).
STRING16 toECLIndex(CONST h3_index_t h3Idx)
Converts a h3Index to an ECL Index.
h3_index_t fromECLIndex(CONST STRING16 eclIdx)
Converts an ECL Index to a h3Index.
h3_resolution_t ECLIndexResolution(CONST STRING16 eclIdx)
Returns the resolution of the eclIdx
. This is equivilant to: LENGTH(TRIM(eclIdx)) - 1
STRING16 ECLIndexParent(CONST STRING16 eclIdx, CONST h3_resolution_t resolution)
Returns the parent (coarser) index containing eclIdx
at resolution resolution
. This is equivilant to eclIdx[1..resolution + 1]