Last active
December 17, 2015 22:09
-
-
Save jeromenerf/5679866 to your computer and use it in GitHub Desktop.
Back and forth Google WGS84 and STIF Lambert 2 Étendu, via Lambert 93
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
proj "github.com/pebbe/go-proj-4/proj" | |
"math" | |
) | |
type Poi struct { | |
name string | |
x, y, lat, long float64 | |
} | |
func main() { | |
pois := []Poi{ | |
{"Bonne-Nouvelle", 600880.000000, 2430251.000000, 48.87052, 2.34880}, | |
{"Invalides", 598395.000000, 2429196.000000, 48.86232, 2.31494}, | |
{"Strasbourg-Saint-Denis", 601274.000000, 2430002.000000, 48.86949, 2.35427}, | |
{"Denfert-Rochereau", 599760.000000, 2426181.000000, 48.833898, 2.332610}, | |
{"Corvisart", 600945.000000, 2425692.000000, 48.82987, 2.35066}, | |
} | |
sl2et := "+init=IGNF:LAMBE" | |
//swgs84 := "+init=espg:8326" | |
sl93 := "+init=IGNF:LAMB93" | |
for _, poi := range pois { | |
//wgs84, _ := proj.NewProj(swgs84) | |
l2et, _ := proj.NewProj(sl2et) | |
l93, _ := proj.NewProj(sl93) | |
//long, lat, _ := proj.Inv(l2et, poi.x, poi.y) | |
x1, y1, _ := proj.Fwd(l93, poi.long, poi.lat) | |
x, y, _ := proj.Transform2(l93, l2et, x1, y1) | |
x2, y2, _ := proj.Transform2(l2et, l93, poi.x, poi.y) | |
long, lat, _ := proj.Inv(l93, x2, y2) | |
fmt.Printf("## %s : ", poi.name) | |
fmt.Printf("%.0fm\n", math.Sqrt((poi.x-x)*(poi.x-x)+(poi.y-y)*(poi.y-y))) | |
fmt.Printf("http://maps.google.fr?q=%f,%f\n", lat, long) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment