aboutsummaryrefslogtreecommitdiff
path: root/pkg/static
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/static')
-rw-r--r--pkg/static/map.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/static/map.go b/pkg/static/map.go
index 2597aaf..8de861f 100644
--- a/pkg/static/map.go
+++ b/pkg/static/map.go
@@ -26,7 +26,7 @@ const (
th = 256
)
-func GetMapImage(lat, lon float64, zoom, width, height int) ([]byte, error) {
+func GetMapImage(lat, lon float64, zoom, width, height int) (image.Image, error) {
x, y, dx, dy := getCoords(lat, lon, zoom)
dst := imaging.New(width, height, color.NRGBA{0, 255, 0, 255})
wg := sync.WaitGroup{}
@@ -57,13 +57,17 @@ func GetMapImage(lat, lon float64, zoom, width, height int) ([]byte, error) {
tx := cx + i*tw - di
ty := cy + j*th - dj
dst = imaging.Paste(dst, img, image.Pt(tx, ty))
- }(int(i), int(j))
+ }(i, j)
}
}
wg.Wait()
+ return dst, nil
+}
+
+func AsBytes(image image.Image) ([]byte,error) {
out := bytes.NewBuffer([]byte{})
- if err := imaging.Encode(out, dst, imaging.PNG); err != nil {
+ if err := imaging.Encode(out, image, imaging.PNG); err != nil {
return nil, err
}
return out.Bytes(), nil