go-nmea

A NMEA parser library in pure Go

Github星跟蹤圖

go-nmea Build Status Go Report Card Coverage Status GoDoc

This is a NMEA library for the Go programming language (http://golang.org).

Installing

Using go get

go get github.com/adrianmo/go-nmea

After this command go-nmea is ready to use. Its source will be in:

$GOPATH/src/github.com/adrianmo/go-nmea

Supported sentences

At this moment, this library supports the following sentence types:

  • RMC - Recommended Minimum Specific GPS/Transit data
  • PMTK - Messages for setting and reading commands for MediaTek gps modules.
  • GGA - GPS Positioning System Fix Data
  • GSA - GPS DOP and active satellites
  • GSV - GPS Satellites in view
  • GLL - Geographic Position, Latitude / Longitude and time
  • VTG - Track Made Good and Ground Speed
  • ZDA - Date & time data
  • HDT - Actual vessel heading in degrees True
  • GNS - Combined GPS fix for GPS, Glonass, Galileo, and BeiDou
  • PGRME - Estimated Position Error (Garmin proprietary sentence)
  • THS - Actual vessel heading in degrees True and status
  • VDM/VDO - Encapsulated binary payload
  • WPL - Waypoint location
  • RTE - Route
  • VHW - Water Speed and Heading

Example

package main

import (
	"fmt"
	"log"
	"github.com/adrianmo/go-nmea"
)

func main() {
	sentence := "$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70"
	s, err := nmea.Parse(sentence)
	if err != nil {
		log.Fatal(err)
	}
	if s.DataType() == nmea.TypeRMC {
		m := s.(nmea.RMC)
		fmt.Printf("Raw sentence: %v\n", m)
		fmt.Printf("Time: %s\n", m.Time)
		fmt.Printf("Validity: %s\n", m.Validity)
		fmt.Printf("Latitude GPS: %s\n", nmea.FormatGPS(m.Latitude))
		fmt.Printf("Latitude DMS: %s\n", nmea.FormatDMS(m.Latitude))
		fmt.Printf("Longitude GPS: %s\n", nmea.FormatGPS(m.Longitude))
		fmt.Printf("Longitude DMS: %s\n", nmea.FormatDMS(m.Longitude))
		fmt.Printf("Speed: %f\n", m.Speed)
		fmt.Printf("Course: %f\n", m.Course)
		fmt.Printf("Date: %s\n", m.Date)
		fmt.Printf("Variation: %f\n", m.Variation)
	}
}

Output:

$ go run main/main.go

Raw sentence: $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
Time: 22:05:16.0000
Validity: A
Latitude GPS: 5133.8200
Latitude DMS: 51° 33' 49.200000"
Longitude GPS: 042.2400
Longitude DMS: 0° 42' 14.400000"
Speed: 173.800000
Course: 231.800000
Date: 13/06/94
Variation: -4.200000

Contributions

Please, feel free to implement support for new sentences, fix bugs, refactor code, etc. and send a pull-request to update the library.

主要指標

概覽
名稱與所有者adrianmo/go-nmea
主編程語言Go
編程語言Go (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2015-07-22 08:55:54
推送於2024-12-09 14:22:53
最后一次提交2024-12-09 06:22:52
發布數13
最新版本名稱v1.10.0 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數244
關注者數11
派生數80
提交數232
已啟用問題?
問題數30
打開的問題數1
拉請求數69
打開的拉請求數0
關閉的拉請求數19
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?