]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 4 May 2015 19:24:51 +0000 (21:24 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 4 May 2015 19:24:51 +0000 (21:24 +0200)
1  2 
lib/Geocode.php
lib/lib.php
sql/functions.sql
utils/setup.php

diff --combined lib/Geocode.php
index 5464c386b21631aee1a67f8fcd45990ea2be41a4,18062d8c8784d259824115382cbcf0c4ac3e2716..2d5d33944e640a7b0fa92bfc6bb028ae84dc68bb
@@@ -16,7 -16,7 +16,7 @@@
  
                protected $aExcludePlaceIDs = array();
                protected $bDeDupe = true;
 -              protected $bReverseInPlan = false;
 +              protected $bReverseInPlan = true;
  
                protected $iLimit = 20;
                protected $iFinalLimit = 10;
                                $sSQL .= "and 30 between $this->iMinAddressRank and $this->iMaxAddressRank ";
                                $sSQL .= "group by place_id";
                                if (!$this->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, min(parent_place_id) as parent_place_id,'us' as country_code,";
                                $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= "group by place_id";
                                if (!$this->bDeDupe) $sSQL .= ",place_id";
                                $sSQL .= ",get_address_by_language(place_id, $sLanguagePrefArraySQL) ";
 +                              */
                        }
  
                        $sSQL .= " order by importance desc";
                                                        // TODO: filter out the pointless search terms (2 letter name tokens and less)
                                                        // they might be right - but they are just too darned expensive to run
                                                        if (sizeof($aSearch['aName'])) $aTerms[] = "name_vector @> ARRAY[".join($aSearch['aName'],",")."]";
 -                                                      if (sizeof($aSearch['aNameNonSearch'])) $aTerms[] = "array_cat(name_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aNameNonSearch'],",")."]";
 +                                                      //if (sizeof($aSearch['aNameNonSearch'])) $aTerms[] = "array_cat(name_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aNameNonSearch'],",")."]";
                                                        if (sizeof($aSearch['aAddress']) && $aSearch['aName'] != $aSearch['aAddress'])
                                                        {
                                                                // For infrequent name terms disable index usage for address
                                                                                sizeof($aSearch['aName']) == 1 &&
                                                                                $aWordFrequencyScores[$aSearch['aName'][reset($aSearch['aName'])]] < CONST_Search_NameOnlySearchFrequencyThreshold)
                                                                {
 -                                                                      $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join(array_merge($aSearch['aAddress'],$aSearch['aAddressNonSearch']),",")."]";
 +                                                                      //$aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join(array_merge($aSearch['aAddress'],$aSearch['aAddressNonSearch']),",")."]";
 +                                                                      $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aAddress'],",")."]";
                                                                }
                                                                else
                                                                {
                                                                        $aTerms[] = "nameaddress_vector @> ARRAY[".join($aSearch['aAddress'],",")."]";
 -                                                                      if (sizeof($aSearch['aAddressNonSearch'])) $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aAddressNonSearch'],",")."]";
 +                                                                      //if (sizeof($aSearch['aAddressNonSearch'])) $aTerms[] = "array_cat(nameaddress_vector,ARRAY[]::integer[]) @> ARRAY[".join($aSearch['aAddressNonSearch'],",")."]";
                                                                }
                                                        }
                                                        if ($aSearch['sCountryCode']) $aTerms[] = "country_code = '".pg_escape_string($aSearch['sCountryCode'])."'";
                                                                $aPlaceIDs = $this->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 = $this->oDB->getCol($sSQL);
                                                                }
 +                                                              */
  
                                                                if (!sizeof($aPlaceIDs))
                                                                {
                                                        {
                                                                preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/',$aMatch[1],$aPolyPoints,PREG_SET_ORDER);
                                                        }
 +                            /*
                                                        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;
                                if (isset($aClassType[$aResult['class'].':'.$aResult['type']]['importance'])
                                        && $aClassType[$aResult['class'].':'.$aResult['type']]['importance'])
                                {
-                                       $aResult['foundorder'] = $aResult['foundorder'] + 0.000001 * $aClassType[$aResult['class'].':'.$aResult['type']]['importance'];
+                                       $aResult['foundorder'] += 0.0001 * $aClassType[$aResult['class'].':'.$aResult['type']]['importance'];
                                }
                                else
                                {
-                                       $aResult['foundorder'] = $aResult['foundorder'] + 0.001;
+                                       $aResult['foundorder'] += 0.01;
                                }
                                $aSearchResults[$iResNum] = $aResult;
                        }
diff --combined lib/lib.php
index 48fba5accf7d8d284990af76786db80ecc0ec880,c68f04eb9df20e05c13c0a9819cdb4a743148b75..e548dc3af3abe35fd82efc1e6df040ab63632e23
        {
                $aResult = array(array(join(' ',$aWords)));
                $sFirstToken = '';
 -              if ($iDepth < 8) {
 +              if ($iDepth < 7) {
                        while(sizeof($aWords) > 1)
                        {
                                $sWord = array_shift($aWords);
   'tourism:hotel' => array('label'=>'Hotel','frequency'=>2150,'icon'=>'accommodation_hotel2',),
   'tourism:motel' => array('label'=>'Motel','frequency'=>43,'icon'=>'',),
   'amenity:cinema' => array('label'=>'Cinema','frequency'=>277,'icon'=>'tourist_cinema',),
-  'tourism:information' => array('label'=>'Information','frequency'=>224,'icon'=>'amenity_information',),
   'tourism:artwork' => array('label'=>'Artwork','frequency'=>171,'icon'=>'tourist_art_gallery2',),
   'historic:archaeological_site' => array('label'=>'Archaeological Site','frequency'=>407,'icon'=>'tourist_archaeological2',),
   'amenity:doctors' => array('label'=>'Doctors','frequency'=>581,'icon'=>'health_doctors',),
   'shop:travel_agency' => array('label'=>'Travel Agency','frequency'=>21,'icon'=>'',),
   'shop:hifi' => array('label'=>'Hifi','frequency'=>21,'icon'=>'',),
   'amenity:shop' => array('label'=>'Shop','frequency'=>61,'icon'=>'',),
+  'tourism:information' => array('label'=>'Information','frequency'=>224,'icon'=>'amenity_information',),
  
   'place:house' => array('label'=>'House','frequency'=>2086,'icon'=>'','defzoom'=>18,),
   'place:house_name' => array('label'=>'House','frequency'=>2086,'icon'=>'','defzoom'=>18,),
diff --combined sql/functions.sql
index 898cdb69530daefaee4f5faa2759e5fb24193830,878c69c972746770d748750193224520a9f518e2..e1ec138a9d54e966094019af11ba376098f630ca
@@@ -2035,12 -2035,6 +2035,12 @@@ BEGI
    END IF;
  
  
 +  -- refuse to update multiplpoygons with too many objects, too much of a performance hit
 +  IF ST_NumGeometries(NEW.geometry) > 2000 THEN
 +    RAISE WARNING 'Dropping update of % % because of geometry complexity.', NEW.osm_type, NEW.osm_id;
 +    RETURN NULL;
 +  END IF;
 +
    IF coalesce(existing.name::text, '') != coalesce(NEW.name::text, '')
       OR coalesce(existing.extratags::text, '') != coalesce(NEW.extratags::text, '')
       OR coalesce(existing.housenumber, '') != coalesce(NEW.housenumber, '')
@@@ -2247,9 -2241,11 +2247,11 @@@ BEGI
    END IF;
  
    IF for_place_id IS NULL THEN
-     for_place_id := in_place_id;
-     select calculated_country_code, housenumber, rank_search, postcode, null from placex where place_id = for_place_id 
-       INTO searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode, searchhousename;
+     select coalesce(linked_place_id, place_id),  calculated_country_code,
+            housenumber, rank_search, postcode, null
+       from placex where place_id = in_place_id
+       INTO for_place_id, searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode, searchhousename;
+       RAISE WARNING '% fffff %', in_place_id, for_place_id;
    END IF;
  
  --RAISE WARNING '% % % %',searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode;
diff --combined utils/setup.php
index fbf902e72509d989384b31edc304e6f9e51ac6e3,a8f81bbeab248b869b84b40f105f1d170645ad01..3b04b1617c749b02f6d40a51b0f78cce433035dd
@@@ -33,7 -33,6 +33,6 @@@
                array('disable-token-precalc', '', 0, 1, 0, 0, 'bool', 'Disable name precalculation (EXPERT)'),
                array('import-tiger-data', '', 0, 1, 0, 0, 'bool', 'Import tiger data (not included in \'all\')'),
                array('calculate-postcodes', '', 0, 1, 0, 0, 'bool', 'Calculate postcode centroids'),
-               array('create-roads', '', 0, 1, 0, 0, 'bool', ''),
                array('osmosis-init', '', 0, 1, 0, 0, 'bool', 'Generate default osmosis configuration'),
                array('index', '', 0, 1, 0, 0, 'bool', 'Index the data'),
                array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse operations during index (EXPERT)'),
                if (CONST_Tablespace_Place_Index)
                        $osm2pgsql .= ' --tablespace-main-index '.CONST_Tablespace_Place_Index;
                $osm2pgsql .= ' -lsc -O gazetteer --hstore';
 -              $osm2pgsql .= ' -C '.$iCacheMemory;
 +              $osm2pgsql .= ' -C 25000';
                $osm2pgsql .= ' -P '.$aDSNInfo['port'];
                $osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file'];
                passthruCheckReturn($osm2pgsql);
                pgsqlRunScript('ANALYSE');
        }
  
-       if ($aCMDResult['create-roads'])
-       {
-               $bDidSomething = true;
-               $oDB =& getDB();
-               $aDBInstances = array();
-               for($i = 0; $i < $iInstances; $i++)
-               {
-                       $aDBInstances[$i] =& getDB(true);
-                       if (!pg_query($aDBInstances[$i]->connection, 'set enable_bitmapscan = off')) fail(pg_last_error($oDB->connection));
-                       $sSQL = 'select count(*) from (select insertLocationRoad(partition, place_id, calculated_country_code, geometry) from ';
-                       $sSQL .= 'placex where osm_id % '.$iInstances.' = '.$i.' and rank_search between 26 and 27 and class = \'highway\') as x ';
-                       if ($aCMDResult['verbose']) echo "$sSQL\n";
-                       if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($oDB->connection));
-               }
-               $bAnyBusy = true;
-               while($bAnyBusy)
-               {
-                       $bAnyBusy = false;
-                       for($i = 0; $i < $iInstances; $i++)
-                       {
-                               if (pg_connection_busy($aDBInstances[$i]->connection)) $bAnyBusy = true;
-                       }
-                       sleep(1);
-                       echo '.';
-               }
-               echo "\n";
-       }
        if ($aCMDResult['import-tiger-data'])
        {
                $bDidSomething = true;
                $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) ";