| 821 | |
| 822 | template <class Grid, class GridSet, class EvaluatorIface> |
| 823 | bool Evaluator<Grid, GridSet, EvaluatorIface>::forward( |
| 824 | EvaluatorIface &iface, double x, double y, double z, double t, |
| 825 | bool forInverseComputation, double &x_out, double &y_out, double &z_out) |
| 826 | |
| 827 | { |
| 828 | x_out = x; |
| 829 | y_out = y; |
| 830 | z_out = z; |
| 831 | |
| 832 | const double EPS = mIsGeographicCRS ? 1e-10 : 1e-5; |
| 833 | |
| 834 | // Check against global model spatial extent, potentially wrapping |
| 835 | // longitude to match |
| 836 | { |
| 837 | const auto &extent = mModel->extent(); |
| 838 | const double minx = extent.minxNormalized(mIsGeographicCRS); |
| 839 | const double maxx = extent.maxxNormalized(mIsGeographicCRS); |
| 840 | if (mIsGeographicCRS) { |
| 841 | while (x < minx - EPS) { |
| 842 | x += 2.0 * DEFMODEL_PI; |
| 843 | } |
| 844 | while (x > maxx + EPS) { |
| 845 | x -= 2.0 * DEFMODEL_PI; |
| 846 | } |
| 847 | } |
| 848 | const double miny = extent.minyNormalized(mIsGeographicCRS); |
| 849 | const double maxy = extent.maxyNormalized(mIsGeographicCRS); |
| 850 | const double extraMarginForInverse = |
| 851 | mIsGeographicCRS ? DegToRad(0.1) : 10000; |
| 852 | if (!bboxCheck(x, y, forInverseComputation, minx, miny, maxx, maxy, EPS, |
| 853 | extraMarginForInverse)) { |
| 854 | #ifdef DEBUG_DEFMODEL |
| 855 | iface.log("Calculation point " + toString(x) + "," + toString(y) + |
| 856 | " is outside the extents of the deformation model"); |
| 857 | #endif |
| 858 | return false; |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | // Check against global model temporal extent |
| 863 | { |
| 864 | const auto &timeExtent = mModel->timeExtent(); |
| 865 | if (t < timeExtent.first.toDecimalYear() || |
| 866 | t > timeExtent.last.toDecimalYear()) { |
| 867 | #ifdef DEBUG_DEFMODEL |
| 868 | iface.log("Calculation epoch " + toString(t) + |
| 869 | " is not valid for the deformation model"); |
| 870 | #endif |
| 871 | return false; |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | // For mIsHorizontalUnitDegree |
| 876 | double dlam = 0; |
| 877 | double dphi = 0; |
| 878 | |
| 879 | // For !mIsHorizontalUnitDegree |
| 880 | double de = 0; |
no test coverage detected