diff options
| -rw-r--r-- | nad/CH | 6 | ||||
| -rw-r--r-- | src/lib_proj.cmake | 8 | ||||
| -rw-r--r-- | src/pj_phi2.c | 64 |
3 files changed, 47 insertions, 31 deletions
@@ -1,6 +1,6 @@ # This init file provides definitions for CH1903 and CH1903/LV03 # projections using the distortion grids developed by Swisstopo. -# See: http://www.swisstopo.admin.ch/internet/swisstopo/en/home/topics/survey/lv03-lv95/chenyx06/distortion_grids.html +# See: https://shop.swisstopo.admin.ch/en/products/geo_software/GIS_info # # You'll need to download the grids separately and put in a directory # scanned by libproj. Directories may be added to the scan list through @@ -18,6 +18,6 @@ # <metadata> +origin=Swisstopo +lastupdate=2012-02-27 # CH1903/LV03 -<1903_LV03> +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +units=m +nadgrids=chenyx06etrs.gsb +no_defs +<1903_LV03> +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +units=m +nadgrids=CHENYX06_etrs.gsb +no_defs # CH1903 -<1903> +proj=longlat +ellps=bessel +nadgrids=chenyx06etrs.gsb +no_defs <> +<1903> +proj=longlat +ellps=bessel +nadgrids=CHENYX06_etrs.gsb +no_defs <> diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake index 82a8fc81..0a05b18d 100644 --- a/src/lib_proj.cmake +++ b/src/lib_proj.cmake @@ -26,13 +26,11 @@ endif(NOT USE_THREAD) find_package(Threads QUIET) if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT ) add_definitions( -DMUTEX_win32) -endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT ) -if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT ) +elseif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT ) add_definitions( -DMUTEX_pthread) -endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT ) -if(USE_THREAD AND NOT Threads_FOUND) +elseif(USE_THREAD AND NOT Threads_FOUND) message(FATAL_ERROR "No thread library found and thread/mutex support is required by USE_THREAD option") -endif(USE_THREAD AND NOT Threads_FOUND) +endif() ############################################## diff --git a/src/pj_phi2.c b/src/pj_phi2.c index 13419df8..a83302e6 100644 --- a/src/pj_phi2.c +++ b/src/pj_phi2.c @@ -1,28 +1,46 @@ -/* determine latitude angle phi-2 */ +/* Determine latitude angle phi-2. */ + +#include <math.h> + #include "projects.h" -#define TOL 1.0e-10 -#define N_ITER 15 +static const double TOL = 1.0e-10; +static const int N_ITER = 15; + +/*****************************************************************************/ +double pj_phi2(projCtx ctx, double ts, double e) { +/****************************************************************************** +Determine latitude angle phi-2. +Inputs: + ts = exp(-psi) where psi is the isometric latitude (dimensionless) + e = eccentricity of the ellipsoid (dimensionless) +Output: + phi = geographic latitude (radians) +Here isometric latitude is defined by + psi = log( tan(pi/4 + phi/2) * + ( (1 - e*sin(phi)) / (1 + e*sin(phi)) )^(e/2) ) + = asinh(tan(phi)) - e * atanh(e * sin(phi)) +This routine inverts this relation using the iterative scheme given +by Snyder (1987), Eqs. (7-9) - (7-11) +*******************************************************************************/ + double eccnth = .5 * e; + double Phi = M_HALFPI - 2. * atan(ts); + double con; + int i = N_ITER; + + for(;;) { + double dphi; + con = e * sin(Phi); + dphi = M_HALFPI - 2. * atan(ts * pow((1. - con) / + (1. + con), eccnth)) - Phi; - double -pj_phi2(projCtx ctx, double ts, double e) { - double eccnth, Phi, con; - int i; + Phi += dphi; - eccnth = .5 * e; - Phi = M_HALFPI - 2. * atan (ts); - i = N_ITER; - for(;;) { - double dphi; - con = e * sin (Phi); - dphi = M_HALFPI - 2. * atan (ts * pow((1. - con) / - (1. + con), eccnth)) - Phi; - Phi += dphi; - if( fabs(dphi) > TOL && --i ) - continue; - break; - } - if (i <= 0) - pj_ctx_set_errno( ctx, PJD_ERR_NON_CON_INV_PHI2 ); - return Phi; + if (fabs(dphi) > TOL && --i) + continue; + break; + } + if (i <= 0) + pj_ctx_set_errno(ctx, PJD_ERR_NON_CON_INV_PHI2); + return Phi; } |
