Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
Correction of Zero!
Browse files Browse the repository at this point in the history
Correction of Zero!
  • Loading branch information
ph-il committed Oct 6, 2014
1 parent 80c6c41 commit 189d91e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 18 additions & 4 deletions EventListener/UserGeolocationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ private function getLatitudeLongitude(Request $request, $cookie)
try {
$coords = $this->geocoder->geocode($request->getClientIp());
} catch (\Exception $e) {
$coords = $this->getDefaultCoords();
}

$coords = array(
'latitude' => "43.650297000",
'longitude' => "-79.385298000"
);
if ($coords['latitude'] == 0 || $coords['longitude']) {
$coords = $this->getDefaultCoords();
}


$cookie['latitude'] = $coords['latitude'];
$cookie['longitude'] = $coords['longitude'];
$cookie['geotype'] = 'ip';
Expand All @@ -132,4 +133,17 @@ private function getCookie($request)
return $cookie;
}
}

/**
* @return array
*/
private function getDefaultCoords()
{
$coords = array(
'latitude' => "43.650297000",
'longitude' => "-79.385298000"
);

return $coords;
}
}
2 changes: 1 addition & 1 deletion Twig/Extension/DistanceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getFilters()
);
}

public function address(Point $from, Point $to, $flags = AbstractGeotools::KILOMETER_UNIT)
public function distance(Point $from, Point $to, $flags = AbstractGeotools::KILOMETER_UNIT)
{
return $this->distance->setFrom($from)->setTo($to)->in($flags)->vincenty();
}
Expand Down

0 comments on commit 189d91e

Please sign in to comment.