make distance stuff greate again
This commit is contained in:
@@ -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{}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/storage"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
@@ -24,6 +25,13 @@ func NewTilesHandler(cfg *viper.Viper, persistantStorage storage.Storage) (*Tile
|
||||
|
||||
// GetTiles retrieves tiles
|
||||
func (h *TilesHandler) GetTiles(driverOrPassenger string, date time.Time, points ...orb.Point) (*Tileset, error) {
|
||||
dateString := date.Format("2006-01-02")
|
||||
|
||||
log.Debug().
|
||||
Any("points", points).
|
||||
Str("date", dateString).
|
||||
Msg("Get Tiles")
|
||||
|
||||
result := Tileset{}
|
||||
|
||||
grid_ids := []GridId{}
|
||||
@@ -36,7 +44,6 @@ func (h *TilesHandler) GetTiles(driverOrPassenger string, date time.Time, points
|
||||
grid_ids = []GridId{PointGridId(points[0])}
|
||||
}
|
||||
|
||||
dateString := date.Format("2006-01-02")
|
||||
for _, gid := range grid_ids {
|
||||
tile, err := h.GetTile(driverOrPassenger, date, gid)
|
||||
if err != nil {
|
||||
|
||||
@@ -29,6 +29,12 @@ func (tile *Tile) ID() string {
|
||||
|
||||
// GetTile retrieves a tile from persistant storage or cache
|
||||
func (h *TilesHandler) GetTile(driverOrPassenger string, date time.Time, gridid GridId) (*Tile, error) {
|
||||
log.Debug().
|
||||
Str("driver_or_passenger", driverOrPassenger).
|
||||
Str("date", date.Format("2006-01-02")).
|
||||
Any("grid_id", gridid).
|
||||
Msg("GetTile")
|
||||
|
||||
routes := []*geojson.FeatureCollection{}
|
||||
day := strings.ToUpper(date.Format("Mon"))
|
||||
dateString := date.Format("2006-01-02")
|
||||
|
||||
Reference in New Issue
Block a user