Page 1 of 2

enhancements and source of GPSGO

PostPosted: Mon Jun 15, 2009 11:24 am
by Ludo
Hi!

At first i have to say great work Dr Matt.
Your GPSmap-OS works perfect with my PDA (PPC2003) here in germany and I am using it for recording bike tours and orientation aside the streets.

I needed some more features and I've downloaded the source of GPSmap-OS and added some important enhancements.

1. write altitude to trl-files and kml-files
2. added LOD+ and LOD- (LOD = level of detail) buttons so that I can load a specific part of the map (marked by cursor or GPS-Position) in a higher

resolution
3. programmed a python script to split up a high-res map (400mb) into smaller 20mb pieces and automatically create "child-mcd" files based on the

"master-mcd" of the whole map

At point 3 is my problem.
When I set two calibration points at the left bottom pixel and the right top pixel then the map calibration seems to be correct.
But if I split the map into 4 pieces and then split these 4 pieces again and calculate the mcd based on the first mcd i've set manualy there seems to be a

problem. In higher LODs there's a huge displacement. I've downscaled the full eastings and full nothings in a linar way. Maybe the linear calculation is the

fault or are the eastings and northings no good way to calibrate in germany? Is it possible to get the source code of GPSGO where you used lat and log?

Sorry for all the questions, but I am very interested in improving this programm to make it more useable for my bike tours.

Thanks in advance.

PostPosted: Tue Jun 16, 2009 9:12 pm
by jolly47roger
Can you PM an example of an MCD for a big map and it's 'children' - I may be able to help. Also tell me the map projection.

PostPosted: Tue Jun 16, 2009 11:33 pm
by Ludo
hi jolly47roger

thank you for responding.

What i've done is that i have downloaded 50x50 tiles of satelite maps from google maps and combined them to a high res 400mb satelite map.

As far as i know this map in real has a height of 15,781km and a width of 22,5km. (=span from master mcd-file in easting/northing, I think this is what you mean by "map projection"?!?!)
Because this map won't fit to my pda memory and I've "LOD-ized" this huge map.
This means that the huge pic is scaled down to 2560x2560 for LOD 0 (map.lodized.jpg approximately 20mb in memory).
Then i've calibrated the master map manualy(left lower pixel, right upper pixel) and read the calibration points(full easting and full northing) back to my python script as calculation base.

Then i've divided the master map into 4 pieces for each corner.
These first divided maps are called map.lodized_1.jpg, map.lodized_2.jpg, map.lodized_3.jpg, map.lodized_4.jpg and are scaled down to 2560x2560, too.
The numbers identify the quadrants of a Cartesian coordinate system which is layed over the master map which has it's origin located in the middle of the master map.
While processing and deviding the master map pic I also tried to calculate the child-mcd files based on the master mcd. The calculation is done linear from masters SW and NE calibration points.

For the first LOD all seems to work right, but after entering recursion for further LOD-levels something wents wrong.
I've already checked the generated mcd files an they are correct. GPSMap seems to have poblems with the mcd files or my linear algo is wrong or the OS-Coordinates don't work here in germany. Maybe i will have more success with lat,long based calculation?!?!

The automatic reload of detail maps in the ppc program is not the problem. This part works already.

the files

PostPosted: Wed Jun 17, 2009 4:10 pm
by jolly47roger
*** Revised post ***

By 'projection' I meant the (mathematical) way by which the curved earth is projected onto a flat map. Google Earth uses a Mercator projection whilst the OS uses a Transverse Mercator projection. (Wikipedia has better descriptions than I can write here).

Mercator projections are non-linear in the North-south direction - but on a map of the size you describe the error on the middle is around 10 metres. Too small to worry about, I think

The Transverse Mercator projection is (almost) linear within its zone. When using UTM coordinates on a map, the zone is usually 6 degrees (+/-3) wide. The centre of the OS coordinate zone is 2 degrees west so, in Germany, you will be around 11 degrees away from the zone centre and things will get distorted.

I am guessing that GPSMAP and GPSGO both assume a linear map - no doubt Dr Matt will tell me if I am wrong!

I suggest you try GPSGO which is based on Latitude and Longitude. For a bigger map, you will need to adjust for the Mercator projection if the error is important to you. Wikipedia has the mathematical rules or I can send you what I do.

If you are using Google maps then GMAPMAKER will do the hard work of stitching tiles together and my MAPC2MAPC program will convert the .map file it writes to a (latitude and longitude) .mcd file.

Can you PM me your set of MCD files - parent and all children?

PostPosted: Wed Jun 17, 2009 10:09 pm
by jolly47roger
Thinking about it a bit more, a linear method should give close results as long as you realise that the map is rotated in comparison with the coordinate system. For example, the eastings of the top right will not be the same as the eastings of the bottom right of the map; the northings of the top right will not be the same as the northings for the top left.

