World Wind Forums

Go Back   World Wind Forums > WorldWind Development (Other) > Add-on & Script Development > C# code to convert DD to UTM .. here it is !!

Add-on & Script Development Creating add-ons and scripts for World Wind.

Thread: C# code to convert DD to UTM .. here it is !! Reply to Thread
Your Username: Click here to log in
Image Verification
Title:
  
Message:
Post Icons
You may choose an icon for your message from the following list:
 

Additional Options
Miscellaneous Options

Topic Review (Newest First)
08-15-2011 11:13 AM
markfly We also need imagery from outside the US :P
07-29-2010 02:36 PM
Unregistered Your method for finding the letter for the UTM zone is worthy of a post on thedailywtf.com
07-31-2009 12:10 AM
nlneilson
Quote:
Originally Posted by Unregistered View Post
I have tried testing the accuracy against the online tool (such as nearby.org.uk) and the accuracy is off (well, the Northing usually off so far)....
You can check for accuracy at this site, OldCoder's is probably correct.
http://home.hiwaay.net/~taylorc/tool...sy/datumtrans/
click on "Version 2.00.03
This uses the Molodensky transformation.
http://home.hiwaay.net/~taylorc/book...rm/molodensky/
Code:
    /*
    * transform
    *
    * Parameters:
    *     from:     The geodetic position to be translated.
    *     from_a:   The semi-major axis of the "from" ellipsoid.
    *     from_f:   Flattening of the "from" ellipsoid.
    *     from_esq: Eccentricity-squared of the "from" ellipsoid.
    *     da:       Change in semi-major axis length (meters); "to" minus "from"    *     df:       Change in flattening; "to" minus "from"
    *     dx:       Change in x between "from" and "to" datum.
    *     dy:       Change in y between "from" and "to" datum.
    *     dz:       Change in z between "from" and "to" datum.
    */
    public GeodeticPosition transform (GeodeticPosition from,
                                       double from_a, double from_f,

                                       double from_esq, double da, double df,
                                       double dx, double dy, double dz)
    {
        double slat = Math.sin (from.lat);
        double clat = Math.cos (from.lat);
        double slon = Math.sin (from.lon);
        double clon = Math.cos (from.lon);
        double ssqlat = slat * slat;
        double adb = 1.0 / (1.0 - from_f);  // "a divided by b"
        double dlat, dlon, dh;

        double rn = from_a / Math.sqrt (1.0 - from_esq * ssqlat);
        double rm = from_a * (1. - from_esq) / Math.pow ((1.0 - from_esq * ssqlat), 1.5);

        dlat = (((((-dx * slat * clon - dy * slat * slon) + dz * clat)
                    + (da * ((rn * from_esq * slat * clat) / from_a)))
                + (df * (rm * adb + rn / adb) * slat * clat)))
            / (rm + from.h);

        dlon = (-dx * slon + dy * clon) / ((rn + from.h) * clat);

        dh = (dx * clat * clon) + (dy * clat * slon) + (dz * slat)
             - (da * (from_a / rn)) + ((df * rn * ssqlat) / adb);

        return new GeodeticPosition (from.lon + dlon, from.lat + dlat, from.h + dh);
    }
This is java code but can be ported to C#.
It has been years since I have used this but it is accurate.

If you are in the UK and using a datum other than WGS84 enter the data (semi-major axis and Flattening) for that datum.
07-29-2009 02:52 PM
Unregistered
Polar to UTM

http://serialcs.sourceforge.net

Method serial.Utils.toUTM()

Cheers!
06-06-2009 01:06 PM
yoyo RonnyGydar - I'm also trying to come up with a compact framework app that will take lat/long gps coordinates and convert them to UTM. Is it possible for you to post your code that you were able to get working?
Thanks
02-13-2009 04:00 PM
Unregistered
Not accurate

I have tried testing the accuracy against the online tool (such as nearby.org.uk) and the accuracy is off (well, the Northing usually off so far)....
01-15-2009 11:59 PM
RonnyGydar Tested the code...after a little cut-and-pasting, I ended up with just 4 functions and some declarations, the stuff needed to do the LongLat-to-UTM convertion...and it worked perfectly!

A big thanks for the help! Truly saved my day! And looking at all the math and code...this is not something I would have been able solve on my own, thats for sure!
01-14-2009 05:12 PM
RonnyGydar
Quote:
Originally Posted by OldCoder View Post
Sorry about the confusion. I've zip'd up all my "base common" stuff - all .cs source (didn't even realize there was/is something called BaseCmn in the VB world) and attached here. Just include the source in your project; not every .cs is needed, but some depend on others - thus, I tossed them all in the .zip. Let me know if there are issues - glad to help.
Will test it out tomorrow and report back!

You are doing ME a favor, so I am certainly not the one that should complain!
Thanks for your time and effort, really appreciate it!
01-13-2009 09:28 PM
OldCoder
BaseCmn problem

Sorry about the confusion. I've zip'd up all my "base common" stuff - all .cs source (didn't even realize there was/is something called BaseCmn in the VB world) and attached here. Just include the source in your project; not every .cs is needed, but some depend on others - thus, I tossed them all in the .zip. Let me know if there are issues - glad to help.
01-13-2009 08:00 PM
RonnyGydar
Quote:
Originally Posted by Hactic View Post
The basecmn comes from a VB file called basecmn.cpp
I am trying to do this from a C#.Net Compact Framework solution I have (I get degrees, minutes and seconds from GPS-code from Microsoft, but need to send the coordinates as UTM to a webpage...and I am a bit lost here.

Have included the C# class (from the "textfile"), and have Googled "basecmn.cpp" but not found anything? Where do I get the baseclass(es)?

Any extra hints are appreciated!

...30 minutes ago, I did not even know there was something called UTM!
This thread has more than 10 replies. Click here to review the whole thread.

Posting Rules
You may post new threads
You may 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

All times are GMT +1. The time now is 01:50 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.