]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 1 May 2013 09:11:06 +0000 (11:11 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 1 May 2013 09:11:06 +0000 (11:11 +0200)
1  2 
utils/setup.php
website/search.php

diff --combined utils/setup.php
index 6dc8772499d7fb06db99b578aab4671cf890959c,1c61a56b31f23c558465744e2797534afada8b23..6b0a5b37504bb94a1f5b1613996bdc2aeb5e12e6
                        echo "Please download and build osm2pgsql.\nIf it is already installed, check the path in your local settings (settings/local.php) file.\n";
                        fail("osm2pgsql not found in '$osm2pgsql'");
                }
 +              $osm2pgsql .= ' --tablespace-slim-index ssd --tablespace-main-index ssd --tablespace-main-data ssd --tablespace-slim-data data';
                $osm2pgsql .= ' -lsc -O gazetteer --hstore';
 -              $osm2pgsql .= ' -C '.$iCacheMemory;
 +              $osm2pgsql .= ' -C 16000';
                $osm2pgsql .= ' -P '.$aDSNInfo['port'];
                $osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file'];
                passthruCheckReturn($osm2pgsql);
                {
                        $aDBInstances[$i] =& getDB(true);
                        $sSQL = 'insert into placex (osm_type, osm_id, class, type, name, admin_level, ';
-                       $sSQL .= 'housenumber, street, isin, postcode, country_code, extratags, ';
+                       $sSQL .= 'housenumber, street, addr_place, isin, postcode, country_code, extratags, ';
                        $sSQL .= 'geometry) select * from place where osm_id % '.$iInstances.' = '.$i;
                        if ($aCMDResult['verbose']) echo "$sSQL\n";
                        if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($oDB->connection));
                $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,calculated_country_code,";
                $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from (select calculated_country_code,postcode,";
                $sSQL .= "avg(st_x(st_centroid(geometry))) as x,avg(st_y(st_centroid(geometry))) as y ";
 -              $sSQL .= "from placex where postcode is not null group by calculated_country_code,postcode) as x";
 +              $sSQL .= "from placex where postcode is not null and calculated_country_code not in ('ie') group by calculated_country_code,postcode) as x";
                if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
  
                $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,calculated_country_code,geometry) ";
diff --combined website/search.php
index b8a7dcde308f8a2dfd8f5aef189518a0e3df48d9,395790a2a7b6e0143068ff492d7f36f0529eabfb..54cd556d504858f37e52277e538896482a161652
@@@ -78,7 -78,6 +78,7 @@@
        if (isset($aLangPrefOrder['name:de'])) $bReverseInPlan = true;
        if (isset($aLangPrefOrder['name:ru'])) $bReverseInPlan = true;
        if (isset($aLangPrefOrder['name:ja'])) $bReverseInPlan = true;
 +      if (isset($aLangPrefOrder['name:pl'])) $bReverseInPlan = true;
  
        $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
  
                                                        }
                                                }
                                                if ($aSearch['sCountryCode']) $aTerms[] = "country_code = '".pg_escape_string($aSearch['sCountryCode'])."'";
