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

Shell docs for the H3 CLI #931

Merged
merged 5 commits into from
Oct 16, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The public API of this library consists of the functions declared in file
[h3api.h.in](./src/h3lib/include/h3api.h.in).

## [Unreleased]
### Added
- `h3` binary for shell scripts ready for use (#818, #826, #846, #923, #924, #931)

### Fixed
- Fixed compacting all or many resolution 1 cells (#919)

Expand Down
30 changes: 15 additions & 15 deletions src/apps/filters/h3.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ SUBCOMMAND(getResolution, "Extracts the resolution (0 - 15) from the H3 cell") {
// few functions that doesn't do any error handling (for some reason? I
// don't see how this would ever be in a hot loop anywhere.
int res = H3_EXPORT(getResolution)(cell);
printf("%i", res);
printf("%i\n", res);
return E_SUCCESS;
}

Expand All @@ -243,7 +243,7 @@ SUBCOMMAND(getBaseCellNumber,
// few functions that doesn't do any error handling (for some reason? I
// don't see how this would ever be in a hot loop anywhere.
int baseCell = H3_EXPORT(getBaseCellNumber)(cell);
printf("%i", baseCell);
printf("%i\n", baseCell);
return E_SUCCESS;
}

Expand All @@ -267,7 +267,7 @@ SUBCOMMAND(stringToInt, "Converts an H3 index in string form to integer form") {
free(rawCell);
return err;
}
printf("%" PRIu64, c);
printf("%" PRIu64 "\n", c);
free(rawCell);
return E_SUCCESS;
}
Expand All @@ -291,7 +291,7 @@ SUBCOMMAND(isValidCell, "Checks if the provided H3 index is actually valid") {
Arg *args[] = {&isValidCellArg, &helpArg, &cellArg};
PARSE_SUBCOMMAND(argc, argv, args);
bool isValid = H3_EXPORT(isValidCell)(cell);
printf("%s", isValid ? "true" : "false");
printf("%s\n", isValid ? "true" : "false");
return E_SUCCESS;
}

Expand All @@ -311,7 +311,7 @@ SUBCOMMAND(isResClassIII,
// few functions that doesn't do any error handling (for some reason? I
// don't see how this would ever be in a hot loop anywhere.
bool isClassIII = H3_EXPORT(isResClassIII)(cell);
printf("%s", isClassIII ? "true" : "false");
printf("%s\n", isClassIII ? "true" : "false");
return E_SUCCESS;
}

Expand All @@ -332,7 +332,7 @@ SUBCOMMAND(
// few functions that doesn't do any error handling (for some reason? I
// don't see how this would ever be in a hot loop anywhere.
bool is = H3_EXPORT(isPentagon)(cell);
printf("%s", is ? "true" : "false");
printf("%s\n", is ? "true" : "false");
return E_SUCCESS;
}

Expand Down Expand Up @@ -373,6 +373,7 @@ SUBCOMMAND(getIcosahedronFaces,
}
printf("%i", faces[faceCount - 1]);
}
printf("\n");
free(faces);
return E_SUCCESS;
}
Expand Down Expand Up @@ -838,7 +839,7 @@ SUBCOMMAND(cellToChildrenSize,
if (err) {
return err;
}
printf("%" PRId64, len);
printf("%" PRId64 "\n", len);
return E_SUCCESS;
}

Expand Down Expand Up @@ -892,7 +893,7 @@ SUBCOMMAND(
if (err) {
return err;
}
printf("%" PRId64, len);
printf("%" PRId64 "\n", len);
return E_SUCCESS;
}

Expand Down Expand Up @@ -1625,8 +1626,7 @@ SUBCOMMAND(cellsToMultiPolygon,
printf("]");
}
}
printf("]");
printf("\n");
printf("]\n");
free(cells);
H3_EXPORT(destroyLinkedMultiPolygon)(&out);
return E_SUCCESS;
Expand Down Expand Up @@ -1740,7 +1740,7 @@ SUBCOMMAND(
if (err != E_SUCCESS) {
return err;
}
printf("[%" PRIx64 ", %" PRIx64 "]\n", out[0], out[1]);
printf("[\"%" PRIx64 "\", \"%" PRIx64 "\"]\n", out[0], out[1]);
return E_SUCCESS;
}

