Skip to content
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

Merged
merged 7 commits into from
May 17, 2019

Conversation

isaacbrodsky
Copy link
Collaborator

Continues from #224 to rewrite argument parsing for these three filter applications.

@coveralls
Copy link

coveralls commented May 1, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 7f3de95 on isaacbrodsky:args-h3-to-geo into a6cd31b on uber:master.

@@ -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,
Copy link
Collaborator

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?

Copy link
Collaborator Author

@isaacbrodsky isaacbrodsky May 2, 2019

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.

.valueName = "res",
.value = &res,
.helpText = "Resolution, 0-15 inclusive."};
Arg latArg = {.names = {"-lat", "--latitude"},
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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).

Copy link
Collaborator

@nrabinowitz nrabinowitz left a 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.

error("parsing lat/lon");

// convert to H3
GeoCoord g;
Copy link
Collaborator

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 Show resolved Hide resolved
.scanFormat = "%255c", // BUFF_SIZE - 1
.valueName = "name",
.value = &userKmlName,
.helpText = "Name of the KML file."};
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

*
* 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" <
Copy link
Collaborator

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/h3ToGeo.c Outdated Show resolved Hide resolved
*
* 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"
Copy link
Collaborator

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/h3ToGeoBoundary.c Outdated Show resolved Hide resolved
src/apps/filters/h3ToGeoBoundary.c Outdated Show resolved Hide resolved
Arg kArg = {.names = {"-k", NULL},
.required = true,
.scanFormat = "%d",
.valueName = "k",
.value = &k,
.helpText = "Radius of hexagons"};
.helpText = "Radius of hexagons."};
Copy link
Collaborator

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"

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

src/apps/filters/kRing.c Outdated Show resolved Hide resolved
@nrabinowitz nrabinowitz changed the title Argument parsing for h3ToGeo, h3ToGeoBoundayr, geoToH3 Argument parsing for h3ToGeo, h3ToGeoBoundary, geoToH3 May 4, 2019
"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"},
Copy link
Collaborator

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.

@isaacbrodsky isaacbrodsky merged commit fc8c80a into uber:master May 17, 2019
@isaacbrodsky isaacbrodsky deleted the args-h3-to-geo branch May 17, 2019 17:37
mrdvt92 pushed a commit to mrdvt92/h3 that referenced this pull request Jun 19, 2022
Argument parsing for h3ToGeo, h3ToGeoBoundary, geoToH3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants