Skip to content

Commit

Permalink
Merge pull request #271 from saprykin/master
Browse files Browse the repository at this point in the history
Fix validity check for IJK+ coordinates
  • Loading branch information
Nick Rabinowitz authored Aug 12, 2019
2 parents 5a8522c + 607640e commit b6210f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/apps/testapps/testH3ToLocalIj.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,17 @@ SUITE(h3ToLocalIj) {
ij.i = 2;
t_assert(
H3_EXPORT(experimentalLocalIjToH3)(origin, &ij, &retrieved) != 0,
"out of range base cell");
"out of range base cell (1)");
ij.i = 0;
ij.j = 2;
t_assert(
H3_EXPORT(experimentalLocalIjToH3)(origin, &ij, &retrieved) != 0,
"out of range base cell (2)");
ij.i = -2;
ij.j = -2;
t_assert(
H3_EXPORT(experimentalLocalIjToH3)(origin, &ij, &retrieved) != 0,
"out of range base cell (3)");
}

TEST(ijOutOfRange) {
Expand Down
2 changes: 1 addition & 1 deletion src/h3lib/lib/localij.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ int localIjkToH3(H3Index origin, const CoordIJK* ijk, H3Index* out) {

// check for res 0/base cell
if (res == 0) {
if (ijk->i > 1 || ijk->i > 1 || ijk->i > 1) {
if (ijk->i > 1 || ijk->j > 1 || ijk->k > 1) {
// out of range input
return 1;
}
Expand Down

0 comments on commit b6210f7

Please sign in to comment.