You have been subscribed to a public bug:

Upon opening a .gpx file I got the message :

$ gpxviewer 
Traceback (most recent call last):
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 300, in onTrackAdded
    self.selectTrace(trace)
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 347, in selectTrace
    distance = trace.get_distance()
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 153, in get_distance
    return self._get_cached_value("distance")
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 99, in _get_cached_value
    self._walk_points()
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 75, in _walk_points
    d = calculate_distance(point['lat'], pointp['lat'], point['lon'], 
pointp['lon'])
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 36, in calculate_distance
    arc = acos((sin(lat1) * sin(lat2)) + (cos(lat1) * cos(lat2) * cos(lon2 - 
lon1)))
ValueError: math domain error

I inserted the line :

print "lat1=",lat1, "lat2=",lat2, "lon1=",lon1, "lon2=",lon2

And got :

.....
lat1= -22.951462 lat2= -22.951447 lon1= -43.356941 lon2= -43.356937
lat1= -22.951469 lat2= -22.951462 lon1= -43.356941 lon2= -43.356941
lat1= -22.951469 lat2= -22.951469 lon1= -43.356941 lon2= -43.356941
Traceback (most recent call last):
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 300, in onTrackAdded
    self.selectTrace(trace)
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 347, in selectTrace
    distance = trace.get_distance()
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 156, in get_distance
    return self._get_cached_value("distance")
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 102, in _get_cached_value
    self._walk_points()
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 78, in _walk_points
    d = calculate_distance(point['lat'], pointp['lat'], point['lon'], 
pointp['lon'])
  File "/usr/share/gpxviewer/gpxviewer/gpx.py", line 39, in calculate_distance
    arc = acos((sin(lat1) * sin(lat2)) + (cos(lat1) * cos(lat2) * cos(lon2 - 
lon1)))
ValueError: math domain error

Interactively computing the value I got :

>>> ((sin(lat1) * sin(lat2)) + (cos(lat1) * cos(lat2) * cos(lon2 - lon1)))
1.0000000000000002

This seems to be a typical perversion of floating point rounding error.
Do not seems too complicated to fix.

Something like the patch I am attaching.

** Affects: ubuntu
     Importance: Undecided
         Status: New


** Tags: valueerror
-- 
rounding error interrupts GPXViewer
https://bugs.launchpad.net/bugs/832059
You received this bug notification because you are a member of Ubuntu Bugs, 
which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to