1
0
forked from MTSR/mapserver
mapserver/layerconfig/layerconfig.go
NatureFreshMilk f8f524013e go fmt
2019-01-18 09:13:37 +01:00

48 lines
651 B
Go

package layerconfig
import (
"encoding/json"
"io/ioutil"
)
type LayerContainer struct {
Layers []Layer `json:"layers"`
}
type Layer struct {
Id int `json:"id"`
Name string `json:"name"`
To int `json:"to"`
From int `json:"from"`
}
var DefaultLayers []Layer
func init() {
DefaultLayers = []Layer{
Layer{
Id: 0,
Name: "Base",
From: -16,
To: 160,
},
}
}
func ParseFile(filename string) ([]Layer, error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
lc := LayerContainer{}
err = json.Unmarshal(data, &lc)
if err != nil {
return nil, err
}
return lc.Layers, nil
}