make distance stuff greate again

This commit is contained in:
2023-03-30 00:45:18 +02:00
parent fafa58daf1
commit bf6453b963
12 changed files with 414 additions and 42 deletions

View File

@@ -1,6 +1,9 @@
package tiles
import "github.com/paulmach/orb"
import (
"github.com/paulmach/orb"
"github.com/rs/zerolog/log"
)
// GridId defines the position of a tile
// It follows the Valhalla way of handling tiles : https://github.com/Telenav/open-source-spec/blob/master/valhalla/doc/valhalla-tiles-basic.md
@@ -10,13 +13,17 @@ const tilesize float64 = 1.0
// PointGridId returns the id on the grid for a given point
func PointGridId(point orb.Point) GridId {
log.Debug().Any("Point", point).Msg("PointGridId")
width := int64(360 / tilesize)
return GridId(int64((point.Lat()+90)/tilesize)*width + int64((point.Lon()+180)/tilesize))
gridid := GridId(int64((point.Lat()+90)/tilesize)*width + int64((point.Lon()+180)/tilesize))
log.Debug().Any("value", gridid).Msg("")
return gridid
}
// LineStringGridIds returns the list of ids on the grid the linestring goes through.
// In some really specific cases on tile edges, this could be unaccurate if the polyline was too much simplified
func LineStringGridIds(linestring orb.LineString) []GridId {
log.Debug().Any("Linestring", linestring).Msg("LineStringGridIds")
results := []GridId{}
gidmap := map[int64]bool{}