I had some trouble converting DD to UTM ( WGS84 ). I looked in every dark corner on the net, but I was unable to find the code to do it programmatically without the use of ( sometimes ) expensive third party controls. So .. I decided to hack something together myself , and all in managed code :D. I decide to post it, since I know there are many people looking for it and they don't have to go throught the same struggle as me to get is done.

remember .. this is just code to convert Lat/Long DD ( eg. 44.123456 ) to UTM Northing/Easting ( eg. 7342333, 218734, 31T). I'm still working on the code to do it the other way around and code to include other Datums. You can use this code directly in your application. You'll need to do a little bit of work if you want to update MathEngine.cs with this code.

Nice.. I posted the URL to the forum to let the other devs take a peak.

06-18-2007, 02:02 PM

what_nick

Reprojection

General purpose reprojection is rather tricky. We use proj.4 as a standard reprojection library. It is part of the WorldWind SVN I was planning to make a similar method in PluginSDK. http://proj.maptools.org/

06-18-2007, 03:49 PM

Hactic

I couldn't agree more. I need this particular conversion for a DLL that I'm writing. I don't want to blow the DLL out of proportion so I 'hardcoded' the conversion. I couldn't see any harm in posting it.

What are you suggesting ? .. for the sake of standarisation quit posting customised code. I could go with that .. not a problem :)

06-19-2007, 04:32 AM

mdsumner

Thanks for posting this, arguably it's better solved by other means but it's always great to find other's solutions via this or that code.

BTW, there are C# examples of running GDAL/OGR/PROJ.4 in the /csharp directory of FWTools. Not relevant given your immediate need, but they might be of interest.

06-19-2007, 04:36 AM

withak

Also keep in mind with OGR that the C# bindings are based off of the OGR C libs, so the detailed C++ documentation and examples on the fwtools site aren't of much use.

06-19-2007, 07:12 AM

nigel_ht

Nice

Nice. Using proj.4 would be nice too if reduced to a set of simple calls in pluginSDK for common stuff... That way we would abstract out what library or implementation were using.

Thank you all for posting back at me. I value the input. It may look like I'm re-inventing the wheel and to be honest .. that's exactly what I'm doing. I finished the code to convert UTM to Lat/long and it's working well.

I know that What_nick is making a similar projection conversion in pluginSDK, so I might as well wait to prevent me from doing double work. Currently I'm working on implementing this in MathEngine.cs. I'm thinking about posting that instead of continiously dumping code in here. Two birds with one stone. Perhaps I'm going to rattle a few dev cages and run this particular topic by them, if they're not reading it already. Although it's an open forum and that bits of code are always more than welcome , I'm still fairly new on WW and therefore unaware of any code of conduct and/or the hierachie in here.

Cheers

06-21-2007, 08:09 PM

withak

Quote:

Originally Posted by Hactic

I know that What_nick is making a similar projection conversion in pluginSDK, so I might as well wait to prevent me from doing double work.

Go ahead and do it anyway, I bet you finish before he does. ;)

You can post patches here or in the irc channel. If you are going to be making a lot of changes then check with Bull_[UK] on irc to see about getting commit access.

06-22-2007, 10:31 PM

nigel_ht

Yah, post it. Should be interesting to fiddle with.

Nigel

Quote:

Originally Posted by Hactic

Thank you all for posting back at me. I value the input. It may look like I'm re-inventing the wheel and to be honest .. that's exactly what I'm doing. I finished the code to convert UTM to Lat/long and it's working well.

I know that What_nick is making a similar projection conversion in pluginSDK, so I might as well wait to prevent me from doing double work. Currently I'm working on implementing this in MathEngine.cs. I'm thinking about posting that instead of continiously dumping code in here. Two birds with one stone. Perhaps I'm going to rattle a few dev cages and run this particular topic by them, if they're not reading it already. Although it's an open forum and that bits of code are always more than welcome , I'm still fairly new on WW and therefore unaware of any code of conduct and/or the hierachie in here.