+ // For state / country level searches the normal radius search doesn't work very well
+ $sPlaceGeom = false;
+ if ($iMaxRank < 9 && $bCacheTable)
+ {
+ // Try and get a polygon to search in instead
+ $sSQL = "select geometry from placex where place_id in ($sPlaceIDs) and rank_search < $iMaxRank + 5 and st_geometrytype(geometry) in ('ST_Polygon','ST_MultiPolygon') order by rank_search asc limit 1";
+ if (CONST_Debug) var_dump($sSQL);
+ $sPlaceGeom = $oDB->getOne($sSQL);
+ }
+
+ if ($sPlaceGeom)
+ {
+ $sPlaceIDs = false;
+ }
+ else
+ {
+ $iMaxRank += 5;