[TYPO3-mvc] How would you realize a radius search

Xavier Perseguers xavier at typo3.org
Tue Feb 19 13:46:18 CET 2013


Hi,

> At the moment my approach is a single sql query for my results. It works
> for the moment but i dont like it.
> public function findClosest($regionalObject,
> $excludeAllreadyDisplayed=FALSE, $andWhere = '',$limit=6) {
>        
>         if ($regionalObject instanceof
> \Pixelpoint\RegionalObject\Domain\Model\RegionalObject) {
>        
>             $lat = $regionalObject->getLatitude();
>             $lng = $regionalObject->getLongitude();
>             $table = $this->getTableName();
>        
>             $sql =
>             "SELECT *,
>             (
>                 acos(
>                       sin(latitude)
>                     * sin($lat)
>                     + cos(latitude)
>                     * cos($lat)
>                     * cos(longitude - $lng)
>                 ) * 6371
>             ) AS distance

^^^^ this is exactly why I suggested to NOT do it totally in SQL :)

Cheers
Xavier

-- 
Xavier Perseguers
Release Manager TYPO3 4.6

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org



More information about the TYPO3-project-typo3v4mvc mailing list