With some basic geometry it should be possible to work out the rotation and hence the coordinates for a linear (affine) transformation.

GPSGO source

PostPosted: Wed Jun 17, 2009 10:13 pm
by shanks
Sorry I don't have time to answer fully at the moment (although jolly47roger has already done a great job), but for starters here's a link to the source for GPSGO 0.92 beta (slightly newer than the version currently available for download).

http://www.craporola.com/GPSGO0.92b_eVC4_Workspace.zip

Hope it's some use to you Ludo - the changes you describe sound really interesting and I'd love to see the results integrated into the program for everybody to use.

dr. matt

PostPosted: Fri Jun 19, 2009 10:30 pm
by Ludo
jolly47roger wrote:Thinking about it a bit more, a linear method should give close results as long as you realise that the map is rotated in comparison with the coordinate system. For example, the eastings of the top right will not be the same as the eastings of the bottom right of the map; the northings of the top right will not be the same as the northings for the top left.

With some basic geometry it should be possible to work out the rotation and hence the coordinates for a linear (affine) transformation.


I think I got it. Forget the mcd files I posted before.
My stupid fault was that I just devided the eastings and northings assuming that theres is NO rotation and the top right WILL BE the same as the northings for the top left. Because of this I got this huge distortion or maybe only translation of approximately 20% of the master-map-size.

I've moved the child-mcd file creation to the ppc application and now it's done on the fly when loading higher LOD maps, but in this case I don't devide the
eastings and northings, I devide the pixels and calculate the eastings and northings with the build-in MapFunc-Functions.
This seems to work and gives me nearly correct calibration-data for the child maps.
The slightly distortion/translation must be a result of the Mercator projection for google-map maps or you described before.

shanks wrote:Sorry I don't have time to answer fully at the moment (although jolly47roger has already done a great job), but for starters here's a link to the source for GPSGO 0.92 beta (slightly newer than the version currently available for download).

http://www.craporola.com/GPSGO0.92b_eVC4_Workspace.zip

Hope it's some use to you Ludo - the changes you describe sound really interesting and I'd love to see the results integrated into the program for everybody to use.

dr. matt


Now that I have the source of GPSGO which can be used worldwide with lat/long calibration I will implement the changes I've done to the GPSMap source to GPSGO. Thanks to dr. matt for the source.

Of course any changes which could be usefull to you/others will be send to you after testing, code cleaning and finishing touch.

I'll get back when i have new veryfied results.

PostPosted: Sun Jun 21, 2009 4:51 pm
by jolly47roger
If you are adding altitude to the .trl file, is it possible to add a time and date to each point too - either GPS time or PocketPC time. And to the .kml file??

PostPosted: Sun Jun 21, 2009 8:06 pm
by Ludo
It took me a while to reproduce the changes i've done to the GPSMap source for the GPSGO source.
The the MapFuncs-class and it's serailize function works in a different way and saves the whole CPrecisePoint objects instead of only 12+1 double values.(I've added member variables for height and timestamp to this class)
This made it realy hard to debug the child-mcd files with a hex-editor. I had to change the serialze funtion into the GPSMap style and now it only writes 12+1 double values.

Writing timestamps to KML files would be possible. But as far as i know you can't add timestamps to path-points in the KML format.
I decided to make a 3rd save option for trails and it writes a plain csv file (lat,long,height,PocketPC-timestamp) which can be imported into an other great open source program called GPS-Track-Analyse.NET.

I've also added a real time display for distance in km and cumulated positive delta height in meters for the currently loaded or recorded trail.
But this part is not completly finished yet.

In conclusion the calibration seems to be better with GPSGO's lat/long calculations and I will proceed adding features to GPSGO.
On the fly child mcd file creation for LOD-maps is no longer the problem.

@dr. matt
Why two programs, shouldn't GPSGO work in GB, too?
Is GPSGO older than GPSMap?

PostPosted: Sun Jun 21, 2009 10:17 pm
by jolly47roger
I don't claim to fully understand kml but a placemark seems to allow a timestamp - see this example created by GPSU (also recommended!)

<Placemark><visibility>0</visibility>
<name>2009-06-09 16:14:35Z</name>
<TimeStamp><when>2009-06-09T16:14:35Z</when></TimeStamp>
<description> 2:41:38 56.09 53.9</description>
<Point><coordinates>-2.930540,52.099025,92.1999969482422</coordinates></Point>
<styleUrl>#trkpntStyle</styleUrl></Placemark>
<Placemark><visibility>0</visibility>
<name>2009-06-09 16:14:45Z</name>
<TimeStamp><when>2009-06-09T16:14:45Z</when></TimeStamp>
<description> 2:41:48 56.25 58.2</description>
<Point><coordinates>-2.927002,52.098163,78.9000015258789</coordinates></Point>
<styleUrl>#trkpntStyle</styleUrl></Placemark>

