-
Notifications
You must be signed in to change notification settings - Fork 470
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
Argument parsing for h3ToGeo, h3ToGeoBoundary, geoToH3 #227
Conversation
@@ -68,12 +68,12 @@ int parseArgs(int argc, char* argv[], int numArgs, Arg* args[], | |||
const char* errorMessage = NULL; | |||
const char* errorDetails = NULL; | |||
|
|||
int failed = _parseArgsList(argc, argv, 4, args, helpArg, &errorMessage, |
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 was a bug from the last diff?
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.
Yes, this was a copy paste error when refactoring the code. I found it from a segfault when testing another filter with only three arguments.
src/apps/filters/geoToH3.c
Outdated
.valueName = "res", | ||
.value = &res, | ||
.helpText = "Resolution, 0-15 inclusive."}; | ||
Arg latArg = {.names = {"-lat", "--latitude"}, |
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: I'd have thought --lat
and --lon
would be the short forms - I've generally seen single-dash only for single-char args (partly so that if we wanted we could stack like -xvf
).
One one-char option would be to use -y
for lat and -x
for long.
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.
Do you have a preference between adding --lat
/--lon
or -y
/-x
? I am leaning towards --lat
/--lon
since it does not have the ambiguity about which comes first.
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.
To me -y / -x sounds like either planar coordinates or two components of 3D ECEF coordinates. Both might be potential arguments to some future program (especially given that H3 can now output planar IJK grids).
7531329
to
1c5cb75
Compare
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.
LG overall, most comments on clearing up the --kml-name
params.
src/apps/filters/geoToH3.c
Outdated
error("parsing lat/lon"); | ||
|
||
// convert to H3 | ||
GeoCoord g; |
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 moving these 4 lines into a separate function to DRY out the two branches?
src/apps/filters/h3ToGeo.c
Outdated
.scanFormat = "%255c", // BUFF_SIZE - 1 | ||
.valueName = "name", | ||
.value = &userKmlName, | ||
.helpText = "Name of the KML file."}; |
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 isn't correct, right? Isn't this name used inside a tag in KML, rather than the file name?
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 had some difficulty with this because the tag is named "name" rather than "title", which I felt would be clearly not the name of the file. I think rewriting it to mention the tag and not refer to a "file" is a good idea.
src/apps/filters/h3ToGeo.c
Outdated
* | ||
* Examples: | ||
* | ||
* `h3ToGeo < indexes.txt` | ||
* - outputs plain text cell center points for the H3 indexes contained | ||
* in the file `indexes.txt` | ||
* | ||
* `h3ToGeo 1 "kml file" "h3 cells" < indexes.txt > cells.kml` | ||
* `h3ToGeo --kml --kml-name "kml file" --kml-description "h3 cells" < |
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.
As below, should this read "kml file"
or "My KML Title"
src/apps/filters/h3ToGeoBoundary.c
Outdated
* | ||
* Examples: | ||
* | ||
* `h3ToGeoBoundary < indexes.txt` | ||
* - outputs plain text cell boundaries for the H3 indexes contained | ||
* in the file `indexes.txt` | ||
* | ||
* `h3ToGeoBoundary 1 "kml file" "h3 cells" < indexes.txt > cells.kml` | ||
* `h3ToGeoBoundary --kml --kml-name "kml file" --kml-description "h3 cells" |
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.
Ditto on "kml file"
src/apps/filters/kRing.c
Outdated
Arg kArg = {.names = {"-k", NULL}, | ||
.required = true, | ||
.scanFormat = "%d", | ||
.valueName = "k", | ||
.value = &k, | ||
.helpText = "Radius of hexagons"}; | ||
.helpText = "Radius of hexagons."}; |
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: Might be clearer as "Radius of ring in hexagons"
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'm not sure I understand that since this would produce the neighborhood around the index (cf #42) rather than a hollow ring.
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.
Per offline: Radius in hexagons.
"Index, or not specified to read indexes from standard in."}; | ||
Arg kmlArg = {.names = {"-k", "--kml"}, | ||
.helpText = "Print output in KML format."}; | ||
Arg kmlNameArg = {.names = {"--kn", "--kml-name"}, |
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.
Here I might have gone for -n
and -d
, but that's just bikeshedding.
Argument parsing for h3ToGeo, h3ToGeoBoundary, geoToH3
Continues from #224 to rewrite argument parsing for these three filter applications.