X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/e94b667e16177916dc34d790df475a69fe01a7d9..6f442b6617dc30729b7657f3e5e6e5dfb57e6ac0:/lib/Geocode.php diff --git a/lib/Geocode.php b/lib/Geocode.php index 8eaa5402..d699263e 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -399,7 +399,7 @@ $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$this->aLangPrefOrder))."]"; // Get the details for display (is this a redundant extra step?) - $sPlaceIDs = join(',',array_keys($aPlaceIDs)); + $sPlaceIDs = join(',', array_keys($aPlaceIDs)); $sImportanceSQL = ''; if ($this->sViewboxSmallSQL) $sImportanceSQL .= " case when ST_Contains($this->sViewboxSmallSQL, ST_Collect(centroid)) THEN 1 ELSE 0.75 END * "; @@ -437,9 +437,10 @@ //Tiger search only if a housenumber was searched and if it was found (i.e. aPlaceIDs[placeID] = housenumber != -1) (realized through a join) //only Tiger housenumbers need to be interpolated, because they are saved as lines with start- and endnumber, the common osm housenumbers are usually saved as points $sHousenumbers = ""; - $i=0; - $length=count($aPlaceIDs); - foreach($aPlaceIDs as $placeID => $housenumber){ + $i = 0; + $length = count($aPlaceIDs); + foreach($aPlaceIDs as $placeID => $housenumber) + { $i++; $sHousenumbers .= "(".$placeID.", ".$housenumber.")"; if($i<$length) @@ -453,13 +454,13 @@ $sSQL .= ", null as ref"; if ($this->bIncludeExtraTags) $sSQL .= ", null as extra"; if ($this->bIncludeNameDetails) $sSQL .= ", null as names"; - $sSQL .= ", avg(st_x(point)) as lon, avg(st_y(point)) as lat"; - $sSQL .= $sImportanceSQL.", -1.15 as importance "; + $sSQL .= ", avg(st_x(centroid)) as lon, avg(st_y(centroid)) as lat,"; + $sSQL .= $sImportanceSQL."-1.15 as importance "; $sSQL .= ", (select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(blub.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 .= " from (select place_id"; //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 centroid, parent_place_id, housenumber_for_place "; $sSQL .= "from (location_property_tiger "; $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 @@ -873,7 +874,8 @@ } // Do we have anything that looks like a lat/lon pair? - if ( $aLooksLike = looksLikeLatLonPair($sQuery) ){ + if ( $aLooksLike = looksLikeLatLonPair($sQuery) ) + { $this->setNearPoint(array($aLooksLike['lat'], $aLooksLike['lon'])); $sQuery = $aLooksLike['query']; } @@ -1216,7 +1218,7 @@ foreach($aSearches as $aSearch) { $iQueryLoop++; - $searchedHousenumber=-1; + $searchedHousenumber = -1; if (CONST_Debug) { echo "