Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions src/generic_inverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,23 @@ PJ_LP pj_generic_inverse_2d(PJ_XY xy, PJ *P, PJ_LP lpInitial,
}
}

if (xy.x != 0) {
// Limit the amplitude of correction to avoid overshoots due to
// bad initial guess
const double delta_lam = std::max(
std::min(deltaX * deriv_lam_X + deltaY * deriv_lam_Y, 0.3),
-0.3);
lp.lam -= delta_lam;
if (lp.lam < -M_PI)
lp.lam = -M_PI;
else if (lp.lam > M_PI)
lp.lam = M_PI;
}
// Limit the amplitude of correction to avoid overshoots due to
// bad initial guess
const double delta_lam = std::max(
std::min(deltaX * deriv_lam_X + deltaY * deriv_lam_Y, 0.3), -0.3);
lp.lam -= delta_lam;
if (lp.lam < -M_PI)
lp.lam = -M_PI;
else if (lp.lam > M_PI)
lp.lam = M_PI;

if (xy.y != 0) {
const double delta_phi = std::max(
std::min(deltaX * deriv_phi_X + deltaY * deriv_phi_Y, 0.3),
-0.3);
lp.phi -= delta_phi;
if (lp.phi < -M_HALFPI)
lp.phi = -M_HALFPI;
else if (lp.phi > M_HALFPI)
lp.phi = M_HALFPI;
}
const double delta_phi = std::max(
std::min(deltaX * deriv_phi_X + deltaY * deriv_phi_Y, 0.3), -0.3);
lp.phi -= delta_phi;
if (lp.phi < -M_HALFPI)
lp.phi = -M_HALFPI;
else if (lp.phi > M_HALFPI)
lp.phi = M_HALFPI;
}
proj_context_errno_set(P->ctx,
PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN);
Expand Down
15 changes: 15 additions & 0 deletions test/gie/builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,21 @@ accept 179.99433652777776 -16.841456527777776
expect 16015.28901692 13369.66005367
roundtrip 1


-------------------------------------------------------------------------------
# Scenario of https://github.com/OSGeo/PROJ/issues/4385
-------------------------------------------------------------------------------
operation +proj=cass +lat_0=50.6177 +lon_0=-1.19725 +x_0=500000 +y_0=100000 +ellps=airy +units=m

tolerance 0.1 mm
direction inverse

accept 300000 100000
expect -4.022094267169 50.583438725252

accept 500000 100000
expect -1.19725 50.6177

===============================================================================
# Central Conic
# Sph
Expand Down
Loading