projections

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package projections provides map projections for converting between WGS84 geographic coordinates and flat projected coordinate systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*TransverseMercator)

Option configures a TransverseMercator projection.

func WithCenter

func WithCenter(center orb.Point) Option

WithCenter sets the central meridian and origin latitude from a geographic point (orb.Point{longitude, latitude} in degrees). This is a convenience option that sets both values at once.

func WithCentralMeridian

func WithCentralMeridian(degrees float64) Option

WithCentralMeridian sets the longitude (in degrees) of the central meridian.

func WithFalseEasting

func WithFalseEasting(meters float64) Option

WithFalseEasting sets the constant offset (in meters) added to easting coordinates so that all values in the useful area are positive.

func WithFalseNorthing

func WithFalseNorthing(meters float64) Option

WithFalseNorthing sets the constant offset (in meters) added to northing coordinates so that all values in the useful area are positive.

func WithOriginLatitude

func WithOriginLatitude(degrees float64) Option

WithOriginLatitude sets the latitude (in degrees) used as the northing origin.

func WithScaleFactor

func WithScaleFactor(k float64) Option

WithScaleFactor sets the scale factor at the central meridian. For UTM and DCS World projections this is typically 0.9996.

type Projection

type Projection interface {
	// ToProjected converts a WGS84 point (orb.Point{longitude, latitude} in
	// degrees) to projected coordinates (orb.Point{easting, northing} in
	// meters).
	ToProjected(point orb.Point) orb.Point
	// ToWGS84 converts projected coordinates (orb.Point{easting, northing} in
	// meters) back to WGS84 geographic coordinates (orb.Point{longitude,
	// latitude} in degrees).
	ToWGS84(projected orb.Point) orb.Point
}

Projection converts between WGS84 geographic coordinates and a flat projected coordinate system.

type TransverseMercator

type TransverseMercator struct {
	// contains filtered or unexported fields
}

TransverseMercator converts between WGS84 geographic coordinates (longitude/latitude in degrees) and a flat Transverse Mercator coordinate system (easting/northing in meters).

A Transverse Mercator projection works by conceptually wrapping a cylinder around the Earth so that it touches along a chosen line of longitude (the central meridian) instead of along the equator. Points on the ellipsoid are then projected onto this cylinder and unrolled into a flat surface. Near the central meridian the distortion is very small, making it a good local coordinate system for distance and angle calculations. Farther from the central meridian, distortion grows — which is why each DCS terrain uses its own projection centered on that terrain's longitude.

func NewTransverseMercator

func NewTransverseMercator(opts ...Option) *TransverseMercator

NewTransverseMercator creates a Transverse Mercator projection with the given options. The default scale factor is 1.0; all other parameters default to 0.

func (*TransverseMercator) ToProjected

func (p *TransverseMercator) ToProjected(point orb.Point) orb.Point

ToProjected converts a WGS84 point (orb.Point{longitude, latitude} in degrees) to flat projected coordinates (orb.Point{easting, northing} in meters).

The implementation uses the series expansion from "Map Projections: A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), Chapter 8: Transverse Mercator projection.

func (*TransverseMercator) ToWGS84

func (p *TransverseMercator) ToWGS84(projected orb.Point) orb.Point

ToWGS84 converts projected coordinates (orb.Point{easting, northing} in meters) back to WGS84 geographic coordinates (orb.Point{longitude, latitude} in degrees).

The inverse projection is not a simple algebraic inversion of the forward formulas. Instead it uses the "footpoint latitude" approach (Snyder eq. 8-18 through 8-23): first, the northing is converted back to a meridional arc distance, then a series expansion recovers an approximate latitude (the footpoint), and finally correction terms refine the latitude and recover the longitude.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL