You are here

protected function Proximity::getCalculatedDistance in CiviCRM Entity 8.3

Get the distance.

Parameters

int $distance: The distance.

string $distance_unit: The distance unit whether i.e. miles or kilometers.

Return value

float The calculated distance depending on the distance unit.

See also

\CRM_Contact_BAO_ProximityQuery::process()

1 call to Proximity::getCalculatedDistance()
Proximity::query in src/Plugin/views/filter/Proximity.php
Add this filter to the query.

File

src/Plugin/views/filter/Proximity.php, line 226

Class

Proximity
Filter handler for proximity.

Namespace

Drupal\civicrm_entity\Plugin\views\filter

Code

protected function getCalculatedDistance($distance, $distance_unit) {
  switch ($distance_unit) {
    case 'miles':
      $distance *= 1609.344;
      break;
    case 'kilometers':
    default:
      $distance *= 1000.0;
      break;
  }
  return $distance;
}