1
0
forked from MTSR/mapserver
mapserver/web/colormapping.go
2024-08-11 13:44:11 +02:00

26 lines
469 B
Go

package web
import (
"encoding/json"
"net/http"
)
type Color struct {
R uint8 `json:"r"`
G uint8 `json:"g"`
B uint8 `json:"b"`
A uint8 `json:"a"`
}
func (api *Api) GetColorMapping(resp http.ResponseWriter, req *http.Request) {
cm := make(map[string]Color)
for k, v := range api.Context.Colormapping.GetColors() {
cm[k] = Color{R: v.R, G: v.G, B: v.B, A: v.A}
}
resp.Header().Add("content-type", "application/json")
json.NewEncoder(resp).Encode(cm)
}