diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2019-04-19 20:00:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-19 20:00:21 +0200 |
| commit | e1da8e5f6933bfb914dccb26a755a23b5ce9f36f (patch) | |
| tree | 3f0ed0985b9bdb8754cd835c499fa37af0e46fbe | |
| parent | fb88946ac55fafd25a021e26c151b492efe5fd4c (diff) | |
| parent | 3ff04e06a2ba9d40ead861be0ebdb22af45eaa0d (diff) | |
| download | PROJ-e1da8e5f6933bfb914dccb26a755a23b5ce9f36f.tar.gz PROJ-e1da8e5f6933bfb914dccb26a755a23b5ce9f36f.zip | |
Merge pull request #1432 from rouault/ossfuzz_14348
Inverse cart: better deal with x,y,z equal of very close to zero
| -rw-r--r-- | src/conversions/cart.cpp | 6 | ||||
| -rw-r--r-- | test/gie/more_builtins.gie | 59 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/conversions/cart.cpp b/src/conversions/cart.cpp index e6942d65..c1f6f09d 100644 --- a/src/conversions/cart.cpp +++ b/src/conversions/cart.cpp @@ -162,6 +162,12 @@ static PJ_LPZ geodetic (PJ_XYZ cart, PJ *P) { c = cos(theta); s = sin(theta); lpz.phi = atan2 (cart.z + P->e2s*P->b*s*s*s, p - P->es*P->a*c*c*c); + if( fabs(lpz.phi) > M_HALFPI ) { + // this happen on non-sphere ellipsoid when x,y,z is very close to 0 + // there is no single solution to the cart->geodetic conversion in + // that case, so arbitrarily pickup phi = 0. + lpz.phi = 0; + } lpz.lam = atan2 (cart.y, cart.x); N = normal_radius_of_curvature (P->a, P->es, lpz.phi); diff --git a/test/gie/more_builtins.gie b/test/gie/more_builtins.gie index ba146b06..75ba55e9 100644 --- a/test/gie/more_builtins.gie +++ b/test/gie/more_builtins.gie @@ -794,5 +794,64 @@ expect 25 25 25 25 operation +proj=aeqd +R=1 +lat_0=91 expect failure errno lat_larger_than_90 +------------------------------------------------------------------------------- +# cart +------------------------------------------------------------------------------- + +operation +proj=cart +ellps=GRS80 +tolerance 0.001mm + +accept 0 0 0 +expect 6378137 0 0 + +accept 0 90 0 +expect 0 0 6356752.314140347 + +accept 0 -90 0 +expect 0 0 -6356752.314140347 + +accept 90 0 0 +expect 0 6378137 0 + +accept -90 0 0 +expect 0 -6378137 0 + +accept 180 0 0 +expect -6378137 0 0 + +accept -180 0 0 +expect -6378137 0 0 + +# Center of Earth ! +accept 0 0 -6378137 +expect 0 0 0 + +accept 0 90 -6356752.314140347 +expect 0 0 0 + +direction inverse + +accept 6378137 0 0 +expect 0 0 0 + +accept 0 0 6356752.314140347 +expect 0 90 0 + +accept 0 0 -6356752.314140347 +expect 0 -90 0 + +accept 0 6378137 0 +expect 90 0 0 + +accept 0 -6378137 0 +expect -90 0 0 + +accept -6378137 0 0 +expect 180 0 0 + +# Center of Earth ! +accept 0 0 0 +expect 0 0 -6378137 + </gie> |
