in src/apps/filters/hexRange.c [54:98]
int main(int argc, char* argv[]) {
int k = 0;
H3Index origin = 0;
Arg helpArg = ARG_HELP;
Arg kArg = {.names = {"-k", NULL},
.required = true,
.scanFormat = "%d",
.valueName = "k",
.value = &k,
.helpText = "Radius in hexagons."};
Arg originArg = {
.names = {"-o", "--origin"},
.scanFormat = "%" PRIx64,
.valueName = "origin",
.value = &origin,
.helpText =
"Origin, or not specified to read origins from standard input."};
const int numArgs = 3;
Arg* args[] = {&helpArg, &kArg, &originArg};
if (parseArgs(argc, argv, numArgs, args, &helpArg,
"Print indexes k distance away from the origin")) {
return helpArg.found ? 0 : 1;
}
if (originArg.found) {
doCell(origin, k);
} else {
// process the indexes on stdin
char buff[BUFF_SIZE];
while (1) {
// get an index from stdin
if (!fgets(buff, BUFF_SIZE, stdin)) {
if (feof(stdin))
break;
else
error("reading H3 index from stdin");
}
H3Index h3 = H3_EXPORT(stringToH3)(buff);
doCell(h3, k);
}
}
}