1
0
Fork 0
mirror of https://github.com/Luzifer/staticmap.git synced 2024-12-20 21:01:18 +00:00
staticmap/cache.go
Knut Ahlers 4414239854
Initial version
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-06-27 22:49:53 +02:00

22 lines
563 B
Go

package main
import (
"crypto/sha256"
"fmt"
"io"
"strings"
"github.com/golang/geo/s2"
)
type cacheFunction func(center s2.LatLng, zoom int, marker []marker, x, y int) (io.ReadCloser, error)
func cacheKeyHelper(center s2.LatLng, zoom int, marker []marker, x, y int) string {
markerString := []string{}
for _, m := range marker {
markerString = append(markerString, m.String())
}
hashString := fmt.Sprintf("%s|%d|%s|%dx%d", center.String(), zoom, strings.Join(markerString, "+"), x, y)
return fmt.Sprintf("%x", sha256.Sum256([]byte(hashString)))
}