what is the query you result in?
Until very recently I got a bug in my distance query, as well. Maybe thats what happens here?
might be just some () missing or $lng instead of $lng somewhere
To confirm that you could try using my (now correctly working) behavior to compare it:
http://www.dereuromark.de/2012/06/12/geocoding-with-cakephp/
$this->setDistanceAsVirtualField($lat, $lng);
and see if it returns sth now.
Am Freitag, 7. Dezember 2012 15:21:31 UTC+1 schrieb Mathias R:
Hi,
i have a Modelaction where i want to list all zipcodes within a radius nearby another zipcode
public function listZipcodesNearBy($zipcode = '', $radius = false, $km = 1.609344) {
if ($data = $this->findByZipcode($zipcode)) {
$lat = $data['Zipcode']['cityLat'];
$lng = $data['Zipcode']['cityLng'];
$this->virtualFields['distance'] = '
ACOS (
SIN('.$lat.' * PI() / 180) *
SIN(cityLat * PI() / 180) +
COS('.$lat.' * PI() / 180) *
COS(cityLat * PI() / 180) *
COS(('.$lng.' - cityLng) * PI() / 180)
) * 180 / PI() * 60 * 1.1515 * '.$km;
$conditions = array();
if (isset($radius)) {
$conditions = array("distance <=", (int)$radius);
}
return $this->find('list', compact('conditions'));
}
return false;
}
When i don't use virtualfields and comment out $conditions with distance <= $radius i get a list of zipcodes. But with virtualfields there's no output. no errors too..
Do you see the error? Is there a way to print sql statements build in models without action?
Please help.
Greetings from Germany
M.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment