コード例 #1
0
ファイル: hotspots.go プロジェクト: Poltergeist/refugeemaps
// 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
ファイル: categories.go プロジェクト: pwambach/refugeemaps
// Load and parse the categories
func Load(c appengine.Context) (categories []Category) {
	sheetId := "0"
	headerRow := 0
	categoriesData := spreadsheet.Get(c, constants.CategoriesSpreadsheetId, sheetId, headerRow)

	categories = append(categories, allCategories)

	for rowId, categoryData := range categoriesData {
		if rowId == 0 {
			continue
		}

		if categoryData["visible"] != "y" {
			continue
		}

		var translations []translation.Translation

		for key, value := range categoryData {
			if key == "visible" || key == "key" {
				continue
			}

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

		categories = append(categories, Category{
			Key:          categoryData["key"],
			Checked:      false,
			Translations: translations,
		})
	}

	return
}
コード例 #3
0
// Get all the pois for that location
func (location Location) GetPois(c appengine.Context) (allPois []poi.Poi) {
	headerRow := 1
	poisData := spreadsheet.Get(c, location.SpreadsheetId, location.SheetId, headerRow)

	for _, poiData := range poisData {
		newPoi, success := poi.Create(c, poiData)

		if success {
			allPois = append(allPois, newPoi)
		}
	}

	return
}
コード例 #4
0
ファイル: load.go プロジェクト: pwambach/refugeemaps
// 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
}
コード例 #5
0
ファイル: locations.go プロジェクト: refugeemaps/refugeemaps
// 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
}