nautical.location package

Submodules

nautical.location.point module

class nautical.location.point.Point(lat: float = 0.0, lon: float = 0.0, alt: float = 0.0)[source]

Bases: object

A 3D point containing latitude, longitude and altitude coordinates.

__init__(lat: float = 0.0, lon: float = 0.0, alt: float = 0.0) None[source]

The latitude, longitude, and altitude are supplied to the base class as the x, y, z parameters respectively.

property latitude: float

Latitude Property (degrees) :return: latitude (degrees)

property longitude: float

Longitude Property (degrees) :return: longitude (degrees)

property altitude: float

Altitude Property (meters) :return: altitude (meters)

property x: float
property y: float
property z: float
as_tuple() tuple[float, float][source]

Get the values of the object as a simple tuple. The lat and lon are used but not the altitude. The altitude is omitted for use with haverine.

Returns:

Tuple of lat, lon

__str__() str[source]

Python version of the to string function. Turn this object into a string

Returns:

string representation of this object

to_json() dict[str, float][source]

Convert the instance to a json dictionary

static from_json(json_dict: dict[str, float]) Point[source]

Fill the instance from a json dictionary

from_dict(point_dict: dict[str, float]) None[source]

Fill the instance from a json dictionary

distance(other: Point, units: DistanceUnits = DistanceUnits.METERS) float[source]

Get the distance using the Haversine function. The function will determine the distance between this instance and another Point.

Parameters:
  • other – The other Point

  • units – Units used for measurement

Returns:

Distance between the points in units specified

in_range(other: Point, distance: float, units: DistanceUnits = DistanceUnits.METERS) bool[source]

Deteremine if the points are within a specific distance of eachother.

Parameters:
  • other – The other Point

  • distance – Max distance between the points

  • units – Units used for measurement

Returns:

True when points are within the specified distance

static parse(data: str) Point[source]

Parse the string containing lon, lat, alt [optional] values respectively.

Parameters:

data – A string containing lon, lat, altitude.

Returns:

instance of Point on success, None on failure

static parse_noaa_kml_format(data: str) Point[source]

Parse the string containing lon, lat, alt [optional] values respectively. See Point.parse for implementation and notes.

nautical.location.util module

nautical.location.util.haversine(point_one, point_two, units=DistanceUnits.METERS) float[source]

Wrapper for the Haversine for the Point class in this module

Parameters:
  • p1Point 1

  • point_twoPoint 2

  • units – nautical.units.DistanceUnits

Returns:

Distance between the points, in units

nautical.location.util.in_range_ll(lat1_deg, lon1_deg, lat2_deg, lon2_deg, distance, units=DistanceUnits.METERS)[source]

Determine if points are within a distance of each other provided with the latitude, longitude of each point

Parameters:
  • lat1_deg – Latitude of point 1 in degrees

  • lon1_deg – Longitude of point 1 in degrees

  • lat2_deg – Latitude of point 2 in degrees

  • lon2_deg – Longitude of point 2 in degrees

  • distance_m – Max allowed distance between points to return true (meters).

Returns:

True when the distance between P1 and P2 is less than (or equal to) distance_m

nautical.location.util.in_range(point_one, point_two, distance, units=DistanceUnits.METERS)[source]

Determine if the points are within a distance of each other.

Parameters:
  • point_one – Point 1

  • point_two – Point 2

  • distance – Max allowed distance between points to return true.

  • units – Units of measurement [default=METERS]

Returns:

True when the distance between P1 and P2 is less than (or equal to) distance_m

nautical.location.util.in_area(geometry, point)[source]

Determine if a point exists within a geometry of points. The algorithm can be found here: https://www.eecs.umich.edu/courses/eecs380/HANDOUTS/PROJ2/InsidePoly.html

Parameters:
  • geometry – Ordered list of Point objects

  • pointPoint that should be checked if exists in the geometry

Returns:

True when the value lies in the geometry, false otherwise

Module contents

The module contains data to create and manage 3D points. The points can be generated from the data contained inside of NOAA’s kml and html data.

class nautical.location.Point(lat: float = 0.0, lon: float = 0.0, alt: float = 0.0)[source]

Bases: object

A 3D point containing latitude, longitude and altitude coordinates.

__init__(lat: float = 0.0, lon: float = 0.0, alt: float = 0.0) None[source]

The latitude, longitude, and altitude are supplied to the base class as the x, y, z parameters respectively.

property latitude: float

Latitude Property (degrees) :return: latitude (degrees)

property longitude: float

Longitude Property (degrees) :return: longitude (degrees)

property altitude: float

Altitude Property (meters) :return: altitude (meters)

property x: float
property y: float
property z: float
as_tuple() tuple[float, float][source]

Get the values of the object as a simple tuple. The lat and lon are used but not the altitude. The altitude is omitted for use with haverine.

Returns:

Tuple of lat, lon

__str__() str[source]

Python version of the to string function. Turn this object into a string

Returns:

string representation of this object

to_json() dict[str, float][source]

Convert the instance to a json dictionary

static from_json(json_dict: dict[str, float]) Point[source]

Fill the instance from a json dictionary

from_dict(point_dict: dict[str, float]) None[source]

Fill the instance from a json dictionary

distance(other: Point, units: DistanceUnits = DistanceUnits.METERS) float[source]

Get the distance using the Haversine function. The function will determine the distance between this instance and another Point.

Parameters:
  • other – The other Point

  • units – Units used for measurement

Returns:

Distance between the points in units specified

in_range(other: Point, distance: float, units: DistanceUnits = DistanceUnits.METERS) bool[source]

Deteremine if the points are within a specific distance of eachother.

Parameters:
  • other – The other Point

  • distance – Max distance between the points

  • units – Units used for measurement

Returns:

True when points are within the specified distance

static parse(data: str) Point[source]

Parse the string containing lon, lat, alt [optional] values respectively.

Parameters:

data – A string containing lon, lat, altitude.

Returns:

instance of Point on success, None on failure

static parse_noaa_kml_format(data: str) Point[source]

Parse the string containing lon, lat, alt [optional] values respectively. See Point.parse for implementation and notes.