IWEUA.COM
Openstreetmap &
MAPPING
I have been an Openstreetmap contributor since 2008. My first traces were taken during 2003-5 with my original
Garmin Etrex given to me my Neil and the team at BLP as I departed to become a VSO in Zaria Nigeria.

I have owned a 'few' Garmin hand held units since 2003, the original yellow Etrex, a Legend and since 2008, a
Legend HCX, a Garmin 30, a GPS62 and lately a Garmin GPSMAP62S ( see later )  all of which have been great
mapping tools, each one progressively more sophisticated and useful.

The free maps available to download for Garmins units just gets better with the country and custom Garmin Maps
from
http://garmin.openstreetmap.nl/

Originally I used GPSBabel for downloading track points form the Garmins which worked well before SD cards &
USB! It is still great for the GPX conversions you might need to do.

I have been using
JOSM since 2008 which is a fantastic mapping tool, and just gets better and better, a great
piece of software which is very reliable and powerful since the Bing imagery addition at the beginning of 2011.
I run on Windows 7 / 32 / 64 bit on my
HP 8440p which has proved to be a great, robust machine.
The Garmin 62 and Garmin GPSMAP62S : Corrupt GPX files : December 2020

I have been running the Garmin 62's for about six years, originally the Garmin 62, which I left on a bus in Korea
during the winter Olympics,  and since 2018, my Garmin 62S.
I set the caching to run every second which gives the greatest level of accuracy for speec and location for Strava
and walking and caching my routes for subsequent upload to Strava / Openstreetmap.

Normally when set to cache every second, the unit will record a GPS file with 3,000 points = 50 minutes at a
trackpoint / second ( ~ 310 kbytes,  variable depending if you are caching extras like heart rate)

You can increase this to up to 10,000 points per file ( 2h 46m ) , or perhaps 3600 points, a file per hour.

One issue with the Gar
min 62 &  GPSmap62S is that occasionally they go a bit crazy and generate huge gpx files
between 500M and 1.2 Gbyte
stored on the internal storage.

If you take the time to look at these files using the amazing
XVI32 or notepad++ you will find that trkpts are
replicated, so instead of having one entry per second, you will have 500 - 1000 entires of the same identical
trackpoint
, over and over

The GPS unit does close this file and generates a new subsequent file, so the data
cached is valid and  worth
saving. Your challenge is how to open it with an editor so you can post it up to Strava or wherever
Copy /
Replace ain't going to work.


I puzzled this in January and eventually wrote some C code to do it, and it worked, fairly well.

Last week I spent some time learning and putting my first proper Python 3 program together to actually do
something more than 'Hello Wold'.

The result as below : Python 3.

You need to copy the multi megabye files to your PC as the Garmins are only USB 1, file processing would be
painfully slow link over this link.

I placed my GPX files on my windows machine on the 'D' drive in folder AAA, you can change this in the source
code, line 3 and run direct from
Idle. Note the forward slashes used in Windows and I guess, Linux ( not tried )

I have to say, the Power of Python for a newbie like me is staggering. My original C code from zero, took a month

The code will ignore <  <extensions></extensions> including heart rate and other extra data your GPS can cache.

GARMINGPS62GPX.zip

SHA256 : 41aa4f2f2f26c87a6f254f064f89e23a1909bdcb9958345774be6bc9880ec17b

I still use JOSM with the Edit GPX plugin to Merge and Edit and cleanup my GPX traces before uploading.
import sys                                                                                        # used for the exit.sys()

FileBufferSize = 100000                                                                 # used in the def OpenFilesToReadWrite()
FileToProcessLocationName = "D:/AAA/"                                       # used in WGetFileNameToProcess()
   

def WGetFileNameToProcess():

gpxfilename = input("Copy paste the full filename ( stored in D:\AAA ) here > ")
gpxfile = FileToProcessLocationName + str(gpxfilename)              # = "D:/AAA/somegpxfile.gpx"
print(gpxfile)

