nmea gps library - without any serial

Dependents:   HARP2 HARP3 20180621_FT813

Fork of GPS_parser by Tyler Weaver

NMEA GPS Serial Output parser.

Routine taken from NMEA Software Standard (NMEA 0183) http://www.winsystems.com/software/nmea.pdf

Only handles GGA and RMC Messages

Files at this revision

API Documentation at this revision

Comitter:
tylerjw
Date:
Mon Dec 17 23:42:13 2012 +0000
Parent:
9:9b2351e25a84
Commit message:
publish

Changed in this revision

nmea_parser.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 9b2351e25a84 -r a6e1707fdec0 nmea_parser.cpp
--- a/nmea_parser.cpp	Mon Dec 17 22:11:24 2012 +0000
+++ b/nmea_parser.cpp	Mon Dec 17 23:42:13 2012 +0000
@@ -162,40 +162,18 @@
 {
     const double d2r = PI / 180.0;
     const double r2d = 180.0 / PI;
-    double dlat = abs(pointLat - calc_dec_latitude()) * d2r;
-    double dlong = abs(pontLong - calc_dec_longitude()) * d2r;
+    double calc_latitude = calc_dec_latitude();
+    double calc_longitude = calc_dec_longitude();
+    
+    double dlat = abs(pointLat - calc_latitude) * d2r;
+    double dlong = abs(pontLong - calc_longitude) * d2r;
     double y = sin(dlong) * cos(pointLat * d2r);
-    double x = cos(calc_dec_latitude()*d2r)*sin(pointLat*d2r) - sin(calc_dec_latitude()*d2r)*cos(pointLat*d2r)*cos(dlong);
+    double x = cos(calc_latitude*d2r)*sin(pointLat*d2r) - sin(calc_latitude*d2r)*cos(pointLat*d2r)*cos(dlong);
     return 360.0-(atan2(y,x)*r2d);
+    
+    // (atan2(y,x*r2d) + 360.0) % 360.0 ??? http://www.movable-type.co.uk/scripts/latlong.html
 }
 
-/*
-var y = Math.sin(dLon) * Math.cos(lat2);
-var x = Math.cos(lat1)*Math.sin(lat2) -
-        Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
-var brng = Math.atan2(y, x).toDeg();
-*/
-
-/*
-            The Haversine formula according to Dr. Math.
-            http://mathforum.org/library/drmath/view/51879.html
-
-            dlon = lon2 - lon1
-            dlat = lat2 - lat1
-            a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
-            c = 2 * atan2(sqrt(a), sqrt(1-a))
-            d = R * c
-
-            Where
-                * dlon is the change in longitude
-                * dlat is the change in latitude
-                * c is the great circle distance in Radians.
-                * R is the radius of a spherical Earth.
-                * The locations of the two points in
-                    spherical coordinates (longitude and
-                    latitude) are lon1,lat1 and lon2, lat2.
-*/
-
 double NmeaParser::calc_dist_to_mi(float pointLat, float pontLong)
 {
     const double d2r = PI / 180.0;