QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCGeo Namespace Reference

Functions

void convertGeoToNed (const QGeoCoordinate &coord, const QGeoCoordinate &origin, double &x, double &y, double &z)
void convertNedToGeo (double x, double y, double z, const QGeoCoordinate &origin, QGeoCoordinate &coord)
QVector3D convertGpsToEnu (const QGeoCoordinate &coord, const QGeoCoordinate &ref)
QGeoCoordinate convertEnuToGps (const QVector3D &enu, const QGeoCoordinate &ref)
QVector3D convertGeodeticToEcef (const QGeoCoordinate &coord)
QGeoCoordinate convertEcefToGeodetic (const QVector3D &ecef)
QVector3D convertEcefToEnu (const QVector3D &ecef, const QGeoCoordinate &ref)
QVector3D convertEnuToEcef (const QVector3D &enu, const QGeoCoordinate &ref)
int convertGeoToUTM (const QGeoCoordinate &coord, double &easting, double &northing)
bool convertUTMToGeo (double easting, double northing, int zone, bool southhemi, QGeoCoordinate &coord)
QString convertGeoToMGRS (const QGeoCoordinate &coord)
bool convertMGRSToGeo (const QString &mgrs, QGeoCoordinate &coord)
QString convertDegreesToDMS (double value, bool isLatitude)
double convertDMSToDegrees (const QString &text, bool isLatitude, bool *ok)
bool convertDMSToGeo (const QString &latitude, const QString &longitude, QGeoCoordinate &coord)
double geodesicDistance (const QGeoCoordinate &from, const QGeoCoordinate &to)
double geodesicAzimuth (const QGeoCoordinate &from, const QGeoCoordinate &to)
QGeoCoordinate geodesicDestination (const QGeoCoordinate &from, double azimuth, double distance)
double pathLength (const QList< QGeoCoordinate > &path)
double polygonArea (const QList< QGeoCoordinate > &polygon)
double polygonPerimeter (const QList< QGeoCoordinate > &polygon)
QList< QGeoCoordinate > interpolatePath (const QGeoCoordinate &from, const QGeoCoordinate &to, int numPoints)
QGeoCoordinate interpolateAtDistance (const QGeoCoordinate &from, const QGeoCoordinate &to, double distance)

Function Documentation

◆ convertDegreesToDMS()

QString QGCGeo::convertDegreesToDMS ( double value,
bool isLatitude )

Format a latitude or longitude as degrees, minutes, seconds with hemisphere.

Parameters
valueAngle in decimal degrees (negative = south/west).
isLatitudeTrue for latitude (N/S), false for longitude (E/W).
Returns
String such as "34° 44' 17.60\" N". Seconds are rounded to 0.01.

Definition at line 231 of file QGCGeo.cc.

References convertDegreesToDMS().

Referenced by convertDegreesToDMS(), and TransformPositionController::initValues().

◆ convertDMSToDegrees()

double QGCGeo::convertDMSToDegrees ( const QString & text,
bool isLatitude,
bool * ok = nullptr )

Parse a latitude or longitude typed in any common notation. Accepts degrees-minutes-seconds ("34 44 17.6 N", "34°44'17.6\"N"), degrees-decimal-minutes ("34 44.293 N") and decimal degrees ("34.7382", "-86.6017"). The hemisphere letter (N/S for latitude, E/W for longitude, either case) may lead or trail; without one a leading '-' means S/W.

Parameters
textText to parse.
isLatitudeTrue for latitude (N/S, +/-90), false for longitude (E/W, +/-180).
[out]okSet to false for malformed input, a hemisphere letter of the other axis, '-' together with a hemisphere letter, minutes/seconds >= 60, or an out of range value.
Returns
Signed decimal degrees, or 0 on failure.

Definition at line 245 of file QGCGeo.cc.

References convertDMSToDegrees().

Referenced by convertDMSToDegrees(), and convertDMSToGeo().

◆ convertDMSToGeo()

