adapt to code style conventions

This commit is contained in:
Markus Gail
2016-03-21 12:42:38 +01:00
parent 28166c5bb1
commit d8703c223b
4 changed files with 107 additions and 108 deletions

View File

@@ -439,13 +439,13 @@
$length=count($aPlaceIDs); $length=count($aPlaceIDs);
foreach($aPlaceIDs as $placeID => $housenumber){ foreach($aPlaceIDs as $placeID => $housenumber){
$i++; $i++;
$sHousenumbers .= "(".$placeID.",".$housenumber.")"; $sHousenumbers .= "(".$placeID.", ".$housenumber.")";
if($i<$length) if($i<$length)
$sHousenumbers .= ","; $sHousenumbers .= ", ";
} }
$sSQL .= "union "; $sSQL .= "union ";
$sSQL .= "select 'T' as osm_type, place_id as osm_id,'place' as class,'house' as type,null as admin_level,30 as rank_search,30 as rank_address,min(place_id) as place_id, min(parent_place_id) as parent_place_id,'us' as country_code"; $sSQL .= "select 'T' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, 30 as rank_search, 30 as rank_address, min(place_id) as place_id, min(parent_place_id) as parent_place_id, 'us' as country_code";
$sSQL .= ", get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) as langaddress "; $sSQL .= ", get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) as langaddress ";
$sSQL .= ", null as placename"; $sSQL .= ", null as placename";
$sSQL .= ", null as ref"; $sSQL .= ", null as ref";
@@ -457,29 +457,29 @@
$sSQL .= ", null as extra_place "; $sSQL .= ", null as extra_place ";
$sSQL .= " from (select place_id"; $sSQL .= " from (select place_id";
//interpolate the Tiger housenumbers here //interpolate the Tiger housenumbers here
$sSQL .= ",ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) as point, parent_place_id, housenumber_for_place "; $sSQL .= ", ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) as point, parent_place_id, housenumber_for_place ";
$sSQL .= "from (location_property_tiger "; $sSQL .= "from (location_property_tiger ";
$sSQL .= " join (values ".$sHousenumbers.") as housenumbers(place_id,housenumber_for_place) using(place_id)) "; $sSQL .= " join (values ".$sHousenumbers.") as housenumbers(place_id, housenumber_for_place) using(place_id)) ";
$sSQL .= " where housenumber_for_place>=0 and 30 between $this->iMinAddressRank and $this->iMaxAddressRank) as blub"; //postgres wants an alias here $sSQL .= " where housenumber_for_place>=0 and 30 between $this->iMinAddressRank and $this->iMaxAddressRank) as blub"; //postgres wants an alias here
$sSQL .= " group by place_id, housenumber_for_place"; //is this group by really needed?, place_id + housenumber (in combination) are unique $sSQL .= " group by place_id, housenumber_for_place"; //is this group by really needed?, place_id + housenumber (in combination) are unique
if (!$this->bDeDupe) $sSQL .= ",place_id "; if (!$this->bDeDupe) $sSQL .= ", place_id ";
$sSQL .= " union "; $sSQL .= " union ";
$sSQL .= "select 'L' as osm_type,place_id as osm_id,'place' as class,'house' as type,null as admin_level,30 as rank_search,30 as rank_address,min(place_id) as place_id, min(parent_place_id) as parent_place_id,'us' as country_code,"; $sSQL .= "select 'L' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, 0 as rank_search, 0 as rank_address, min(place_id) as place_id, min(parent_place_id) as parent_place_id, 'us' as country_code, ";
$sSQL .= "get_address_by_language(place_id, -1, $sLanguagePrefArraySQL) as langaddress,"; $sSQL .= "get_address_by_language(place_id, -1, $sLanguagePrefArraySQL) as langaddress, ";
$sSQL .= "null as placename,"; $sSQL .= "null as placename, ";
$sSQL .= "null as ref,"; $sSQL .= "null as ref, ";
if ($this->bIncludeExtraTags) $sSQL .= "null as extra,"; if ($this->bIncludeExtraTags) $sSQL .= "null as extra, ";
if ($this->bIncludeNameDetails) $sSQL .= "null as names,"; if ($this->bIncludeNameDetails) $sSQL .= "null as names, ";
$sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, "; $sSQL .= "avg(ST_X(centroid)) as lon, avg(ST_Y(centroid)) as lat, ";
$sSQL .= $sImportanceSQL."-1.10 as importance, "; $sSQL .= $sImportanceSQL."-1.10 as importance, ";
$sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(location_property_aux.parent_place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, "; $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(location_property_aux.parent_place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, ";
$sSQL .= "null as extra_place "; $sSQL .= "null as extra_place ";
$sSQL .= "from location_property_aux where place_id in ($sPlaceIDs) "; $sSQL .= "from location_property_aux where place_id in ($sPlaceIDs) ";
$sSQL .= "and 30 between $this->iMinAddressRank and $this->iMaxAddressRank "; $sSQL .= "and 30 between $this->iMinAddressRank and $this->iMaxAddressRank ";
$sSQL .= "group by place_id"; $sSQL .= "group by place_id";
if (!$this->bDeDupe) $sSQL .= ",place_id"; if (!$this->bDeDupe) $sSQL .= ", place_id";
$sSQL .= ",get_address_by_language(place_id, -1, $sLanguagePrefArraySQL) "; $sSQL .= ", get_address_by_language(place_id, -1, $sLanguagePrefArraySQL) ";
} }
$sSQL .= " order by importance desc"; $sSQL .= " order by importance desc";
@@ -1444,7 +1444,6 @@
$searchedHousenumber = intval($aSearch['sHouseNumber']); $searchedHousenumber = intval($aSearch['sHouseNumber']);
if (!sizeof($aPlaceIDs)) if (!sizeof($aPlaceIDs))
{ {
//$sSQL = "select place_id from location_property_tiger where parent_place_id in (".$sPlaceIDs.") and housenumber = '".pg_escape_string($aSearch['sHouseNumber'])."'";
//new query for lines, not housenumbers anymore //new query for lines, not housenumbers anymore
if($searchedHousenumber%2==0){ if($searchedHousenumber%2==0){
//if housenumber is even, look for housenumber in streets with interpolationtype even or all //if housenumber is even, look for housenumber in streets with interpolationtype even or all
@@ -1456,12 +1455,12 @@
if (sizeof($this->aExcludePlaceIDs)) if (sizeof($this->aExcludePlaceIDs))
{ {
$sSQL .= " and place_id not in (".join(',',$this->aExcludePlaceIDs).")"; $sSQL .= " and place_id not in (".join(',', $this->aExcludePlaceIDs).")";
} }
//$sSQL .= " limit $this->iLimit"; //$sSQL .= " limit $this->iLimit";
if (CONST_Debug) var_dump($sSQL); if (CONST_Debug) var_dump($sSQL);
//get place IDs //get place IDs
$aPlaceIDs = $this->oDB->getCol($sSQL,0); $aPlaceIDs = $this->oDB->getCol($sSQL, 0);
} }
// Fallback to the road (if no housenumber was found) // Fallback to the road (if no housenumber was found)
@@ -1478,7 +1477,7 @@
if ($aSearch['sClass'] && sizeof($aPlaceIDs)) if ($aSearch['sClass'] && sizeof($aPlaceIDs))
{ {
$sPlaceIDs = join(',',$aPlaceIDs); $sPlaceIDs = join(',', aPlaceIDs);
$aClassPlaceIDs = array(); $aClassPlaceIDs = array();
if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'name') if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'name')