@@ -127,14 +127,14 @@ int32_t TinyGPSPlus::parseDecimal(const char *term)
127127
128128// static
129129// Parse degrees in that funny NMEA format DDMM.MMMM
130- void TinyGPSPlus::parseDegrees (const char *term, int16_t °rees, uint32_t &billionths )
130+ void TinyGPSPlus::parseDegrees (const char *term, RawDegrees ° )
131131{
132132 uint32_t leftOfDecimal = (uint32_t )atol (term);
133133 uint16_t minutes = (uint16_t )(leftOfDecimal % 100 );
134134 uint32_t multiplier = 10000000UL ;
135135 uint32_t tenMillionthsOfMinutes = minutes * multiplier;
136136
137- degrees = (int16_t )(leftOfDecimal / 100 );
137+ deg. deg = (int16_t )(leftOfDecimal / 100 );
138138
139139 while (isdigit (*term))
140140 ++term;
@@ -146,7 +146,8 @@ void TinyGPSPlus::parseDegrees(const char *term, int16_t °rees, uint32_t &bil
146146 tenMillionthsOfMinutes += (*term - ' 0' ) * multiplier;
147147 }
148148
149- billionths = (5 * tenMillionthsOfMinutes + 1 ) / 3 ;
149+ deg.billionths = (5 * tenMillionthsOfMinutes + 1 ) / 3 ;
150+ deg.negative = false ;
150151}
151152
152153#define COMBINE (sentence_type, term_number ) (((unsigned )(sentence_type) << 5 ) | term_number)
@@ -233,21 +234,19 @@ bool TinyGPSPlus::endOfTermHandler()
233234 break ;
234235 case COMBINE (GPS_SENTENCE_GPRMC, 3 ): // Latitude
235236 case COMBINE (GPS_SENTENCE_GPGGA, 2 ):
236- location.setLatitude (term);
237+ location.setLatitude (term);
237238 break ;
238239 case COMBINE (GPS_SENTENCE_GPRMC, 4 ): // N/S
239240 case COMBINE (GPS_SENTENCE_GPGGA, 3 ):
240- if (term[0 ] == ' S' )
241- location.iNewLatDegrees = -location.iNewLatDegrees ;
241+ location.rawNewLatData .negative = term[0 ] == ' S' ;
242242 break ;
243243 case COMBINE (GPS_SENTENCE_GPRMC, 5 ): // Longitude
244244 case COMBINE (GPS_SENTENCE_GPGGA, 4 ):
245245 location.setLongitude (term);
246246 break ;
247247 case COMBINE (GPS_SENTENCE_GPRMC, 6 ): // E/W
248248 case COMBINE (GPS_SENTENCE_GPGGA, 5 ):
249- if (term[0 ] == ' W' )
250- location.iNewLngDegrees = -location.iNewLngDegrees ;
249+ location.rawNewLngData .negative = term[0 ] == ' W' ;
251250 break ;
252251 case COMBINE (GPS_SENTENCE_GPRMC, 7 ): // Speed (GPRMC)
253252 speed.set (term);
@@ -335,38 +334,34 @@ const char *TinyGPSPlus::cardinal(double course)
335334
336335void TinyGPSLocation::commit ()
337336{
338- iLatDegrees = iNewLatDegrees;
339- uLatBillionths = uNewLatBillionths;
340- iLngDegrees = iNewLngDegrees;
341- uLngBillionths = uNewLngBillionths;
337+ rawLatData = rawNewLatData;
338+ rawLngData = rawNewLngData;
342339 lastCommitTime = millis ();
343340 valid = updated = true ;
344341}
345342
346343void TinyGPSLocation::setLatitude (const char *term)
347344{
348- TinyGPSPlus::parseDegrees (term, iNewLatDegrees, uNewLatBillionths );
345+ TinyGPSPlus::parseDegrees (term, rawNewLatData );
349346}
350347
351348void TinyGPSLocation::setLongitude (const char *term)
352349{
353- TinyGPSPlus::parseDegrees (term, iNewLngDegrees, uNewLngBillionths );
350+ TinyGPSPlus::parseDegrees (term, rawNewLngData );
354351}
355352
356353double TinyGPSLocation::lat ()
357354{
358355 updated = false ;
359- return iLatDegrees > 0 ?
360- (iLatDegrees + uLatBillionths / 1000000000.0 ) :
361- (iLatDegrees - uLatBillionths / 1000000000.0 );
356+ double ret = rawLatData.deg + rawLatData.billionths / 1000000000.0 ;
357+ return rawLatData.negative ? -ret : ret;
362358}
363359
364360double TinyGPSLocation::lng ()
365361{
366362 updated = false ;
367- return iLngDegrees > 0 ?
368- (iLngDegrees + uLngBillionths / 1000000000.0 ) :
369- (iLngDegrees - uLngBillionths / 1000000000.0 );
363+ double ret = rawLngData.deg + rawLngData.billionths / 1000000000.0 ;
364+ return rawLngData.negative ? -ret : ret;
370365}
371366
372367void TinyGPSDate::commit ()
0 commit comments