in src/apps/testapps/mkRandGeo.c [32: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 lat/lon pairs and indexes them 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);
h3Print(h);
printf(" ");
geoPrintlnNoFmt(&g);
}
}