示例#1
0
// Load and parse the hotspots
func Get(c appengine.Context, selectedCity city.City) (hotspots []Hotspot) {
	headerRow := 1
	hotspotsData := spreadsheet.Get(c, selectedCity.SpreadsheetId, selectedCity.SheetId, headerRow)

	for _, hotspotData := range hotspotsData {
		if hotspotData["Visible"] != "y" {
			continue
		}

		var translations []translation.Translation
		translations = append(translations, translation.Translation{"english", hotspotData["Description"]})

		for key, value := range hotspotData {
			_, exists := nonTranslationKeys[key]
			if exists || key == "" {
				continue
			}

			translations = append(translations, translation.Translation{strings.ToLower(key), value})
		}

		hotspots = append(hotspots, Hotspot{
			Category:     mapEmoji(hotspotData["Category"]),
			Name:         hotspotData["Name"],
			Address:      hotspotData["Address"],
			Position:     position.Create(c, hotspotData["Latitude"], hotspotData["Longitude"]),
			Contact:      hotspotData["Contact"],
			OpeningHours: hotspotData["OpeningHours"],
			Translations: translations,
		})
	}

	return
}
示例#2
0
// Create a Poi from raw data
func Create(c appengine.Context, poiData map[string]string) (poi Poi, success bool) {
	success = false

	if poiData["Visible"] != "y" {
		return
	}

	for requiredKey := range requiredKeys {
		if poiData[requiredKey] == "" {
			return
		}
	}

	var translations []translation.Translation
	translations = append(translations, translation.Translation{"english", poiData["Description"]})

	for key, value := range poiData {
		_, exists := nonTranslationKeys[key]
		if exists || key == "" {
			continue
		}

		translations = append(translations, translation.Translation{strings.ToLower(key), value})
	}

	success = true
	poi = Poi{
		Category:     mapEmoji(poiData["Category"]),
		Name:         poiData["Name"],
		Address:      poiData["Address"],
		Position:     position.Create(c, poiData["Latitude"], poiData["Longitude"]),
		Contact:      poiData["Contact"],
		OpeningHours: poiData["OpeningHours"],
		Translations: translations,
	}

	return
}
示例#3
0
// Parse the city data
func load(c appengine.Context) (cities []City) {
	sheetId := "0"
	headerRow := 0
	citiesData := spreadsheet.Get(c, constants.CitySpreadsheetId, sheetId, headerRow)

	for _, cityData := range citiesData {
		if cityData["visible"] != "y" {
			continue
		}

		city := City{
			ID:            cityData["ID"],
			Name:          cityData["City"],
			Position:      position.Create(c, cityData["lat"], cityData["lng"]),
			SpreadsheetId: cityData["Spreadsheet ID"],
			SheetId:       cityData["Sheet ID"],
		}

		cities = append(cities, city)
	}

	return
}
示例#4
0
// Parse the location data
func All(c appengine.Context) (locations []Location) {
	sheetId := "0"
	headerRow := 0
	locationsData := spreadsheet.Get(c, constants.LocationSpreadsheetId, sheetId, headerRow)

	for _, locationData := range locationsData {
		if locationData["visible"] != "y" {
			continue
		}

		location := Location{
			ID:            locationData["ID"],
			Name:          locationData["City"],
			Position:      position.Create(c, locationData["Lat"], locationData["Lng"]),
			SpreadsheetId: locationData["Spreadsheet ID"],
			SheetId:       locationData["Sheet ID"],
		}

		locations = append(locations, location)
	}

	return
}