/** * Pretty print a position mapping either to a city or cleaned coordinates * * @return string */ static function pretty_print_location(midgardmvc_helper_location_spot $spot) { $closest = midgardmvc_helper_location_utils::get_closest('midgardmvc_helper_location_city', $spot, 1); $city_string = midgardmvc_helper_location_utils::pretty_print_coordinates($spot); foreach ($closest as $city) { $city_spot = new midgardmvc_helper_location_spot($city); $city_distance = round(midgardmvc_helper_location_utils::get_distance($spot, $city_spot)); if ($city_distance <= 4) { $city_string = "{$city->city}, {$city->country}"; } else { $bearing = midgardmvc_helper_location_utils::get_bearing($city_spot, $spot); $city_string = sprintf(midgardmvc_core::get_instance()->i18n->get_string('%skm %s of %s', 'midgardmvc_helper_location'), $city_distance, $bearing, "{$city->city}, {$city->country}"); } } return $city_string; }