Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GeoPosition.h
00001 #ifndef __GEOPOSITION_H 00002 #define __GEOPOSITION_H 00003 00004 #ifndef _PI 00005 #define _PI 3.141592653 00006 #endif 00007 00008 #define degrees(x) ((x)*180/_PI) 00009 #define radians(x) ((x)*_PI/180) 00010 00011 /** Geographical position and calculation. Most of this comes from http://www.movable-type.co.uk/scripts/latlong.html 00012 * 00013 */ 00014 class GeoPosition { 00015 public: 00016 00017 /** Create a new emtpy position object 00018 * 00019 */ 00020 GeoPosition(); 00021 00022 /** Create a new position with the specified latitude and longitude. See set() 00023 * 00024 * @param latitude is the latitude to set 00025 * @param longitude is the longitude to set 00026 */ 00027 GeoPosition(double latitude, double longitude); 00028 00029 /** Get the position's latitude 00030 * 00031 * @returns the position's latitude 00032 */ 00033 double latitude(); 00034 00035 /** Get the position's longitude 00036 * 00037 * @returns the position's longitude 00038 */ 00039 double longitude(); 00040 00041 /** Set the position's location to another position's coordinates 00042 * 00043 * @param pos is another position from which coordinates will be copied 00044 */ 00045 void set(GeoPosition pos); 00046 00047 /** Set the position's location to the specified coordinates 00048 * 00049 * @param latitude is the new latitude to set 00050 * @param longitude is the new longitude to set 00051 */ 00052 void set(double latitude, double longitude); 00053 00054 /** Move the location of the position by the specified distance and in 00055 * the specified direction 00056 * 00057 * @param course is the direction of movement in degrees, absolute not relative 00058 * @param distance is the distance of movement along the specified course in meters 00059 */ 00060 void move(float course, float distance); 00061 00062 /** Get the bearing from the specified origin position to this position. To get 00063 * relative bearing, subtract the result from your heading. 00064 * 00065 * @param from is the position from which to calculate bearing 00066 * @returns the bearing in degrees 00067 */ 00068 float bearing(GeoPosition from); 00069 00070 /** Get the distance from the specified origin position to this position 00071 * 00072 * @param from is the position from which to calculate distance 00073 * @returns the distance in meters 00074 */ 00075 float distance(GeoPosition from); 00076 00077 /** Set an arbitrary timestamp on the position 00078 * 00079 * @param timestamp is an integer timestamp, eg., seconds, milliseconds, or whatever 00080 */ 00081 void setTimestamp(int time); 00082 00083 /** Return a previously set timestamp on the position 00084 * 00085 * @returns the timestamp (e.g., seconds, milliseconds, etc.) 00086 */ 00087 int getTimestamp(void); 00088 00089 private: 00090 double _R; /** Earth's mean radius */ 00091 double _latitude; /** The position's latitude */ 00092 double _longitude; /** The position's longitude */ 00093 double _northing; /** The position's UTM northing coordinate */ 00094 double _easting; /** The position's UTM easting coordinate */ 00095 int _time; /** Timestamp */ 00096 }; 00097 00098 #endif
Generated on Wed Jul 13 2022 20:50:53 by
1.7.2