https://github.com/twpayne/go-gpx
Package gpx provides convenience types for reading and writing GPX files.
https://github.com/twpayne/go-gpx
geospatial gis go golang gpx
Last synced: 11 months ago
JSON representation
Package gpx provides convenience types for reading and writing GPX files.
- Host: GitHub
- URL: https://github.com/twpayne/go-gpx
- Owner: twpayne
- License: mit
- Created: 2016-04-24T17:12:42.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-12-25T14:41:42.000Z (over 1 year ago)
- Last Synced: 2025-04-02T00:34:53.231Z (over 1 year ago)
- Topics: geospatial, gis, go, golang, gpx
- Language: Go
- Homepage:
- Size: 123 KB
- Stars: 40
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-gpx
[](https://pkg.go.dev/github.com/twpayne/go-gpx)
Package `gpx` provides convenince methods for reading and writing GPX documents.
## Read example
```go
r := bytes.NewBufferString(`
44.586548
5066
5066
Crossing
Crossing
`)
t, err := gpx.Read(r)
if err != nil {
fmt.Printf("err == %v", err)
return
}
fmt.Printf("t.Wpt[0] == %+v", t.Wpt[0])
// Output:
// t.Wpt[0] == &{Lat:42.438878 Lon:-71.119277 Ele:44.586548 Speed:0 Course:0 Time:2001-11-28 21:05:28 +0000 UTC MagVar:0 GeoidHeight:0 Name:5066 Cmt: Desc:5066 Src: Link:[] Sym:Crossing Type:Crossing Fix: Sat:0 HDOP:0 VDOP:0 PDOP:0 AgeOfDGPSData:0 DGPSID:[] Extensions:}
```
## Write example
```go
g := &gpx.GPX{
Version: "1.1",
Creator: "ExpertGPS 1.1 - http://www.topografix.com",
Wpt: []*gpx.WptType{
{
Lat: 42.438878,
Lon: -71.119277,
Ele: 44.586548,
Time: time.Date(2001, 11, 28, 21, 5, 28, 0, time.UTC),
Name: "5066",
Desc: "5066",
Sym: "Crossing",
Type: "Crossing",
},
},
}
if _, err := os.Stdout.WriteString(xml.Header); err != nil {
fmt.Printf("err == %v", err)
}
if err := g.WriteIndent(os.Stdout, "", " "); err != nil {
fmt.Printf("err == %v", err)
}
// Output:
//
//
//
// 44.586548
//
// 5066
// 5066
// Crossing
// Crossing
//
//
```
## License
MIT