[OSM-talk] An old question about GPX traces

matthew-osm at newtoncomputing.co.uk matthew-osm at newtoncomputing.co.uk
Wed Sep 13 21:57:15 BST 2006


On Wed, Sep 13, 2006 at 10:34:22PM +0200, Joerg Ostertag (OSM Munich/Germany) wrote:
> >   sed -e 's/\(<trkpt[^>]\+>\)/\1<time>2006-01-01T00:00:00.000Z<\/time>/' \
> >     withouttime.gpx > withtime.gpx
> 
> or
>   osmfilter.pl <filename.gpx>
> ;-)

OK... I knew there was probably already a way of doing this :-).

Can osmfilter also randomise time data for you? I currently run the following
script but it would be nice to use a more common method.

#! /usr/bin/perl
$time = (time()-(2**21)) + int(rand()*2**22);
while (<>) { @t = gmtime($time);
  $o = sprintf '%4d-%02d-%02dT%02d:%02d:%02dZ', 1900+$t[5],
     $t[4], $t[3], $t[2], $t[1], $t[0];
  s/<time>\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ<\/time>/<time>$o<\/time>/g;
  print; $time += int(rand()*15)+1;
}

Thanks!

-- 
Matthew




More information about the talk mailing list