TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
GPSCoordinate Class Reference

Represents a geodetic GPS coordinate with latitude, longitude, and optional altitude. More...

#include <GPSCoordinate.h>

Public Member Functions

 GPSCoordinate (float lat, float lon, float alt=0)
 
bool isValid () const
 Check if the values are valid.
 
 operator bool () const
 Check if the values are valid.
 
float distance (const GPSCoordinate &other, DistanceUnit unit=DistanceUnit::M) const
 Calculate distance to other GPS coordinate.
 
float bearing (const GPSCoordinate &other, AngleUnit unit=AngleUnit::DEG) const
 
float elevation (const GPSCoordinate &other, AngleUnit unit=AngleUnit::DEG) const
 
float altitudeDifference (const GPSCoordinate &other) const
 
GPSCoordinate navigate (Distance distance, Angle bearing, Distance altDiff) const
 Calculate a new GPS coordinate given a distance (in meters) and bearing.
 
GPSCoordinate navigate (float distance_m, float bearing_deg, float alt_diff_m=0) const
 Calculate a new GPS coordinate given a distance (in meters) and bearing.
 
bool equals (const GPSCoordinate &other, float limit) const
 
bool equalsWithAltitude (const GPSCoordinate &other, float limit, float altLimit) const
 
std::string toString () const
 Serialize GPS coordinate to string representation.
 
bool fromString (const std::string &str)
 
const char * getTypeName () const
 

Public Attributes

float latitude = 360
 
float longitude = 360
 
float altitude = 0
 

Protected Member Functions

float bearingDegree (const GPSCoordinate &other) const
 
float elevationDeg (const GPSCoordinate &other) const
 
float distanceM (const GPSCoordinate &other) const
 Distance in meters between this coordinate and another GPS coordinate.
 

Detailed Description

Represents a geodetic GPS coordinate with latitude, longitude, and optional altitude.

The GPSCoordinate class encapsulates a single point on Earth using WGS84 latitude and longitude (in degrees), and optional altitude (in meters). It provides methods for:

Fields:

Usage:

Example: GPSCoordinate a(48.8584, 2.2945, 35); // Eiffel Tower GPSCoordinate b(51.5007, -0.1246, 15); // London float dist = a.distance(b); // meters float brng = a.bearing(b); // degrees GPSCoordinate c = a.navigate(1000, 90); // 1km east

This class is suitable for robotics, mapping, navigation, and geospatial applications on embedded or desktop systems.

Member Function Documentation

◆ altitudeDifference()

float altitudeDifference ( const GPSCoordinate other) const
inline

Calculate the altitude difference in meters between this coordinate and another

◆ bearing()

float bearing ( const GPSCoordinate other,
AngleUnit  unit = AngleUnit::DEG 
) const
inline

Calculate the bearing (heading) in degrees from this coordinate to another GPS coordinate.

◆ bearingDegree()

float bearingDegree ( const GPSCoordinate other) const
inlineprotected

Calculate the bearing (heading) in degrees from this coordinate to another GPS coordinate.

◆ elevation()

float elevation ( const GPSCoordinate other,
AngleUnit  unit = AngleUnit::DEG 
) const
inline

Calculate the elevation angle in degrees from this coordinate to another GPS coordinate.

◆ equals()

bool equals ( const GPSCoordinate other,
float  limit 
) const
inline

Compare two GPS coordinates for proximity within a specified distance limit

◆ equalsWithAltitude()

bool equalsWithAltitude ( const GPSCoordinate other,
float  limit,
float  altLimit 
) const
inline

Compare two GPS coordinates for proximity within specified distance and altitude limits

◆ fromString()

bool fromString ( const std::string &  str)
inline

load GPS coordinate from string representation (must match toString() format)


The documentation for this class was generated from the following file: