in src/apps/testapps/mkRandGeoBoundary.c [31:79]
int main(int argc, char *argv[]) {
int res = 0;
int numPoints = 0;
Arg helpArg = ARG_HELP;
Arg numPointsArg = {
.names = {"-n", "--num-points"},
.required = true,
.scanFormat = "%d",
.valueName = "num",
.value = &numPoints,
.helpText = "Number of random lat/lng pairs to generate."};
Arg resArg = {.names = {"-r", "--resolution"},
.required = true,
.scanFormat = "%d",
.valueName = "res",
.value = &res,
.helpText = "Resolution, 0-15 inclusive."};
Arg *args[] = {&helpArg, &numPointsArg, &resArg};
const int numArgs = 3;
const char *helpText =
"Generates random cell indexes and cell boundaries at the specified "
"resolution.";
if (parseArgs(argc, argv, numArgs, args, &helpArg, helpText)) {
return helpArg.found ? 0 : 1;
}
if (res > MAX_H3_RES) {
printHelp(stderr, argv[0], helpText, numArgs, args,
"Resolution exceeds maximum resolution.", NULL);
return 1;
}
for (int i = 0; i < numPoints; i++) {
LatLng g;
randomGeo(&g);
H3Index h;
if (!H3_EXPORT(latLngToCell)(&g, res, &h)) {
CellBoundary b;
H3_EXPORT(cellToBoundary)(h, &b);
h3Println(h);
cellBoundaryPrintln(&b);
}
}
}