YNProceed = input('\nContinue Processing ? "' + gpxfile + '" Press any key to proceed / or type "exit" to exit >')
if YNProceed == "exit":             
   print("\nBYE")
   sys.exit()
return gpxfile                                                                              # We can proceed : return the file neame entered to main()


def FileNameToWriteTo(gpxfile):
FileToWriteName =  gpxfile +'_FIX.gpx'                                      # File to write to >> D:/AAA/somegpxfile.gpx_FIX.gpx
fooglobal = open( FileToWriteName , 'w' )
return fooglobal

def OpenFilesToReadWrite( gpxfile ):
   with open(gpxfile,"r",FileBufferSize ) as file_object:
           mytext = file_object.read()

def WriteGPXHeader( fooglobal ):
   fooglobal.write ('''<?xml version='1.0' encoding='UTF-8'?>\n<gpx version="1.1" creator="GPX FIX export" xmlns="http://www.topografix.com/GPX/1/1"\n    
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n    xsi:schemaLocation="http://www.topografix.com/GPX/1/1
http://www.topografix.com/GPX/1/1/gpx.xsd">\n<metadata></metadata>\n<trk><name></name>\n<trkseg>\n''''')

def WriteGPXFooter( fooglobal ):
   fooglobal.write('\n</trkseg></trk></gpx>')


def StringToFind( TextBlob, StartPoint, ActualStringToLookFor  ):
   return TextBlob.find( ActualStringToLookFor , (StartPoint + 1 ) )

def PrintGPXSent( SenLat,SenLon,SenEle,SenTime, fooglobal ):
   Sent =  '<trkpt lat="'+ str(SenLat)  + '"'
   Sent += ' lon="' + str(SenLon) + '">'
   Sent += '<ele>' + str( SenEle) + '</ele>'
   Sent += '<time>' + str( SenTime) + '</time></trkpt>\n'
   fooglobal.write(Sent)                                                             #  Write the GPX Sentence to File D:/AAA/gpxfile_FIX.gpx
   #print ( Sent )                                                                        # Option Print it to the screen as well                        



#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# main ()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gpxfile = WGetFileNameToProcess()                                   # Ask the user for the file to process stored in d:\AAA        

with open(gpxfile,"r",100000) as file_object:        
   mytext = file_object.read()
   
#FileNameToReadFrom(gpxfile)

FileToWriteTo = FileNameToWriteTo( gpxfile )

WriteGPXHeader( FileToWriteTo )

SenTimeLastSen = " "                                                # Define a String of the Last Time Stamp

TrkSegStart = 0                                                             # Initialise the Counter Variable

while ( TrkSegStart != -1 ):
   TrkSegStart = StringToFind ( mytext, TrkSegStart,'<trkpt lat='  ) + 12   ## 12 = fixed numer of chars between <trk and "52.

   SenLat = (mytext[ TrkSegStart : StringToFind ( mytext, TrkSegStart,'"' ) ])

   TrkSegStart = StringToFind ( mytext, TrkSegStart,'lon="'  ) + 5

   SenLon = (mytext[ TrkSegStart : StringToFind ( mytext, TrkSegStart,'"' ) ])

   TrkSegStart = StringToFind ( mytext, TrkSegStart,'<ele>'  ) + 5

   SenEle = (mytext[ TrkSegStart : StringToFind ( mytext, TrkSegStart,'<' ) ])

   TrkSegStart = StringToFind ( mytext, TrkSegStart,'<time>'  ) + 6

   SenTime = (mytext[ TrkSegStart : StringToFind ( mytext, TrkSegStart,'<' ) ])

   

   if StringToFind ( mytext, TrkSegStart,'<trkpt lat='  )  < TrkSegStart :
           TrkSegStart = -1

   if ( SenTimeLastSen != SenTime):
           PrintGPXSent( SenLat,SenLon,SenEle,SenTime,FileToWriteTo )
           SenTimeLastSen = SenTime


WriteGPXFooter( FileToWriteTo )
FileToWriteTo.close()

# feedback to : w e b 2 0 at i w e u a . c o m