utm

package
v0.0.0-...-3cd2f5a Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package utm provides the ability to work with UTM coordinates

References:
	https://stevedutch.net/FieldMethods/UTMSystem.htm
	https://gisgeography.com/central-meridian/

Index

Constants

View Source
const (
	// ErrInvalidZone will be return if the given zone is invalid
	ErrInvalidZone = errors.String("zone is invalid")
	// ErrLatitudeOutOfRange will be returned if the latitude is not in the correct range of acceptable values
	ErrLatitudeOutOfRange = errors.String("latitude out of range")
)

Variables

This section is empty.

Functions

func CentralMeridian

func CentralMeridian(zone Zone) (degree int, err error)

CentralMeridian returns the central meridian degree for the given zone.

Possible errors:

ErrInvalidZone

func ScalarFactor

func ScalarFactor(lnglat coord.LngLat, e float64) float64

ScalarFactor will calculate the correct k scalar value for the given lnglat and eccentricity

func ZoneNumberFromLngLat

func ZoneNumberFromLngLat(lnglat coord.LngLat) int

ZoneNumberFromLngLat will get the zone number for the given LngLat value.

The returned value will be from 1-60. If 0 is returned it means that the lat,lng value was in the polar region and UPS should be used instead.

 Transcribed from:
	 https://github.com/gdey/GDGeoCocoa/blob/master/GDGeoCoordConv.m

Types

type Coord

type Coord struct {
	Northing float64
	Easting  float64
	Zone     Zone
	Digraph  Digraph
}

Coord defines an UTM coordinate

func FromLngLat

func FromLngLat(lnglat coord.LngLat, ellips coord.Ellipsoid) (Coord, error)

FromLngLat returns a new utm coordinate based on the provided longitude and latitude values.

func (Coord) NatoEasting

func (c Coord) NatoEasting() int

NatoEasting returns the easting value for NATO

func (Coord) NatoNorthing

func (c Coord) NatoNorthing() int

NatoNorthing returns the northing value for NATO

func (Coord) ToLngLat

func (c Coord) ToLngLat(ellips coord.Ellipsoid) (coord.LngLat, error)

ToLngLat transforms the utm Coord to it's Lat Lng representation based on the given datum

type Digraph

type Digraph [2]rune

Digraph is the NATO diagraph

func (Digraph) String

func (d Digraph) String() string

String returns the string representation of a diagraph

type Zone

type Zone struct {
	Number int
	Letter ZoneLetter
}

Zone describes an UTM zone

func NewZone

func NewZone(lnglat coord.LngLat) (Zone, error)

NewZone returns the UTM zone for the given LngLat value.

Possible errors:

ErrLatitudeOutOfRange

func (Zone) IsNorthern

func (z Zone) IsNorthern() bool

IsNorthern returns if the Zone is in the northern hemisphere

func (Zone) IsValid

func (z Zone) IsValid() bool

IsValid will run validity check on the zone letter and number

func (Zone) String

func (z Zone) String() string

String implements the stringer interface

type ZoneLetter

type ZoneLetter byte

ZoneLetter describes the UTM zone letter

const (
	ZoneC ZoneLetter = 'C'
	ZoneD ZoneLetter = 'D'
	ZoneE ZoneLetter = 'E'
	ZoneF ZoneLetter = 'F'
	ZoneG ZoneLetter = 'G'
	ZoneH ZoneLetter = 'H'
	ZoneI ZoneLetter = 'I'
	ZoneJ ZoneLetter = 'J'
	ZoneK ZoneLetter = 'K'
	ZoneL ZoneLetter = 'L'
	ZoneM ZoneLetter = 'M'
	ZoneN ZoneLetter = 'N'
	ZoneP ZoneLetter = 'P'
	ZoneQ ZoneLetter = 'Q'
	ZoneR ZoneLetter = 'R'
	ZoneS ZoneLetter = 'S'
	ZoneT ZoneLetter = 'T'
	ZoneU ZoneLetter = 'U'
	ZoneV ZoneLetter = 'V'
	ZoneW ZoneLetter = 'W'
	ZoneX ZoneLetter = 'X'
)

UTM Zone Letters

func ZoneLetterForLat

func ZoneLetterForLat(lat float64) (ZoneLetter, error)

ZoneLetterForLat returns the UTM zone letter for the given latitude value

Possible errors:

ErrLatitudeOutOfRange

func (ZoneLetter) IsNorthern

func (zl ZoneLetter) IsNorthern() bool

IsNorthern returns if the Zone is in the northern hemisphere

func (ZoneLetter) IsValid

func (zl ZoneLetter) IsValid() bool

IsValid will run validity check on the zone letter and number

func (ZoneLetter) String

func (zl ZoneLetter) String() string

String implements the stringer interface

Jump to

Keyboard shortcuts

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