2017-06-27 20:49:53 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/golang/geo/s2"
|
|
|
|
)
|
|
|
|
|
2018-04-03 19:20:34 +00:00
|
|
|
type cacheFunction func(center s2.LatLng, zoom int, marker []marker, x, y int, disableAttribution bool) (io.ReadCloser, error)
|
2017-06-27 20:49:53 +00:00
|
|
|
|
2018-04-03 19:20:34 +00:00
|
|
|
func cacheKeyHelper(center s2.LatLng, zoom int, marker []marker, x, y int, disableAttribution bool) string {
|
2017-06-27 20:49:53 +00:00
|
|
|
markerString := []string{}
|
|
|
|
for _, m := range marker {
|
|
|
|
markerString = append(markerString, m.String())
|
|
|
|
}
|
2018-04-03 19:20:34 +00:00
|
|
|
hashString := fmt.Sprintf("%s|%d|%s|%dx%d|%v", center.String(), zoom, strings.Join(markerString, "+"), x, y, disableAttribution)
|
2017-06-27 20:49:53 +00:00
|
|
|
|
|
|
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(hashString)))
|
|
|
|
}
|