[Proj] NAD problems on OSX 10.5 Leopard

Ed McNierney ed at topozone.com
Thu Jan 17 12:58:25 EST 2008

Rich -

It's actually not much, and is pretty hardwired for NAD27/NAD83 support
and converting UTM to lat/lon coordinates.

All maps displayed on TopoZone are in the UTM projection.  I calculate
the bounding box coordinates for each map in NAD27 UTM and NAD83 UTM,
and pre-load that data on the page, accessible to JavaScript (just some
global variables).  As a subscriber moves the mouse over the map, the
coordinates of the point under the cursor are displayed in the browser
status bar.  For UTM coordinates, it's simple linear interpolation
across the image extent.  If the user chooses lat/lon display, I use the
JavaScript code below to convert on the fly as the mouse is moved over
the map. It's a one-way conversion from UTM to LL, and relies on a
global variable (datumFlag) to indicate NAD27 (0) or NAD83 (1).

Please remember that this is not a general solution but is designed only
to work properly for valid NAD27 (North American) coordinates.

	- Ed

function UTMtoLL(UTMNorthing, UTMEasting, UTMZone)
	var deg2rad = Math.PI / 180;
	var rad2deg = 180.0 / Math.PI;

	var k0 = 0.9996;
	var a;
	var eccSquared;
	var eccPrimeSquared;
	var e1;
	var N1, T1, C1, R1, D, M;
	var LongOrigin;
	var mu, phi1, phi1Rad;
	var x, y;
	var ZoneNumber;

	if (datumFlag == 0)
		a = 6378206;
		eccSquared = 0.006768658;
	} else
		a = 6378137;
		eccSquared = 0.00669438;
	e1 = (1-Math.sqrt(1-eccSquared))/(1+Math.sqrt(1-eccSquared));
	x = UTMEasting - 500000.0; //remove 500,000 meter offset for
	y = UTMNorthing;

	ZoneNumber = UTMZone;

	LongOrigin = (ZoneNumber - 1)*6 - 180 + 3;  //+3 puts origin in
middle of zone

	eccPrimeSquared = (eccSquared)/(1-eccSquared);

	M = y / k0;
	mu =

	phi1Rad = mu	+ (3*e1/2-27*e1*e1*e1/32)*Math.sin(2*mu) 
	phi1 = phi1Rad*rad2deg;

	N1 =
	T1 = Math.tan(phi1Rad)*Math.tan(phi1Rad);
	C1 = eccPrimeSquared*Math.cos(phi1Rad)*Math.cos(phi1Rad);
	R1 =
d), 1.5);
	D = x/(N1*k0);

	Lat = phi1Rad -
	Lat = Lat * rad2deg;
	LatS = formatDeg (Lat,0) + "N";
	Long =
	Long = LongOrigin + Long * rad2deg;
	LongS = formatDeg (Long,0) + "W";

-----Original Message-----
From: proj-bounces at lists.maptools.org
[mailto:proj-bounces at lists.maptools.org] On Behalf Of Richard Greenwood
Sent: Wednesday, January 16, 2008 11:13 PM
To: PROJ.4 and general Projections Discussions
Subject: Re: [Proj] NAD problems on OSX 10.5 Leopard

On Jan 16, 2008 9:09 AM, Ed McNierney <ed at topozone.com> wrote:
> William -
> I wouldn't claim to be "definitive" but I get the same results as you
report on PROJ 4.5.0 running on Windows, and with my interactive
JavaScript coordinate/datum converter on the TopoZone site (which uses
PROJ behind the scenes for datum shifts).
>      - Ed


I curious about your JavaScript coordinate converted because I've done
a little work on one myself. I took a quick look on TopoZone and
didn't see it. Could you point me to it?


Richard Greenwood
richard.greenwood at gmail.com
Proj mailing list
Proj at lists.maptools.org

More information about the Proj mailing list