Documentation
¶
Overview ¶
Package coco (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 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
Data objects:
UTM : ZoneNumber ZoneLetter Easting Northing LL : Longitude Latitude MGRS : String
Abbreviations:
Lon : Longitude Lat : Latitude MGRS : Military Grid Reference System (same as UTMREF) 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 LL ¶
LL defines coordinate in Longitude / Latitude
func (LL) String ¶
String returns stringified LL object (order according to ISO-6709, precision 0.11 meter).
func (LL) ToMGRS ¶
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)
type MGRS ¶
type MGRS string
MGRS defines cordinate in MGRS/UTMREF
func (MGRS) ToLL ¶
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 ¶
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 UTM ¶
UTM defines coordinate in Universal Transverse Mercator
func (UTM) ToLL ¶
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 ¶
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