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)