diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2018-05-06 17:43:26 +0300 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2018-05-08 09:16:07 +0200 |
| commit | 58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e (patch) | |
| tree | dec50c945b01d09c5cf94d0665a6996e2d34ae5d /src/pj_apply_vgridshift.c | |
| parent | 8fef2126f1c9fa17b79e6669f4457c299c0e33bf (diff) | |
| download | PROJ-58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e.tar.gz PROJ-58cbb9fe4f89b9febd780f7bdcfa4c2bb74a723e.zip | |
Replace int typecasts with calls to lround to avoid bad conversions on NaN input. Added test to check for those cases.
Diffstat (limited to 'src/pj_apply_vgridshift.c')
| -rw-r--r-- | src/pj_apply_vgridshift.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pj_apply_vgridshift.c b/src/pj_apply_vgridshift.c index e7106b25..b5b35640 100644 --- a/src/pj_apply_vgridshift.c +++ b/src/pj_apply_vgridshift.c @@ -37,8 +37,8 @@ static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GR int itable = 0; double value = HUGE_VAL; double grid_x, grid_y; - int grid_ix, grid_iy; - int grid_ix2, grid_iy2; + long grid_ix, grid_iy; + long grid_ix2, grid_iy2; float *cvs; /* do not deal with NaN coordinates */ /* cppcheck-suppress duplicateExpression */ @@ -97,8 +97,8 @@ static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GR /* Interpolation a location within the grid */ grid_x = (input.lam - ct->ll.lam) / ct->del.lam; grid_y = (input.phi - ct->ll.phi) / ct->del.phi; - grid_ix = (int) floor(grid_x); - grid_iy = (int) floor(grid_y); + grid_ix = lround(floor(grid_x)); + grid_iy = lround(floor(grid_y)); grid_x -= grid_ix; grid_y -= grid_iy; |
