From fcf2b9e9a9e0182b7ed5b2b5cf682cd88965b7a5 Mon Sep 17 00:00:00 2001 From: Doug Fales Date: Sun, 3 Dec 2006 07:31:18 +0000 Subject: [PATCH] Fixing more nil time exceptions. --- lib/gpx/point.rb | 8 +++++--- lib/gpx/segment.rb | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/gpx/point.rb b/lib/gpx/point.rb index 8aa0565..e697bf5 100644 --- a/lib/gpx/point.rb +++ b/lib/gpx/point.rb @@ -90,9 +90,11 @@ module GPX pt = Element.new('trkpt') pt.attributes['lat'] = lat pt.attributes['lon'] = lon - time_elem = Element.new('time') - time_elem.text = time.xmlschema - pt.elements << time_elem + unless time.nil? + time_elem = Element.new('time') + time_elem.text = time.xmlschema + pt.elements << time_elem + end elev = Element.new('ele') elev.text = elevation pt.elements << elev diff --git a/lib/gpx/segment.rb b/lib/gpx/segment.rb index 43dbc45..ed83056 100644 --- a/lib/gpx/segment.rb +++ b/lib/gpx/segment.rb @@ -204,8 +204,10 @@ module GPX end def update_meta_data(pt, last_pt) - @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) + unless pt.time.nil? + @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) + end unless pt.elevation.nil? @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)