pipeline.domain.measures.Longitude

class Longitude(value: int | float | Decimal = 0, units: dict = {'html': '°', 'name': 'DEGREE', 'symbol': 'd', 'units per circle': Decimal('360')})[source]

Bases: EquatorialArc

Methods

convert_to

Converts this arc to the new units.

isEastOf

Returns true if this longitude is east of other.

isOpposite

Returns True if this longitude and other are separated by one half circle.

isWestOf

Returns True if this longitude is west of other.

parse

Returns a new longitude based on the given text.

toDms

Returns a representation of this arc in degrees, minutes, and seconds.

toHms

Returns a representation of this arc in hours, minutes, and seconds.

to_units

Returns the magnitude of this arc in otherUnits.

Attributes

value

units

patt

__init__(value: int | float | Decimal = 0, units: dict = {'html': '°', 'name': 'DEGREE', 'symbol': 'd', 'units per circle': Decimal('360')}) None[source]

Creates a new longitude with the given magnitude and units.

If magnitude is not a valid value1 for longitude, it will be normalised in a way that will transform it to a legal value. To be legal, magnitude must be greater than or equal to zero and less than one full circle, in the given units.

If no arguments are given, a longitude of 0 degrees will be created.

Parameters:
  • value -- The magnitude of the longitude.

  • units -- The units of longitude.

convert_to(newUnits: dict = {'html': '°', 'name': 'DEGREE', 'symbol': 'd', 'units per circle': Decimal('360')}) EquatorialArc

Converts this arc to the new units.

After this method is complete this arc will have units of units and its value will have been converted accordingly.

Parameters:

newUnits -- The new units for this arc. Default: degrees.

Returns:

This arc. The reason for this return type is to allow code of this nature:

radians = myArc.convert_to(ArcUnits.RADIAN).value;

isEastOf(other: Longitude) bool[source]

Returns true if this longitude is east of other.

One longitude is east of another if there are fewer lines of longitude to cross by travelling eastward along a given latitude than there would be by travelling westward along that same latitude.

Two special cases are worth noting. First, a longitude that is equal to this one is neither east nor west of this one. Second, a longitude that is opposite this one is both east and west of this one.

Parameters:

other -- The longitude to be tested.

Returns:

True if this longitude is east of other.

isOpposite(other: Longitude) bool[source]

Returns True if this longitude and other are separated by one half circle.

Parameters:

other -- The other longitude to be tested.

Returns:

True if other is separated from this longitude by one half circle.

isWestOf(other: Longitude)[source]

Returns True if this longitude is west of other.

One longitude is west of another if there are fewer lines of longitude to cross by travelling westward along a given latitude than there would be by travelling eastward along that same latitude.

Two special cases are worth noting. First, a longitude that is equal to this one is neither east nor west of this one. Second, a longitude that is opposite this one is both east and west of this one.

Parameters:

other -- The longitude to be tested.

Returns:

True if this longitude is west of other.

static parse(value: str) Longitude[source]

Returns a new longitude based on the given text.

See the parse method of Angle for information on the format of text. This Longitude class offers two other formats:

hh:mm:ss.sss hh mm ss.sss

Both of the above are in hours, minutes, and seconds. For the first alternative form, whitespace is permitted around the colon characters. For the second alternative form, any type and number of whitespace characters may be used in between the three parts.

The parsed value, if not a legal value for longitude, will be normalised in such a way that it is transformed to a legal value. To be

legal, magnitude must be greater than or equal zero and less than or equal to one full circle, in the given units.

Parameters:

value -- A string that will be converted into a longitude.

Returns:

A new Longitude. If parsing was successful, the value of the Longitude will be based on the parameter string. If it was not, the returned longitude will be of zero degrees.

Raises:

ValueError - if text is not in the expected form. --

toDms() tuple[int, int, float]

Returns a representation of this arc in degrees, minutes, and seconds.

Returns:

An integer holding the number of degrees. An integer holding the number of arc minutes. A float holding the number of arc seconds.

Return type:

a tuple of size three in this order

toHms() tuple[int, int, float]

Returns a representation of this arc in hours, minutes, and seconds.

Returns:

An integer holding the number of hours. An integer holding the number of minutes. A float holding the number of seconds.

Return type:

a tuple of size three in this order

to_units(otherUnits: dict = {'html': '°', 'name': 'DEGREE', 'symbol': 'd', 'units per circle': Decimal('360')}) Decimal

Returns the magnitude of this arc in otherUnits.

Note that this method does not alter the state of this arc. Contrast this with convert_to(ArcUnits).

Parameters:

otherUnits -- The units in which to express this arc's magnitude (default: degrees)

Returns:

This arc's value converted to otherUnits.