blank tile

This commit is contained in:
NatureFreshMilk 2019-01-23 12:56:45 +01:00
parent 1cd324f483
commit 20e151f3bd
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,25 @@
package tilerenderer
import (
"image"
"image/draw"
"image/png"
"image/color"
"bytes"
)
func CreateBlankTile(c color.RGBA) ([]byte){
rect := image.Rectangle{
image.Point{0, 0},
image.Point{IMG_SIZE, IMG_SIZE},
}
img := image.NewNRGBA(rect)
draw.Draw(img, rect, &image.Uniform{c}, image.ZP, draw.Src)
buf := new(bytes.Buffer)
png.Encode(buf, img)
return buf.Bytes()
}

View File

@ -3,6 +3,8 @@ package web
import ( import (
"mapserver/app" "mapserver/app"
"mapserver/coords" "mapserver/coords"
"mapserver/tilerenderer"
"image/color"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -37,7 +39,8 @@ func (t *Tiles) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
resp.Header().Add("content-type", "image/png") resp.Header().Add("content-type", "image/png")
if tile == nil { if tile == nil {
//TODO: blank tile resp.Write(tilerenderer.CreateBlankTile(color.RGBA{0,0,0,0}))
//TODO: cache/layer color
} else { } else {
resp.Write(tile.Data) resp.Write(tile.Data)