public static function ProximityTrait::getDistanceConversions in Geolocation Field 8.3
Same name and namespace in other branches
- 8.2 src/ProximityTrait.php \Drupal\geolocation\ProximityTrait::getDistanceConversions()
Get distance conversion factor.
Parameters
string $unit: Optional unit.
Return value
array|float Either specific factor or all.
1 call to ProximityTrait::getDistanceConversions()
- ProximityTrait::convertDistance in src/
ProximityTrait.php - Convert to/from km.
File
- src/
ProximityTrait.php, line 19
Class
- ProximityTrait
- Trait ProximityTrait.
Namespace
Drupal\geolocationCode
public static function getDistanceConversions($unit = NULL) {
$conversions = [
'km' => 1,
'mi' => 1.609344,
'nm' => 1.852,
'm' => 0.001,
'ly' => 9460753090819,
];
if (!empty($conversions[$unit])) {
return $conversions[$unit];
}
return $conversions;
}