Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Add additional schema locations to fix Garmin Connect import problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Metalnem committed Nov 30, 2016
1 parent 6f83652 commit eaa0d11
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"log"
"os"
"strings"
"time"

"github.com/metalnem/runtastic/api"
Expand All @@ -27,6 +28,15 @@ var (

// Error is used for logging errors.
Error = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime)

schemaLocation = strings.Join([]string{
"http://www.topografix.com/GPX/1/1",
"http://www.topografix.com/GPX/1/1/gpx.xsd",
"http://www.garmin.com/xmlschemas/GpxExtensions/v3",
"http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd",
"http://www.garmin.com/xmlschemas/TrackPointExtension/v1",
"http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd",
}, " ")
)

type rfc3339Time struct {
Expand All @@ -43,11 +53,11 @@ type trackPoint struct {

type gpx struct {
XMLName xml.Name `xml:"http://www.topografix.com/GPX/1/1 gpx"`
SchemaInstance string `xml:"xmlns:xsi,attr"`
SchemaLocation string `xml:"xsi:schemaLocation,attr"`
Extension string `xml:"xmlnss:gpxtpx,attr"`
Version float32 `xml:"version,attr"`
Creator string `xml:"creator,attr"`
SchemaInstance string `xml:"xmlns:xsi,attr"`
SchemaLocation string `xml:"xsi:schemaLocation,attr"`
Extension string `xml:"xmlns:gpxtpx,attr"`
Time rfc3339Time `xml:"metadata>time"`
TrackPoints []trackPoint `xml:"trk>trkseg>trkpt"`
}
Expand Down Expand Up @@ -123,7 +133,7 @@ func archive(filename string, activities []api.Activity) (err error) {

data := gpx{
SchemaInstance: "http://www.w3.org/2001/XMLSchema-instance",
SchemaLocation: "http://www.topografix.com/GPX/1/1",
SchemaLocation: schemaLocation,
Extension: "http://www.garmin.com/xmlschemas/TrackPointExtension/v1",
Version: 1.1,
Creator: "Runtastic Archiver, https://github.com/Metalnem/runtastic",
Expand Down

0 comments on commit eaa0d11

Please sign in to comment.