Ejemplo n.º 1
0
func main() {
	api := distance.NewDirectionsAPI("<you google directions api key>")
	distance, err := api.GetDistance(
		distance.Coord{40.71117416, -74.00016545},
		distance.Coord{40.68382604, -73.97632328},
		distance.Bicycling,
	)

	fmt.Println(distance, err)
}
Ejemplo n.º 2
0
func NewBikage(google_api_key string, mongo_url string) (*Bikage, error) {
	stations, err := GetStations()
	if err != nil {
		return nil, errors.New("Bikage STATIONS GET error -> " + err.Error())
	}

	var cache Cache
	cache, err = NewMongoCache(mongo_url)
	if err != nil {
		cache = NewJsonCache()
	}

	directions_api := distance.NewDirectionsAPI(google_api_key)

	bikage := Bikage{
		RouteAPI: NewRouteAPI(directions_api).WithCache(cache),
		TripAPI:  NewTripAPI(stations).WithCache(cache),
	}

	return &bikage, nil
}