]> git.openstreetmap.org Git - nominatim.git/commitdiff
Coding style adaptions and correcting small errors from merge.
authorMarkus Gail <markus.gail.94@gmail.com>
Mon, 25 Apr 2016 11:58:28 +0000 (13:58 +0200)
committerMarkus Gail <markus.gail.94@gmail.com>
Mon, 25 Apr 2016 11:58:28 +0000 (13:58 +0200)
lib/Geocode.php
utils/setup.php

index de178431b98ba9f28b388a17a57e16c086bc54c4..a37455faf92c66ccc244b5142e0a32222eb8d07b 100644 (file)
 
                        if (30 >= $this->iMinAddressRank && 30 <= $this->iMaxAddressRank)
                        {
+                               //only Tiger housenumbers and interpolation lines 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++;
+                                       $sHousenumbers .= "(".$placeID.", ".$housenumber.")";
+                                       if($i<$length)
+                                               $sHousenumbers .= ", ";
+                               }
                                if (CONST_Use_US_Tiger_Data)
                                {
-                                       //query also location_property_tiger and location_property_aux
                                        //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++;
-                                               $sHousenumbers .= "(".$placeID.", ".$housenumber.")";
-                                               if($i<$length)
-                                                       $sHousenumbers .= ", ";
-                                       }
-
-                                       $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 .= " 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 .= ", get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) as langaddress ";
                                        $sSQL .= ", null as placename";
                                        $sSQL .= ", null as ref";
                                        $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 centroid, parent_place_id, housenumber_for_place ";
-                                       $sSQL .= "from (location_property_tiger ";
+                                       $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
                                        $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 ";
                                }
                                // osmline, osm_type is 'I' for Interpolation Line
+                               // interpolation line search only if a housenumber was searched and if it was found (i.e. aPlaceIDs[placeID] = housenumber != -1) (realized through a join)
                                $sSQL .= " union ";
                                $sSQL .= "select 'I' 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, calculated_country_code as country_code, ";
                                $sSQL .= "get_address_by_language(place_id, housenumber_for_place, $sLanguagePrefArraySQL) as langaddress, ";
                                                        {
                                                                $sHouseNumberRegex = '\\\\m'.$aSearch['sHouseNumber'].'\\\\M';
                                 $aOrder[] = "";
-                                                               $aOrder[0] = "exists(select place_id from placex where parent_place_id = search_name.place_id and transliteration(housenumber) ~* E'".$sHouseNumberRegex."' limit 1) ";
+                                                               $aOrder[0] = " exists(select place_id from placex where parent_place_id = search_name.place_id";
+                                $aOrder[0] .= " and transliteration(housenumber) ~* E'".$sHouseNumberRegex."' limit 1) ";
                                                                // also housenumbers from interpolation lines table are needed
-                                                               $aOrder[0] .= " or exists(select place_id from location_property_osmline where parent_place_id = search_name.place_id and ".$aSearch['sHouseNumber'].">=startnumber and ".$aSearch['sHouseNumber']."<=endnumber limit 1)";
+                                                               $aOrder[0] .= " or exists(select place_id from location_property_osmline where parent_place_id = search_name.place_id";
+                                $aOrder[0] .= " and ".$aSearch['sHouseNumber'].">=startnumber and ".$aSearch['sHouseNumber']."<=endnumber limit 1)";
                                                                $aOrder[0] .= " desc";
                                                        }
 
                                                                        //set to -1, if no housenumbers were found
                                                                        $searchedHousenumber = -1;
                                                                }
-                                //else: housenumber was found, remains saved in searchedHousenumber
+                                                               //else: housenumber was found, remains saved in searchedHousenumber
                                                        }
 
 
                                                $aFilteredPlaceIDs = $this->oDB->getCol($sSQL);
                                                $tempIDs = array();
                                                foreach($aFilteredPlaceIDs as $placeID)
-                        {
+                                               {
                                                        $tempIDs[$placeID] = $aResultPlaceIDs[$placeID];  //assign housenumber to placeID
                                                }
                                                $aResultPlaceIDs = $tempIDs;
index caaf0f9126141dba717782a8804cdfa03becc712..a7daa1fce6bcb3eab28125330b8a4a33fb7cd3cc 100755 (executable)
 
                echo "Load Data\n";
                $aDBInstances = array();
-        
-        $aQueriesPlacex = array();
-        $aQueriesOsmline = array();
-        // the query is divided into parcels, so that the work between the processes, i.e. the DBInstances, will be evenly distributed
-        $iNumberOfParcels = 100;
-        for($i = 0; $i < $iNumberOfParcels; $i++)
-        {
+               $aQueriesPlacex = array();
+               $aQueriesOsmline = array();
+               // the query is divided into parcels, so that the work between the processes, i.e. the DBInstances, will be evenly distributed
+               $iNumberOfParcels = 100;
+               for($i = 0; $i < $iNumberOfParcels; $i++)
+               {
                        $sSQL = 'insert into placex (osm_type, osm_id, class, type, name, admin_level, ';
                        $sSQL .= 'housenumber, street, addr_place, isin, postcode, country_code, extratags, ';
                        $sSQL .= 'geometry) select * from place where osm_id % '.$iNumberOfParcels.' = '.$i.' and not ';