-                                               if ($aSearch['sHouseNumber']) $aTerms[] = "address_rank between 22 and 27";
+                                               if ($aSearch['sHouseNumber']) $aTerms[] = "address_rank between 16 and 27";
                                                if ($aSearch['fLon'] && $aSearch['fLat'])
                                                {
                                                        $aTerms[] = "ST_DWithin(centroid, ST_SetSRID(ST_Point(".$aSearch['fLon'].",".$aSearch['fLat']."),4326), ".$aSearch['fRadius'].")";
                                                        $aPlaceIDs = $oDB->getCol($sSQL);
  
                                                        // If not try the aux fallback table
 +                                                      /*
                                                        if (!sizeof($aPlaceIDs))
                                                        {
                                                                $sSQL = "select place_id from location_property_aux where parent_place_id in (".$sPlaceIDs.") and housenumber = '".pg_escape_string($aSearch['sHouseNumber'])."'";
                                                                if (CONST_Debug) var_dump($sSQL);
                                                                $aPlaceIDs = $oDB->getCol($sSQL);
                                                        }
 +                                                      */
  
                                                        if (!sizeof($aPlaceIDs))
                                                        {
                                //var_Dump($aResultPlaceIDs);exit;
                                // Get the details for display (is this a redundant extra step?)
                                $sPlaceIDs = join(',',$aResultPlaceIDs);
 +                              $sImportanceSQL = '';
 +                              if ($sViewboxSmallSQL) $sImportanceSQL .= " case when ST_Contains($sViewboxSmallSQL, ST_Collect(centroid)) THEN 1 ELSE 0.75 END * ";
 +                              if ($sViewboxLargeSQL) $sImportanceSQL .= " case when ST_Contains($sViewboxLargeSQL, ST_Collect(centroid)) THEN 1 ELSE 0.75 END * ";
 +
                                $sOrderSQL = 'CASE ';
                                foreach(array_keys($aResultPlaceIDs) as $iOrder => $iPlaceID)
                                {
                                $sSQL .= "get_name_by_language(name, ARRAY['ref']) as ref,";
                                $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
                                //$sSQL .= $sOrderSQL." as porder, ";
 -                              $sSQL .= "coalesce(importance,0.75-(rank_search::float/40)) as importance, ";
 +                              $sSQL .= $sImportanceSQL."coalesce(importance,0.75-(rank_search::float/40)) as importance, ";
                                $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(placex.place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, ";
                                $sSQL .= "(extratags->'place') as extra_place ";
                                $sSQL .= "from placex where place_id in ($sPlaceIDs) ";
                                $sSQL .= "null as ref,";
                                $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
                                //$sSQL .= $sOrderSQL." as porder, ";
 -                              $sSQL .= "-0.15 as importance, ";
 +                              $sSQL .= $sImportanceSQL."0.015 as importance, ";
                                $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(location_property_tiger.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 location_property_tiger where place_id in ($sPlaceIDs) ";
                                $sSQL .= "and 30 between $iMinAddressRank and $iMaxAddressRank ";
                                $sSQL .= "group by place_id";
                                if (!$bDeDupe) $sSQL .= ",place_id";
 +                              /*
                                $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,'us' as country_code,";
                                $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= "null as ref,";
                                $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
                                //$sSQL .= $sOrderSQL." as porder, ";
 -                              $sSQL .= "-0.10 as importance, ";
 +                              $sSQL .= $sImportanceSQL."0.01 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.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 location_property_aux where place_id in ($sPlaceIDs) ";
                                $sSQL .= ",get_address_by_language(place_id, $sLanguagePrefArraySQL) ";
                                $sSQL .= "order by importance desc";
                                //$sSQL .= "order by rank_search,rank_address,porder asc";
 +                              */
                                if (CONST_Debug) { echo "<hr>"; var_dump($sSQL); }
                                $aSearchResults = $oDB->getAll($sSQL);
                                //var_dump($sSQL,$aSearchResults);exit;
                                $sSQL .= "and 30 between $iMinAddressRank and $iMaxAddressRank ";
                                $sSQL .= "group by place_id";
                                if (!$bDeDupe) $sSQL .= ",place_id";
 +                              /*
                                $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,'us' as country_code,";
                                $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= ",get_address_by_language(place_id, $sLanguagePrefArraySQL) ";
                                $sSQL .= "order by importance desc";
                                //$sSQL .= "order by rank_search,rank_address,porder asc";
 +                              */
                                if (CONST_Debug) { echo "<hr>", var_dump($sSQL); }
                                $aSearchResults = $oDB->getAll($sSQL);
                                //var_dump($sSQL,$aSearchResults);exit;
                                        {
                                                preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/',$aMatch[1],$aPolyPoints,PREG_SET_ORDER);
                                        }
 -                                      elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#',$aPointPolygon['astext'],$aMatch))
 +                                      /*elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#',$aPointPolygon['astext'],$aMatch))
                                        {
                                                preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/',$aMatch[1],$aPolyPoints,PREG_SET_ORDER);
 -                                      }
 +                                      }*/
                                        elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#',$aPointPolygon['astext'],$aMatch))
                                        {
                                                $fRadius = 0.01;