diff options
| author | Andrew Bell <andrew.bell.ia@gmail.com> | 2019-05-15 10:47:03 -0400 |
|---|---|---|
| committer | Andrew Bell <andrew.bell.ia@gmail.com> | 2019-05-15 10:47:03 -0400 |
| commit | 8f268409d37cea329d263e177b83e42f8384d3c7 (patch) | |
| tree | c4d0f3dd19456600f718a6e0c8573577f433549b /src/conversions | |
| parent | 886ced02f0aaab5d66d16459435f7447cf976650 (diff) | |
| parent | d67203a6f76a74f5ac029ff052dbcc72e3b59624 (diff) | |
| download | PROJ-8f268409d37cea329d263e177b83e42f8384d3c7.tar.gz PROJ-8f268409d37cea329d263e177b83e42f8384d3c7.zip | |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/conversions')
| -rw-r--r-- | src/conversions/axisswap.cpp | 1 | ||||
| -rw-r--r-- | src/conversions/cart.cpp | 7 | ||||
| -rw-r--r-- | src/conversions/geoc.cpp | 1 | ||||
| -rw-r--r-- | src/conversions/noop.cpp | 19 | ||||
| -rw-r--r-- | src/conversions/unitconvert.cpp | 25 |
5 files changed, 37 insertions, 16 deletions
diff --git a/src/conversions/axisswap.cpp b/src/conversions/axisswap.cpp index 97c8899a..15ec016b 100644 --- a/src/conversions/axisswap.cpp +++ b/src/conversions/axisswap.cpp @@ -59,7 +59,6 @@ operation: #include "proj.h" #include "proj_internal.h" -#include "proj_internal.h" PROJ_HEAD(axisswap, "Axis ordering"); diff --git a/src/conversions/cart.cpp b/src/conversions/cart.cpp index d9aea9b8..c1f6f09d 100644 --- a/src/conversions/cart.cpp +++ b/src/conversions/cart.cpp @@ -43,7 +43,6 @@ #define PJ_LIB__ #include "proj_internal.h" -#include "proj_internal.h" #include "proj_math.h" PROJ_HEAD(cart, "Geodetic/cartesian conversions"); @@ -163,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/src/conversions/geoc.cpp b/src/conversions/geoc.cpp index e0ca3df3..3d86b531 100644 --- a/src/conversions/geoc.cpp +++ b/src/conversions/geoc.cpp @@ -32,7 +32,6 @@ #include "proj.h" #include "proj_internal.h" -#include "proj_internal.h" PROJ_HEAD(geoc, "Geocentric Latitude"); diff --git a/src/conversions/noop.cpp b/src/conversions/noop.cpp new file mode 100644 index 00000000..a5dd6023 --- /dev/null +++ b/src/conversions/noop.cpp @@ -0,0 +1,19 @@ +#define PJ_LIB__ + +#include "proj_internal.h" + +PROJ_HEAD(noop, "No operation"); + +static PJ_COORD noop(PJ_COORD coord, PJ *P) { + (void) P; + return coord; +} + +PJ *CONVERSION(noop, 0) { + P->fwd4d = noop; + P->inv4d = noop; + P->left = PJ_IO_UNITS_WHATEVER; + P->right = PJ_IO_UNITS_WHATEVER; + return P; +} + diff --git a/src/conversions/unitconvert.cpp b/src/conversions/unitconvert.cpp index 1e3372d6..7ef07311 100644 --- a/src/conversions/unitconvert.cpp +++ b/src/conversions/unitconvert.cpp @@ -72,7 +72,6 @@ Last update: 2017-05-16 #include "proj_internal.h" #include "proj_math.h" -#include "proj_internal.h" PROJ_HEAD(unitconvert, "Unit conversion"); @@ -473,11 +472,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "xy_in unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dxy_in").f) == 0.0) + f = pj_param (P->ctx, P->params, "dxy_in").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->xy_factor *= f; + Q->xy_factor = f; if (normalized_name != nullptr && strcmp(normalized_name, "Radian") == 0) P->left = PJ_IO_UNITS_RADIANS; } @@ -488,11 +487,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "xy_out unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dxy_out").f) == 0.0) + f = pj_param (P->ctx, P->params, "dxy_out").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->xy_factor /= f; + Q->xy_factor /= f; if (normalized_name != nullptr && strcmp(normalized_name, "Radian") == 0) P->right= PJ_IO_UNITS_RADIANS; } @@ -509,11 +508,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "z_in unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dz_in").f) == 0.0) + f = pj_param (P->ctx, P->params, "dz_in").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->z_factor *= f; + Q->z_factor = f; } if ((name = pj_param (P->ctx, P->params, "sz_out").s) != nullptr) { @@ -522,11 +521,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "z_out unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dz_out").f) == 0.0) + f = pj_param (P->ctx, P->params, "dz_out").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->z_factor /= f; + Q->z_factor /= f; } if( z_in_is_linear >= 0 && z_out_is_linear >= 0 && |
