Skip to content

Commit

Permalink
docs: make example even clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Apr 6, 2024
1 parent d60079d commit 0b813fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ func ExamplePJ_Forward() {
panic(err)
}

// Convert Zürich's WGS84 latitude/longitude to Web Mercator.
// Start with Zürich's WGS84 latitude/longitude.
zurich4326 := proj.NewCoord(47.374444, 8.541111, 408, 0)
fmt.Printf("initial: x=%.6f y=%.6f z=%.6f\n", zurich4326.X(), zurich4326.Y(), zurich4326.Z())

// Convert Zürich's WGS84 latitude/longitude to Web Mercator.
zurich3857, err := pj.Forward(zurich4326)
if err != nil {
panic(err)
Expand All @@ -48,6 +51,7 @@ func ExamplePJ_Forward() {
fmt.Printf("inverse: x=%.6f y=%.6f z=%.6f", zurich4326After.X(), zurich4326After.Y(), zurich4326After.Z())

// Output:
// initial: x=47.374444 y=8.541111 z=408.000000
// forward: x=950792.127329 y=6003408.475803 z=408.000000
// inverse: x=47.374444 y=8.541111 z=408.000000
}
Expand Down
6 changes: 5 additions & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ func ExamplePJ_Forward() {
panic(err)
}

// Convert Zürich's WGS84 latitude/longitude to Web Mercator.
// Start with Zürich's WGS84 latitude/longitude.
zurich4326 := proj.NewCoord(47.374444, 8.541111, 408, 0)
fmt.Printf("initial: x=%.6f y=%.6f z=%.6f\n", zurich4326.X(), zurich4326.Y(), zurich4326.Z())

// Convert Zürich's WGS84 latitude/longitude to Web Mercator.
zurich3857, err := pj.Forward(zurich4326)
if err != nil {
panic(err)
Expand All @@ -28,6 +31,7 @@ func ExamplePJ_Forward() {
fmt.Printf("inverse: x=%.6f y=%.6f z=%.6f", zurich4326After.X(), zurich4326After.Y(), zurich4326After.Z())

// Output:
// initial: x=47.374444 y=8.541111 z=408.000000
// forward: x=950792.127329 y=6003408.475803 z=408.000000
// inverse: x=47.374444 y=8.541111 z=408.000000
}

0 comments on commit 0b813fe

Please sign in to comment.