WGS module

WGS coordinate system conversion module.

This module provides functions to convert latitude and longitude coordinates to and from x and y coordinates in the WGS coordinate system.

WGS.__CIRCUMFERENCE

The circumference of the Earth in meters.

Type

float

WGS.__LATITUDE_ORIGIN

The origin latitude in degrees.

Type

float

WGS.__LONGITUDE_ORIGIN

The origin longitude in degrees.

Type

float

Example

>>> wgs = WGS()
>>> x, y = wgs.latlon2xy(63.42690974, 10.3969373)
>>> print(x, y)
>>> 0.0, 0.0
>>> x, y = 1000, 2000
>>> lat, lon = wgs.xy2latlon(x, y)
>>> print(lat, lon)
>>> 63.43589289658141 10.437112521492383
class WGS.WGS

Bases: object

__CIRCUMFERENCE = 40075000
__LATITUDE_ORIGIN = 63.42690974
__LONGITUDE_ORIGIN = 10.3969373
static get_circumference() float

Get the circumference of the earth.

Returns

The circumference of the earth in meters.

Return type

float

static get_origin() tuple

Get the origin of the coordinate system.

Returns

A tuple of two floats representing the latitude and longitude of the origin in decimal degrees.

Return type

tuple

static latlon2xy(lat: float, lon: float) tuple

Convert latitude and longitude coordinates to a two-dimensional Cartesian coordinate system.

Parameters
  • lat (float) – Latitude in decimal degrees.

  • lon (float) – Longitude in decimal degrees.

Returns

A tuple of two floats representing x and y coordinates in meters.

Return type

tuple

static set_origin(lat: float, lon: float) None

Set the origin for the coordinate system.

Parameters
  • lat (float) – Latitude in decimal degrees.

  • lon (float) – Longitude in decimal degrees.

Returns

None

static xy2latlon(x: float, y: float) tuple

Convert a two-dimensional Cartesian coordinate system to latitude and longitude coordinates.

Parameters
  • x (float) – X-coordinate in meters.

  • y (float) – Y-coordinate in meters.

Returns

A tuple of two floats representing latitude and longitude in decimal degrees.

Return type

tuple