Skip to content

Commit

Permalink
Check latitude and longitude validity in h3_geo_to_h3 function
Browse files Browse the repository at this point in the history
  • Loading branch information
trylinka committed Aug 14, 2020
1 parent 423f8f0 commit cbae81e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/indexing.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ h3_geo_to_h3(PG_FUNCTION_ARGS)
H3Index idx;
GeoCoord location;

ASSERT_EXTERNAL(geo->x >= -180 && geo->x <= 180, "Longitude must be between -180 and 180 degrees inclusive, but got %f.", geo->x);
ASSERT_EXTERNAL(geo->y >= -90 && geo->y <= 90, "Latitude must be between -90 and 90 degrees inclusive, but got %f.", geo->y);

location.lon = degsToRads(geo->x);
location.lat = degsToRads(geo->y);

Expand Down

0 comments on commit cbae81e

Please sign in to comment.