Register
It is currently Sat Nov 22, 2014 10:34 am

Extract Longitude/Latitude


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Tue Aug 31, 2010 5:15 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
I'm using gpxlogger to output my current location

on startup it outputs

Code:
<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.1" creator="navsys logger"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.topografix.com/GPX/1.1"
        xsi:schemaLocation="http://www.topografix.com/GPS/1/1
        http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata>
  <name>NavSys GPS logger dump</name>
  <author>Amaury Jacquot</author>
  <copyright>BSD or GPL v 2.0</copyright>
</metadata>
<trk>
  <trkseg>
   <trkpt lat="11.111111" lon="-2.222222">
    <ele>nan</ele>
    <time>2010-08-31T11:10:41Z</time>
    <fix>2d</fix>
   </trkpt>


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

http://maps.google.com/maps?q=11.111111,-2.222222


Top
 Profile  
 PostPosted: Tue Aug 31, 2010 6:05 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
I don't know anything about gpxlogger but from the info you supplied the following may work;

Code:
gpxlogger | awk -F \" '/<trkpt/ { print "http://maps.google.com/maps?q="$2","$4 }'



Top
 Profile  
 PostPosted: Tue Aug 31, 2010 7:28 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Code:
sed -rn '/<trkpt lat="/{s%.* lat="([^"]+)" lon="([^"]+)">.*%http://maps.google.com/maps?q=\1,\2%;p}'


Top
 Profile  
 PostPosted: Wed Sep 01, 2010 8:14 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
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.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP