|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Establishing Direction of Travel / Bearing (Python)I'm currently writing a script in Python which records the longitude,
latitude and speed from the GPS device. What I'd like to do is also record the direction of travel / bearing for each hit (ie. North, South, East, West). I've tried researching this but to no avail. Any suggestions on how this can be implemented or does anyone have any examples of Python code containing bearings? Thanks GPSD-gurus :) _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)On Thu, 3 Nov 2011 19:37:06 +0000
Neil Greenough <neilgreenough@...> wrote: > I'm currently writing a script in Python which records the longitude, > latitude and speed from the GPS device. What I'd like to do is also > record the direction of travel / bearing for each hit (ie. North, > South, East, West). I've tried researching this but to no avail. Any > suggestions on how this can be implemented or does anyone have any > examples of Python code containing bearings? Direction of travel, or heading, and bearing are not the same thing. Heading is the direction in which you are moving, i.e. your course made good. Bearing is the angle from the heading to a feature. That nitpick aside... In C: if (gpsdata.set & TRACK_SET) { formatTrack (gpsdata.fix.track); } gpsdata.fix.track is a double, and seems to be a value in the range 0 to 360, of degrees from true north, where 0 and 360 are both true north. (To be really pedantic, it should be either 0-359 or 1-360, but I actually prefer the extra degree.) -- Charles Curley /"\ ASCII Ribbon Campaign Looking for fine software \ / Respect for open standards and/or writing? X No HTML/RTF in email http://www.charlescurley.com / \ No M$ Word docs in email Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)Here's my snippet of code that does both distance and heading (although I
think in terms of bearings, not headings): track = gpsdata->fix.track; speed = gpsdata->fix.speed; ... if (speed < 0.3 ) sprintf(brg, ""); else if (track < 1.0) sprintf (brg, "N"); else if (track < 89.0) sprintf (brg, "N%.0fE", track); else if (track < 91.0) sprintf (brg, "E"); else if (track < 179.0) sprintf (brg, "S%.0fE", 180.0 - track); else if (track < 181.0) sprintf (brg, "S"); else if (track < 269.0) sprintf (brg, "S%.0fW", track - 180.0); else if (track < 271.0) sprintf (brg, "W"); else if (track < 359.0) sprintf (brg, "N%.0fW", 360 - track); else sprintf (brg, "N"); if(speed < 0.5) sprintf (info, "stopped"); else sprintf (info, "\"%s %.0f MPH\"", brg, speed * 2.237); If you keep track of the last lat & long you can also get the distance: double haversine_mi (double lat1, double long1, double lat2, double long2) { double d2r = 0.0174532925; double dlong = (long2 - long1) * d2r; double dlat = (lat2 - lat1) * d2r; double a = pow (sin (dlat / 2.0), 2) + cos (lat1 * d2r) * cos (lat2 * d2r) * pow (sin (dlong / 2.0), 2); double c = 2 * atan2 (sqrt (a), sqrt (1 - a)); double d = 3956 * c; return d; } (Sorry it's C code but it should all translate to python). On Thu, November 3, 2011 1:06 pm, Charles Curley wrote: > On Thu, 3 Nov 2011 19:37:06 +0000 > Neil Greenough <neilgreenough@...> wrote: > >> I'm currently writing a script in Python which records the longitude, >> latitude and speed from the GPS device. What I'd like to do is also >> record the direction of travel / bearing for each hit (ie. North, >> South, East, West). I've tried researching this but to no avail. Any >> suggestions on how this can be implemented or does anyone have any >> examples of Python code containing bearings? > > Direction of travel, or heading, and bearing are not the same thing. > Heading is the direction in which you are moving, i.e. your course > made good. Bearing is the angle from the heading to a feature. > > That nitpick aside... In C: > > if (gpsdata.set & TRACK_SET) { > formatTrack (gpsdata.fix.track); > } > > gpsdata.fix.track is a double, and seems to be a value in the range 0 to > 360, of degrees from true north, where 0 and 360 are both true north. > (To be really pedantic, it should be either 0-359 or 1-360, but I > actually prefer the extra degree.) > > > > -- > > Charles Curley /"\ ASCII Ribbon Campaign > Looking for fine software \ / Respect for open standards > and/or writing? X No HTML/RTF in email > http://www.charlescurley.com / \ No M$ Word docs in email > > Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB > _______________________________________________ > Gpsd-users mailing list > Gpsd-users@... > https://lists.berlios.de/mailman/listinfo/gpsd-users > > !DSPAM:4eb2f44e263845133180498! > > -- Pain is temporary. It may last a minute, or an hour, or a day, or a year, but eventually it will subside and something else will take its place. If I quit, however, it lasts forever. _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)As a nit, my memory from reading the glossary at the back of Bowditch is
that heading is the direction the vessel is pointing and course is the direction it is moving. For cars these are pretty close unless you are driving really hard... _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Yo Greg! On Thu, 3 Nov 2011, Greg Troxel wrote: > As a nit, my memory from reading the glossary at the back of Bowditch is > that heading is the direction the vessel is pointing and course is the > direction it is moving. For cars these are pretty close unless you are > driving really hard... To be overly pedantic, with help from Google: http://lists.kjsl.com/pipermail/beech-owners/2008-February/068608.html I did find my copies of Bowditch for Yachtsmen: Piloting and Dutton's Navigation and Piloting by Hill, Utegaard and Riordan. The latter book is used in the navigation courses at USNA. Air navigation is derived from marine navigation. From Dutton's: "Course...is the direction in which a ship is to be steered or is steering. The course may be designated as true, magnetic, compass, or grid as its reference direction is true, magnetic, compass, or grid north respectively, and it expressed as an angle from that reference direction from 000deg clockwise through 360deg." "Heading .... is the dirction in which the ship (sic) actually points or heads at any particular instant"...."Heading should not be confused with course. A ship is frequently off the course, but it is never off the heading." "Bearing is the horizontal direction of one point from another." "Track is the direction of an intended track measured from 000deg at north clockwise through 360deg." And slightly different definitions for airplanes: An old copy of the AIM defines: Course: "The intended direction of flight in the horizontal plane measured in degrees from North." Bearing: "The horizontal dirction to or trom any point, usually measured clockwise from true north, magnetic north, or some other reference point through 360 degrees." Track: "The actual flight path of an aircraft over the surface of the earth." I don't actually find a definition of Heading in the AIM! RGDS GARY - --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701 gem@... Tel:+1(541)382-8588 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFOswPVBmnRqz71OvMRAkXDAJ9zdI+OLXK4m90RYStqHUmkNicyTQCdHL5S /DL2b8aQKQfQ/2Focc8vjBg= =I/RY -----END PGP SIGNATURE----- _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)On Thu, 03 Nov 2011 16:44:09 -0400
Greg Troxel <gdt@...> wrote: > As a nit, my memory from reading the glossary at the back of Bowditch > is that heading is the direction the vessel is pointing and course is > the direction it is moving. For cars these are pretty close unless > you are driving really hard... I stand corrected. It's been a while since I've sailed close hauled in a strong wind, and seen the difference up close. Thank you. -- Charles Curley /"\ ASCII Ribbon Campaign Looking for fine software \ / Respect for open standards and/or writing? X No HTML/RTF in email http://www.charlescurley.com / \ No M$ Word docs in email Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)On Thu, 3 Nov 2011 14:12:49 -0700 (PDT)
"Gary E. Miller" <gem@...> wrote: > Bearing: "The horizontal dirction to or trom any point, usually ^^^^ from I claim coup on pedantry points. -- Charles Curley /"\ ASCII Ribbon Campaign Looking for fine software \ / Respect for open standards and/or writing? X No HTML/RTF in email http://www.charlescurley.com / \ No M$ Word docs in email Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
|
|
Re: Establishing Direction of Travel / Bearing (Python)-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Yo Charels! You have to take that up with the guy that wrote the email I quoted. I decided against adding [sic]s. RGDS GARY - --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701 gem@... Tel:+1(541)382-8588 On Thu, 3 Nov 2011, Charles Curley wrote: > Date: Thu, 3 Nov 2011 15:21:18 -0600 > From: Charles Curley <charlescurley@...> > To: gpsd-users@... > Subject: Re: [Gpsd-users] Establishing Direction of Travel / Bearing (Python) > > On Thu, 3 Nov 2011 14:12:49 -0700 (PDT) > "Gary E. Miller" <gem@...> wrote: > > > Bearing: "The horizontal dirction to or trom any point, usually > ^^^^ > from > > I claim coup on pedantry points. > > -- > > Charles Curley /"\ ASCII Ribbon Campaign > Looking for fine software \ / Respect for open standards > and/or writing? X No HTML/RTF in email > http://www.charlescurley.com / \ No M$ Word docs in email > > Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB > _______________________________________________ > Gpsd-users mailing list > Gpsd-users@... > https://lists.berlios.de/mailman/listinfo/gpsd-users > > Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFOswbOBmnRqz71OvMRAgSKAKDkNNVXBtqYvtKWGqQO0MbuqGSKJwCghwgi NKqhPNbByTBG7b4w32ffUnQ= =fHxs -----END PGP SIGNATURE----- _______________________________________________ Gpsd-users mailing list Gpsd-users@... https://lists.berlios.de/mailman/listinfo/gpsd-users |
| Free embeddable forum powered by Nabble | Forum Help |