bool QGCGeo::convertDMSToGeo ( const QString & latitude,
const QString & longitude,
QGeoCoordinate & coord )

Convert a latitude/longitude pair in any notation accepted by convertDMSToDegrees() to a coordinate.

Parameters
latitudeLatitude text.
longitudeLongitude text.
[out]coordLatitude and longitude are set on success; altitude is left unchanged.
Returns
True on success, false if either value fails to parse.

Definition at line 318 of file QGCGeo.cc.

References convertDMSToDegrees(), and convertDMSToGeo().

Referenced by convertDMSToGeo(), and TransformPositionController::setFromDMS().

◆ convertEcefToEnu()

QVector3D QGCGeo::convertEcefToEnu ( const QVector3D & ecef,
const QGeoCoordinate & ref )

Convert ECEF to ENU relative to a reference point.

Parameters
ecefECEF vector in meters.
refReference point for local tangent plane.
Returns
ENU vector in meters.

Definition at line 118 of file QGCGeo.cc.

References convertEcefToEnu().

Referenced by convertEcefToEnu().

◆ convertEcefToGeodetic()

QGeoCoordinate QGCGeo::convertEcefToGeodetic ( const QVector3D & ecef)

Convert ECEF (Earth-Centered Earth-Fixed) to geodetic coordinate.

Parameters
ecefECEF vector in meters.
Returns
Geodetic coordinate (lat/lon/alt).

Definition at line 111 of file QGCGeo.cc.

References convertEcefToGeodetic().

Referenced by convertEcefToGeodetic().

◆ convertEnuToEcef()

QVector3D QGCGeo::convertEnuToEcef ( const QVector3D & enu,
const QGeoCoordinate & ref )

Convert ENU to ECEF relative to a reference point.

Parameters
enuENU vector in meters.
refReference point for local tangent plane.
Returns
ECEF vector in meters.

Definition at line 132 of file QGCGeo.cc.

References convertEnuToEcef().

Referenced by convertEnuToEcef().

◆ convertEnuToGps()

QGeoCoordinate QGCGeo::convertEnuToGps ( const QVector3D & enu,
const QGeoCoordinate & ref )

Convert ENU (East-North-Up) coordinate to geodetic.

Parameters
enuENU vector in meters (x=East, y=North, z=Up).
refReference point for local tangent plane.
Returns
Geodetic coordinate.

Definition at line 91 of file QGCGeo.cc.

References convertEnuToGps().

Referenced by convertEnuToGps().

◆ convertGeodeticToEcef()

QVector3D QGCGeo::convertGeodeticToEcef ( const QGeoCoordinate & coord)

Convert geodetic coordinate to ECEF (Earth-Centered Earth-Fixed).

Parameters
coordGeodetic coordinate (lat/lon/alt).
Returns
ECEF vector in meters.
Note
Uses float precision (QVector3D). Large coordinates may lose precision.

Definition at line 104 of file QGCGeo.cc.

References convertGeodeticToEcef().

Referenced by convertGeodeticToEcef().

◆ convertGeoToMGRS()

QString QGCGeo::convertGeoToMGRS ( const QGeoCoordinate & coord)

Convert geodetic coordinate to MGRS string.

Parameters
coordGeodetic coordinate to convert.
Returns
MGRS string (e.g., "32TMT 65886 47092"), or empty string on failure.

Definition at line 181 of file QGCGeo.cc.

References convertGeoToMGRS().

Referenced by convertGeoToMGRS(), and TransformPositionController::initValues().

◆ convertGeoToNed()

void QGCGeo::convertGeoToNed ( const QGeoCoordinate & coord,
const QGeoCoordinate & origin,
double & x,
double & y,
double & z )

Convert geodetic coordinate to NED (North-East-Down) relative to origin.

Parameters
coordGeodetic coordinate to convert.
originReference point for local tangent plane.
[out]xNorth component in meters.
[out]yEast component in meters.
[out]zDown component in meters (positive = below origin).
Note
NaN altitudes are treated as 0.0 (sea level).

