Skip to content
Open
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The public API of this library consists of the functions declared in file
[h3api.h.in](./src/h3lib/include/h3api.h.in).

## [Unreleased]
### Added
- Added `edgeToVertexes` to H3 CLI. (#1324)

## [4.6.0] - 2026-11-18
### Added
Expand Down
23 changes: 23 additions & 0 deletions src/apps/filters/h3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2412,6 +2412,28 @@ SUBCOMMAND(cellToVertexes,
return E_SUCCESS;
}

SUBCOMMAND(edgeToVertexes,
"Returns the start, end pair of vertexes from the directed edge") {
DEFINE_FORMAT_ARG(
"'json' for [\"CELL\", ...], 'newline' for CELL\\n... (Default: json)");
DEFINE_CELL_ARG(cell, cellArg);
Arg *args[] = {&edgeToVertexesArg, &cellArg, &helpArg, &formatArg};
PARSE_SUBCOMMAND(argc, argv, args);
H3Index out[2] = {0};
H3Error err = H3_EXPORT(edgeToVertexes)(cell, &out[0], &out[1]);
if (err != E_SUCCESS) {
return err;
}
if (strcmp(format, "json") == 0 || strcmp(format, "") == 0) {
printf("[\"%" PRIx64 "\", \"%" PRIx64 "\"]\n", out[0], out[1]);
} else if (strcmp(format, "newline") == 0) {
printf("%" PRIx64 "\n%" PRIx64 "\n", out[0], out[1]);
} else {
return E_FAILED;
}
return E_SUCCESS;
}

SUBCOMMAND(vertexToLatLng, "Returns the lat, lng pair for the given vertex") {
DEFINE_FORMAT_ARG(
"'json' for [lat, lng], 'wkt' for a WKT POINT, 'newline' for "
Expand Down Expand Up @@ -3107,6 +3129,7 @@ SUBCOMMAND_INDEX(directedEdgeToBoundary)
/// Vertex subcommands
SUBCOMMAND_INDEX(cellToVertex)
SUBCOMMAND_INDEX(cellToVertexes)
SUBCOMMAND_INDEX(edgeToVertexes)
SUBCOMMAND_INDEX(vertexToLatLng)
SUBCOMMAND_INDEX(isValidVertex)

Expand Down
10 changes: 10 additions & 0 deletions tests/cli/edgeToVertexes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_h3_cli_test(
testCliEdgeToVertexes "edgeToVertexes -c 115283473fffffff"
"[\"255283463fffffff\", \"22528340ffffffff\"]")
add_h3_cli_test(
testCliEdgeToVertexesNewline
"edgeToVertexes -c 115283473fffffff -f newline | tr -s '\\\\r\\\\n' ',' | tr -s '\\\\n' ','"
"255283463fffffff,22528340ffffffff,")
add_h3_cli_test(
testCliNotEdgeToVertexes "edgeToVertexes -c 85283473fffffff 2>&1"
"Error 6: Directed edge argument was not valid")
Loading