Coordinate

Represents a geographic coordinate with latitude, longitude, and altitude.

class MAVez.coordinate.Coordinate(lat, lon, alt, use_int=True, heading=None, timestamp=0)

Bases: object

This class represents a coordinate in latitude, longitude, and altitude. It provides methods to initialize the coordinate, convert between degrees and decimal degrees, and offset the coordinate by a given distance and heading.

Parameters:
  • lat (float | str) – Latitude in decimal degrees or DMS format if dms is True.

  • lon (float | str) – Longitude in decimal degrees or DMS format if dms is True.

  • alt (float) – Altitude in meters.

  • dms (bool) – If True, the coordinates are in degrees, minutes, seconds format. Defaults to False.

  • use_int (bool) – If True, the coordinates are stored as integers. Defaults to True.

  • heading (float | None) – Heading in degrees. Defaults to None.

  • timestamp (int) – Timestamp associated with the coordinate. Defaults to 0.

Returns:

An instance of the Coordinate class.

Return type:

Coordinate

bearing_to(other)

Calculate the bearing between two coordinates in degrees.

Parameters:

other (Coordinate) – The other coordinate to calculate the bearing to.

Returns:

The bearing in degrees from self to other.

Return type:

float

distance_to(other)

Calculate the distance between two coordinates in meters using the haversine formula.

Parameters:

other (Coordinate) – The other coordinate to calculate the distance to.

Returns:

The distance in meters between the two coordinates.

Return type:

float

normalize()

Normalize the coordinates to decimal degrees.

Returns:

A tuple containing the latitude and longitude in decimal degrees.

Return type:

tuple

offset_coordinate(offset, heading)

Offset the coordinate by a given distance and heading.

Parameters:
  • offset (float) – The distance to offset in meters.

  • heading (float) – The heading in degrees.

Returns:

A new Coordinate object with the offset applied.

Return type:

Coordinate

MAVez.coordinate.main()