Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change H3_HEXAGON_MODE to H3_CELL_MODE #495

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/apps/filters/h3ToComponents.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void doCell(H3Index h, bool verboseMode) {
}
printf("╚════════════╝\n\n");
} else {
if (h3Mode == H3_HEXAGON_MODE) {
if (h3Mode == H3_CELL_MODE) {
printf("%d:%d:%d:", h3Mode, h3Res, h3BaseCell);
for (int i = 1; i <= h3Res; i++) {
printf("%c", resDigitToChar(H3_GET_INDEX_DIGIT(h, i)));
Expand Down
2 changes: 1 addition & 1 deletion src/apps/miscapps/h3ToHier.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) {
// Generate all
for (int bc = 0; bc < NUM_BASE_CELLS; bc++) {
H3Index rootCell = H3_INIT;
H3_SET_MODE(rootCell, H3_HEXAGON_MODE);
H3_SET_MODE(rootCell, H3_CELL_MODE);
H3_SET_BASE_CELL(rootCell, bc);
if (res == 0) {
h3Println(rootCell);
Expand Down
14 changes: 7 additions & 7 deletions src/apps/testapps/testH3Index.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ SUITE(h3Index) {
TEST(isValidCellBaseCell) {
for (int i = 0; i < NUM_BASE_CELLS; i++) {
H3Index h = H3_INIT;
H3_SET_MODE(h, H3_HEXAGON_MODE);
H3_SET_MODE(h, H3_CELL_MODE);
H3_SET_BASE_CELL(h, i);
char failureMessage[BUFF_SIZE];
sprintf(failureMessage, "isValidCell failed on base cell %d", i);
Expand All @@ -103,7 +103,7 @@ SUITE(h3Index) {

TEST(isValidCellBaseCellInvalid) {
H3Index hWrongBaseCell = H3_INIT;
H3_SET_MODE(hWrongBaseCell, H3_HEXAGON_MODE);
H3_SET_MODE(hWrongBaseCell, H3_CELL_MODE);
H3_SET_BASE_CELL(hWrongBaseCell, NUM_BASE_CELLS);
t_assert(!H3_EXPORT(isValidCell)(hWrongBaseCell),
"isValidCell failed on invalid base cell");
Expand All @@ -113,7 +113,7 @@ SUITE(h3Index) {
for (int i = 0; i <= 0xf; i++) {
H3Index h = H3_INIT;
H3_SET_MODE(h, i);
if (i == H3_HEXAGON_MODE) {
if (i == H3_CELL_MODE) {
t_assert(H3_EXPORT(isValidCell)(h),
"isValidCell succeeds on valid mode");
} else {
Expand All @@ -127,7 +127,7 @@ SUITE(h3Index) {
TEST(isValidCellReservedBits) {
for (int i = 0; i < 8; i++) {
H3Index h = H3_INIT;
H3_SET_MODE(h, H3_HEXAGON_MODE);
H3_SET_MODE(h, H3_CELL_MODE);
H3_SET_RESERVED_BITS(h, i);
if (i == 0) {
t_assert(H3_EXPORT(isValidCell)(h),
Expand All @@ -143,15 +143,15 @@ SUITE(h3Index) {

TEST(isValidCellHighBit) {
H3Index h = H3_INIT;
H3_SET_MODE(h, H3_HEXAGON_MODE);
H3_SET_MODE(h, H3_CELL_MODE);
H3_SET_HIGH_BIT(h, 1);
t_assert(!H3_EXPORT(isValidCell)(h), "isValidCell failed on high bit");
}

TEST(h3BadDigitInvalid) {
H3Index h = H3_INIT;
// By default the first index digit is out of range.
H3_SET_MODE(h, H3_HEXAGON_MODE);
H3_SET_MODE(h, H3_CELL_MODE);
H3_SET_RESOLUTION(h, 1);
t_assert(!H3_EXPORT(isValidCell)(h),
"isValidCell failed on too large digit");
Expand Down Expand Up @@ -193,7 +193,7 @@ SUITE(h3Index) {
setH3Index(&h, 5, 12, 1);
t_assert(H3_GET_RESOLUTION(h) == 5, "resolution as expected");
t_assert(H3_GET_BASE_CELL(h) == 12, "base cell as expected");
t_assert(H3_GET_MODE(h) == H3_HEXAGON_MODE, "mode as expected");
t_assert(H3_GET_MODE(h) == H3_CELL_MODE, "mode as expected");
for (int i = 1; i <= 5; i++) {
t_assert(H3_GET_INDEX_DIGIT(h, i) == 1, "digit as expected");
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/testapps/testH3NeighborRotations.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) {
// generate the test cases
for (int bc = 0; bc < NUM_BASE_CELLS; bc++) {
H3Index rootCell = H3_INIT;
H3_SET_MODE(rootCell, H3_HEXAGON_MODE);
H3_SET_MODE(rootCell, H3_CELL_MODE);
H3_SET_BASE_CELL(rootCell, bc);

if (res == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/testapps/testVertex.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ SUITE(Vertex) {

// Assert that origin does not own the vertex
H3Index owner = vert;
H3_SET_MODE(owner, H3_HEXAGON_MODE);
H3_SET_MODE(owner, H3_CELL_MODE);
H3_SET_RESERVED_BITS(owner, 0);

t_assert(origin != owner, "origin does not own the canonical vertex");
Expand Down
2 changes: 1 addition & 1 deletion src/h3lib/include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#define NUM_PENTAGONS 12

/** H3 index modes */
#define H3_HEXAGON_MODE 1
#define H3_CELL_MODE 1
#define H3_DIRECTEDEDGE_MODE 2
#define H3_EDGE_MODE 3
#define H3_VERTEX_MODE 4
Comment on lines 80 to 84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these maybe be exposed in h3api.h?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these returned or accepted by the API anywhere? Definitely if so.

Expand Down
2 changes: 1 addition & 1 deletion src/h3lib/lib/baseCells.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ int H3_EXPORT(res0CellCount)() { return NUM_BASE_CELLS; }
void H3_EXPORT(getRes0Cells)(H3Index *out) {
for (int bc = 0; bc < NUM_BASE_CELLS; bc++) {
H3Index baseCell = H3_INIT;
H3_SET_MODE(baseCell, H3_HEXAGON_MODE);
H3_SET_MODE(baseCell, H3_CELL_MODE);
H3_SET_BASE_CELL(baseCell, bc);
out[bc] = baseCell;
}
Expand Down
6 changes: 3 additions & 3 deletions src/h3lib/lib/directedEdge.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
*/
int H3_EXPORT(areNeighborCells)(H3Index origin, H3Index destination) {
// Make sure they're hexagon indexes
if (H3_GET_MODE(origin) != H3_HEXAGON_MODE ||
H3_GET_MODE(destination) != H3_HEXAGON_MODE) {
if (H3_GET_MODE(origin) != H3_CELL_MODE ||
H3_GET_MODE(destination) != H3_CELL_MODE) {
return 0;
}

Expand Down Expand Up @@ -127,7 +127,7 @@ H3Index H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge) {
return H3_NULL;
}
H3Index origin = edge;
H3_SET_MODE(origin, H3_HEXAGON_MODE);
H3_SET_MODE(origin, H3_CELL_MODE);
H3_SET_RESERVED_BITS(origin, 0);
return origin;
}
Expand Down
6 changes: 3 additions & 3 deletions src/h3lib/lib/h3Index.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz) {
int H3_EXPORT(isValidCell)(H3Index h) {
if (H3_GET_HIGH_BIT(h) != 0) return 0;

if (H3_GET_MODE(h) != H3_HEXAGON_MODE) return 0;
if (H3_GET_MODE(h) != H3_CELL_MODE) return 0;

if (H3_GET_RESERVED_BITS(h) != 0) return 0;

Expand Down Expand Up @@ -133,7 +133,7 @@ int H3_EXPORT(isValidCell)(H3Index h) {
*/
void setH3Index(H3Index *hp, int res, int baseCell, Direction initDigit) {
H3Index h = H3_INIT;
H3_SET_MODE(h, H3_HEXAGON_MODE);
H3_SET_MODE(h, H3_CELL_MODE);
H3_SET_RESOLUTION(h, res);
H3_SET_BASE_CELL(h, baseCell);
for (int r = 1; r <= res; r++) H3_SET_INDEX_DIGIT(h, r, initDigit);
Expand Down Expand Up @@ -631,7 +631,7 @@ H3Index _h3Rotate60cw(H3Index h) {
H3Index _faceIjkToH3(const FaceIJK *fijk, int res) {
// initialize the index
H3Index h = H3_INIT;
H3_SET_MODE(h, H3_HEXAGON_MODE);
H3_SET_MODE(h, H3_CELL_MODE);
H3_SET_RESOLUTION(h, res);

// check for res 0/base cell
Expand Down
2 changes: 1 addition & 1 deletion src/h3lib/lib/localij.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ int localIjkToH3(H3Index origin, const CoordIJK *ijk, H3Index *out) {
// This logic is very similar to faceIjkToH3
// initialize the index
*out = H3_INIT;
H3_SET_MODE(*out, H3_HEXAGON_MODE);
H3_SET_MODE(*out, H3_CELL_MODE);
H3_SET_RESOLUTION(*out, res);

// check for res 0/base cell
Expand Down
4 changes: 2 additions & 2 deletions src/h3lib/lib/vertex.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void H3_EXPORT(vertexToLatLng)(H3Index vertex, LatLng *coord) {
// Get the vertex number and owner from the vertex
int vertexNum = H3_GET_RESERVED_BITS(vertex);
H3Index owner = vertex;
H3_SET_MODE(owner, H3_HEXAGON_MODE);
H3_SET_MODE(owner, H3_CELL_MODE);
H3_SET_RESERVED_BITS(owner, 0);

// Get the single vertex from the boundary
Expand Down Expand Up @@ -320,7 +320,7 @@ int H3_EXPORT(isValidVertex)(H3Index vertex) {

int vertexNum = H3_GET_RESERVED_BITS(vertex);
H3Index owner = vertex;
H3_SET_MODE(owner, H3_HEXAGON_MODE);
H3_SET_MODE(owner, H3_CELL_MODE);
H3_SET_RESERVED_BITS(owner, 0);

if (!H3_EXPORT(isValidCell)(owner)) {
Expand Down