A set of longitude/latitude coordinates, measured in degrees, with 64-bit floating-point precision.
struct
|
LatLon
|
implements
|
IEquatable<LatLon>
|
A set of longitude/latitude values represent a location on a planetary body, for example on earth:
+---------------------------------------------------------------------------------+ 90°N | @@ @@@@@@@@ @@@ @ | +90° | @ @@@@@@ @ @@@@ | | @@@@ @ @@@ @ @ @@@@@ @ @ @@@@@@@@@@@@@@@@@ @ | | @@@@@@@@@@@@@@@ @@@ @@ @ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | | @@@@@@@@@@@@@@@ @ @ @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ | | @@@@@@@@@ @@@ @ @@@@@@@@@@@@@@@@@@@@@@@@@ | | @@@@@@@@@@@@@@@ @ @@ @@@@@@@@@@@ @@@@@@@@@@@@@ @ | | @@@@@@@@@@@@@@@ @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ | | @@@@@@@ @@@@@ @@@ @@@@@ @@ @@@@@@@@@@@@@@@ @@@@ | | @@@@@@@@@@@@@ @@ @ @ @@ @@@@@@@@@@@@@@@@@@@ @ | | @@@@@@@@@@@ @@ @@ @@@@@ @@@@@@@@@@@@@@@ | | @@@@@@@@@@@ @@@ @@@@@@@@@@ @@@@@@@@@@ @ @ | | @@@@@@@@@ @@@@@@ @@@@@@@@@@@@@@@@@@@@@@ | | @@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ | | @@@ @@@@@@@@@@@@ @@@@ @@@@@@ @ @@@@@ | L | @@ @ @@@@@@@@@ @@@@ @@@@@ @@@@@ @@@@@ | a | @@@@ @ @@@@@@@@ @@@@@ @@@@ @@@ @ @ | t | @@@ @@@@@@@@@@@@@@ @ @ @ @ | i | @@ @@@@@@@@@@@@@@ @ @ @@ + 0° t | @@@@@ @@ @@ @@@@@@@@@ @ @ @ @ @ | u | @@@@@@@ @@@@@@@@@@ @ | d | @@@@@@@@ @@@@@@@@@ @ @@ | e | @@@@@@@@@@@ @@@@@@@@ @ @ @@@@ | | @@@@@@@@@@@@ @@@@@@@ @ @@ | | @@@@@@@@@@@ @@@@@@@ @ | | @@@@@@@@@ @@@@@@@ @@ @ | | @@@@@@@@ @ @@ @ @@@@@@ | | @@@ @@@@ @@@@@ @ @@@@@@@@ | | @@@ @@ @ @@@ @@@@@@@@@ | | @@@@@@ @@@ @@@@@@@@@@ | | @@@@ @@@ @@@ @@@@@ | | @@@ @@@ @ | | @@ @ | | @@ @ | | @@ @ | | @ | | @ | 90°S +-----------------------------------------+---------------------------------------+ -90° 180°W 0° 180°E -180° Longitude +180°The mapping from longitude/latitude coordinates to cubemap coordinates (see Cubemap class) is defined as follows:
Cubemap | Face center lies at: face | Longitude | Latitude --------+-----------+--------- X- | 90°W | 0°N | -90° | 0° --------+-----------+--------- X+ | 90°E | 0°N | +90° | 0° --------+-----------+--------- Y- | 0°E | 90°N | 0° | +90° --------+-----------+--------- Y+ | 0°E | 90°S | 0° | -90° --------+-----------+--------- Z- | 0°E | 0°N | 0° | 0° --------+-----------+--------- Z+ | 180°W | 0°N | -180° | 0°
The serialization helper object for values of LatLon.
public
static
readonly
field
|
Serializer
|
||
type
|
ITypeSerializer<LatLon>
|
0°N 180°E
public
static
readonly
field
|
East
|
||
type
|
LatLon
|
90°N 0°E
public
static
readonly
field
|
North
|
||
type
|
LatLon
|
90°N 180°E
public
static
readonly
field
|
NorthEast
|
||
type
|
LatLon
|
90°N 180°W
public
static
readonly
field
|
NorthWest
|
||
type
|
LatLon
|
One degree longitude/latitude.
public
constant
|
OneDegree
=
1
|
||
type
|
float64
|
One thousandth of a second longitude/latitude.
public
constant
|
OneMillisecond
=
1
/
3600000
|
||
type
|
float64
|
One minute longitude/latitude.
public
constant
|
OneMinute
=
1
/
60
|
||
type
|
float64
|
One second longitude/latitude.
public
constant
|
OneSecond
=
1
/
3600
|
||
type
|
float64
|
90°S 0°E
public
static
readonly
field
|
South
|
||
type
|
LatLon
|
90°S 180°E
public
static
readonly
field
|
SouthEast
|
||
type
|
LatLon
|
90°S 180°W
public
static
readonly
field
|
SouthWest
|
||
type
|
LatLon
|
Undefined location.
public
static
readonly
field
|
Undefined
|
||
type
|
LatLon
|
See also:
IsUndefined0°N 180°W
public
static
readonly
field
|
West
|
||
type
|
LatLon
|
0°N 0°E
public
static
readonly
field
|
Zero
|
||
type
|
LatLon
|
Are these geographic coordinates normalized?
public
property
|
IsNormalized
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
the
coordinates
are
normalized,
false
if
not. |
Remarks:
Normalized latitude angles are in the range [-90..90], normalized longitude angles are in the range [-180..180].
See also:
NormalizeIs this coordinate set undefined?
public
property
|
IsUndefined
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
the
coordinates
are
undefined,
false
if
not. |
See also:
UndefinedThe
latitude
in
the
range
[-90..90]
.
public
readonly
field
|
Latitude
|
||
type
|
float64
|
The
latitude
in
the
range
[-pi/2..pi/2]
.
public
property
|
LatitudeRadians
{
get
}
|
||
type
|
float64
|
||
value
|
The latitude angle, in radians. |
The
longitude
in
the
range
[-180..180]
.
public
readonly
field
|
Longitude
|
||
type
|
float64
|
The
longitude
in
the
range
[-pi..pi]
.
public
property
|
LongitudeRadians
{
get
}
|
||
type
|
float64
|
||
value
|
The longitude angle, in radians. |
Returns the LatLon value that represents the center of the given cubemap face.
[Pure]
|
||||
public
static
method
|
ForCubemapFace
(CubemapFace face)
|
|||
type
|
LatLon
|
|||
params
|
face
|
The cubemap face (see Cubemap). | ||
returns
|
The resulting value. |
Converts the given cubemap coordinates to longitude/latitude coordinates.
[Pure]
|
||||
public
static
method
|
FromCube
(Vec3I cube,
int32 n = HeightmapsUtil.MaxCoord)
|
|||
type
|
LatLon
|
|||
params
|
cube
|
The cubemap coordinates. | ||
n
|
Size of cubemap, minus one. | |||
returns
|
The longitude/latitude coordinates. |
Converts the given cubemap coordinates to longitude/latitude coordinates.
[Pure]
|
||||
public
static
method
|
FromCube
(Vec3D cube,
int32 n = HeightmapsUtil.MaxCoord)
|
|||
type
|
LatLon
|
|||
params
|
cube
|
The cubemap coordinates. | ||
n
|
Size of cubemap, minus one. | |||
returns
|
The longitude/latitude coordinates. |
Converts the given cubemap coordinates to longitude/latitude coordinates.
[Pure]
|
||||
public
static
method
|
FromCube
(int32 x,
int32 y,
int32 z,
int32 n = HeightmapsUtil.MaxCoord)
|
|||
type
|
LatLon
|
|||
params
|
x
|
The cubemap X-coordinate. | ||
y
|
The cubemap X-coordinate. | |||
z
|
The cubemap X-coordinate. | |||
n
|
Size of cubemap, minus one. | |||
returns
|
The longitude/latitude coordinates. |
Converts the given cubemap coordinates to longitude/latitude coordinates.
[Pure]
|
||||
public
static
method
|
FromCube
(float64 x,
float64 y,
float64 z,
int32 n = HeightmapsUtil.MaxCoord)
|
|||
type
|
LatLon
|
|||
params
|
x
|
The cubemap X-coordinate. | ||
y
|
The cubemap Y-coordinate. | |||
z
|
The cubemap Z-coordinate. | |||
n
|
Size of cubemap, minus one. | |||
returns
|
The longitude/latitude coordinates. |
Creates a new instance of LatLon from the given angles.
[Pure]
|
||||
public
static
method
|
FromDegrees
(Vec2D v)
|
|||
type
|
LatLon
|
|||
params
|
v
|
The longitude (see X) and latitude (see Y) angles, in degrees. | ||
returns
|
The LatLon value. |
See also:
ToDegreesComputes a LatLon value by projecting the given rectangular map coordinates to cubemap coordinates.
[Pure]
|
||||
public
static
method
|
FromProjection
(IMapProjection projectRectToCube,
Vec2D v)
|
|||
type
|
LatLon
|
|||
params
|
projectRectToCube
|
[not-null]
|
The map projection to use. Must project from Rect ( Source) to Cube ( Target). | |
v
|
The map coordinates in the source raster (see Source) of projectRectToCube. | |||
returns
|
The LatLon value. |
Creates a new instance of LatLon from the given angles.
[Pure]
|
||||
public
static
method
|
FromRadians
(Vec2D v)
|
|||
type
|
LatLon
|
|||
params
|
v
|
The longitude (see X) and latitude (see Y) angles, in radians. | ||
returns
|
The LatLon value. |
See also:
ToRadiansCreates a new instance of LatLon from the given angles.
[Pure]
|
||||
public
static
method
|
FromRadians
(float64 latitude,
float64 longitude)
|
|||
type
|
LatLon
|
|||
params
|
latitude
|
The latitude angle, in radians. | ||
longitude
|
The longitude angle, in radians. | |||
returns
|
The LatLon value. |
See also:
ToRadiansCreates a LatLon value from the given string representation.
[Pure]
|
||||
public
static
method
|
FromString
(string str)
|
|||
type
|
LatLon
|
|||
params
|
str
|
The string representation. | ||
returns
|
The LatLon value. |
Exceptions:
Creates a LatLon value from the given string representation.
[Pure]
|
||||
public
static
method
|
FromString
(string str,
LatLon defaultValue)
|
|||
type
|
LatLon
|
|||
params
|
str
|
The string representation. | ||
defaultValue
|
The value to return if str is invalid. | |||
returns
|
The LatLon value. |
Creates a LatLon value from the given string representation.
[Pure]
|
||||
public
static
method
|
FromStringTry
(string str,
out LatLon latLon)
|
|||
type
|
bool
|
|||
params
|
str
|
The string representation. | ||
latLon
|
The output LatLon value. | |||
returns
|
true
if
a
LatLon
value
has
been
parsed
and
stored
into
latLon,
false
if
the
input
string
was
invalid
(
latLon
will
be
set
to
Undefined
in
this
case).
|
Creates a new instance of LatLon.
public
constructor
|
LatLon
(float64 latitude,
float64 longitude)
|
||
params
|
latitude
|
The
latitude
in
the
range
[-90..90] . |
|
longitude
|
The
longitude
in
the
range
[-180..180] .s |
Creates a new instance of LatLon.
public
constructor
|
LatLon
(float64 latDeg,
float64 latMin,
float64 latSec,
float64 lonDeg,
float64 lonMin,
float64 lonSec)
|
||
params
|
latDeg
|
The latitude degrees. | |
latMin
|
The latitude minutes. | ||
latSec
|
The latitude seconds. | ||
lonDeg
|
The longitude degrees. | ||
lonMin
|
The longitude minutes. | ||
lonSec
|
The longitude seconds. |
Adds the given longitude/latitude values to this LatLon value.
[Pure]
|
||||
public
method
|
Add
(LatLon value)
|
|||
type
|
LatLon
|
|||
params
|
value
|
The longitude/latitude values to add to this value. | ||
returns
|
The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows). |
Adds the given longitude/latitude values to this LatLon value.
[Pure]
|
||||
public
method
|
Add
(float64 latitude,
float64 longitude)
|
|||
type
|
LatLon
|
|||
params
|
latitude
|
The value to add to the latitude of this value. | ||
longitude
|
The value to add to the longitude of this value. | |||
returns
|
The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows). |
Clamps the latitude to the given range.
[Pure]
|
||||
public
method
|
ClampLatitude
(float64 max)
|
|||
type
|
LatLon
|
|||
params
|
max
|
The latitude range: [-max..max]. | ||
returns
|
The clamped value. |
Clamps the latitude to the given range: [a..b] resp. [b..a].
[Pure]
|
||||
public
method
|
ClampLatitude
(float64 a,
float64 b)
|
|||
type
|
LatLon
|
|||
params
|
a
|
First range bound. | ||
b
|
Second range bound. | |||
returns
|
The clamped value. |
Divides the longitude and latitude values of this LatLon value by the given scalar.
[Pure]
|
||||
public
method
|
Div
(float64 value)
|
|||
type
|
LatLon
|
|||
params
|
value
|
The scalar value to divide by. | ||
returns
|
The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows). |
Computes an angle in degrees from the given DMS tuple.
[Pure]
|
||||
public
static
method
|
DMS
(float64 degrees,
float64 minutes = 0,
float64 seconds = 0)
|
|||
type
|
float64
|
|||
params
|
degrees
|
The degrees part. | ||
minutes
|
The minutes part (1/60th degree). | |||
seconds
|
The seconds part (1/60th minute). | |||
returns
|
The angle in degrees. |
Compares this LatLon value with the given one.
[Pure]
|
||||
public
method
|
Equals
(LatLon other)
|
|||
type
|
bool
|
|||
params
|
other
|
The other LatLon value. | ||
returns
|
true
if
both
values
are
equal,
false
if
they
are
not. |
Is the given geographic coordinate undefined?
public
static
method
|
IsUndefinedCoordinate
(float64 coordinate)
|
||
type
|
bool
|
||
params
|
coordinate
|
The coordinate value. | |
returns
|
true
if
coordinate
is
undefined,
false
if
it
is
valid.
|
See also:
UndefinedMultiplies the longitude/latitude values of this LatLon value by the given scalar factor.
[Pure]
|
||||
public
method
|
Mul
(float64 value)
|
|||
type
|
LatLon
|
|||
params
|
value
|
The scalar multiplication factor. | ||
returns
|
The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows). |
Negates the longitude and latitude values of this LatLon value.
[Pure]
|
||||
public
method
|
Neg
()
|
|||
type
|
LatLon
|
|||
returns
|
The resulting LatLon value. |
Returns a nice-looking angle value that is similar to the given angle value..
[Pure]
|
||||
public
static
method
|
NiceStepFind
(float64 angle,
bool divisible = false)
|
|||
type
|
int32
|
|||
params
|
angle
|
The angle value, in degrees. | ||
divisible
|
Return
nice-looking
values
that
are
also
nicely
divisible
(see
remarks)?
Defaults
to
false .
|
|||
returns
|
|
Index of nice-looking value that is nearest to angle. |
Remarks:
A nice-looking angle value sums up without creating big fractions, i.e. degrees are always a divisor of 360, minutes and seconds are always a divisor of 60 and milliseconds are always a divisor of 1000:
true
,
the
list
of
nice-looking
angle
values
is
reduced
to
this:
See also:
NiceStepGetReturns a nice-looking angle step value.
[Pure]
|
||||
public
static
method
|
NiceStepGet
(int32 index)
|
|||
type
|
float64
|
|||
params
|
index
|
[0..60]
|
Index of nice-looking value to get (see remarks). | |
returns
|
The nice-looking angle value, in degrees. |
Remarks:
A nice-looking angle value sums up without creating big fractions, i.e. degrees are always a divisor of 360, minutes and seconds are always a divisor of 60 and milliseconds are always a divisor of 1000:
See also:
NiceStepFind
public
static
method
|
NiceStepList
()
|
||
type
|
IVectorConst<float64>
|
Rounds this latitude/longitude tuple to the given nice-looking step value.
[Pure]
|
||||
public
method
|
NiceStepRound
(int32 step)
|
|||
type
|
LatLon
|
|||
params
|
step
|
[0..60]
|
Index of nice-looking step value. | |
returns
|
The rounded latitude/longitude tuple. |
See also:
NiceStepFindRounds the given latitude resp. longitude angle to the given nice-looking step value.
[Pure]
|
||||
public
static
method
|
NiceStepRound
(int32 step,
float64 degrees)
|
|||
type
|
float64
|
|||
params
|
step
|
[0..60]
|
Index of nice-looking step value. | |
degrees
|
The latitude resp. longitude angle, in degrees. | |||
returns
|
The rounded latitude/longitude tuple. |
See also:
NiceStepFindNormalizes
this
pair
of
latitude/longitude
values
so
that
the
longitude
value
lies
in
the
range
[-180..180]
and
the
latitude
lies
within
[-90..90]
.
[Pure]
|
||||
public
method
|
Normalize
()
|
|||
type
|
LatLon
|
|||
returns
|
The normalized value pair. |
Remarks:
Longitude values are wrapped at the normalization range boundaries; latitude values are clamped to the range boundaries.
See also:
NormalizeLatitudeNormalizes the given latitude angle.
[Pure]
|
||||
public
static
method
|
NormalizeLatitude
(float64 latitude)
|
|||
type
|
float64
|
|||
params
|
latitude
|
The input latitude angle, in degrees. | ||
returns
|
|
The normalized latitude angle. |
See also:
NormalizeNormalizes the given longitude angle.
[Pure]
|
||||
public
static
method
|
NormalizeLongitude180
(float64 longitude,
bool unique = true)
|
|||
type
|
float64
|
|||
params
|
longitude
|
The input longitude angle, in degrees. | ||
unique
|
Return
-180
instead
of
180 ?
Defaults
to
true .
|
|||
returns
|
|
The normalized longitude angle. |
See also:
NormalizeNormalizes the given longitude angle.
[Pure]
|
||||
public
static
method
|
NormalizeLongitude360
(float64 longitude,
bool unique = true)
|
|||
type
|
float64
|
|||
params
|
longitude
|
The input longitude angle, in degrees. | ||
unique
|
Return
0
instead
of
360 ?
Defaults
to
true .
|
|||
returns
|
|
The normalized longitude angle. |
See also:
NormalizeSubtracts the given longitude/latitude values from this LatLon value.
[Pure]
|
||||
public
method
|
Sub
(LatLon value)
|
|||
type
|
LatLon
|
|||
params
|
value
|
The longitude/latitude values to subtract from this value. | ||
returns
|
The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows). |
Subtracts the given longitude/latitude values from this LatLon value.
[Pure]
|
||||
public
method
|
Sub
(float64 latitude,
float64 longitude)
|
|||
type
|
LatLon
|
|||
params
|
latitude
|
The value to subtract from the latitude of this value, in degrees. | ||
longitude
|
The value to subtract from the longitude of this value, in degrees. | |||
returns
|
The resulting LatLon value (Normalize) should be called on the returned value in order to avoid range overflows). |
Converts this set of longitude/latitude coordinates to cubemap coordinates.
[Pure]
|
||||
public
method
|
ToCubeD
(int32 n = HeightmapsUtil.MaxCoord)
|
|||
type
|
Vec3D
|
|||
params
|
n
|
Size of cubemap, minus one. | ||
returns
|
The cubemap coordinates. |
Converts this set of longitude/latitude coordinates to cubemap coordinates.
[Pure]
|
||||
public
method
|
ToCubeI
(int32 n = HeightmapsUtil.MaxCoord)
|
|||
type
|
Vec3I
|
|||
params
|
n
|
Size of cubemap, minus one. | ||
returns
|
The cubemap coordinates. |
Converts this LatLon value to a vector of longitude/latitude in degrees.
[Pure]
|
||||
public
method
|
ToDegrees
()
|
|||
type
|
Vec2D
|
|||
returns
|
The resulting vector holding the longitude (see X) and latitude (see Y) angles, in degrees. |
Projects this LatLon value onto a rectangular map.
[Pure]
|
||||
public
method
|
ToProjection
(IMapProjection projectCubeToRect)
|
|||
type
|
Vec2D
|
|||
params
|
projectCubeToRect
|
[not-null]
|
The map projection to use. Must project from Cube ( Source) to Rect ( Target). | |
returns
|
The map coordinates in the target raster (see Target) of projectCubeToRect. |
Converts this LatLon value to a vector of longitude/latitude in radians.
[Pure]
|
||||
public
method
|
ToRadians
()
|
|||
type
|
Vec2D
|
|||
returns
|
The resulting vector holding the longitude (see X) and latitude (see Y) angles, in radians. |
public
override
method
|
ToString
()
|
||
type
|
string
|
Returns the string representation of this set of latitude/longitude coordinates.
[Pure]
|
||||
public
method
|
ToString
(LatLonFormat format)
|
|||
type
|
string
|
|||
params
|
format
|
The formatting options. | ||
returns
|
|
The string representation. |
Remarks:
The string representation has the following form:
a°b'c".dX e°f'g".hYwhere...
a
,
b
,
c
and
d
are
the
latitude
degrees,
minutes,
seconds
and
milliseconds,
X
is
either
N
(positive
latitude)
or
S
(negative
latitude).
e
,
f
,
g
and
h
are
the
longitude
degrees,
minutes,
seconds
and
milliseconds,
Y
is
either
E
(positive
longitude)
or
W
(negative
longitude).
The parts for minutes, seconds and milliseconds are omitted if their value is zero:
12°34'56.789"N 123°45'57.891"E 12°34'56"N 123°45'57"E 12°34'N 123°45'E 12°N 123°E
Returns the string representation of the given latitude/longitude angle.
[Pure]
|
||||
public
static
method
|
ToString
(float64 angle,
bool latOrLon,
LatLonFormat format = LatLonFormat.Default)
|
|||
type
|
string
|
|||
params
|
angle
|
The angle value to format, in degrees. | ||
latOrLon
|
true
if
angle
is
a
latitude
angle,
false
if
it
is
a
longitude
angle.
|
|||
format
|
The formatting options. | |||
returns
|
|
The string representation. |
Remarks:
The string representation has the following form:
a°b'c".dXwhere...
a
,
b
,
c
and
d
are
the
latitude
degrees,
minutes,
seconds
and
milliseconds,
X
is
either
N
(positive
latitude),
S
(negative
latitude),
E
(positive
longitude)
or
W
(negative
longitude).
Translates these longitude/latitude coordinates into geocentric coordinates.
method
|
ToCoords
(float64 elevation,
IGeometry geometry)
|
||
type
|
Vec3D
|
||
params
|
elevation
|
The terrain-space elevation. | |
geometry
|
[not-null]
|
The geometry object. | |
returns
|
The geocentric coordinates. |