| 121 | // --------------------------------------------------------------------------- |
| 122 | |
| 123 | static PJ_COORD iterative_adjustment(PJ *P, xyzgridshiftData *Q, |
| 124 | const PJ_COORD &pointInit, double factor) { |
| 125 | PJ_COORD point = pointInit; |
| 126 | for (int i = 0; i < 10; i++) { |
| 127 | PJ_COORD geodetic; |
| 128 | geodetic.lpz = pj_inv3d(point.xyz, Q->cart); |
| 129 | |
| 130 | double dx, dy, dz; |
| 131 | if (!get_grid_values(P, Q, geodetic.lp, dx, dy, dz)) { |
| 132 | return proj_coord_error(); |
| 133 | } |
| 134 | |
| 135 | dx *= factor; |
| 136 | dy *= factor; |
| 137 | dz *= factor; |
| 138 | |
| 139 | const double err = SQUARE((point.xyz.x - pointInit.xyz.x) - dx) + |
| 140 | SQUARE((point.xyz.y - pointInit.xyz.y) - dy) + |
| 141 | SQUARE((point.xyz.z - pointInit.xyz.z) - dz); |
| 142 | |
| 143 | point.xyz.x = pointInit.xyz.x + dx; |
| 144 | point.xyz.y = pointInit.xyz.y + dy; |
| 145 | point.xyz.z = pointInit.xyz.z + dz; |
| 146 | if (err < 1e-10) { |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | return point; |
| 151 | } |
| 152 | |
| 153 | // --------------------------------------------------------------------------- |
| 154 |
no test coverage detected