@@ -2,21 +2,21 @@ |
||
| 2 | 2 | |
| 3 | 3 | class DistanceDataExtension extends DataExtension |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * @param SQLQuery $query |
|
| 7 | - */ |
|
| 8 | - public function augmentSQL(SQLQuery &$query) |
|
| 9 | - { |
|
| 10 | - if (Controller::curr()->getRequest()->getVar('Address')) { // on frontend |
|
| 11 | - $coords = GoogleGeocoding::address_to_point(Controller::curr()->getRequest()->getVar('Address')); |
|
| 5 | + /** |
|
| 6 | + * @param SQLQuery $query |
|
| 7 | + */ |
|
| 8 | + public function augmentSQL(SQLQuery &$query) |
|
| 9 | + { |
|
| 10 | + if (Controller::curr()->getRequest()->getVar('Address')) { // on frontend |
|
| 11 | + $coords = GoogleGeocoding::address_to_point(Controller::curr()->getRequest()->getVar('Address')); |
|
| 12 | 12 | |
| 13 | - $Lat = $coords['lat']; |
|
| 14 | - $Lng = $coords['lng']; |
|
| 13 | + $Lat = $coords['lat']; |
|
| 14 | + $Lng = $coords['lng']; |
|
| 15 | 15 | |
| 16 | - $query |
|
| 17 | - ->addSelect(array( |
|
| 18 | - '( 3959 * acos( cos( radians('.$Lat.') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians('.$Lng.') ) + sin( radians('.$Lat.') ) * sin( radians( `Lat` ) ) ) ) AS distance', |
|
| 19 | - )); |
|
| 20 | - } |
|
| 21 | - } |
|
| 16 | + $query |
|
| 17 | + ->addSelect(array( |
|
| 18 | + '( 3959 * acos( cos( radians('.$Lat.') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians('.$Lng.') ) + sin( radians('.$Lat.') ) * sin( radians( `Lat` ) ) ) ) AS distance', |
|
| 19 | + )); |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | /** |
| 6 | 6 | * @param SQLQuery $query |
| 7 | 7 | */ |
| 8 | - public function augmentSQL(SQLQuery &$query) |
|
| 8 | + public function augmentSQL(SQLQuery & $query) |
|
| 9 | 9 | { |
| 10 | 10 | if (Controller::curr()->getRequest()->getVar('Address')) { // on frontend |
| 11 | 11 | $coords = GoogleGeocoding::address_to_point(Controller::curr()->getRequest()->getVar('Address')); |