[josm-dev] Display issues with downloaded raw GPS data
Frank Cremer
frank at polarphysics.net
Tue Nov 13 03:23:03 GMT 2007
Hi,
I seem to have a problem with the downloaded raw GPS data. I am relative
new to OSM and JOSM (only a few days), but have quite a bit of
experience with mapping/surveying/GIS. So, it may be that I am doing
something wrong, or missed the obvious...
When I download raw GPS data within JOSM (directly from the server), it
displays the tracks, but also seem to be connecting track points that
should not have been connected. This is very confusing as there may be
many long lines crossing most of the area. I know that it is possible to
switch of the drawing of all lines, but for mapping it helps to know
which points are connected within a track.
By saving these downloaded tracks, I have identified the problem. The
GPX file contains only one track (<trk>), whereas the underlying data
appears to be constructed from several tracks. So what happens is that
the last point of one track is connected to the first point of the next
track. This connection is drawn by JOSM as a line, which actually should
not have been there.
I am not sure about the cause of this problem. It may be that the server
is providing the GPX data correctly in independent tracks and JOSM does
not handle this properly. Or it may be that the problem is within the
server.
As a work around I have created a little Octave (a open source Matlab
clone) script that load the GPX data and if there is a jump of more than
50 m between track points it creates a new track. The script is provided
below.
If need be, I can help to implement a solution (either as plug in or
change of code), but before that it's better to know what is the actual
root of the problem. So if anyone has an idea (or can give tips on how I
should use JOSM to avoid the problem) that would be great. Thank you.
Best regards,
Frank
------------------------------------
# fix_gpx.m
#
# This Octave script loads an existing gpx file and creates an output file
# that has new tracks if the distance between track points is larger
than 50 m.
# It can be used to clean up the downloaded raw GPS data in JOSM.
#
# To run it, use e.g.:
# octave --silent fix_gpx.m Track.gpx
# It will create a file named "Track_fixed.gpx" as output.
#
# Please note that:
# 1. It requires Linux/Unix (for loading/processing GPX files with
grep/cut).
# 2. It uses a brainless method for reading GPX files that assumes
that the GPX
# file contains lines with 'lat="<data>" lon="<data>"'.
# 3. The "headers" are copied, but all other data is ignored (like the
time).
# Create the output file
fname=argv{1};
i=findstr(fname,'.gpx');
fno=sprintf('%s_fixed.gpx',fname(1:i-1));
# Copy the header of the input file to the output file
fi=fopen(fname,'rb');
fo=fopen(fno,'wb');
start_track=0;
while !start_track
line=fgetl(fi);
if isempty(findstr(line,'<trk>'))
fprintf(fo,line);
else
start_track=1;
end
end
fclose(fi);
# Read the file using grep/cut (much faster than processed line by line)
cmd=sprintf('grep lat= %s | cut -d\'"\' -f 2,4 --output-delimiter=\'
\'',fname);
fi=popen(cmd,'r');
p=fscanf(fi,'%f');
p=reshape(p,[2 length(p)/2])';
fclose(fi);
# Approximate conversion factor from degrees to meters
pm=mean(p);
a=[1 cos(pm(1)*pi/180)]*40e6/360;
# Estimate the distances between subsequent track points
dp=p(2:end,:)-p(1:end-1,:);
dp=[a(1)*dp(:,1) a(2)*dp(:,2)];
d=sqrt(sum(dp'.^2)');
# Get a list of all distances that are larger than 50 m
f=find(d>50);
f=[f;size(p,1)];
# Output new tracks if the distance is larger than this 50 m
s=1;
for k=1:size(f)
r=s:f(k);
fprintf(fo,'<trk>\n<trkseg>\n');
fprintf(fo,'<trkpt lat="%.6f" lon="%.6f"></trkpt>\n',p(r,:)')
fprintf(fo,'</trkseg>\n</trk>\n');
s=f(k)+1;
end
# Properly close the file
fprintf(fo,'</gpx>\n');
fclose(fo);
More information about the josm-dev
mailing list