diff --git a/lib/gpx/segment.rb b/lib/gpx/segment.rb index 0cb68d4..6b895d6 100644 --- a/lib/gpx/segment.rb +++ b/lib/gpx/segment.rb @@ -48,8 +48,10 @@ module GPX unless segment_element.is_a?(Text) XPath.each(segment_element, "child::trkpt") do |trkpt| pt = TrackPoint.new(:element => trkpt, :segment => self) - @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)