Skip to content

Commit

Permalink
doc: example
Browse files Browse the repository at this point in the history
  • Loading branch information
pebbe committed Aug 31, 2019
1 parent 9dfdeee commit 5edcc3b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
22 changes: 22 additions & 0 deletions v5/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion v5/proj.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions v5/utm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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
}

0 comments on commit 5edcc3b

Please sign in to comment.