Definition at line 36 of file QGCGeo.cc.

References convertGeoToNed().

Referenced by convertGeoToNed(), QGCMapPolygon::nedPolygon(), and QGCMapPolyline::nedPolyline().

◆ convertGeoToUTM()

int QGCGeo::convertGeoToUTM ( const QGeoCoordinate & coord,
double & easting,
double & northing )

Convert geodetic coordinate to UTM.

Parameters
coordGeodetic coordinate to convert.
[out]eastingUTM easting in meters.
[out]northingUTM northing in meters.
Returns
UTM zone (1-60), or 0 on failure.

Definition at line 150 of file QGCGeo.cc.

References convertGeoToUTM().

Referenced by convertGeoToUTM(), and TransformPositionController::initValues().

◆ convertGpsToEnu()

QVector3D QGCGeo::convertGpsToEnu ( const QGeoCoordinate & coord,
const QGeoCoordinate & ref )

Convert geodetic coordinate to ENU (East-North-Up) relative to reference.

Parameters
coordGeodetic coordinate to convert.
refReference point for local tangent plane.
Returns
ENU vector in meters (x=East, y=North, z=Up).
Note
Uses float precision (QVector3D). For high precision, use NED functions.

Definition at line 82 of file QGCGeo.cc.

References convertGpsToEnu().

Referenced by convertGpsToEnu(), and OsmBuildingHandler::way().

◆ convertMGRSToGeo()

bool QGCGeo::convertMGRSToGeo ( const QString & mgrs,
QGeoCoordinate & coord )

Convert MGRS string to geodetic coordinate.

Parameters
mgrsMGRS string (spaces optional, e.g., "32TMT6588647092" or "32T MT 65886 47092").
[out]coordResulting geodetic coordinate (altitude = 0).
Returns
True on success, false on failure.

Definition at line 207 of file QGCGeo.cc.

References convertMGRSToGeo().

Referenced by convertMGRSToGeo(), and TransformPositionController::setFromMGRS().

◆ convertNedToGeo()

void QGCGeo::convertNedToGeo ( double x,
double y,
double z,
const QGeoCoordinate & origin,
QGeoCoordinate & coord )

Convert NED (North-East-Down) coordinate to geodetic.

Parameters
xNorth component in meters.
yEast component in meters.
zDown component in meters (positive = below origin).
originReference point for local tangent plane.
[out]coordResulting geodetic coordinate.

Definition at line 58 of file QGCGeo.cc.

References convertNedToGeo().

Referenced by convertNedToGeo(), QGCMapPolygon::offset(), and QGCMapPolyline::offsetPolyline().

◆ convertUTMToGeo()

bool QGCGeo::convertUTMToGeo ( double easting,
double northing,
int zone,
bool southhemi,
QGeoCoordinate & coord )

Convert UTM to geodetic coordinate.

Parameters
eastingUTM easting in meters.
northingUTM northing in meters.
zoneUTM zone (1-60).
southhemiTrue if southern hemisphere.
[out]coordResulting geodetic coordinate (altitude = 0).
Returns
True on success, false on failure.

Definition at line 163 of file QGCGeo.cc.

References convertUTMToGeo().

Referenced by convertUTMToGeo(), SHPFileHelper::loadPointsFromFile(), SHPFileHelper::loadPolygonsFromFile(), SHPFileHelper::loadPolylinesFromFile(), and TransformPositionController::setFromUTM().

◆ geodesicAzimuth()

double QGCGeo::geodesicAzimuth ( const QGeoCoordinate & from,
const QGeoCoordinate & to )

Calculate geodesic azimuth (bearing) from one coordinate to another using WGS84 ellipsoid.

Parameters
fromStarting coordinate.
toEnding coordinate.
Returns
Forward azimuth in degrees [0, 360), clockwise from north.
Note
More accurate than QGeoCoordinate::azimuthTo() which uses spherical approximation.

