NeowayLabs / gis

Geographic Information System
Apache License 2.0
3 stars 1 forks source link

Add support for WGS84 #5

Open i4ki opened 7 years ago

i4ki commented 7 years ago

I'm thinking in adding support for spherical GCS and WGS84 first and then we can discuss a properly GCS framework to build upon it. On the way at #1 About the API, I'm thinking in something like that:

package main

import (
        "os"
        "fmt"

        "github.com/NeowayLabs/gis/layer"

        // imports below add support for geojson and KML decoding
        _ "github.com/NeowayLabs/gis/encoding/geojson"
        _ "github.com/NeowayLabs/gis/encoding/kml"

        "github.com/NeowayLabs/gis/gcs"

        _ "github.com/NeowayLabs/gis/gcs/wgs84"
        // Uncomment line below to add support for SIRGAS 2000
        //"github.com/NeowayLabs/gis/gcs/sirgas2000"
)

func main() {
        shape, crs, err := layer.Open("./features.kml")
        if err != nil {
                fmt.Fprintf("Failed to load layer: %s\n", err.Error())
                os.Exit(1)
        }

        fmt.Printf("Loaded layer using CRS: %s", crs)

        shape2, err := gcs.Transform(shape, crs, "SIRGAS2000")
        if err != nil {
                // Uncomment the SIRGAS2000 import to work
                fmt.Fprintf("Failed to transform layer: %s\n", err.Error())
                os.Exit(1)
        }
        geojsonContent, err := geojson.Encode(layer)
        if err != nil {
                fmt.Fprintf("geojson encoder error: %s\n", err.Error())
                os.Exit(1)
        }
        fmt.Printf("%s\n", geojsonContent)
}

What do you guys think? @OctavioBR @vitor-tyburski @rzanato

OctavioBR commented 7 years ago

I find well designed (and cool) your API but I think we would not need so much translation between different coordinate systems. At first let's stick to the simplest GCS, then when we get to support WGS84, we could stop maintaining others... Thoughts?