Error in Geographical Template - input is out of range - Doctrine / Symfony

This discussion is closed: you can't post new comments.

If you are using the getDistance method provided by Geogrphical Template in Doctrine and got this error:

UPDATE: IT WAS FIXED, CHECK IT OUT AT http://www.doctrine-project.org/jira/browse/DC-524


500 | Internal Server Error | Doctrine_Connection_Pgsql_Exception
SQLSTATE[22003]: Numeric value out of range: 7 ERROR: input is out of range

You probably have the same problem that I got today..

I'm using NUMERIC on column type with precision 10, but the problem is not in the column latitude and longitude, it´s on calculation.

To resolve this problem I made a casting inside of ACOS function calculation, I tested it only in postgresql.

My DQL used to get all hotels around 3 kilometers of hotel id 189646


at Doctrine_Connection->execute('SELECT h.latitude AS hlatitude, h.longitude AS hlongitude, ((ACOS(SIN(45.41244780000000000000 * PI() / 180) * SIN(h.latitude * PI() / 180) + COS(45.41244780000000000000 * PI() / 180) * COS(h.latitude * PI() / 180) * COS((6.63685100000000000000 - h.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS h0, ((ACOS(SIN(45.41244780000000000000 * PI() / 180) * SIN(h.latitude * PI() / 180) + COS(45.41244780000000000000 * PI() / 180) * COS(h.latitude * PI() / 180) * COS((6.63685100000000000000 - h.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344) AS h1 FROM hotel h WHERE (((ACOS(SIN(45.41244780000000000000 * PI() / 180) * SIN(h.latitude * PI() / 180) + COS(45.41244780000000000000 * PI() / 180) * COS(h.latitude * PI() / 180) * COS((6.63685100000000000000 - h.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344) < 3 AND h.is_published = ? AND h.id != ?) ORDER BY h_1 asc LIMIT 5', array('true', 189646))

I post this issue on doctrine project: http://www.doctrine-project.org/jira/browse/DC-524

AttachmentSize
Geographical.patch1.1 KB