in src/apps/testapps/mkRandGeoBoundary.c [31:77]
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/lon 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++) {
GeoCoord g;
randomGeo(&g);
H3Index h = H3_EXPORT(geoToH3)(&g, res);
GeoBoundary b;
H3_EXPORT(h3ToGeoBoundary)(h, &b);
h3Println(h);
geoBoundaryPrintln(&b);
}
}