-
Notifications
You must be signed in to change notification settings - Fork 486
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
Add H3Error for core indexing functions #436
Conversation
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.
Nonblocking comments. Can always come up in a followup PR.
src/apps/filters/geoToH3.c
Outdated
if (e == E_SUCCESS) { | ||
h3Println(h); | ||
} else { | ||
h3Println(H3_NULL); |
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.
Ideally it would print some nice data about which error it ran into to stderr
instead. :)
typedef enum { | ||
E_SUCCESS = 0, // Success (no error) | ||
E_FAILED = | ||
1, // The operation failed but a more specific error is not available | ||
E_DOMAIN = 2, // Argument was outside of acceptable range (when a more | ||
// specific error code is not available) | ||
E_LATLON_DOMAIN = | ||
3, // Latitude or longitude arguments were outside of acceptable range | ||
E_RES_DOMAIN = 4, // Resolution argument was outside of acceptable range | ||
E_CELL_INVALID = 5, // `H3Index` cell argument was not valid | ||
E_DIR_EDGE_INVALID = 6, // `H3Index` directed edge argument was not valid | ||
E_UNDIR_EDGE_INVALID = | ||
7, // `H3Index` undirected edge argument was not valid | ||
E_VERTEX_INVALID = 8, // `H3Index` vertex argument was not valid | ||
E_PENTAGON = 9, // Pentagon distortion was encountered which the algorithm | ||
// could not handle it | ||
E_DUPLICATE_INPUT = 10, // Duplicate input was encountered in the arguments | ||
// and the algorithm could not handle it | ||
E_NOT_NEIGHBORS = 11, // `H3Index` cell arguments were not neighbors | ||
E_RES_MISMATCH = | ||
12, // `H3Index` cell arguments had incompatible resolutions | ||
E_MEMORY = 13 // Necessary memory allocation failed | ||
} H3ErrorCodes; |
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.
Would be really nice if these comments were available in an exported array of strings (and/or a function to convert error code to error string). Could be used by the bindings as well as the filter apps.
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.
Agree, we duplicate a lot of this in JS
docs/api/indexing.md
Outdated
``` | ||
|
||
Finds the centroid of the index. | ||
|
||
## h3ToGeoBoundary | ||
|
||
``` | ||
void h3ToGeoBoundary(H3Index h3, GeoBoundary *gp); | ||
H3Error h3ToGeoBoundary(H3Index h3, GeoBoundary *gp); |
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: This should be gb
?
src/apps/testapps/mkRandGeo.c
Outdated
printf(" "); | ||
geoPrintlnNoFmt(&g); | ||
H3Index h; | ||
if (!H3_EXPORT(geoToH3)(&g, res, &h)) { |
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.
Should we use != E_SUCCESS
in this and similar cases?
typedef enum { | ||
E_SUCCESS = 0, // Success (no error) | ||
E_FAILED = | ||
1, // The operation failed but a more specific error is not available | ||
E_DOMAIN = 2, // Argument was outside of acceptable range (when a more | ||
// specific error code is not available) | ||
E_LATLON_DOMAIN = | ||
3, // Latitude or longitude arguments were outside of acceptable range | ||
E_RES_DOMAIN = 4, // Resolution argument was outside of acceptable range | ||
E_CELL_INVALID = 5, // `H3Index` cell argument was not valid | ||
E_DIR_EDGE_INVALID = 6, // `H3Index` directed edge argument was not valid | ||
E_UNDIR_EDGE_INVALID = | ||
7, // `H3Index` undirected edge argument was not valid | ||
E_VERTEX_INVALID = 8, // `H3Index` vertex argument was not valid | ||
E_PENTAGON = 9, // Pentagon distortion was encountered which the algorithm | ||
// could not handle it | ||
E_DUPLICATE_INPUT = 10, // Duplicate input was encountered in the arguments | ||
// and the algorithm could not handle it | ||
E_NOT_NEIGHBORS = 11, // `H3Index` cell arguments were not neighbors | ||
E_RES_MISMATCH = | ||
12, // `H3Index` cell arguments had incompatible resolutions | ||
E_MEMORY = 13 // Necessary memory allocation failed | ||
} H3ErrorCodes; |
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.
Agree, we duplicate a lot of this in JS
2c87037
to
70d4b6a
Compare
src/apps/testapps/testDirectedEdge.c
Outdated
SUITE(h3UniEdge) { | ||
TEST(h3IndexesAreNeighbors) { |
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.
Revert these names?
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.
Just one accidental revert when you rebased that needs to be cleaned up, as far as I can see.
I updated this PR based on master, note that I removed the website changes until we're ready to make a v4 website |
First implementation of the error code RFC work for v4. In this PR the error codes are applied to only
geoToH3
,h3ToGeo
, andh3ToGeoBoundary
in order to get feedback on these core functions first.H3Error is not made an enum type since from what I could determine setting the base type of the enum is a C++ feature. (Although when I test using Apple Clang it permits it even with
-std=c89
?)