Hello,
I got a geolocator app running which list locations based on their
location latitude / longitude and distance,
this works wonderfully so far...
But I got stuck howto paginate these results, since there is 2
functions used to generate the resulting array.
The 1st functions finds all records, 2nd 'fetchpoints' function just
flattens the results to a simple array...
Any help is appreciated..
Thanks,
Andras Kende
=======================================
CONTROLLER:
$locations = $this->TblClass->fetchpoints($longitude, $latitude,
$distance, $day, '0');
$this->set('locations', $locations);
=======================================
MODEL:
function findAllByDistance($x, $y, $distance = null) {
$x2 = "`TblClassLocation`.`classLocationLong`";
$y2 = "`TblClassLocation`.`classLocationLat`";
list($x, $y, $distance) = array(floatval($x), floatval($y),
floatval($distance));
return $this->find('all',array(
'limit'=>'1000',
'order'=>'distance ASC',
'fields'=>"*,
(3958 * 3.1415926 * SQRT(({$y2} - {$y}) * ({$y2} - {$y}) +
COS({$y2} / 57.29578) * COS({$y} / 57.29578) * ({$x2} - {$x}) * ({$x2}
- {$x})) / 180) AS distance",
'conditions'=>"
1=1
HAVING distance <= {$distance}"
));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
function fetchpoints($longitude, $latitude, $distance){
$points = $this->findAllByDistance($longitude, $latitude,
$distance, $day, $recursive);
$i =0;
foreach ($points as $point)
{
$id = $i;
$newpoints[$id][] = $point;
}
return $newpoints;
}
=======================================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---