[OSM-talk] Privacy - Time - Houses

matthew-osm at newtoncomputing.co.uk matthew-osm at newtoncomputing.co.uk
Fri Aug 17 21:53:50 BST 2007


Hi,

On Thu, Aug 16, 2007 at 10:04:50PM +0200, Thomas Krauss wrote:
> I want to delete or fake the timestaps of the gpx file AND

If you are using Linux you can use the following perl and shell script[1]:

randtime.pl:
--- 8< --------------------------------------------------------------------
#! /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;
}
--- 8< --------------------------------------------------------------------

makerand
--- 8< --------------------------------------------------------------------
#! /bin/bash
mkdir rand
for i in *.gpx
do
  echo -n $i
  if [ ! -e rand/$i ]; then
    echo -n "  ./randtime.pl $i > rand/$i"
    ./randtime.pl $i > rand/$i
  fi
  echo
done
--- 8< --------------------------------------------------------------------

Sit in the directory with .gpx files, copy both those files to there, and run
./makerand - a directory "rand" will be created with randomised timestamps.

The timestamps are kept in order (but with random seconds between each stamp) so
that anything that shows direction of travel from the time will still work.
Initial time is kept within a month or so of the real starting time so that you
know roughly when the GPX was created (i.e. in 5 years time the roads may have
changed - this information is useful to "age" the data).

I know, I know - someone will complain that you can fake this data. Sorry in
advance (but it's trivial even if I don't say how to :) ).

Cheers,

-- 
Matthew

[1] Standard disclaimer: backup your own stuff, it's not my fault if it goes
wrong. Treat the scripts as public domain.





More information about the talk mailing list