mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -177,8 +177,8 @@ func TestLevel(t *testing.T) {
|
||||
func TestLatLng(t *testing.T) {
|
||||
t.Run("Valid", func(t *testing.T) {
|
||||
lat, lng := LatLng("4799e370ca54c8b9")
|
||||
assert.Equal(t, 48.56344835921243, lat)
|
||||
assert.Equal(t, 8.996878323369781, lng)
|
||||
assert.Equal(t, 48.5634484, lat)
|
||||
assert.Equal(t, 8.9968783, lng)
|
||||
})
|
||||
|
||||
t.Run("Invalid", func(t *testing.T) {
|
||||
|
@@ -2,6 +2,8 @@ package s2
|
||||
|
||||
import (
|
||||
gs2 "github.com/golang/geo/s2"
|
||||
|
||||
"github.com/photoprism/photoprism/pkg/geo/latlng"
|
||||
)
|
||||
|
||||
// IsZero returns true if the coordinates are both empty.
|
||||
@@ -32,7 +34,7 @@ func TokenLevel(lat, lng float64, level int) string {
|
||||
return gs2.CellIDFromLatLng(l).Parent(level).ToToken()
|
||||
}
|
||||
|
||||
// LatLng returns the coordinates for a S2 cell token.
|
||||
// LatLng returns the rounded coordinates for a S2 cell token.
|
||||
func LatLng(token string) (lat, lng float64) {
|
||||
token = NormalizeToken(token)
|
||||
|
||||
@@ -48,5 +50,5 @@ func LatLng(token string) (lat, lng float64) {
|
||||
|
||||
l := cell.LatLng()
|
||||
|
||||
return l.Lat.Degrees(), l.Lng.Degrees()
|
||||
return latlng.Round(l.Lat.Degrees()), latlng.Round(l.Lng.Degrees())
|
||||
}
|
||||
|
Reference in New Issue
Block a user