X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/616c7e2b40ac842f1358463f0cf84c76d1aa5292..7239687e5b7fab3c48a567cfee811fc8e9d1f2e8:/website/search.php diff --git a/website/search.php b/website/search.php index 2765ab45..7169c829 100755 --- a/website/search.php +++ b/website/search.php @@ -101,7 +101,6 @@ $aPhrases = array_reverse($aPhrases); $sQuery = join(', ',$aPhrases); } - if ($sQuery) { $hLog = logStart($oDB, 'search', $sQuery, $aLangPrefOrder); @@ -113,6 +112,7 @@ $sQuery = preg_replace('/\\bil\\b/','illinois', $sQuery); $sQuery = preg_replace('/\\bal\\b/','alabama', $sQuery); $sQuery = preg_replace('/\\bla\\b/','louisiana', $sQuery); + $sQuery = preg_replace('/\\bde louisiana\\b/','de la', $sQuery); } // If we have a view box create the SQL @@ -191,7 +191,7 @@ $_GET['nearlon'] = ($aData[6]=='E'?1:-1) * ($aData[4] + $aData[5]/60); $sQuery = trim(str_replace($aData[0], ' ', $sQuery)); } - elseif (preg_match('/(\\[|\\b)(-?[0-9]+[0-9.]*)[, ]+(-?[0-9]+[0-9.]*)(\\]|\\b)/', $sQuery, $aData)) + elseif (preg_match('/(\\[|^|\\b)(-?[0-9]+[0-9.]*)[, ]+(-?[0-9]+[0-9.]*)(\\]|$|\\b)/', $sQuery, $aData)) { $_GET['nearlat'] = $aData[2]; $_GET['nearlon'] = $aData[3]; @@ -899,9 +899,9 @@ $fRange = 0.05; $sOrderBySQL = ''; - if ($sNearPointSQL) $sOrderBySQL .= "ST_Distance($sNearPointSQL, l.centroid)"; - else if ($sPlaceIDs) $sOrderBySQL .= "ST_Distance(l.centroid, f.geometry)"; - else if ($sPlaceGeom) $sOrderBysSQL .= "ST_Distance(st_centroid('".$sPlaceGeom."'), l.centroid)"; + if ($sNearPointSQL) $sOrderBySQL = "ST_Distance($sNearPointSQL, l.centroid)"; + else if ($sPlaceIDs) $sOrderBySQL = "ST_Distance(l.centroid, f.geometry)"; + else if ($sPlaceGeom) $sOrderBysSQL = "ST_Distance(st_centroid('".$sPlaceGeom."'), l.centroid)"; $sSQL = "select distinct l.place_id".($sOrderBysSQL?','.$sOrderBysSQL:'')." from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." as l"; if ($sCountryCodesSQL) $sSQL .= " join placex as lp using (place_id)"; @@ -931,8 +931,8 @@ if (isset($aSearch['fRadius']) && $aSearch['fRadius']) $fRange = $aSearch['fRadius']; $sOrderBySQL = ''; - if ($sNearPointSQL) $sOrderBySQL .= "ST_Distance($sNearPointSQL, l.geometry)"; - else $sOrderBySQL .= "ST_Distance(l.geometry, f.geometry)"; + if ($sNearPointSQL) $sOrderBySQL = "ST_Distance($sNearPointSQL, l.geometry)"; + else $sOrderBySQL = "ST_Distance(l.geometry, f.geometry)"; $sSQL = "select distinct l.place_id".($sOrderBysSQL?','.$sOrderBysSQL:'')." from placex as l,placex as f where "; $sSQL .= "f.place_id in ( $sPlaceIDs) and ST_DWithin(l.geometry, st_centroid(f.geometry), $fRange) "; @@ -1161,7 +1161,7 @@ } // Output data suitable for display (points and a bounding box) - if ($bShowPolygons) + if ($bShowPolygons && isset($aPolyPoints)) { $aResult['aPolyPoints'] = array(); foreach($aPolyPoints as $aPoint)