Heres a little app I wrote....

A few weeks ago, I started looking round for some code/examples that I could use in Xojo, to assist with converting UK (OSGB36) National Grid co-ordinates to international (WGS84) standards. It didnt go well. I found examples written in c but they were not well documented or complete and were therefore unusable. I even submitted a request for a Xojo developer to write the code as I was willing to pay, but alas no takers there either.

I then set about writing the code myself; this app is the result of that.

The brief was very simple; convert UK Eastings and Northings to Latitude/Longitude values and then further convert them to WGS84 standard. The longer term plan is for these to be used as input to a vehicle routing engine.

Ordnance Survey UK has a very good pdf document titled ‘A Guide To Coordinate Systems In Great Britain’, 48 pages, which explains many different coordinate systems, the limitations of each and provides some very long and detailed conversion algorithms. Reading them on paper made my head spin a lot.

With the help of that document and a very helpful chap at Ordnance Survey who sent me some test data, I have now coded all the routines in a small Xojo app. The interface is very simple and also shows a table of all the test data together with the expected results, as seen here:

The app not only contains the routines I needed, but every single one that was detailed in the document mentioned above, which allows for all manner of conversions. All of the routines use the required double precision arithmetic and work on radian values, after which they are converted back to decimal degree values and DMS+Direction.

For anyone who has read this document or knows about the conversions that are required, its a lot of work; it took many attempts to get it right. Here is a list of the routines included :

The ouput of every function has been tested and verified, and they are all contained within a module which can obviously be imported should anyone want to use them.

As my little contribution to the Xojo community, I’m making the app, including source code, freely available to anyone who wants it. Drop me a PM with email so I can send it; alternatively if anyone wishes to host the source code, then let me know.

Thanks all.

Isn’t it great when it all comes together and you can say “I did that!”
Sounds way over my head but interesting

Yep, indeed. Geoconversion isnt the most exciting subject in the world and is technically very involved.

I needed this though, as the destination app can not rely on web services to do it, of which there are plenty. The most efficent way is to obviously code it and include it in the app itself, so it doesnt have to rely on other services or websites to do the work.

Although I couldn’t imagine a personal use for my projects right now, one never knows what will come. Thanks a lot for sharing your code!
Did you consider promoting your app to the geocaching community? I could imagine this is mighty useful for them – maybe with an iOS version to take along?

Not at the moment, no. iOS is beyond me for now, and the intended app where the code will be used is taking priority. Plus the interface would need to be massively increased to show all the outputs. While Im not against that, its not a huge priority. My app Im working on here only uses a small number of the actual routines included and it has achieved that very nicely. I expect I will come back to it at some point in the future though as my next area that Ive started working on is a small dedicated mapping system.

… don’t worry, be happy!

[quote=142477:@Oliver Osswald]… don’t worry, be happy!

Yep, i was in a happy mood when it was all tested and complete :slight_smile: