OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
h3ToParent

Functions

EXTENSION_NOINLINE H3Index
H3_EXPORT() 
h3ToParent (H3Index h, int parentRes)
 returns the parent (or grandparent, etc) hexagon of the given hexagon More...
 

Detailed Description

Functions for h3ToParent

Function Documentation

EXTENSION_NOINLINE H3Index H3_EXPORT() h3ToParent ( H3Index  h,
int  parentRes 
)

returns the parent (or grandparent, etc) hexagon of the given hexagon

Returns the H3 resolution of an H3 index.

Parameters
hThe H3 index.
Returns
The resolution of the H3 index argument. Returns the H3 base cell "number" of an H3 cell (hexagon or pentagon).

Note: Technically works on H3 edges, but will return base cell of the origin cell.

Parameters
hThe H3 cell.
Returns
The base cell "number" of the H3 cell argument. Converts a string representation of an H3 index into an H3 index.
Parameters
strThe string representation of an H3 index.
Returns
The H3 index corresponding to the string argument, or H3_NULL if invalid. Converts an H3 index into a string representation.
Parameters
hThe H3 index to convert.
strThe string representation of the H3 index.
szSize of the buffer str Returns whether or not an H3 index is a valid cell (hexagon or pentagon).
hThe H3 index to validate.
Returns
1 if the H3 index if valid, and 0 if it is not. Initializes an H3 index.
Parameters
hpThe H3 index to initialize.
resThe H3 resolution to initialize the index to.
baseCellThe H3 base cell to initialize the index to.
initDigitThe H3 digit (0-7) to initialize all of the index digits to. h3ToParent produces the parent index for a given H3 index
hH3Index to find parent of
parentResThe resolution to switch to (parent, grandparent, etc)
Returns
H3Index of the parent, or H3_NULL if you actually asked for a child

Definition at line 144 of file h3Index.hpp.

References H3_DIGIT_MASK, H3_GET_RESOLUTION, H3_NULL, H3_SET_INDEX_DIGIT, H3_SET_RESOLUTION, H3Index, and MAX_H3_RES.

144  {
145  int childRes = H3_GET_RESOLUTION(h);
146  if (parentRes > childRes) {
147  return H3_NULL;
148  } else if (parentRes == childRes) {
149  return h;
150  } else if (parentRes < 0 || parentRes > MAX_H3_RES) {
151  return H3_NULL;
152  }
153  H3Index parentH = H3_SET_RESOLUTION(h, parentRes);
154  for (int i = parentRes + 1; i <= childRes; i++) {
155  H3_SET_INDEX_DIGIT(parentH, i, H3_DIGIT_MASK);
156  }
157  return parentH;
158 }
#define H3_SET_INDEX_DIGIT(h3, res, digit)
Definition: h3Index.h:157
#define H3_SET_RESOLUTION(h3, res)
Definition: h3Index.h:133
#define H3Index
the H3Index fits within a 64-bit unsigned integer
Definition: h3api.h:75
#define H3_DIGIT_MASK
Definition: h3Index.h:80
#define MAX_H3_RES
Definition: constants.h:68
#define H3_NULL
Definition: h3Index.h:165
#define H3_GET_RESOLUTION(h3)
Definition: h3Index.h:128