From 5edcc3b87af6d68b23d53a5a88f2c0d374458769 Mon Sep 17 00:00:00 2001
From: Peter Kleiweg
Date: Sat, 31 Aug 2019 15:07:44 +0200
Subject: [PATCH] doc: example
---
v5/doc.go | 22 ++++++++++++++++++++++
v5/proj.go | 2 +-
v5/utm.go | 8 ++++----
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/v5/doc.go b/v5/doc.go
index b34ee8d..18fb89b 100644
--- a/v5/doc.go
+++ b/v5/doc.go
@@ -7,5 +7,27 @@ This package supports PROJ version 5 and above.
For PROJ.4, see: https://github.com/pebbe/go-proj-4
+Example usage:
+
+ ctx := proj.NewContext()
+ defer ctx.Close() // if omitted, this will be called on garbage collection
+
+ pj, err := ctx.Create(`
+ +proj=pipeline
+ +step +proj=unitconvert +xy_in=deg +xy_out=rad
+ +step +proj=utm +zone=31
+ `)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer pj.Close() // if omitted, this will be called on garbage collection
+
+ x, y, _, _, err := pj.Trans(proj.Fwd, 3, 58, 0, 0)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(x, y)
+
*/
package proj
diff --git a/v5/proj.go b/v5/proj.go
index 25ee951..4662a64 100644
--- a/v5/proj.go
+++ b/v5/proj.go
@@ -182,7 +182,7 @@ Transform a series of coordinates, where the individual coordinate dimension may
3. of length one, i.e. a constant, which will be treated as a fully populated slice of that constant value
-TODO: what if input is constant, but output is not?
+Note: if an input coordinate is constant, but the output coordinate varies, you need to supply a fully populated slice as input
*/
func (p *PJ) TransSlice(direction Direction, u1, v1, w1, t1 []float64) (u2, v2, w2, t2 []float64, err error) {
if !p.opened {
diff --git a/v5/utm.go b/v5/utm.go
index 443ce84..1ad2d40 100644
--- a/v5/utm.go
+++ b/v5/utm.go
@@ -12,7 +12,7 @@ import (
func UTMzone(lng, lat float64) (xzone int, yzone string, err error) {
if lat < -80 || lat > 84 {
- err = errors.New("Arctic and antarctic region are not in UTM")
+ err = errors.New("Arctic and Antarctic region are not in UTM")
return
}
@@ -23,7 +23,7 @@ func UTMzone(lng, lat float64) (xzone int, yzone string, err error) {
lng -= 360
}
- xzone = 1 + int((lng + 180) / 6)
+ xzone = 1 + int((lng+180)/6)
if lat > 72 && lng > 0 && lng < 42 {
if lng < 9 {
xzone = 31
@@ -39,7 +39,7 @@ func UTMzone(lng, lat float64) (xzone int, yzone string, err error) {
xzone = 32
}
- yzone = string("CDEFGHJKLMNPQRSTUVWXX"[int((lat + 80) / 8)])
+ yzone = string("CDEFGHJKLMNPQRSTUVWXX"[int((lat+80)/8)])
- return
+ return
}