diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-01-22 14:09:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-22 14:09:14 +0100 |
| commit | c5fb54168665d41503ef3a08f0534da58949b632 (patch) | |
| tree | 19e2adc8809290881a6a13ec6001013d03170c7d /src/grids.cpp | |
| parent | a6390b59ae2bad2a763e7ab3341ee4c80e708b3d (diff) | |
| parent | 66fd99a8831955034cb25c8468ecfe1f9d3a7d62 (diff) | |
| download | PROJ-c5fb54168665d41503ef3a08f0534da58949b632.tar.gz PROJ-c5fb54168665d41503ef3a08f0534da58949b632.zip | |
Merge pull request #1839 from rouault/rfc4_utf8
[RFC4_dev] Use Win32 Unicode APIs and expect all strings to be UTF-8 (fixes #1765)
Diffstat (limited to 'src/grids.cpp')
| -rw-r--r-- | src/grids.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/grids.cpp b/src/grids.cpp index 3007fedc..d5f961f7 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -112,9 +112,7 @@ VerticalShiftGrid::VerticalShiftGrid(const std::string &nameIn, int widthIn, // --------------------------------------------------------------------------- -bool VerticalShiftGrid::isNodata(float /*val*/, double /* multiplier */) const { - return false; -} +VerticalShiftGrid::~VerticalShiftGrid() = default; // --------------------------------------------------------------------------- @@ -2360,12 +2358,14 @@ bool HorizontalShiftGridSet::reopen(PJ_CONTEXT *ctx) { // --------------------------------------------------------------------------- +#define REL_TOLERANCE_HGRIDSHIFT 1e-5 + const HorizontalShiftGrid *HorizontalShiftGrid::gridAt(double lon, double lat) const { for (const auto &child : m_children) { const auto &extentChild = child->extentAndRes(); - const double epsilon = - (extentChild.resLon + extentChild.resLat) / 10000.0; + const double epsilon = (extentChild.resLon + extentChild.resLat) * + REL_TOLERANCE_HGRIDSHIFT; if ((extentChild.fullWorldLongitude() || (lon + epsilon >= extentChild.westLon && lon - epsilon <= extentChild.eastLon)) && @@ -2385,7 +2385,8 @@ const HorizontalShiftGrid *HorizontalShiftGridSet::gridAt(double lon, return grid.get(); } const auto &extent = grid->extentAndRes(); - const double epsilon = (extent.resLon + extent.resLat) / 10000.0; + const double epsilon = + (extent.resLon + extent.resLat) * REL_TOLERANCE_HGRIDSHIFT; if ((extent.fullWorldLongitude() || (lon + epsilon >= extent.westLon && lon - epsilon <= extent.eastLon)) && @@ -2857,26 +2858,26 @@ static PJ_LP pj_hgrid_interpolate(PJ_LP t, const HorizontalShiftGrid *grid, frct.phi = t.phi - indx.phi; val.lam = val.phi = HUGE_VAL; if (indx.lam < 0) { - if (indx.lam == -1 && frct.lam > 0.99999999999) { + if (indx.lam == -1 && frct.lam > 1 - 10 * REL_TOLERANCE_HGRIDSHIFT) { ++indx.lam; frct.lam = 0.; } else return val; } else if ((in = indx.lam + 1) >= grid->width()) { - if (in == grid->width() && frct.lam < 1e-11) { + if (in == grid->width() && frct.lam < 10 * REL_TOLERANCE_HGRIDSHIFT) { --indx.lam; frct.lam = 1.; } else return val; } if (indx.phi < 0) { - if (indx.phi == -1 && frct.phi > 0.99999999999) { + if (indx.phi == -1 && frct.phi > 1 - 10 * REL_TOLERANCE_HGRIDSHIFT) { ++indx.phi; frct.phi = 0.; } else return val; } else if ((in = indx.phi + 1) >= grid->height()) { - if (in == grid->height() && frct.phi < 1e-11) { + if (in == grid->height() && frct.phi < 10 * REL_TOLERANCE_HGRIDSHIFT) { --indx.phi; frct.phi = 1.; } else @@ -2937,8 +2938,6 @@ static PJ_LP pj_hgrid_apply_internal(projCtx ctx, PJ_LP in, tb.lam -= extent->westLon; tb.phi -= extent->southLat; - tb.lam = adjlon(tb.lam - M_PI) + M_PI; - t = pj_hgrid_interpolate(tb, grid, true); if (grid->hasChanged()) { shouldRetry = gridset->reopen(ctx); @@ -2981,7 +2980,6 @@ static PJ_LP pj_hgrid_apply_internal(projCtx ctx, PJ_LP in, tb = in; tb.lam -= extent->westLon; tb.phi -= extent->southLat; - tb.lam = adjlon(tb.lam - M_PI) + M_PI; dif.lam = std::numeric_limits<double>::max(); dif.phi = std::numeric_limits<double>::max(); continue; |
