geoutm

package
v0.0.0-...-d34e1d5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package geoutm (coordinate conversion) provides methods for converting coordinates between WGS84 Lon Lat, UTM and MGRS/UTMREF.

Supported conversions:

utm.ToLL()   : converts from UTM to LL
utm.ToMGRS() : converts from UTM to MGRS
utm.ToUSNG   : converts from UTM to USNG
ll.ToUTM()   : converts from LL to UTM
ll.ToMGRS()  : converts from LL to MGRS
mgrs.ToUTM() : converts from MGRS to UTM
mgrs.ToLL()  : converts from MGRS to LL
usng.ToLL	 : converts from USNG to LL
usng.ToMGRS	 : converts from USNG to MGRS
usng.toUTM   : converts from USNG to UTM

Data objects:

UTM  : ZoneNumber ZoneLetter Easting Northing
LL   : Longitude Latitude
MGRS : String
USNG : string

Abbreviations:

	Lon    : Longitude
	Lat    : Latitude
	MGRS   : Military Grid Reference System (same as UTMREF)
    USNG   : United Tastes National Grid samt as MGRS formated with spaces
	UTM    : Universal Transverse Mercator
	UTMREF : UTM Reference System (same as MGRS)
	WGS84  : World Geodetic System 1984 (same as EPSG:4326)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	Name         string
	Zip          string
	Municipality string
	Region       string
	Population   int64
	Geoloc       LL
	Utm          UTM
	Zone         int64
	Easting      float64
	Northing     float64
	Belt         string
	Kmkv         string
	East         int64
	North        int64
}

func (*City) BuildCity

func (city *City) BuildCity(koord []string)

func (*City) CityToMgrs

func (city *City) CityToMgrs() MGRS

func (*City) CityToUsng

func (city *City) CityToUsng() USNG

type LL

type LL struct {
	Lat float64
	Lon float64
}

LL defines coordinate in Longitude / Latitude

func (LL) String

func (ll LL) String() string

String returns stringified LL object (order according to ISO-6709, precision 0.11 meter).

func (LL) ToMGRS

func (ll LL) ToMGRS(accuracy int) (MGRS, error)

ToMGRS converts Lon Lat to MGRS. accuracy holds the wanted accuracy in meters. Possible values are 1, 10, 100, 1000 or 10000 meters.

Example
ll := LL{Lon: -88.53, Lat: 51.95}
accuracy := 10 // meters
mgrs, err := ll.ToMGRS(accuracy)
if err != nil {
	log.Fatalf("error <%v> at ll.ToMGRS()", err)
}
fmt.Printf("%s -> %s (accuracy %d meters)\n", ll, mgrs, accuracy)
Output:

51.950000 -88.530000 -> 16UCC94855658 (accuracy 10 meters)

func (LL) ToUTM

func (ll LL) ToUTM() UTM

ToUTM converts Lon Lat to UTM.

Example
ll := LL{Lon: -115.08209766, Lat: 36.23612346}
utm := ll.ToUTM()
fmt.Printf("%s -> %s\n", ll, utm)
Output:

36.236123 -115.082098 -> 11S 672349 4011843

type MGRS

type MGRS string

MGRS defines cordinate in MGRS/UTMREF

func (MGRS) ToLL

func (mgrs MGRS) ToLL() (LL, int, error)

ToLL converts MGRS/UTMREF to Lon Lat.

Example
mgrs := MGRS("11SPA7234911844")
ll, accuracy, err := mgrs.ToLL()
if err != nil {
	log.Fatalf("error <%v> at mgrs.ToLL()", err)
}
fmt.Printf("%s (with accuracy %d meters) -> %s\n", mgrs, accuracy, ll)
Output:

11SPA7234911844 (with accuracy 1 meters) -> 36.236123 -115.082098

func (MGRS) ToUTM

func (mgrs MGRS) ToUTM() (UTM, int, error)

ToUTM converts MGRS/UTMREF to UTM.

Example
mgrs := MGRS("32ULC989564")
utm, accuracy, err := mgrs.ToUTM()
if err != nil {
	log.Fatalf("error <%v> at mgrs.ToUTM()", err)
}
fmt.Printf("%s -> %s (accuracy %d meters)\n", mgrs, utm, accuracy)
Output:

32ULC989564 -> 32U 398900 5756400 (accuracy 100 meters)

type USNG

type USNG string

USNG defines cordinate in USNG format

func (USNG) ToLL

func (usng USNG) ToLL() (LL, int, error)

ToLL converts USNG/UTMREF to Lon Lat.

func (USNG) ToMGRS

func (usng USNG) ToMGRS() MGRS

ToMGRS converts USNG to MGRS

func (USNG) ToUTM

func (usng USNG) ToUTM() (UTM, int, error)

type UTM

type UTM struct {
	ZoneNumber int
	ZoneLetter byte
	Easting    float64
	Northing   float64
}

UTM defines coordinate in Universal Transverse Mercator

func (UTM) String

func (utm UTM) String() string

String returns stringified UTM object.

func (UTM) ToLL

func (utm UTM) ToLL() (LL, error)

ToLL converts UTM to Lon Lat.

Example
utm := UTM{ZoneNumber: 23, ZoneLetter: 'K', Easting: 611733, Northing: 7800614}
ll, err := utm.ToLL()
if err != nil {
	log.Fatalf("error <%v> at utm.ToLL()", err)
}
fmt.Printf("%s -> %s\n", utm, ll)
Output:

23K 611733 7800614 -> -19.887498 -43.932664

func (UTM) ToMGRS

func (utm UTM) ToMGRS(accuracy int) MGRS

ToMGRS converts UTM to MGRS/UTMREF. accuracy holds the wanted accuracy in meters. Possible values are 1, 10, 100, 1000 or 10000 meters.

Example
utm := UTM{ZoneNumber: 31, ZoneLetter: 'U', Easting: 700373, Northing: 5704554}
accuracy := 1 // meters
mgrs := utm.ToMGRS(accuracy)
fmt.Printf("%s -> %s\n", utm, mgrs)
Output:

31U 700373 5704554 -> 31UGT0037304554

func (UTM) ToUSNG

func (utm UTM) ToUSNG(accuracy int) USNG

ToUSN converts UTM to USNG. accuracy holds the wanted accuracy in meters. Possible values are 1, 10, 100, 1000 or 10000 meters.

Jump to

Keyboard shortcuts

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