PostPosted: Mon Jun 22, 2009 6:47 pm
by shanks
Sounds like you're doing some fine work Ludo. To answer your question GPSMap-OS was created first, and then GPSGO when I started to travel to places like France and wanted to use the local maps.

GPSMap uses a simpler calibration algorithm (just 2 points because it only works on the square British National Grid system) but it has the more complex maths in the coordinate conversion code between OS and WGS84.

GPSGO uses a polynomial calibration function so it can cater for a far greater range of linear deformations in the map image (scaling, stretching, rotation, shearing..) which should cover most map projections used for small-scale local maps around the World. But I never had time to finish the calibration system (it's a little clumsy and I want to allow modifying the calibration points, not overwriting them) so it's not reached version 1.0 yet!

I have been intending to convert the .mcd, .trl and .pts files into an XML format for some time now, as the binary format makes it very difficult for people like you to write separate utilities to create them. In the GPSGO source you will see I now use an open source XML parser, CMarkup, to read KML placemarks - this I will use for the new ".mcx" file. I already have some ideas for the format:

Code: Select all
<calibrationPoint>
  <imagePoint>
    <pixelX>10</pixelX>
    <pixelY>15</pixelY>
  </imagePoint>
  <mapPoint>
    <latitude>51.12345</latitude>
    <longitude>-2.12345</longitude>
  </mapPoint>
</calibrationPoint>
.. further calibrationPoints...


If you find you need an extra piece of work please implement the above! :wink:

dr. matt.

PostPosted: Tue Jun 23, 2009 6:54 pm
by Ludo
Thanks for the detailed answers dr. matt.

I have some comments regarding your TODO-list.

Code: Select all
- Fix sharing violation that occurs on mcd file if prog was previously exited after entering only 1 or 2 calib points.

I tripped over the same thing and I could not resolve it in the Serialize function. As dirty fix I changed the code and don't write mcd files until three calib points are entered.

Code: Select all
- Use text format for mcd to allow easier external prog calibration.

concerns your homework for me.
Writing the XML is very easy, the CMarkup class will help to read it.
Let's see if i have time to implement this. :wink:

Code: Select all
- Allow calib with 2 points? (assume rectilinear "grid" - synthesize 3rd point as apex of triangle)

This is a good idea as long as you assume rectilinear "grid".
The three calib points of GPSGO and the transformation matrix gives me better results for probably non rectilinear google-maps images.


@jolly47roger

You are right. I read the kml specs and it's possible to add timestamp tags to landmarks but not to single coordinates of a path like trails are exported from GPSGO.
Please correct me if I am wrong.

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<Style id="trailStyle">
  <LineStyle><width>3</width><color>ff4400ff</color></LineStyle>
</Style>
<Folder><name>GPSMap-OS Trails</name>
  <Placemark>
    <styleUrl>#trailStyle</styleUrl>
    <name>Segment 1</name>
    <TimeStamp><when>2009-06-09T16:14:35Z</when></TimeStamp> <!-- timestamp possible -->
    <LineString><tessellate>1</tessellate>
      <coordinates>
        10.9960796457,51.0202120437,165.1000000000 <!-- no timestamp possible -->
        10.9961579739,51.0203003774,160.8000000000 <!-- no timestamp possible -->
        10.9959763310,51.0203420440,165.0000000000 <!-- no timestamp possible -->
      </coordinates>
    </LineString>
  </Placemark>
</Folder>
</Document>
</kml>

PostPosted: Tue Jun 23, 2009 8:02 pm
by jolly47roger
The example I sent you seems to use every point on the trail as Placemark without using linestrings. I guess there are different ways to achieve the same result but I do like to look at my track to see where I was and when to locate photographs and to plot graphs like distance over time.

PostPosted: Thu Jun 25, 2009 12:00 pm
by Ludo
OK I'll give it a try and implement a Placemark-List export format
after the modifactions for the LOD-system are completly finished.

I want to auto-load lod-tiles when the gps-position is leaving the current map-tile and I still have some problems with adding an input control to the trail settings page. (threshold for delta height tracking) The value can't be read or written from/to registry or I forgot to define an EVENTID or EventHandler.

PostPosted: Tue Jul 07, 2009 6:12 pm
by jolly47roger
I'm just putting the finishing touches to a version of MAPC2MAPC that will calibrate images (previous versions only converted existing calibrations); it will write .mcd (OS or GPSGO version depending on where the map is). If the .mcx layout has been finalised I can add that, too.