int main()

in src/apps/testapps/mkRandGeo.c [32:78]


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 lat/lng 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++) {
        LatLng g;
        randomGeo(&g);

        H3Index h;
        if (!H3_EXPORT(latLngToCell)(&g, res, &h)) {
            h3Print(h);
            printf(" ");
            geoPrintlnNoFmt(&g);
        }
    }
}