rounding error interrupts GPXViewer
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gpxviewer (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Upon opening a .gpx file I got the message :
$ gpxviewer
Traceback (most recent call last):
File "/usr/share/
self.
File "/usr/share/
distance = trace.get_
File "/usr/share/
return self._get_
File "/usr/share/
self.
File "/usr/share/
d = calculate_
File "/usr/share/
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/
self.
File "/usr/share/
distance = trace.get_
File "/usr/share/
return self._get_
File "/usr/share/
self.
File "/usr/share/
d = calculate_
File "/usr/share/
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: | gpxviewer → ubuntu |
tags: | added: patch |
Changed in gpxviewer (Ubuntu): | |
status: | Incomplete → Confirmed |
Could you please specify which version are you using? Is the bug still reproducible?