Definition at line 345 of file QGCGeo.cc.

References geodesicAzimuth().

Referenced by geodesicAzimuth().

◆ geodesicDestination()

QGeoCoordinate QGCGeo::geodesicDestination ( const QGeoCoordinate & from,
double azimuth,
double distance )

Calculate destination coordinate given start point, azimuth, and distance using WGS84 ellipsoid.

Parameters
fromStarting coordinate.
azimuthForward azimuth in degrees, clockwise from north.
distanceDistance in meters.
Returns
Destination coordinate (altitude copied from start).

Definition at line 358 of file QGCGeo.cc.

References geodesicDestination().

Referenced by geodesicDestination().

◆ geodesicDistance()

double QGCGeo::geodesicDistance ( const QGeoCoordinate & from,
const QGeoCoordinate & to )

Calculate geodesic distance between two coordinates using WGS84 ellipsoid.

Parameters
fromStarting coordinate.
toEnding coordinate.
Returns
Distance in meters.
Note
More accurate than QGeoCoordinate::distanceTo() which uses spherical approximation.

Definition at line 337 of file QGCGeo.cc.

References geodesicDistance().

Referenced by geodesicDistance(), and pathLength().

◆ interpolateAtDistance()

QGeoCoordinate QGCGeo::interpolateAtDistance ( const QGeoCoordinate & from,
const QGeoCoordinate & to,
double distance )

Get the coordinate at a specific distance along a geodesic path using WGS84 ellipsoid.

Parameters
fromStarting coordinate.
toEnding coordinate.
distanceDistance from start in meters (clamped to path length).
Returns
Coordinate at the specified distance along the geodesic. Altitude is linearly interpolated.
Note
Useful for midpoint: interpolateAtDistance(from, to, geodesicDistance(from, to) / 2)

Definition at line 457 of file QGCGeo.cc.

References interpolateAtDistance().

Referenced by interpolateAtDistance().

◆ interpolatePath()

QList< QGeoCoordinate > QGCGeo::interpolatePath ( const QGeoCoordinate & from,
const QGeoCoordinate & to,
int numPoints )

Interpolate evenly-spaced points along a geodesic path using WGS84 ellipsoid.

Parameters
fromStarting coordinate.
toEnding coordinate.
numPointsNumber of points to generate (must be >= 2).
Returns
List of coordinates including start and end points, evenly spaced along the geodesic.
Note
Uses GeodesicLine internally for efficiency. Altitude is linearly interpolated.

Definition at line 416 of file QGCGeo.cc.

References interpolatePath().

Referenced by interpolatePath().

◆ pathLength()

double QGCGeo::pathLength ( const QList< QGeoCoordinate > & path)

Calculate total geodesic length of a path using WGS84 ellipsoid.

Parameters
pathList of coordinates defining the path.
Returns
Total path length in meters, or 0 if fewer than 2 points.

Definition at line 369 of file QGCGeo.cc.

References geodesicDistance(), and pathLength().

Referenced by pathLength().

◆ polygonArea()

double QGCGeo::polygonArea ( const QList< QGeoCoordinate > & polygon)

Calculate geodesic area of a polygon using WGS84 ellipsoid.

Parameters
polygonList of coordinates defining the polygon vertices (automatically closed).
Returns
Absolute area in square meters, or 0 if fewer than 3 points.
Note
More accurate than planar projection methods, especially for large polygons.

Definition at line 382 of file QGCGeo.cc.

References polygonArea().

Referenced by polygonArea().

◆ polygonPerimeter()

double QGCGeo::polygonPerimeter ( const QList< QGeoCoordinate > & polygon)

Calculate geodesic perimeter of a polygon using WGS84 ellipsoid.

Parameters
polygonList of coordinates defining the polygon vertices (automatically closed).
Returns
Perimeter in meters, or 0 if fewer than 2 points.

Definition at line 400 of file QGCGeo.cc.

References polygonPerimeter().

Referenced by polygonPerimeter().