Extract Longitude/Latitude
Page 1 of 1

Author:  BrianUK [ Tue Aug 31, 2010 5:15 am ]
Post subject:  Extract Longitude/Latitude

I'm using gpxlogger to output my current location

on startup it outputs

<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.1" creator="navsys logger"
  <name>NavSys GPS logger dump</name>
  <author>Amaury Jacquot</author>
  <copyright>BSD or GPL v 2.0</copyright>
   <trkpt lat="11.111111" lon="-2.222222">

I would like to extract <trkpt lat="11.111111" lon="-2.222222"> ie whatever numbers/characters are between "" in lat= and lon=

so it outputs,-2.222222

Author:  DarthWavy [ Tue Aug 31, 2010 6:05 am ]
Post subject:  Re: Extract Longitude/Latitude

I don't know anything about gpxlogger but from the info you supplied the following may work;

gpxlogger | awk -F \" '/<trkpt/ { print ""$2","$4 }'

Author:  choroba [ Tue Aug 31, 2010 7:28 am ]
Post subject:  Re: Extract Longitude/Latitude

sed -rn '/<trkpt lat="/{s%.* lat="([^"]+)" lon="([^"]+)">.*%\1,\2%;p}'

Author:  BrianUK [ Wed Sep 01, 2010 8:14 am ]
Post subject:  Re: Extract Longitude/Latitude

Thanks for that i've just managed to break the box I was going to test it on so once rebuilt will let you know.

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group •