def add_tracks
      @tracks = []
      doc = Nokogiri::XML(@gpx_data)

      doc.css('xmlns|trk').each do |trk|
        track = Track.new
        trk.css('xmlns|trkpt').each do |trkpt|
          # https://en.wikipedia.org/wiki/GPS_Exchange_Format#Units
          # decimal degrees, wgs84.
          # elevation in meters.
          track.add_point(
            lat: trkpt.attributes['lat'].text.to_f,
            lon: trkpt.attributes['lon'].text.to_f,
            elevation: trkpt.at_css('xmlns|ele').text.to_f,
            time: Time.parse(trkpt.at_css('xmlns|time').text)
          )
        end
        @tracks << track
      end

      @intersegments = []
      @tracks.each_with_index do |track,i|
        next if i == 0

        this_track = track
        prev_track = @tracks[i-1]

        inter_track = Track.new
        inter_track.add_point(
          lat: prev_track.end_location[0],
          lon: prev_track.end_location[1],
          elevation: prev_track.end_location[2],
          time: prev_track.end_time
        )
        inter_track.add_point(
          lat: this_track.start_location[0],
          lon: this_track.start_location[1],
          elevation: this_track.start_location[2],
          time: this_track.start_time
        )
        @intersegments << inter_track
      end

      @tracks_added = true
    end
def add_tracks
      @tracks = []
      doc = Nokogiri::XML(@gpx_data)

      doc.css('xmlns|trk').each do |trk|
        track = Track.new
        trk.css('xmlns|trkpt').each do |trkpt|
          # https://en.wikipedia.org/wiki/GPS_Exchange_Format#Units
          # decimal degrees, wgs84.
          # elevation in meters.
          track.add_point(
            lat: trkpt.attributes['lat'].text.to_f,
            lon: trkpt.attributes['lon'].text.to_f,
            elevation: trkpt.at_css('xmlns|ele').text.to_f,
            time: Time.parse(trkpt.at_css('xmlns|time').text)
          )
        end
        @tracks << track
      end

      @intersegments = []
      @tracks.each_with_index do |track,i|
        next if i == 0

        this_track = track
        prev_track = @tracks[i-1]

        inter_track = Track.new
        inter_track.add_point(
          lat: prev_track.end_location[0],
          lon: prev_track.end_location[1],
          elevation: prev_track.end_location[2],
          time: prev_track.end_time
        )
        inter_track.add_point(
          lat: this_track.start_location[0],
          lon: this_track.start_location[1],
          elevation: this_track.start_location[2],
          time: this_track.start_time
        )
        @intersegments << inter_track
      end

      @tracks_added = true
    end
extract track data from gpx data

 it's not necessary to call this directly