[Proj] C++ code for exact Transverse Mercator Projection

Gerald I. Evenden geraldi.evenden at gmail.com
Tue Sep 16 18:50:24 PDT 2008


On Tuesday 16 September 2008 5:51:06 pm Charles Karney wrote:
	...
> This is just a straightforward implementation of transformations given
> by Lee in his 1976 monograph.  The resulting code is quite fast.  I
> haven't done detailing timing on it.  However I estimate that it's no
> more than a "few" times slower than a standard series solution (a la
> Krueger).

Your claim that the all the code in your procedure is going to come within 
a '"few" times' of the following:

FORWARD(e_forward); /* ellipse */
    double al, als, n, cosphi, sinphi, t;

    sinphi = sin(lp.phi); cosphi = cos(lp.phi);
    t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.;
    t *= t;
    al = cosphi * lp.lam;
    als = al * al;
    al /= sqrt(1. - P->es * sinphi * sinphi);
    n = P->esp * cosphi * cosphi;
    xy.x = P->k0 * al * (FC1 +
        FC3 * als * (1. - t + n +
        FC5 * als * (5. + t * (t - 18.) + n * (14. - 58. * t +
         n * (13. - 64. * t + n * (4. - 24 * t)))
        + FC7 * als * (61. + t * ( t * (179. - t) - 479. ) )
        )));
    xy.y = P->k0 * (proj_mdist(lp.phi, sinphi, cosphi, P->en) - P->ml0 +
        sinphi * al * lp.lam * FC2 * ( 1. +
        FC4 * als * (5. - t + n * (9. + 4. * n) +
        FC6 * als * (61. + t * (t - 58.) + n * (270. - 330 * t +
         n * (445. - 680. * t + n * (324. - 600. * t + n * (88. - 192. * t))))
        + FC8 * als * (1385. + t * ( t * (543. - t) - 3111.) )
        ))));
   return(xy);
}
??  Hmmmm.  I am not strutting my code as the above is straight forward 
implementation of the currently accepted TM with the only exception being the 
proj_mdist procedure which is a fairly simple series procedure that is more 
precise that the standard version.  The above is about 24 lines.

Right now I am trying to get the c++ routines to compile but I can see this 
may take a bit.  First problem was reference to '/GeographicLib/*.hpp' which 
file structure no longer exists in this distribution.  That was reasonably 
simple but I have another snag at the moment.  The distribution was not ready 
for prime time.  ;-)

Surely, there will be more later.  ;-)
	...
-- 
The whole religious complexion of the modern world is due
to the absence from Jerusalem of a lunatic asylum.
-- Havelock Ellis (1859-1939) British psychologist



More information about the Proj mailing list