trk/rte and wpt in GPX fmt file

Started by crforcrq, May 22, 2024, 12:52:40 AM

Previous topic - Next topic

crforcrq

I am trying to combine waypoints and a track (or rte)  into a GPX AND import into Google Maps so I can see lines and points on the map.
It seems Google maps shows routes (or tracks) an waypoints ONLY if the GPX is formatted with all WPTs at the beginning and all routes and tracks in separate section after all the waypoints. I tested that by handcrafting a GPX file.

Google maps expects something like this
<gpx version="1.1 [1] ?" creator="xsd:string [1] ?">
<wpt> wptType </wpt> [0..*] ?
<rte> rteType </rte> [0..*] ?
</gpx>


I am trying to create a fmt file that can combine waypoints and a route in the manner Google Maps would like it but I am not sure if its possible.


The fmt file I am trying to build
#[HEAD]<?xml version="1.0" encoding="utf-8"?>
#[HEAD]<gpx version="1.0"
#[HEAD] creator="ExifTool $ExifToolVersion"
#[HEAD] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
#[HEAD] xmlns="http://www.topografix.com/GPX/1/0"
#[HEAD] xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
#[IF]  $gpslatitude $gpslongitude
#[SECT] <wpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <name>$basename#</name>
#[BODY] <desc>$imagedescription#</desc>
#[ENDS] </wpt>

#[HEAD]<rte>
#[HEAD]<name>$city#</name>
#[HEAD]<cmt>${datetimeoriginal#;my ($ss)=/\.\d+/g;DateFmt("%Y-%m-%d");s/Z/${ss}Z/ if $ss}</cmt>
#[HEAD]<desc>$sub-location#</desc>
#[BODY]<rtept lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <ele>$gpsaltitude#</ele>
#[BODY]  <time>${gpsdatetime#;my ($ss)=/\.\d+/g;DateFmt("%Y-%m-%dT%H:%M:%SZ");s/Z/${ss}Z/ if $ss}</time>
#[BODY] <desc>$imagedescription#</desc>
#[BODY]</rtept>
#[TAIL]</rte>
#[TAIL]</gpx>

I have played around with using BODY instead of SECTS but the output is always rte and wpt mixed in like

<rtept lat="40.75852732107284" lon="-73.98534948114674">
  <ele>100</ele>
   <time>2000-01-01T0:00:00Z</time>
   <desc>Times Square</desc>
</rtept>
 <wpt lat="40.75852732107284" lon="-73.98534948114674">
  <ele>100</ele>
  <name>Times Square 1</name>
 <desc>Times Square</desc>
 </wpt>
</rte>

I understand, it may mean reading the files twice to build the waypoints and then the routes. HEAD/BODY format options seem to work on a file once.

Perhaps splitting into two fmt files and using -p twice? Any suggestions? The attached file 'test.gpx' shows routes and waypoints in Google Maps (rte can be replaced with tracks if needed)

The file "text mixed.gpx" shows only the route but not the waypoints.  That is the general format I get with the fmt file above..
 

Phil Harvey

You'll have to do this in 2 passes with 2 separate fmt files.  The first fmt file will contain the headers and WPT.  Then the second will contain the track points and the gpx trailer.  I can't be more specific at the moment, the the commands would be:

1. exiftool -p one.fmt DIR > out.gpx

2. exiftool -p two.fmt DIR >> out.gpx

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

crforcrq


Phil Harvey

I could have mentioned that you may combine this into a single command line:

exiftool -p one.fmt -execute -p two.fmt -common_args DIR > out.gpx

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).