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

diff --combined lib/lib.php
index 12f7e57e6eddb2217bceb51bd66a9102fdfe5dd8,afcc02eff186f78d5579a4b5136e935edf8b37df..b26038d8f2bcbd317875cabd01897287c0c08145
@@@ -94,8 -94,7 +94,8 @@@
  
        function bySearchRank($a, $b)
        {
 -              if ($a['iSearchRank'] == $b['iSearchRank']) return 0;
 +              if ($a['iSearchRank'] == $b['iSearchRank'])
 +            return strlen($a['sOperator']) + strlen($a['sHouseNumber']) - strlen($b['sOperator']) - strlen($b['sHouseNumber']);
                return ($a['iSearchRank'] < $b['iSearchRank']?-1:1);
        }
  
        {
                $aResult = array(array(join(' ',$aWords)));
                $sFirstToken = '';
 -              if ($iDepth < 8) {
 +              if ($iDepth < 7) {
                        while(sizeof($aWords) > 1)
                        {
                                $sWord = array_shift($aWords);
                        {
                                $sTypeLabel = strtolower(isset($aTypeLabel['simplelabel'])?$aTypeLabel['simplelabel']:$aTypeLabel['label']);
                                $sTypeLabel = str_replace(' ','_',$sTypeLabel);
-                               if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel]))
+                               if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel]) || $aLine['class'] == 'place')
                                {
                                        $aAddress[$sTypeLabel] = $aLine['localname']?$aLine['localname']:$aLine['housenumber'];
                                }
diff --combined sql/functions.sql
index 9cf1bd40a690ca77d9983b19eea0bbf53a9196ee,1da469208d29910001ca04f9351c771232590519..a6fa20ea295be751f907848f663149d4b1e2b3ca
@@@ -936,11 -936,6 +936,11 @@@ DECLAR
  BEGIN
    --DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
  
 +  -- remove operator tag for most places, messes too much with search_name indexes
 +  IF NEW.class not in ('amenity', 'shop') THEN
 +    NEW.name := delete(NEW.name, 'operator');
 +  END IF;
 +
    -- just block these
    IF NEW.class in ('landuse','natural') and NEW.name is null THEN
  --    RAISE WARNING 'empty landuse %',NEW.osm_id;
@@@ -2064,11 -2059,6 +2064,11 @@@ BEGI
      --DEBUG: RAISE WARNING '%', existingplacex;
    END IF;
  
 +  -- remove operator tag for most places, messes too much with search_name indexes
 +  IF NEW.class not in ('amenity', 'shop') THEN
 +    NEW.name := delete(NEW.name, 'operator');
 +  END IF;
 +
    -- Just block these - lots and pointless
    IF NEW.class in ('landuse','natural') and NEW.name is null THEN
      -- if the name tag was removed, older versions might still be lurking in the place table
  
    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, '')
@@@ -2534,7 -2518,9 +2534,9 @@@ BEGI
    FOR location IN 
      select placex.place_id, osm_type, osm_id,
        CASE WHEN class = 'place' and type = 'postcode' THEN hstore('name', postcode) ELSE name END as name,
-       class, type, admin_level, fromarea, isaddress,
+       CASE WHEN extratags ? 'place' THEN 'place' ELSE class END as class,
+       CASE WHEN extratags ? 'place' THEN extratags->'place' ELSE type END as type,
+       admin_level, fromarea, isaddress,
        CASE WHEN address_place_id = for_place_id AND rank_address = 0 THEN 100 WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address,
        distance,calculated_country_code,postcode
        from place_addressline join placex on (address_place_id = placex.place_id) 
diff --combined utils/setup.php
index edf0b14d460f27156569b65f872f2bb8aa934e6d,a1d8ae5db9ef1d122c11ca9a55e6df41773d0e08..734f669f61082774181fe0014858ef064a5f830f
@@@ -22,6 -22,7 +22,7 @@@
                array('create-functions', '', 0, 1, 0, 0, 'bool', 'Create functions'),
                array('enable-diff-updates', '', 0, 1, 0, 0, 'bool', 'Turn on the code required to make diff updates work'),
                array('enable-debug-statements', '', 0, 1, 0, 0, 'bool', 'Include debug warning statements in pgsql commands'),
+               array('ignore-errors', '', 0, 1, 0, 0, 'bool', 'Continue import even when errors in SQL are present (EXPERT)'),
                array('create-minimal-tables', '', 0, 1, 0, 0, 'bool', 'Create minimal main tables'),
                array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'),
                array('create-partition-tables', '', 0, 1, 0, 0, 'bool', 'Create required partition tables'),
                {
                        $osm2pgsql .= ' --flat-nodes '.CONST_Osm2pgsql_Flatnode_File;
                }
 +              $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 18000';
                $osm2pgsql .= ' -P '.$aDSNInfo['port'];
                $osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file'];
                passthruCheckReturn($osm2pgsql);
                $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) ";
  
        function pgsqlRunScript($sScript)
        {
+               global $aCMDResult;
                // Convert database DSN to psql parameters
                $aDSNInfo = DB::parseDSN(CONST_Database_DSN);
                if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
                $sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'];
-               $sCMD .= ' -v ON_ERROR_STOP=1';
+               if (!$aCMDResult['ignore-errors'])
+                       $sCMD .= ' -v ON_ERROR_STOP=1';
                $aDescriptors = array(
                        0 => array('pipe', 'r'),
                        1 => STDOUT, 
                while(strlen($sScript))
                {
                        $written = fwrite($ahPipes[0], $sScript);
+                       if ($written <= 0) break;
                        $sScript = substr($sScript, $written);
                }
                fclose($ahPipes[0]);