Fixing more nil time exceptions.

master
Doug Fales 2006-12-03 07:31:18 +00:00
parent a60385ba51
commit fcf2b9e9a9
2 changed files with 9 additions and 5 deletions

View File

@ -90,9 +90,11 @@ module GPX
pt = Element.new('trkpt') pt = Element.new('trkpt')
pt.attributes['lat'] = lat pt.attributes['lat'] = lat
pt.attributes['lon'] = lon pt.attributes['lon'] = lon
unless time.nil?
time_elem = Element.new('time') time_elem = Element.new('time')
time_elem.text = time.xmlschema time_elem.text = time.xmlschema
pt.elements << time_elem pt.elements << time_elem
end
elev = Element.new('ele') elev = Element.new('ele')
elev.text = elevation elev.text = elevation
pt.elements << elev pt.elements << elev

View File

@ -204,8 +204,10 @@ module GPX
end end
def update_meta_data(pt, last_pt) def update_meta_data(pt, last_pt)
unless pt.time.nil?
@earliest_point = pt if(@earliest_point.nil? or pt.time < @earliest_point.time) @earliest_point = pt if(@earliest_point.nil? or pt.time < @earliest_point.time)
@latest_point = pt if(@latest_point.nil? or pt.time > @latest_point.time) @latest_point = pt if(@latest_point.nil? or pt.time > @latest_point.time)
end
unless pt.elevation.nil? unless pt.elevation.nil?
@lowest_point = pt if(@lowest_point.nil? or pt.elevation < @lowest_point.elevation) @lowest_point = pt if(@lowest_point.nil? or pt.elevation < @lowest_point.elevation)
@highest_point = pt if(@highest_point.nil? or pt.elevation > @highest_point.elevation) @highest_point = pt if(@highest_point.nil? or pt.elevation > @highest_point.elevation)