Skip to content

Instantly share code, notes, and snippets.

@jeromenerf
Last active December 17, 2015 22:09
Show Gist options
  • Select an option

  • Save jeromenerf/5679866 to your computer and use it in GitHub Desktop.

Select an option

Save jeromenerf/5679866 to your computer and use it in GitHub Desktop.

Revisions

  1. jeromenerf revised this gist Jun 7, 2013. No changes.
  2. jeromenerf revised this gist Jun 7, 2013. 2 changed files with 49 additions and 19 deletions.
    49 changes: 49 additions & 0 deletions gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    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)
    }
    }
    19 changes: 0 additions & 19 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,19 +0,0 @@
    package main

    import (
    "fmt"
    proj "github.com/pebbe/go-proj-4/proj"
    )

    func main () {
    // BONNE NOUVELLE
    lat := 48.8674451
    long := 2.3496033

    //l2et, _ := proj.NewProj("+init=epsg:27572")
    l2et, _ := proj.NewProj("+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.33722917 +k_0=0.99987742 +x_0=600000 + y_0=2200000 +a=6378249.2 +b=6356515 +pm=paris +units=m +no_defs no_defs <>")


    x, y, _ := proj.Fwd(l2et, long, lat)
    fmt.Printf("x/y : %.2f %.2f\n", x, y)
    }
  3. jeromenerf created this gist May 30, 2013.
    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    package main

    import (
    "fmt"
    proj "github.com/pebbe/go-proj-4/proj"
    )

    func main () {
    // BONNE NOUVELLE
    lat := 48.8674451
    long := 2.3496033

    //l2et, _ := proj.NewProj("+init=epsg:27572")
    l2et, _ := proj.NewProj("+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.33722917 +k_0=0.99987742 +x_0=600000 + y_0=2200000 +a=6378249.2 +b=6356515 +pm=paris +units=m +no_defs no_defs <>")


    x, y, _ := proj.Fwd(l2et, long, lat)
    fmt.Printf("x/y : %.2f %.2f\n", x, y)
    }