From: Pratik Joshi Date: Mon, 10 Mar 2014 08:33:39 +0000 (+0530) Subject: CRM-14317 fix for : while looking into this issue, found a DB: NAN field not found X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=06415a75741cf532b391dc67a754ef7301872964;p=civicrm-core.git CRM-14317 fix for : while looking into this issue, found a DB: NAN field not found --- diff --git a/CRM/Contact/BAO/ProximityQuery.php b/CRM/Contact/BAO/ProximityQuery.php index 9008e6f4e8..66df70b472 100644 --- a/CRM/Contact/BAO/ProximityQuery.php +++ b/CRM/Contact/BAO/ProximityQuery.php @@ -203,11 +203,25 @@ class CRM_Contact_BAO_ProximityQuery { $distance ); + // DONT consider NAN values (which is returned by rad2deg php function) + // for checking BETWEEN geo_code's criteria as it throws obvious 'NAN' field not found DB: Error + $geoCodeWhere = array(); + if (!is_nan($minLatitude)) { + $geoCodeWhere[] = "{$tablePrefix}.geo_code_1 >= $minLatitude "; + } + if (!is_nan($maxLatitude)) { + $geoCodeWhere[] = "{$tablePrefix}.geo_code_1 <= $maxLatitude "; + } + if (!is_nan($minLongitude)) { + $geoCodeWhere[] = "{$tablePrefix}.geo_code_2 >= $minLongitude "; + } + if (!is_nan($maxLongitude)) { + $geoCodeWhere[] = "{$tablePrefix}.geo_code_2 <= $maxLongitude "; + } + $geoCodeWhereClause = implode(' AND ', $geoCodeWhere); + $where = " -{$tablePrefix}.geo_code_1 >= $minLatitude AND -{$tablePrefix}.geo_code_1 <= $maxLatitude AND -{$tablePrefix}.geo_code_2 >= $minLongitude AND -{$tablePrefix}.geo_code_2 <= $maxLongitude AND +{$geoCodeWhereClause} AND ACOS( COS(RADIANS({$tablePrefix}.geo_code_1)) * COS(RADIANS($latitude)) * @@ -216,7 +230,6 @@ ACOS( SIN(RADIANS($latitude)) ) * 6378137 <= $distance "; - return $where; }