handle 'order state level queries better

This commit is contained in:
Brian Quinion
2011-05-23 16:22:25 +00:00
parent 535c3d60d1
commit c6982e7700

View File

@@ -898,7 +898,7 @@
// More efficient - can make the range bigger // More efficient - can make the range bigger
$fRange = 0.05; $fRange = 0.05;
$sSQL = "select l.place_id from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." as l"; $sSQL = "select distinct l.place_id from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." as l";
if ($sCountryCodesSQL) $sSQL .= " join placex as lp using (place_id)"; if ($sCountryCodesSQL) $sSQL .= " join placex as lp using (place_id)";
if ($sPlaceIDs) if ($sPlaceIDs)
{ {
@@ -926,7 +926,7 @@
else else
{ {
if (isset($aSearch['fRadius']) && $aSearch['fRadius']) $fRange = $aSearch['fRadius']; if (isset($aSearch['fRadius']) && $aSearch['fRadius']) $fRange = $aSearch['fRadius'];
$sSQL = "select l.place_id from placex as l,placex as f where "; $sSQL = "select distinct l.place_id from placex as l,placex as f where ";
$sSQL .= "f.place_id in ( $sPlaceIDs) and ST_DWithin(l.geometry, st_centroid(f.geometry), $fRange) "; $sSQL .= "f.place_id in ( $sPlaceIDs) and ST_DWithin(l.geometry, st_centroid(f.geometry), $fRange) ";
$sSQL .= "and l.class='".$aSearch['sClass']."' and l.type='".$aSearch['sType']."' "; $sSQL .= "and l.class='".$aSearch['sClass']."' and l.type='".$aSearch['sType']."' ";
if (sizeof($aExcludePlaceIDs)) if (sizeof($aExcludePlaceIDs))