gpx

package
v0.0.0-...-23fd4a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GPX

type GPX struct {
	XMLName  xml.Name `xml:"gpx"`
	Metadata Metadata `xml:"metadata"`
	Routes   []Route  `xml:"rte"`
	Tracks   []Track  `xml:"trk"`
}

GPX is the main structure for GPX files

func FromFile

func FromFile(inputPath *string) (GPX, error)

FromFile reads the contents of the supplied filepath and returns a structure of type GPX in case of success

func FromStdin

func FromStdin() (GPX, error)

FromStdin reads all data from Stdin and converts it into a GPX file structure

func (GPX) GetName

func (gpx GPX) GetName() string

GetName returns the name of the route, first trying to read it from the GPX metadata, and if not present here, from the first route. If both are empty, it will return "Unnamed Route"

type Metadata

type Metadata struct {
	XMLName     xml.Name `xml:"metadata"`
	Name        string   `xml:"name"`
	Time        string   `xml:"time"`
	Description string   `xml:"desc"`
}

Metadata contains some metadata from the GPX file

type Route

type Route struct {
	XMLName        xml.Name        `xml:"rte"`
	Name           string          `xml:"name"`
	Description    string          `xml:"desc"`
	RouteWaypoints []RouteWaypoint `xml:"rtept"`
}

Route contains details for a GPX route

type RouteWaypoint

type RouteWaypoint struct {
	XMLName     xml.Name `xml:"rtept"`
	Latitude    float64  `xml:"lat,attr"`
	Longitude   float64  `xml:"lon,attr"`
	Name        string   `xml:"name"`
	Description string   `xml:"desc"`
	Elevation   float64  `xml:"ele"`
}

RouteWaypoint contains details for a GPX route waypoint

type Track

type Track struct {
	XMLName  xml.Name       `xml:"trk"`
	Name     string         `xml:"name"`
	Segments []TrackSegment `xml:"trkseg"`
}

Track contains details for a GPX track

func (Track) CalcTotalDistance

func (track Track) CalcTotalDistance() float64

CalcTotalDistance calculates the distance of a GPX track in meters, also considering the elevation provided in the GPX file.

func (Track) CalcTotalDuration

func (track Track) CalcTotalDuration() (int64, error)

CalcTotalDuration calculates the amount of time you will need for this route, based on the time data provided in the track data of the GPX file this will return the duration in seconds

type TrackPoint

type TrackPoint struct {
	XMLName   xml.Name `xml:"trkpt"`
	Latitude  float64  `xml:"lat,attr"`
	Longitude float64  `xml:"lon,attr"`
	Elevation float64  `xml:"ele"`
	Time      string   `xml:"time"`
}

TrackPoint contains details for a GPX trackpoint

type TrackSegment

type TrackSegment struct {
	XMLName xml.Name     `xml:"trkseg"`
	Points  []TrackPoint `xml:"trkpt"`
}

TrackSegment contain details for a GPX track segment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL