carpool-service/tiles/tilesets.go

19 lines
447 B
Go
Raw Permalink Normal View History

2023-03-29 10:50:25 +00:00
package tiles
// Tileset stores tiles by TileID
type Tileset map[string]*Tile
func (tileset Tileset) GetTiledRoutes() []TiledRoute {
idmap := map[string]bool{}
result := []TiledRoute{}
for _, tile := range tileset {
for _, tr := range tile.TiledRoutes {
if _, ok := idmap[tr.Route.ExtraMembers.MustString("id")]; !ok {
idmap[tr.Route.ExtraMembers.MustString("id")] = true
result = append(result, tr)
}
}
}
return result
}