Exemplo n.º 1
0
func lookupTransitRoutingPreference(transitRoutingPreference string, r *maps.DistanceMatrixRequest) {
	switch transitRoutingPreference {
	case "fewer_transfers":
		r.TransitRoutingPreference = maps.TransitRoutingPreferenceFewerTransfers
	case "less_walking":
		r.TransitRoutingPreference = maps.TransitRoutingPreferenceLessWalking
	case "":
		// ignore
	default:
		log.Fatalf("Unknown transit routing preference %s", transitRoutingPreference)
	}
}
Exemplo n.º 2
0
func lookupUnits(units string, r *maps.DistanceMatrixRequest) {
	switch units {
	case "metric":
		r.Units = maps.UnitsMetric
	case "imperial":
		r.Units = maps.UnitsImperial
	case "":
		// ignore
	default:
		log.Fatalf("Unknown units %s", units)
	}
}
Exemplo n.º 3
0
func lookupAvoid(avoid string, r *maps.DistanceMatrixRequest) {
	switch avoid {
	case "tolls":
		r.Avoid = maps.AvoidTolls
	case "highways":
		r.Avoid = maps.AvoidHighways
	case "ferries":
		r.Avoid = maps.AvoidFerries
	case "":
		// ignore
	default:
		log.Fatalf("Unknown avoid restriction %s", avoid)
	}
}
Exemplo n.º 4
0
func lookupMode(mode string, r *maps.DistanceMatrixRequest) {
	switch mode {
	case "driving":
		r.Mode = maps.TravelModeDriving
	case "walking":
		r.Mode = maps.TravelModeWalking
	case "bicycling":
		r.Mode = maps.TravelModeBicycling
	case "transit":
		r.Mode = maps.TravelModeTransit
	case "":
		// ignore
	default:
		log.Fatalf("Unknown mode %s", mode)
	}
}
Exemplo n.º 5
0
func lookupTransitMode(transitMode string, r *maps.DistanceMatrixRequest) {
	if transitMode != "" {
		for _, m := range strings.Split(transitMode, "|") {
			switch m {
			case "bus":
				r.TransitMode = append(r.TransitMode, maps.TransitModeBus)
			case "subway":
				r.TransitMode = append(r.TransitMode, maps.TransitModeSubway)
			case "train":
				r.TransitMode = append(r.TransitMode, maps.TransitModeTrain)
			case "tram":
				r.TransitMode = append(r.TransitMode, maps.TransitModeTram)
			case "rail":
				r.TransitMode = append(r.TransitMode, maps.TransitModeRail)
			default:
				log.Fatalf("Unknown transit_mode %s", m)
			}
		}
	}
}