Lew is this more what you are looking for?? 

Also I have a link to the forumla I 
used<http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm>


public void onLocationChanged(Location location) {
  
  lat = Math.toRadians(location.getLatitude()); // Latitude in radians
  lng = Math.toRadians(location.getLongitude()); // Longitude in radians
  lngdeg = location.getLongitude();  // Latitude in "normal" form. dd.dd
 convert(); 
 
     pos.setText(zone + "\t"+ UTMn +"\n \t\t\t" +UTMe );
    
     
   
  }

  public void convert(){ // konverter fra Lat /Long til UTM (WGS84 / NAD84)
  public final double knu = 0.9996;  // scale along central meridian of zone
  public final double a = 6378137;   //Equatorial radius in meters 
  public final double b = 6356752.3142; // Polar radius in meters
 
e = Math.sqrt(1-(b*b)/(a*a)); // e = the eccenticity of the earth's 
elliptical cross-section 
e2 = e*e/(1-(e*e)); // The quantile e' only occurs in even powers
n =(a-b)/(a+b);
  zone = (int) (31 + (lngdeg/6)); // Calculating UTM zone using Longetude 
in dd.dd form as supplied by the GPS
 double pi = 6* zone -183; // Central meridian of zone
double pii = (lngdeg-pi)*Math.PI/180; //Differance between Longitude and 
central meridian of zone
 rho = a * (1-e*e)/ Math.pow((1-(e*e) * (Math.sin(lat)*( Math.sin(lat)))), 
(3/2)); // The radius of the curvature of the earth in meridian plane
 nu = a/(Math.pow((1-(e*e *(Math.sin(lat))*(Math.sin(lat)))), (1/2))); 
//The radius of the curvature of the earth perpendicular to the meridian 
plane
 /*
 * A0 - E0 is used for calclulating the Meridinol arc through the given 
point (lat long) 
 * The distance from the earth's surface form the equator. All angles are 
in radians
 * 
 */
 A0 =  a*(1 - n + (5/4)*(Math.pow(n,2) - Math.pow(n,3)) + 
(81/64)*(Math.pow(n,4) - Math.pow(n,5)));
  B0 =(3*a*n/2)*(1 - n - (7*n*n/8)*(1-n) + (55/64)*(Math.pow(n, 
4)-Math.pow(n, 5)));
C0 =(15*a*n*n/16)*(1 - n +(3*n*n/4)*(1-n));
D0 =(35*a*Math.pow(n, 3)/48)*(1 - n + 11*n*n/16);
E0 =(315*a*Math.pow(n,4)/51)*(1-n);
 // Calculation of the Meridional Arc
S  = A0* lat - B0 * Math.sin(2*lat) + C0 * Math.sin(4*lat) - D0 * 
Math.sin(6*lat) + E0 * Math.sin(8*lat);
 /*
 * y = northing = Ki+ Kiip^2 + Kiip^4
 * 
 *
 */
 double Ki = S * knu;
double Kii = knu * nu *Math.sin(lat)*Math.cos(lat)/2;
double Kiii = (knu * nu 
*Math.sin(lat)*Math.pow(Math.cos(lat),3)/24)*(5-Math.pow(Math.tan(lat),2)+9*Math.pow(e2,2)*Math.pow(Math.cos(lat),2)+4*Math.pow(e2
 
,2)*Math.pow(Math.cos(lat),4));
 /*
 *  x = easting = Kivpii + Kvpii^3 + 
 */
double Kiv = knu * nu *Math.cos(lat);
double Kv = knu * 
Math.pow(Math.cos(lat),3)*(nu/6)*(1-Math.pow(Math.tan(lat),2)+e2*Math.pow(Math.cos(lat),2));
   
double UTMni = (Ki+Kii*Math.pow(pii, 2)+ Kiii * Math.pow(pii,4));// Northing
double UTMei = 500000 + (Kiv*pii + Kv * Math.pow(pii, 3));  //Easting is 
relative to the central meridain. Forconvetional UTM Easting add 5000000 
meters to x
 UTMn = (int) UTMni; // Northing, rounded to closest integer
UTMe = (int) UTMei; // Easting, rounded to closest integer 
  }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to