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

Charles Karney ckarney at sarnoff.com
Wed Sep 17 08:35:09 EDT 2008


Gerald I. Evenden wrote:
> 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).

The timing for the forward+reverse transformation is about 2.5 times
slower than my implementation of the Krueger-style series to sixth order
in e^2.  On my 2.6GHz Intel machine, the time for a forward+reverse
transform is 12us (g++ -O3 version 4.3.0).

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

** SNIP **

No I wasn't claiming a few times relative to tmerc but relative to the
Krueger series methods such as you've implemented as etmerc, ftmerc,
ktmerc.  I believe that these latter methods have substantially smaller
errors than tmerc and so are a more appropriate basis for comparison.

Based on the timing I quote above I would be surprised if the exact
method is as much as 10 times slower than the Krueger series.  However
even if it were 100 times slower, I still believe that this is a useful
contribution being (as far as I can tell) the only published code for
the exact projection which covers the whole globe.  (Dozier's code is
published; but it fails in several areas.  Others apparently have
working codes but have not published them.)

(Incidentally the timing comparison I cite above includes convergence
and scale calculations on both the forward and reverse transformations.)

> 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.

Did you include "-I.." in the compile/link line as documented at the top
of test program?  Here are the commands needed to compile and run the
test program...

    $ tar xfz TransverseMercatorExact.tgz
    $ cd GeographicLib
    $ g++ -g -O3 -I.. -o TransverseMercatorTest \
    TransverseMercatorTest.cpp TransverseMercatorExact.cpp \
    Constants.cpp EllipticFunction.cpp
    $ ./TransverseMercatorTest -h
    TransverseMercatorTest [-r]

    Read lines with latitutde and longitude (or easting and northing if
    -r is specified) from stdin and print latitude, longitude, easting,
    northing, convergence and scale.  WGS84 ellipsoid assumed, central
    meridian = 0, UTM central scale, and false easting and false
    northing are zero.
    $ echo 1 89 | ./TransverseMercatorTest
    1 89 23941118.301 8283847.395 80.3736 15.4177

> The distribution was not ready for prime time.  ;-)

This is surely possible.  In fact, I just noticed a blunder in the
convergence calculation for the reverse transform.  (I converted to
degrees twice.)  The fixed version is now posted.

-- 
Charles Karney <charles at karney.com>
702 Prospect Ave, Princeton, NJ 08540-4037

URL: http://charles.karney.info
Tel:  +1 609 497 4662 (H)
      +1 609 734 2312 (W)




More information about the Proj mailing list