Did you ever have a gps file which was consistently moved from the map by few meters?
It happens mainly if you are travelling fast and the gps tries to catch up after tunnels or other losses of a signal. But now there is universal solution to it. And it is in VIM!
Just get the offset (in lat/lng), open file in vim, select problematic region (it helps if the file is not in one line as some programs prefer) and run following mega-command:
:'<,'>s/lon="\([0-9.]*\)"/
\='lon="'.printf('%.10f',str2float(submatch(1))+0.002).'"'/
To explain few things:
:'<,'> matches on selected lines
s/xxx/yyy/ replaces regrexp with yyy
\(xxx\) is a submatch
[0-9.]* matches floating point value
\= tells vim to use expressions instead of strings while replacement
'xxx' is a string expression
. concatenates string expressions
str2float(submatch(1)) gets a floating point value of the matched latitude/longitude
No comments:
Post a Comment