Expand All @@ -1767,7 +1767,7 @@ SUBCOMMAND(originToDirectedEdges,
if (hasPrinted) {
printf(", ");
}
printf("%" PRIx64, out[i]);
printf("\"%" PRIx64 "\"", out[i]);
hasPrinted = true;
}
}
Expand Down Expand Up @@ -1852,7 +1852,7 @@ SUBCOMMAND(cellToVertexes,
if (hasPrinted) {
printf(", ");
}
printf("%" PRIx64, out[i]);
printf("\"%" PRIx64 "\"", out[i]);
hasPrinted = true;
}
}
Expand Down Expand Up @@ -2159,7 +2159,7 @@ SUBCOMMAND(getRes0Cells, "Returns all of the resolution 0 cells") {
if (hasPrinted) {
printf(", ");
}
printf("%" PRIx64, out[i]);
printf("\"%" PRIx64 "\"", out[i]);
hasPrinted = true;
}
}
Expand Down Expand Up @@ -2192,7 +2192,7 @@ SUBCOMMAND(getPentagons,
if (hasPrinted) {
printf(", ");
}
printf("%" PRIx64, out[i]);
printf("\"%" PRIx64 "\"", out[i]);
hasPrinted = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/cellToVertexes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_h3_cli_test(testCliCellToVertexes "cellToVertexes -c 85283473fffffff" "[22528340bfffffff, 235283447fffffff, 205283463fffffff, 255283463fffffff, 22528340ffffffff, 23528340bfffffff]")
add_h3_cli_test(testCliCellToVertexes "cellToVertexes -c 85283473fffffff" "[\"22528340bfffffff\", \"235283447fffffff\", \"205283463fffffff\", \"255283463fffffff\", \"22528340ffffffff\", \"23528340bfffffff\"]")
add_h3_cli_test(testCliNotCellToVertexes "cellToVertexes -c 115283473fffffff 2>&1" "Error 5: Cell argument was not valid")
2 changes: 1 addition & 1 deletion tests/cli/directedEdgeToCells.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_h3_cli_test(testCliDirectedEdgeToCells "directedEdgeToCells -c 115283473fffffff" "[85283473fffffff, 85283477fffffff]")
add_h3_cli_test(testCliDirectedEdgeToCells "directedEdgeToCells -c 115283473fffffff" "[\"85283473fffffff\", \"85283477fffffff\"]")
add_h3_cli_test(testCliNotDirectedEdgeToCells "directedEdgeToCells -c 85283473fffffff 2>&1" "Error 6: Directed edge argument was not valid")
2 changes: 1 addition & 1 deletion tests/cli/getPentagons.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_h3_cli_test(testCliGetPentagons "getPentagons -r 0" "[8009fffffffffff, 801dfffffffffff, 8031fffffffffff, 804dfffffffffff, 8063fffffffffff, 8075fffffffffff, 807ffffffffffff, 8091fffffffffff, 80a7fffffffffff, 80c3fffffffffff, 80d7fffffffffff, 80ebfffffffffff]")
add_h3_cli_test(testCliGetPentagons "getPentagons -r 0" "[\"8009fffffffffff\", \"801dfffffffffff\", \"8031fffffffffff\", \"804dfffffffffff\", \"8063fffffffffff\", \"8075fffffffffff\", \"807ffffffffffff\", \"8091fffffffffff\", \"80a7fffffffffff\", \"80c3fffffffffff\", \"80d7fffffffffff\", \"80ebfffffffffff\"]")
add_h3_cli_test(testCliDontGetPentagons "getPentagons -r 20 2>&1" "Error 4: Resolution argument was outside of acceptable range")
2 changes: 1 addition & 1 deletion tests/cli/getRes0Cells.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_h3_cli_test(testCliGetRes0Cells "getRes0Cells" "[8001fffffffffff, 8003fffffffffff, 8005fffffffffff, 8007fffffffffff, 8009fffffffffff, 800bfffffffffff, 800dfffffffffff, 800ffffffffffff, 8011fffffffffff, 8013fffffffffff, 8015fffffffffff, 8017fffffffffff, 8019fffffffffff, 801bfffffffffff, 801dfffffffffff, 801ffffffffffff, 8021fffffffffff, 8023fffffffffff, 8025fffffffffff, 8027fffffffffff, 8029fffffffffff, 802bfffffffffff, 802dfffffffffff, 802ffffffffffff, 8031fffffffffff, 8033fffffffffff, 8035fffffffffff, 8037fffffffffff, 8039fffffffffff, 803bfffffffffff, 803dfffffffffff, 803ffffffffffff, 8041fffffffffff, 8043fffffffffff, 8045fffffffffff, 8047fffffffffff, 8049fffffffffff, 804bfffffffffff, 804dfffffffffff, 804ffffffffffff, 8051fffffffffff, 8053fffffffffff, 8055fffffffffff, 8057fffffffffff, 8059fffffffffff, 805bfffffffffff, 805dfffffffffff, 805ffffffffffff, 8061fffffffffff, 8063fffffffffff, 8065fffffffffff, 8067fffffffffff, 8069fffffffffff, 806bfffffffffff, 806dfffffffffff, 806ffffffffffff, 8071fffffffffff, 8073fffffffffff, 8075fffffffffff, 8077fffffffffff, 8079fffffffffff, 807bfffffffffff, 807dfffffffffff, 807ffffffffffff, 8081fffffffffff, 8083fffffffffff, 8085fffffffffff, 8087fffffffffff, 8089fffffffffff, 808bfffffffffff, 808dfffffffffff, 808ffffffffffff, 8091fffffffffff, 8093fffffffffff, 8095fffffffffff, 8097fffffffffff, 8099fffffffffff, 809bfffffffffff, 809dfffffffffff, 809ffffffffffff, 80a1fffffffffff, 80a3fffffffffff, 80a5fffffffffff, 80a7fffffffffff, 80a9fffffffffff, 80abfffffffffff, 80adfffffffffff, 80affffffffffff, 80b1fffffffffff, 80b3fffffffffff, 80b5fffffffffff, 80b7fffffffffff, 80b9fffffffffff, 80bbfffffffffff, 80bdfffffffffff, 80bffffffffffff, 80c1fffffffffff, 80c3fffffffffff, 80c5fffffffffff, 80c7fffffffffff, 80c9fffffffffff, 80cbfffffffffff, 80cdfffffffffff, 80cffffffffffff, 80d1fffffffffff, 80d3fffffffffff, 80d5fffffffffff, 80d7fffffffffff, 80d9fffffffffff, 80dbfffffffffff, 80ddfffffffffff, 80dffffffffffff, 80e1fffffffffff, 80e3fffffffffff, 80e5fffffffffff, 80e7fffffffffff, 80e9fffffffffff, 80ebfffffffffff, 80edfffffffffff, 80effffffffffff, 80f1fffffffffff, 80f3fffffffffff]")
add_h3_cli_test(testCliGetRes0Cells "getRes0Cells" "[\"8001fffffffffff\", \"8003fffffffffff\", \"8005fffffffffff\", \"8007fffffffffff\", \"8009fffffffffff\", \"800bfffffffffff\", \"800dfffffffffff\", \"800ffffffffffff\", \"8011fffffffffff\", \"8013fffffffffff\", \"8015fffffffffff\", \"8017fffffffffff\", \"8019fffffffffff\", \"801bfffffffffff\", \"801dfffffffffff\", \"801ffffffffffff\", \"8021fffffffffff\", \"8023fffffffffff\", \"8025fffffffffff\", \"8027fffffffffff\", \"8029fffffffffff\", \"802bfffffffffff\", \"802dfffffffffff\", \"802ffffffffffff\", \"8031fffffffffff\", \"8033fffffffffff\", \"8035fffffffffff\", \"8037fffffffffff\", \"8039fffffffffff\", \"803bfffffffffff\", \"803dfffffffffff\", \"803ffffffffffff\", \"8041fffffffffff\", \"8043fffffffffff\", \"8045fffffffffff\", \"8047fffffffffff\", \"8049fffffffffff\", \"804bfffffffffff\", \"804dfffffffffff\", \"804ffffffffffff\", \"8051fffffffffff\", \"8053fffffffffff\", \"8055fffffffffff\", \"8057fffffffffff\", \"8059fffffffffff\", \"805bfffffffffff\", \"805dfffffffffff\", \"805ffffffffffff\", \"8061fffffffffff\", \"8063fffffffffff\", \"8065fffffffffff\", \"8067fffffffffff\", \"8069fffffffffff\", \"806bfffffffffff\", \"806dfffffffffff\", \"806ffffffffffff\", \"8071fffffffffff\", \"8073fffffffffff\", \"8075fffffffffff\", \"8077fffffffffff\", \"8079fffffffffff\", \"807bfffffffffff\", \"807dfffffffffff\", \"807ffffffffffff\", \"8081fffffffffff\", \"8083fffffffffff\", \"8085fffffffffff\", \"8087fffffffffff\", \"8089fffffffffff\", \"808bfffffffffff\", \"808dfffffffffff\", \"808ffffffffffff\", \"8091fffffffffff\", \"8093fffffffffff\", \"8095fffffffffff\", \"8097fffffffffff\", \"8099fffffffffff\", \"809bfffffffffff\", \"809dfffffffffff\", \"809ffffffffffff\", \"80a1fffffffffff\", \"80a3fffffffffff\", \"80a5fffffffffff\", \"80a7fffffffffff\", \"80a9fffffffffff\", \"80abfffffffffff\", \"80adfffffffffff\", \"80affffffffffff\", \"80b1fffffffffff\", \"80b3fffffffffff\", \"80b5fffffffffff\", \"80b7fffffffffff\", \"80b9fffffffffff\", \"80bbfffffffffff\", \"80bdfffffffffff\", \"80bffffffffffff\", \"80c1fffffffffff\", \"80c3fffffffffff\", \"80c5fffffffffff\", \"80c7fffffffffff\", \"80c9fffffffffff\", \"80cbfffffffffff\", \"80cdfffffffffff\", \"80cffffffffffff\", \"80d1fffffffffff\", \"80d3fffffffffff\", \"80d5fffffffffff\", \"80d7fffffffffff\", \"80d9fffffffffff\", \"80dbfffffffffff\", \"80ddfffffffffff\", \"80dffffffffffff\", \"80e1fffffffffff\", \"80e3fffffffffff\", \"80e5fffffffffff\", \"80e7fffffffffff\", \"80e9fffffffffff\", \"80ebfffffffffff\", \"80edfffffffffff\", \"80effffffffffff\", \"80f1fffffffffff\", \"80f3fffffffffff\"]")
2 changes: 1 addition & 1 deletion tests/cli/originToDirectedEdges.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_h3_cli_test(testCliOriginToDirectedEdges "originToDirectedEdges -c 85283473fffffff" "[115283473fffffff, 125283473fffffff, 135283473fffffff, 145283473fffffff, 155283473fffffff, 165283473fffffff]")
add_h3_cli_test(testCliOriginToDirectedEdges "originToDirectedEdges -c 85283473fffffff" "[\"115283473fffffff\", \"125283473fffffff\", \"135283473fffffff\", \"145283473fffffff\", \"155283473fffffff\", \"165283473fffffff\"]")
add_h3_cli_test(testCliNotOriginToDirectedEdges "originToDirectedEdges -c 115283473fffffff 2>&1" "Error 5: Cell argument was not valid")
Loading
Loading