Struct TransverseMercator
Prepared bounded Transverse Mercator projection.
struct TransverseMercator(T)
if (isGeodesyScalar!T);
Parameters follow the conventional EPSG Transverse Mercator model: ellipsoid, latitude/longitude of natural origin, natural-origin scale factor, false easting, and false northing.
The supported ellipsoid domain is spherical/oblate with
0 <= flattening <= 0.01. Non-polar forward inputs are bounded to
abs(delta longitude) <= 60 degrees from the central meridian. Linear
projected coordinates use the same unit as the ellipsoid axes and false
offsets.
is invalid. Prepared objects are intended for reuse.
Properties
| Name | Type | Description |
|---|---|---|
ellipsoid[get]
|
Ellipsoid!T | Projection ellipsoid. |
falseEasting[get]
|
T | EPSG 8806 false easting. |
falseNorthing[get]
|
T | EPSG 8807 false northing. |
isValid[get]
|
bool | True when the prepared operation contains valid supported parameters. |
latitudeOfNaturalOrigin[get]
|
Latitude!T | EPSG 8801 latitude of natural origin. |
longitudeOfNaturalOrigin[get]
|
Longitude!T | EPSG 8802 longitude of natural origin. |
scaleFactorAtNaturalOrigin[get]
|
T | EPSG 8805 scale factor at natural origin. |
Methods
| Name | Description |
|---|---|
forward
(source)
|
Project a geographic coordinate. |
forwardFactors
(source)
|
Compute conformal factors at a geographic source coordinate or throw on projection/domain failure. |
fromParameters
(ellipsoid, latitudeOfNaturalOrigin, longitudeOfNaturalOrigin, scaleFactorAtNaturalOrigin, falseEasting, falseNorthing)
|
Prepare a bounded Transverse Mercator operation. |
reverse
(source)
|
Reverse a projected coordinate. |
reverseFactors
(source)
|
Compute conformal factors for a represented projected coordinate or throw on projection/domain failure. |
tryForward
(source, result)
|
Project a geographic coordinate. |
tryForwardFactors
(source, result)
|
Compute conformal factors at a geographic source coordinate. |
tryFromParameters
(ellipsoid, latitudeOfNaturalOrigin, longitudeOfNaturalOrigin, scaleFactorAtNaturalOrigin, falseEasting, falseNorthing, result)
|
Prepare a bounded Transverse Mercator operation without throwing. |
tryReverse
(source, result)
|
Reverse a projected coordinate. |
tryReverseFactors
(source, result)
|
Compute conformal factors for a represented projected coordinate. |
Example
Example using struct TransverseMercator(T) if (isGeodesyScalar!T).
import geodesy;
const tm = TransverseMercator!double .fromParameters(
wgs84!double(),
Latitude!double .fromDegrees(0.0),
Longitude!double .fromDegrees(15.0),
0.9996,
500_000.0,
0.0);
const source = GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(48.0),
Longitude!double .fromDegrees(16.0));
const projected = tm .forward(source);
const factors = tm .forwardFactors(source);
assert(projected .easting > 500_000.0);
assert(factors .pointScale > 0.0);
Example
Unit-invariance regression for the represented +60 degree TM boundary.
The same WGS 84 operation expressed in metres and kilometres must make the same reverse-domain acceptance decisions for coordinates produced by its own forward operation.
import geodesy .ellipsoid : Ellipsoid;
import geodesy .geographic : GeographicCoordinate;
import geodesy .angle : Latitude, Longitude;
foreach (unit; [1.0, 0.001])
{
const ellipsoid =
Ellipsoid!double .fromInverseFlattening(
6_378_137.0 * unit,
298.257223563);
const projection =
TransverseMercator!double .fromParameters(
ellipsoid,
Latitude!double .fromDegrees(0.0),
Longitude!double .fromDegrees(15.0),
0.9996,
500_000.0 * unit,
0.0);
foreach (i; 0 .. 2_000)
{
const latitudeDegrees =
-80.0 + 160.0 * i / 2_000.0;
const source =
GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(latitudeDegrees),
Longitude!double .fromDegrees(75.0));
const projected = projection .forward(source);
GeographicCoordinate!double reversed;
assert(projection .tryReverse(projected, reversed));
}
}