-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All remaining subcommands for the h3 cli program #924
Conversation
Oh, this currently includes the region subcommands in this PR, since it depends on that one, but once it gets approved and merged, this'll be reduced to only the new commands. I did (almost) every command in a separate commit, for easier reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, pending #923 merging in
cd00c06
to
de30ae0
Compare
Co-authored-by: Isaac Brodsky <[email protected]>
Co-authored-by: Isaac Brodsky <[email protected]>
d5b44ad
to
d63accf
Compare
SUBCOMMAND(pentagonCount, "Returns 12") { | ||
Arg *args[] = {&pentagonCountArg, &helpArg}; | ||
PARSE_SUBCOMMAND(argc, argv, args); | ||
printf("12\n"); | ||
return E_SUCCESS; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we really need to bind this, but ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find it hilarious, so I want it in. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions and nits, but otherwise looks great!
Arg *args[] = {&isValidDirectedEdgeArg, &helpArg, &cellArg}; | ||
PARSE_SUBCOMMAND(argc, argv, args); | ||
bool isValid = H3_EXPORT(isValidDirectedEdge)(cell); | ||
printf("%s", isValid ? "true\n" : "false\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinion here, but would 1
and 0
be more flexible outputs?
return err; | ||
} | ||
// Using WKT formatting for the output. TODO: Add support for JSON | ||
// formatting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it weird that we use WKT
here but raw lat,lng
polygons for cellsToMultiPolygon
?
if (err) { | ||
return err; | ||
} | ||
printf("%" PRIx64 "\n", out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Should we use h3Println
here?
.helpText = "Angle in radians"}; | ||
Arg *args[] = {&radsToDegsArg, &radArg, &helpArg}; | ||
PARSE_SUBCOMMAND(argc, argv, args); | ||
printf("%.10lf\n", H3_EXPORT(radsToDegs)(rad)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Worth making a common printDouble
function to help us always print with the same format?
hasPrinted = true; | ||
} | ||
} | ||
printf("]\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For polygonToCells
we print newline-delimited cells, but most of the multi-cell outputs here use JSON arrays. Should this be consistent?
"to use greatCircleDistanceKm"); | ||
exit(1); | ||
} | ||
FILE *fp = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It feels like we could share a lot of code between greatCircleDistanceKm
and greatCircleDistanceRads
and greatCircleDistanceM
Discussed offline, some of the inconsistencies will be taken care of in a follow-up PR. |
After implementing the region subcommands, all of the rest documented on h3geo.org were "trivial" as all patterns of subcommand had been implemented, so I just slogged through writing all of them while I had the drive to do it. ;)
There may be some test failures with
degsToRads
and friends due to floating point rounding errors on different CPU architectures. I hope not, but if so, then I'll have to figure out how to test them better.