示例#1
0
func GetCityName(airportCode string) string {
	airport, err := airports.GetByIATACode(airportCode)
	if err != nil {
		return airportCode
	} else {
		return airport.City
	}
}
示例#2
0
func GetAirportInfo(airportIataCode string) (cityName string, coordinates *Location) {
	airport, err := airports.GetByIATACode(airportIataCode)
	if err != nil {
		return airportIataCode, nil
	} else {
		lat, err := strconv.ParseFloat(airport.Latitude, 64)
		if err != nil {
			return airportIataCode, nil
		}

		lon, err := strconv.ParseFloat(airport.Longitude, 64)
		if err != nil {
			return airportIataCode, nil
		}

		return airport.City, &Location{lat, lon}
	}
}