Skip to content

Commit

Permalink
Merge 9f187fc into 4effbc1
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-krawczyk committed Sep 27, 2019
2 parents 4effbc1 + 9f187fc commit 4664901
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gga.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func newGGA(s BaseSentence) (GGA, error) {
return GGA{
BaseSentence: s,
Time: p.Time(0, "time"),
Latitude: p.LatLong(1, 2, "latitude"),
Longitude: p.LatLong(3, 4, "longitude"),
Latitude: p.Latitude(1, 2, "latitude"),
Longitude: p.Longitude(3, 4, "longitude"),
FixQuality: p.EnumString(5, "fix quality", Invalid, GPS, DGPS, PPS, RTK, FRTK, EST),
NumSatellites: p.Int64(6, "number of satellites"),
HDOP: p.Float64(7, "hdop"),
Expand Down
4 changes: 2 additions & 2 deletions gll.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func newGLL(s BaseSentence) (GLL, error) {
p.AssertType(TypeGLL)
return GLL{
BaseSentence: s,
Latitude: p.LatLong(0, 1, "latitude"),
Longitude: p.LatLong(2, 3, "longitude"),
Latitude: p.Latitude(0, 1, "latitude"),
Longitude: p.Longitude(2, 3, "longitude"),
Time: p.Time(4, "time"),
Validity: p.EnumString(5, "validity", ValidGLL, InvalidGLL),
}, p.Err()
Expand Down
4 changes: 2 additions & 2 deletions gns.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func newGNS(s BaseSentence) (GNS, error) {
m := GNS{
BaseSentence: s,
Time: p.Time(0, "time"),
Latitude: p.LatLong(1, 2, "latitude"),
Longitude: p.LatLong(3, 4, "longitude"),
Latitude: p.Latitude(1, 2, "latitude"),
Longitude: p.Longitude(3, 4, "longitude"),
Mode: p.EnumChars(5, "mode", NoFixGNS, AutonomousGNS, DifferentialGNS, PreciseGNS, RealTimeKinematicGNS, FloatRTKGNS, EstimatedGNS, ManualGNS, SimulatorGNS),
SVs: p.Int64(6, "SVs"),
HDOP: p.Float64(7, "HDOP"),
Expand Down
20 changes: 20 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ func (p *parser) LatLong(i, j int, context string) float64 {
return v
}

// Latitude returns the latitude value of the specified fields.
func (p *parser) Latitude(i, j int, context string) float64 {
l := p.LatLong(i, j, context)
if l < -90 || 90 < l {
p.SetErr(context, "latitude is not in range (-90, 90)")
return 0
}
return l
}

// Longitude returns the longitude value of the specified fields.
func (p *parser) Longitude(i, j int, context string) float64 {
l := p.LatLong(i, j, context)
if l < -180 || 180 < l {
p.SetErr(context, "longitude is not in range (-180, 180)")
return 0
}
return l
}

// SixBitASCIIArmour decodes the 6-bit ascii armor used for VDM and VDO messages
func (p *parser) SixBitASCIIArmour(i int, fillBits int, context string) []byte {
if p.err != nil {
Expand Down
4 changes: 2 additions & 2 deletions rmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func newRMC(s BaseSentence) (RMC, error) {
BaseSentence: s,
Time: p.Time(0, "time"),
Validity: p.EnumString(1, "validity", ValidRMC, InvalidRMC),
Latitude: p.LatLong(2, 3, "latitude"),
Longitude: p.LatLong(4, 5, "longitude"),
Latitude: p.Latitude(2, 3, "latitude"),
Longitude: p.Longitude(4, 5, "longitude"),
Speed: p.Float64(6, "speed"),
Course: p.Float64(7, "course"),
Date: p.Date(8, "date"),
Expand Down
4 changes: 2 additions & 2 deletions wpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func newWPL(s BaseSentence) (WPL, error) {
p.AssertType(TypeWPL)
return WPL{
BaseSentence: s,
Latitude: p.LatLong(0, 1, "latitude"),
Longitude: p.LatLong(2, 3, "longitude"),
Latitude: p.Latitude(0, 1, "latitude"),
Longitude: p.Longitude(2, 3, "longitude"),
Ident: p.String(4, "ident of nth waypoint"),
}, p.Err()
}

0 comments on commit 4664901

Please sign in to comment.