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

Add error returns to gridPath/gridDistance functions #507

Merged
merged 8 commits into from
Sep 3, 2021

Conversation

isaacbrodsky
Copy link
Collaborator

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?

@coveralls
Copy link

coveralls commented Aug 24, 2021

Coverage Status

Coverage increased (+0.03%) to 98.685% when pulling 0c60d59 on isaacbrodsky:error-returns-grid-path into 2801fca on uber:master.

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

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?

Copy link
Collaborator Author

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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?

Copy link
Collaborator Author

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)

@isaacbrodsky isaacbrodsky force-pushed the error-returns-grid-path branch from 00749d8 to a502769 Compare September 3, 2021 01:54
@isaacbrodsky isaacbrodsky merged commit 0302b93 into uber:master Sep 3, 2021
@isaacbrodsky isaacbrodsky deleted the error-returns-grid-path branch September 3, 2021 02:23
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