Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

GPStoOSGB library - UK specific!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2008, 04:00 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default GPStoOSGB library - UK specific!

This simple(!) library converts from WSG84 latitude and longitude values, as usually returned by GPS receivers, to OSGB36 values as used by the Great Britain Ordnance Survey and printed on OS maps, and then on to OS National Grid map references. The reverse process is also supported.

For those who don't know the OS is Great Britains national mapping and survey service and is the primary source of map data for the UK. Ordnance Survey, Britain's national mapping agency

Help is in the demo and source is included for merging. Runs under .NET 1.0/1.1 or later on device and desktop.

EDIT :- Version 1.2 posted. ODN height added and more help in the demo. See post #4 below.
Attached Files
File Type: zip GPStoOSGB1.2.zip (9.7 KB, 107 views)

Last edited by agraham : 11-04-2008 at 10:48 AM.
Reply With Quote
  #2 (permalink)  
Old 10-26-2008, 07:32 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

I'm pretty sure you could also use GPS.ChangeDatum to do it.
You should follow the link on this page. This datum does appear in the table.
Reply With Quote
  #3 (permalink)  
Old 10-26-2008, 09:54 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Erel View Post
I'm pretty sure you could also use GPS.ChangeDatum to do it.
It could but I think this library is more accurate as it uses a 7 parameter Helmert transformation (I don't really know what that means but the source code contains the URL of the website that I obtained the code from that initially came from the OS documentation). It could even be a bit more accurate as the algorithm also includes ellipsoid height but I've set that to zero for convenience as it has a really minor effect below the levels at which aircraft fly. The library round trips from WSG84 through OSGB36 to National Grid and back with remarkable accuracy.

Actually the major feature of the library is the transformation to the OS National Grid Reference which is the primary way that map locations are specified in the UK. We don't use lat/long we use the National Grid and it is printed on all OS maps as a grid as the primary location mechanism. Lat/long is included but only as small crosses at spot points for cross reference to the grid.

EDIT:- I've done the comparison and the difference for locations near to me is about 3 metres in both directions between the 7 parameter Helmert transormation from the Ordnance Survey documentation and whatever the transformation implemented in the GPS Converter is. You've got to get the signs of the dx,dy and dz correct though!

Last edited by agraham : 10-27-2008 at 03:54 PM.
Reply With Quote
  #4 (permalink)  
Old 11-04-2008, 10:57 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Altitudes on UK maps are usually measured with reference to the mean sea level at the Newlyn Tidal Observatory. This level is called the "Ordnance Datum Newlyn" (ODN).

After some more research on the OS site version 1.2 of the library now returns an "approximation" (so termed by the OS literature!) of the ODN height from a WGS84/GPS ellipsoid altitude using an equation and parameters specified by the Ordnance Survey for that purpose.

This means that WGS84/GPS latitude longitude and ellipsoid height can now be translated into UK latitude, longitude, height and grid references as printed on UK Ordnance Survey maps.
Reply With Quote
  #5 (permalink)  
Old 10-03-2010, 11:45 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Erel View Post
I'm pretty sure you could also use GPS.ChangeDatum to do it.
You should follow the link on this page. This datum does appear in the table.
The datum change is only part of the process. OS-GB is a Transverse Mercator projection. Like UTM but using different parameters. In particular the base meridian is 2 degrees West so that similar areas of land are to East and West of that meridian.

I've only just discovered this library; it's one I've wanted for a while. (I implemented it myself, with help, years ago for my old Psion computers.)

Mike.
Reply With Quote
  #6 (permalink)  
Old 10-03-2010, 02:19 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
This simple(!) library converts from WSG84 latitude and longitude values, as usually returned by GPS receivers, to OSGB36 values as used by the Great Britain Ordnance Survey and printed on OS maps, and then on to OS National Grid map references. ...
I've just run the demo and noticed a trap for the unwary. It is customary to drop less-significant digits if a less accurate representation of a co-ordinate is satisfactory. However it is essential to retain the leading digit(s), even if they are zero. So in the attached initial MsgBox output the
Code:
National Grid: 146750 28600
should really be
Code:
National Grid: 146750 <font color="Red">0</font>28600
It would be even worse of square SV had been chosen rather than SW because then both Easting and Northing would need leading zeroes.

Mike.

Edit: perhaps I'm wrong about the above, on the grounds that the eastings and northings are defined to be in metres and must always be shown separated by some non-numeric text, unlike the easting and northing parts of an alphanumeric grid reference.
Attached Images
File Type: jpg leading-zero.JPG (12.9 KB, 5 views)

Last edited by mjcoon : 10-03-2010 at 02:29 PM. Reason: Sudden insecurity!
Reply With Quote
  #7 (permalink)  
Old 10-03-2010, 02:36 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Well spotted Mike. The Northing and Easting are actually returned as double values with an implicit significance of six digits so I guess that the display program should use Format(OSGB.Northing, "D6"), rather than just relying on the default format, and then truncate the right side of the string if necessary. Is this correct?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #8 (permalink)  
Old 10-03-2010, 03:51 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
Well spotted Mike. The Northing and Easting are actually returned as double values with an implicit significance of six digits so I guess that the display program should use Format(OSGB.Northing, "D6"), rather than just relying on the default format, and then truncate the right side of the string if necessary. Is this correct?
Hi Andrew, I half-recanted per my Edit. But then saw on the MAGIC web site's Help text that they think the numeric form can validly be truncated in the same way as the alpha-numeric. Not as authentic as a statement on the Ordnance Survey web site but I couldn't find one of those...

BTW a Local Authority near here publishes grid references for planning applications with two decimal places!

Mike.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Door library (Beta) - Special library Erel Official Updates 60 01-13-2011 11:23 AM
Merging Outlook library and Phone library Erel Official Updates 11 09-15-2010 09:22 AM
PhoneticAlgorithms Library (ex-StringComparison Library) moster67 Additional Libraries 10 11-11-2008 07:46 PM
using a specific.NET version. jesb4ppc Questions (Windows Mobile) 3 09-10-2008 09:36 AM


All times are GMT. The time now is 06:32 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0