PassionFord      


Go Back   PassionFord > Main area > General Car Related Discussion.
Sign in using an external account
Register Forgot Password?

General Car Related Discussion. To discuss anything that is related to cars and automotive technology that doesnt naturally fit into another forum catagory.
Sponsored by Cartown
Click Here

Welcome to Passion Ford!
Welcome to Passion Ford.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, at no cost, you will have access to start new topics, reply to conversations, privately message other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, join Passion Ford today!


Reply
 
 
 
submit to reddit
 
Thread Tools Search this Thread Display Modes
Old 30-09-2009, 12:48 PM   #1
Chip
*** Sierra RS Custard ***
 
Chip's Avatar
 
Trader Score: (3)
Join Date: Dec 2006
Posts: 44,611
Rep Power: 51
Chip will become famous soon enoughChip will become famous soon enough
Default converting easting and northing (mercator) values to Lat / Long

Anyone ever needed to convert between easting and northing co-ords and lat/long ones?

Ive got a load of points specified in mercator, but I need them all in lat/long instead.

So im looking for the simplest equation possible to convert between the two.


Google says this:
Quote:
##+############################################### ###########################
#
# utm2utm -- Converts Universal Transverse Mercator (UTM) into
# latitude and longitude coordinates. More fun math which I got off
# the web.
#
proc utm2ll {northing easting zone {letter S}} {
set PI [expr {atan(1) * 4}]
set K0 0.9996

# WGS-84
set er 6378137 ;# EquatorialRadius
set es2 0.00669438 ;# EccentricitySquared
set es2x [expr {1.0 - $es2}]

set x [expr {$easting - 500000.0}]
set northernHemisphere [expr {$letter >= "N"}]
set y [expr {$northing - ($northernHemisphere ? 0.0 : 10000000.0)}]
set long_origin [expr {($zone - 1) * 6 - 180 + 3}] ;# +3 puts in middle
set ep2 [expr {$es2 / $es2x}]
set e1 [expr {(1.0 - sqrt($es2x)) / (1.0 + sqrt($es2x))}]
set M [expr {$y / $K0}]
set mu [expr {$M / ($er * (1.0 - $es2 /4.0 - 3 * $es2 * $es2 /64.0
- 5 * $es2 * $es2 * $es2 /256.0))}]
set phi [expr {$mu + (3 * $e1 / 2 - 27 * $e1 * $e1 * $e1 / 32 ) * sin(2*$mu)
+ (21 * $e1 * $e1 / 16 - 55 * $e1 * $e1 * $e1 * $e1 / 32) *
sin(4*$mu ) + (151 * $e1 * $e1 * $e1 / 96 ) * sin(6*$mu)}]
set N1 [expr {$er / sqrt(1.0 - $es2 * sin($phi) * sin($phi))}]
set T1 [expr {tan($phi) * tan($phi)}]
set C1 [expr {$ep2 * cos($phi) * cos($phi)}]
set R1 [expr {$er * $es2x / pow(1.0 - $es2 * sin($phi) * sin($phi), 1.5)}]
set D [expr {$x / ($N1 * $K0)}]
set latitude [expr {$phi - ($N1 * tan($phi) / $R1) * ($D * $D / 2
- (5 + 3 * $T1 + 10 * $C1 - 4 * $C1 * $C1 - 9 * $ep2) *
$D * $D * $D * $D / 24
+ (61 + 90 * $T1 + 298 * $C1 + 45 * $T1 * $T1
- 252 * $ep2 - 3 * $C1 * $C1 ) * $D * $D * $D * $D * $D * $D / 720)}]
set latitude [expr {$latitude * 180.0 / $PI}]
set longitude [expr {($D - (1 + 2 * $T1 + $C1) * $D * $D * $D / 6
+ (5 - 2 * $C1 + 28 * $T1 - 3 * $C1 * $C1
+ 8 * $ep2 + 24 * $T1 * $T1) * $D * $D * $D * $D * $D / 120)
/ cos($phi)}]
set longitude [expr {$long_origin + $longitude * 180.0 / $PI}]

return[list $latitude $longitude]
}
But ideally I would like to find something easier to implement than that if possible, as this on a time and materials basis and thats going to take a long time to convert to the language I want and error check etc!
If you were logged in, you wouldn't be seeing this ad!
Register your free account today, or log in if you already have an account.
__________________
Sometimes its more fun not to care if things make sense, and just do them anyway!

Vauxhall Nova, Mid Engined, RWD, 457bhp, Autronic SM4, GT35R, Quaiffe ATB Diff
2.0 16v - DIY Specced, DIY Built, DIY Mapped, DIY Abused
www.VauxSport.com

Last edited by Chip; 30-09-2009 at 12:50 PM.
Chip is offline   Reply With Quote
Old 30-09-2009, 12:53 PM   #2
Chip
*** Sierra RS Custard ***
 
Chip's Avatar
 
Trader Score: (3)
Join Date: Dec 2006
Posts: 44,611
Rep Power: 51
Chip will become famous soon enoughChip will become famous soon enough
Default

Never mind, found a javascript one now which is a fairly similar langauge to what im using anyway.

Quote:
function OSGridToLatLong(gridRef) {
var gr = gridrefLetToNum(gridRef);
var E = gr[0], N = gr[1];

var a = 6377563.396, b = 6356256.910; // Airy 1830 major & minor semi-axes
var F0 = 0.9996012717; // NatGrid scale factor on central meridian
var lat0 = 49*Math.PI/180, lon0 = -2*Math.PI/180; // NatGrid true origin
var N0 = -100000, E0 = 400000; // northing & easting of true origin, metres
var e2 = 1 - (b*b)/(a*a); // eccentricity squared
var n = (a-b)/(a+b), n2 = n*n, n3 = n*n*n;

var lat=lat0, M=0;
do {
lat = (N-N0-M)/(a*F0) + lat;

var Ma = (1 + n + (5/4)*n2 + (5/4)*n3) * (lat-lat0);
var Mb = (3*n + 3*n*n + (21/8)*n3) * Math.sin(lat-lat0) * Math.cos(lat+lat0);
var Mc = ((15/8)*n2 + (15/8)*n3) * Math.sin(2*(lat-lat0)) * Math.cos(2*(lat+lat0));
var Md = (35/24)*n3 * Math.sin(3*(lat-lat0)) * Math.cos(3*(lat+lat0));
M = b * F0 * (Ma - Mb + Mc - Md); // meridional arc

} while (N-N0-M >= 0.00001); // ie until < 0.01mm

var cosLat = Math.cos(lat), sinLat = Math.sin(lat);
var nu = a*F0/Math.sqrt(1-e2*sinLat*sinLat); // transverse radius of curvature
var rho = a*F0*(1-e2)/Math.pow(1-e2*sinLat*sinLat, 1.5); // meridional radius of curvature
var eta2 = nu/rho-1;

var tanLat = Math.tan(lat);
var tan2lat = tanLat*tanLat, tan4lat = tan2lat*tan2lat, tan6lat = tan4lat*tan2lat;
var secLat = 1/cosLat;
var nu3 = nu*nu*nu, nu5 = nu3*nu*nu, nu7 = nu5*nu*nu;
var VII = tanLat/(2*rho*nu);
var VIII = tanLat/(24*rho*nu3)*(5+3*tan2lat+eta2-9*tan2lat*eta2);
var IX = tanLat/(720*rho*nu5)*(61+90*tan2lat+45*tan4lat);
var X = secLat/nu;
var XI = secLat/(6*nu3)*(nu/rho+2*tan2lat);
var XII = secLat/(120*nu5)*(5+28*tan2lat+24*tan4lat);
var XIIA = secLat/(5040*nu7)*(61+662*tan2lat+1320*tan4lat+720*tan6la t);

var dE = (E-E0), dE2 = dE*dE, dE3 = dE2*dE, dE4 = dE2*dE2, dE5 = dE3*dE2, dE6 = dE4*dE2, dE7 = dE5*dE2;
lat = lat - VII*dE2 + VIII*dE4 - IX*dE6;
var lon = lon0 + X*dE - XI*dE3 + XII*dE5 - XIIA*dE7;

return new LatLon(lat.toDeg(), lon.toDeg());
}
__________________
Sometimes its more fun not to care if things make sense, and just do them anyway!

Vauxhall Nova, Mid Engined, RWD, 457bhp, Autronic SM4, GT35R, Quaiffe ATB Diff
2.0 16v - DIY Specced, DIY Built, DIY Mapped, DIY Abused
www.VauxSport.com
Chip is offline   Reply With Quote
Old 30-09-2009, 12:53 PM
PassionFord
Ford Focus




Paid Advertisement


 
 
 
submit to reddit
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
York 520 Bench and Lat Curl. fraser9764 Non Ford parts & other stuff for sale 0 12-07-2009 03:37 PM
Lat pull down machine. 007RS Non Ford parts & other stuff for sale 1 08-03-2009 08:46 PM
values of focus rs? fordsportjay General Car Related Discussion. 32 29-03-2007 02:31 PM
ect values mxquattro Ford Escort RS Cosworth 5 05-04-2006 11:26 AM
WHERE DO YOU SEE S2 VALUES GOING Kop2381 Ford Escort RS Turbo 12 28-01-2006 09:34 AM

Advertising - Terms of Service - Privacy Policy - JOBS



All times are GMT. The time now is 09:28 AM.

Contact Us - PassionFord - Archive - Top

This forum is owned and operated by Internet Brands, Inc., a Delaware corporation. It is not authorized or endorsed by the Ford Motor Company and is not affiliated with the Ford Motor Company or its related companies in any way. Ford® is a registered trademark of the Ford Motor Company.

Content Relevant URLs by vBSEO 3.5.2