51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package domain
|
|
|
|
// CityCoordinates contains coordinates for Polish cities with power plants
|
|
var CityCoordinates = map[string]struct{ Lat, Lon float64 }{
|
|
"Zabrze": {Lat: 50.3015, Lon: 18.7912},
|
|
"Piotrków Trybunalski": {Lat: 51.4054, Lon: 19.7031},
|
|
"Grudziądz": {Lat: 53.4836, Lon: 18.7536},
|
|
"Tczew": {Lat: 54.0915, Lon: 18.7793},
|
|
"Radom": {Lat: 51.4027, Lon: 21.1471},
|
|
"Chelmno": {Lat: 53.3479, Lon: 18.4256},
|
|
"Żarnowiec": {Lat: 54.7317, Lon: 18.0431},
|
|
}
|
|
|
|
// PowerPlantInfo contains information about a power plant
|
|
type PowerPlantInfo struct {
|
|
IsActive bool `json:"is_active"`
|
|
Power string `json:"power"`
|
|
Code string `json:"code"`
|
|
}
|
|
|
|
// PowerPlantsData represents the structure from findhim_locations.json
|
|
type PowerPlantsData struct {
|
|
PowerPlants map[string]PowerPlantInfo `json:"power_plants"`
|
|
}
|
|
|
|
// ToLocations converts power plants data to locations with coordinates
|
|
func (p *PowerPlantsData) ToLocations() []Location {
|
|
var locations []Location
|
|
|
|
for city, info := range p.PowerPlants {
|
|
// Only include active power plants
|
|
if !info.IsActive {
|
|
continue
|
|
}
|
|
|
|
coords, ok := CityCoordinates[city]
|
|
if !ok {
|
|
// Skip cities without known coordinates
|
|
continue
|
|
}
|
|
|
|
locations = append(locations, Location{
|
|
Name: city,
|
|
Latitude: coords.Lat,
|
|
Longitude: coords.Lon,
|
|
})
|
|
}
|
|
|
|
return locations
|
|
}
|