-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmeta.go
36 lines (33 loc) · 1004 Bytes
/
meta.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"time"
"fmt"
)
type PokemonMeta struct {
Name string
Icon string
ExpiresAt time.Time
ExpiresAtTimestamp int
Latitude, Longitude float64
Distance int
Location string
URL string
Pokemon Pokemon
PokedexPokemon PokedexPokemon
}
func GetPokemonMeta(config Config, pokedex Pokedex, pokemon Pokemon) PokemonMeta {
pokedexPokemon := pokedex.Get(pokemon.PokedexID)
return PokemonMeta{
Name: pokedexPokemon.Name,
Icon: pokedexPokemon.Icon(),
ExpiresAt: pokemon.ExpiresAt,
ExpiresAtTimestamp: int(pokemon.ExpiresAt.Unix()),
Latitude: pokemon.Latitude,
Longitude: pokemon.Longitude,
Distance: int(DistanceBetweenDP(config.Lat, config.Lon, pokemon.Latitude, pokemon.Longitude, 0)),
Location: config.Name,
URL: fmt.Sprintf("https://maps.google.com/maps?q=%v,%v&z=19", pokemon.Latitude, pokemon.Longitude),
Pokemon: pokemon,
PokedexPokemon: pokedexPokemon,
}
}