From 9751b6011ac9f840a3371d5aa50b90f48360728d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 19 Feb 2020 19:00:47 -0500 Subject: [PATCH] Convert ddmm.mmmm to -ddd.dddddd for consistency Signed-off-by: Sara Damiano --- src/TinyGsmClientSIM7600.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/TinyGsmClientSIM7600.h b/src/TinyGsmClientSIM7600.h index 7a53222..0f05a63 100644 --- a/src/TinyGsmClientSIM7600.h +++ b/src/TinyGsmClientSIM7600.h @@ -466,10 +466,12 @@ class TinyGsmSim7600 : public TinyGsmModem, streamSkipUntil(','); // GPS satellite valid numbers streamSkipUntil(','); // GLONASS satellite valid numbers streamSkipUntil(','); // BEIDOU satellite valid numbers - ilat = streamGetFloatBefore(','); // Latitude - streamSkipUntil(','); // N/S Indicator, N=north or S=south - ilon = streamGetFloatBefore(','); // Longitude - streamSkipUntil(','); // E/W Indicator, E=east or W=west + ilat = streamGetFloatBefore(','); // Latitude in ddmm.mmmmmm + char northSouth = stream.read(); // N/S Indicator, N=north or S=south + streamSkipUntil(','); + ilon = streamGetFloatBefore(','); // Longitude in ddmm.mmmmmm + char eastWest = stream.read(); // E/W Indicator, E=east or W=west + streamSkipUntil(','); // Date. Output format is ddmmyy iday = streamGetIntLength(2); // Two digit day @@ -492,8 +494,12 @@ class TinyGsmSim7600 : public TinyGsmModem, streamSkipUntil('\n'); // TODO(?) is one more field reported?? // Set pointers - if (lat != NULL) *lat = ilat; - if (lon != NULL) *lon = ilon; + if (lat != NULL) + *lat = (floor(ilat / 100) + fmod(ilat, 100.) / 60) * + (northSouth == 'N' ? 1 : -1); + if (lon != NULL) + *lon = (floor(ilon / 100) + fmod(ilon, 100.) / 60) * + (eastWest == 'E' ? 1 : -1); if (speed != NULL) *speed = ispeed; if (alt != NULL) *alt = static_cast(ialt); if (vsat != NULL) *vsat = ivsat;