protected function _filterDistance(AnCommandContext $context)
    {
        $query = $context->query;
        $location = $query->search_nearby;

        $lat = $location['latitude'];
        $lng = $location['longitude'];

        //range in kilometers
        $range = $query->search_range * 1000;

        //Spherical Law of Cosines
        $calc_distance = 'CEIL((ACOS(SIN('.$lat.'*PI()/180) * SIN(@col(locations.geo_latitude)*PI()/180) + COS('.$lat.'*PI()/180) * COS(@col(locations.geo_latitude)*PI()/180) * COS(('.$lng.'*PI()/180) - (@col(locations.geo_longitude)*PI()/180) )) *'.self::EARTH_RADIUS.'))';

        $query->select(array($calc_distance.' AS `distance`'));

        $query->group('@col(node.id)');
        $query->having('distance < '.$range);
    }
protected function _filterDistance(AnCommandContext $context)
    {
        $query = $context->query;
        $location = $query->search_nearby;

        $lat = $location['latitude'];
        $lng = $location['longitude'];

        //range in kilometers
        $range = $query->search_range * 1000;

        //Spherical Law of Cosines
        $calc_distance = 'CEIL((ACOS(SIN('.$lat.'*PI()/180) * SIN(@col(locations.geo_latitude)*PI()/180) + COS('.$lat.'*PI()/180) * COS(@col(locations.geo_latitude)*PI()/180) * COS(('.$lng.'*PI()/180) - (@col(locations.geo_longitude)*PI()/180) )) *'.self::EARTH_RADIUS.'))';

        $query->select(array($calc_distance.' AS `distance`'));

        $query->group('@col(node.id)');
        $query->having('distance < '.$range);
    }
protected function _filterDistance ( AnCommandContext $ context ) { $ query = $ context -> query ; $ location = $ query -> search_nearby ; $ lat = $ location [ 'latitude' ] ; $ lng = $ location [ 'longitude' ] ; //range in kilometers $ range = $ query -> search_range * 1000 ; //Spherical Law of Cosines $ calc_distance = 'CEIL((ACOS(SIN(' . $ lat . '*PI()/180) * SIN(@col(locations.geo_latitude)*PI()/180) + COS(' . $ lat . '*PI()/180) * COS(@col(locations.geo_latitude)*PI()/180) * COS((' . $ lng . '*PI()/180) - (@col(locations.geo_longitude)*PI()/180) )) *' . self :: EARTH_RADIUS . '))' ; $ query -> select ( array ( $ calc_distance . ' AS `distance`' ) ) ; $ query -> group ( '@col(node.id)' ) ; $ query -> having ( 'distance < ' . $ range ) ; }
Filter the nodes nearby a particular longitude and latitude
Filter the nodes nearby a particular longitude and latitude