code: def to_gpx(self):
          
          gpx_segments = []
          for segment in self.segments:
              gpx_points = []
              for point in segment.points:
                  time = ''
                  if point.time:
                      iso_time = point.time.isoformat().split('.')[0]
                      time = '<time>%s</time>' % iso_time
                  gpx_points.append(
                      u'<trkpt lat="%f" lon="%f">%s</trkpt>' % (point.lat, point.lon, time)
                  )
              points = u'\n\t\t\t'.join(gpx_points)
              gpx_segments.append(u'\t\t<trkseg>\n\t\t\t%s\n\t\t</trkseg>' % points)
          segments = u'\t\n'.join(gpx_segments)
          content = [
              u'<?xml version="1.0" encoding="UTF-8"?>',
              u'<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" version="1.0" creator="GatherMySteps">',
              u'\t<trk>',
              segments,
              u'\t</trk>',
              u'</gpx>'
          ]
  
          return u'\n'.join(content)
docs: Converts track to a GPX format
  
          Uses GPXPY library as an intermediate format
  
          Returns:
              A string with the GPX/XML track