mtwebmapper: Some code cleanup in sub baseline rendering.

This commit is contained in:
Sascha L. Teichmann 2014-09-18 11:32:55 +02:00
parent ed9e37e892
commit 617a3081b2

View File

@ -61,19 +61,6 @@ func (sb *subBaseLine) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return return
} }
} }
img := common.LoadPNG(baseTile)
type subImage interface {
SubImage(image.Rectangle) image.Image
}
var si subImage
var ok bool
if si, ok = img.(subImage); !ok {
// Should not happen.
http.Error(rw,
http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
rx := x & ^(^uint(0) << (z - 8)) rx := x & ^(^uint(0) << (z - 8))
ry := y & ^(^uint(0) << (z - 8)) ry := y & ^(^uint(0) << (z - 8))
@ -83,23 +70,27 @@ func (sb *subBaseLine) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
w := uint(256) / parts w := uint(256) / parts
xo := w * rx xo := w * rx
yo := w * (parts - 1 - ry) yo := w * (parts - 1 - ry)
//fmt.Printf("x %d\n", x)
//fmt.Printf("y %d\n", y)
//fmt.Printf("z %d\n", z)
//fmt.Printf("z %d\n", z)
//fmt.Printf("parts %d\n", parts)
//fmt.Printf("w %d\n", w)
//fmt.Printf("xo %d\n", xo)
//fmt.Printf("yo %d\n", yo)
//fmt.Printf("rx %d\n", rx)
//fmt.Printf("ry %d\n", ry)
img := common.LoadPNG(baseTile)
type subImage interface {
SubImage(image.Rectangle) image.Image
}
if si, ok := img.(subImage); ok {
img = si.SubImage(image.Rect(int(xo), int(yo), int(xo+w), int(yo+w))) img = si.SubImage(image.Rect(int(xo), int(yo), int(xo+w), int(yo+w)))
} else {
// Should not happen.
http.Error(rw,
http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
img = blowUp(img) img = blowUp(img)
rw.Header().Set("Content-Type", "image/png") rw.Header().Set("Content-Type", "image/png")
if etag == "" { if etag == "" {
if etag, err = createETag(baseTile); err != nil { if etag, err = createETag(baseTile); err != nil {
// Unlikely
log.Printf("Cannot create ETag: %s", baseTile) log.Printf("Cannot create ETag: %s", baseTile)
} else { } else {
rw.Header().Set("ETag", etag) rw.Header().Set("ETag", etag)