-
Notifications
You must be signed in to change notification settings - Fork 477
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 error returns to gridPath/gridDistance functions #507
Add error returns to gridPath/gridDistance functions #507
Conversation
@@ -141,11 +141,11 @@ int h3ToLocalIjk(H3Index origin, H3Index h3, CoordIJK *out) { | |||
if (originBaseCell < 0 || // LCOV_EXCL_BR_LINE | |||
originBaseCell >= NUM_BASE_CELLS) { | |||
// Base cells less than zero can not be represented in an index | |||
return 1; | |||
return E_CELL_INVALID; |
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 seeing any tests for this specific error, could we add?
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.
Changed/added tests for specific error codes
int res = H3_GET_RESOLUTION(origin); | ||
int originBaseCell = H3_GET_BASE_CELL(origin); | ||
if (originBaseCell < 0 || // LCOV_EXCL_BR_LINE | ||
originBaseCell >= NUM_BASE_CELLS) { | ||
// Base cells less than zero can not be represented in an index | ||
return 1; | ||
return E_CELL_INVALID; |
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, not seeing specific tests for this
@@ -457,12 +457,12 @@ int localIjkToH3(H3Index origin, const CoordIJK *ijk, H3Index *out) { | |||
// accounted for here - instead just fail if the recovered index is | |||
// invalid. | |||
if (_h3LeadingNonZeroDigit(*out) == K_AXES_DIGIT) { | |||
return 4; | |||
return E_PENTAGON; |
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.
Curious why this and the errors above had different codes previously, but now both get E_PENTAGON
?
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.
These codes were arbitrary and just indicated different return sites - they didn't really have any smenatic meaning. In h3-java, 3
, 4
, and 5
were all translated to the same message (essentially E_PENTAGON)
00749d8
to
a502769
Compare
Adds consistent error returns to the gridPathCells, gridDistance, and localIj series of functions. These functions mostly already had error codes but they were not consistent with
H3Error
.Changes to traversal.mdx might need to be rebased with #505.
I'm moving functions to pass int64_t when it refers to a number of cells to be consistent with
getNumCells
. Would it make sense to introduce a typedef (H3NumCells
?H3NumIndexes
?) to avoid confusion about which type to use? Or just standardize on int64_t and let ourselves get used to that?