11struct WeatherCityCandidate {
21inline std::vector<WeatherCityCandidate> selectWeatherCities(std::vector<WeatherCityCandidate> candidates) {
22 std::sort(candidates.begin(), candidates.end(), [](
const auto& a,
const auto& b) {
23 return std::tie(a.priority, a.name, a.latitude, a.longitude) <
24 std::tie(b.priority, b.name, b.latitude, b.longitude);
26 std::vector<WeatherCityCandidate> selected;
27 for (
const auto& candidate : candidates) {
28 if (std::any_of(selected.begin(), selected.end(), [&candidate](
const auto& other) {
29 return (std::abs(candidate.x - other.x) < 150 && std::abs(candidate.y - other.y) < 70) ||
30 (candidate.name == other.name &&
31 std::abs(candidate.latitude - other.latitude) < 0.001 &&
32 std::abs(candidate.longitude - other.longitude) < 0.001);
34 selected.push_back(candidate);
35 if (selected.size() == 12)
break;