blank tile
This commit is contained in:
parent
1cd324f483
commit
20e151f3bd
25
server/tilerenderer/blank.go
Normal file
25
server/tilerenderer/blank.go
Normal 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()
|
||||
}
|
@ -3,6 +3,8 @@ package web
|
||||
import (
|
||||
"mapserver/app"
|
||||
"mapserver/coords"
|
||||
"mapserver/tilerenderer"
|
||||
"image/color"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -37,7 +39,8 @@ func (t *Tiles) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
||||
resp.Header().Add("content-type", "image/png")
|
||||
|
||||
if tile == nil {
|
||||
//TODO: blank tile
|
||||
resp.Write(tilerenderer.CreateBlankTile(color.RGBA{0,0,0,0}))
|
||||
//TODO: cache/layer color
|
||||
|
||||
} else {
|
||||
resp.Write(tile.Data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user