Daniel de kock / TinyGPSplus

Dependents:   WNC_Pubnub_obd2b_ign_em506SoftSerial_RESETFE2 mbed_xbeetest

Files at this revision

API Documentation at this revision

Comitter:
Sir_Binky
Date:
Fri Jan 22 13:30:33 2016 +0000
Parent:
0:3407bd06cfae
Commit message:
added a "Binary" version of the lat and lng; Binary representation of the double;

Changed in this revision

TinyGPSplus.cpp Show annotated file Show diff for this revision Revisions of this file
TinyGPSplus.h Show annotated file Show diff for this revision Revisions of this file
diff -r 3407bd06cfae -r 9163a9f5fc36 TinyGPSplus.cpp
--- a/TinyGPSplus.cpp	Fri Jan 22 08:42:46 2016 +0000
+++ b/TinyGPSplus.cpp	Fri Jan 22 13:30:33 2016 +0000
@@ -366,6 +366,43 @@
    return rawLngData.negative ? -ret : ret;
 }
 
+int32_t TinyGPSLocation::latBinary()
+{
+   int32_t ret;
+   long double temp,lat;
+   lat = TinyGPSLocation::lat();
+    if( lat >= 0 ) // North
+    {    
+        temp = lat *  8388607;       // 2^23 - 1
+        ret = temp / 90;
+    }
+    else                // South
+    {    
+        temp = lat * 8388608;       // -2^23
+        ret = temp / 90;
+    }
+  return ret;
+}
+
+int32_t TinyGPSLocation::lngBinary()
+{
+   int32_t ret;
+   long double temp,lng;
+   lng = TinyGPSLocation::lng();
+   
+    if( lng >= 0 ) // East
+    {    
+        temp = lng * 8388607;        // 2^23 - 1 
+        ret = temp / 180;
+    }
+    else                // West
+    {    
+        temp = lng *  8388608;        // -2^23
+        ret = temp / 180;
+    }
+    return ret;
+}
+
 void TinyGPSDate::commit()
 {
    date = newDate;
diff -r 3407bd06cfae -r 9163a9f5fc36 TinyGPSplus.h
--- a/TinyGPSplus.h	Fri Jan 22 08:42:46 2016 +0000
+++ b/TinyGPSplus.h	Fri Jan 22 13:30:33 2016 +0000
@@ -61,6 +61,8 @@
    const RawDegrees &rawLng()     { updated = false; return rawLngData; }
    double lat();
    double lng();
+   int32_t lngBinary();
+   int32_t latBinary();
 
    TinyGPSLocation() : valid(false), updated(false)
    {}