]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 7 Feb 2014 22:42:53 +0000 (23:42 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 7 Feb 2014 22:42:53 +0000 (23:42 +0100)
1  2 
settings/settings.php
sql/functions.sql
utils/setup.php

diff --combined settings/settings.php
index 52776aeb2e273c97aae2ca688ea5fa04a2b69ddb,fd50a6f0a7c96487468cdfe6cac04b92095600cc..11e450e9e9d74b47eb0b0233fe8e1f21b60dd18d
@@@ -6,6 -6,7 +6,7 @@@
        @define('CONST_Debug', false);
        @define('CONST_Database_DSN', 'pgsql://@/nominatim'); // <driver>://<username>:<password>@<host>:<port>/<database>
        @define('CONST_Max_Word_Frequency', '50000');
+       @define('CONST_Limit_Reindexing', true);
  
        // Software versions
        @define('CONST_Postgresql_Version', '9.1'); // values: 8.3, 8.4, 9.0, 9.1, 9.2
  
        // Website settings
        @define('CONST_NoAccessControl', true);
 -      @define('CONST_ClosedForIndexing', false);
 -      @define('CONST_ClosedForIndexingExceptionIPs', '');
        @define('CONST_BlockedIPs', '');
 +      @define('CONST_IPBanFile', CONST_BasePath.'/settings/ip_blocks');
 +      @define('CONST_WhitelistedIPs', '');
 +      @define('CONST_BlockedUserAgents', '');
 +      @define('CONST_BlockReverseMaxLoad', 15);
        @define('CONST_BulkUserIPs', '');
        @define('CONST_BlockMessage', ''); // additional info to show for blocked IPs
  
 -      @define('CONST_Website_BaseURL', 'http://'.php_uname('n').'/');
 +      @define('CONST_Website_BaseURL', 'http://nominatim.openstreetmap.org/');
        @define('CONST_Tile_Default', 'Mapnik');
  
        @define('CONST_Default_Language', false);
diff --combined sql/functions.sql
index 1e411e04e180397b129fa8ff2b87d99941b19dc3,49a6e97288fc0666538e8647fe23dd8162beabb3..028a72b4e405eecc7697b0fef032dea245d4ec09
@@@ -937,11 -937,6 +937,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;
@@@ -1362,26 -1357,13 +1362,26 @@@ BEGI
      NEW.centroid := null;
  
      -- reclaculate country and partition
 -    IF NEW.rank_search >= 4 THEN
 -      --NEW.calculated_country_code := lower(get_country_code(NEW.geometry, NEW.country_code));
 -      NEW.calculated_country_code := lower(get_country_code(place_centroid));
 +    IF NEW.rank_search = 4 THEN
 +      -- for countries, believe the mapped country code,
 +      -- so that we remain in the right partition if the boundaries
 +      -- suddenly expand.
 +      NEW.partition := get_partition(place_centroid, lower(NEW.country_code));
 +      IF NEW.partition = 0 THEN
 +        NEW.calculated_country_code := lower(get_country_code(place_centroid));
 +        NEW.partition := get_partition(place_centroid, NEW.calculated_country_code);
 +      ELSE
 +        NEW.calculated_country_code := lower(NEW.country_code);
 +      END IF;
      ELSE
 -      NEW.calculated_country_code := NULL;
 +      IF NEW.rank_search > 4 THEN
 +        --NEW.calculated_country_code := lower(get_country_code(NEW.geometry, NEW.country_code));
 +        NEW.calculated_country_code := lower(get_country_code(place_centroid));
 +      ELSE
 +        NEW.calculated_country_code := NULL;
 +      END IF;
 +      NEW.partition := get_partition(place_centroid, NEW.calculated_country_code);
      END IF;
 -    NEW.partition := get_partition(place_centroid, NEW.calculated_country_code);
      NEW.geometry_sector := geometry_sector(NEW.partition, place_centroid);
  
      -- Adding ourselves to the list simplifies address calculations later
@@@ -1971,7 -1953,7 +1971,7 @@@ BEGI
      -- mark everything linked to this place for re-indexing
      --DEBUG: RAISE WARNING 'placex_delete:03 % %',OLD.osm_type,OLD.osm_id;
      UPDATE placex set indexed_status = 2 from place_addressline where address_place_id = OLD.place_id 
-       and placex.place_id = place_addressline.place_id and indexed_status = 0;
+       and placex.place_id = place_addressline.place_id and indexed_status = 0 and place_addressline.isaddress;
  
      --DEBUG: RAISE WARNING 'placex_delete:04 % %',OLD.osm_type,OLD.osm_id;
      DELETE FROM place_addressline where address_place_id = OLD.place_id;
@@@ -2061,11 -2043,6 +2061,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
      RETURN null;
    DELETE from import_polygon_error where osm_type = NEW.osm_type and osm_id = NEW.osm_id;
    DELETE from import_polygon_delete where osm_type = NEW.osm_type and osm_id = NEW.osm_id;
  
-   -- To paraphrase, if there isn't an existing item, OR if the admin level has changed, OR if it is a major change in geometry
-   IF existingplacex.osm_type IS NULL THEN
+   -- To paraphrase, if there isn't an existing item, OR if the admin level has changed
+   IF existingplacex.osm_type IS NULL OR
+      coalesce(existingplacex.admin_level, 15) != coalesce(NEW.admin_level, 15)
+   THEN
+     IF existingplacex.osm_type IS NOT NULL THEN
+       -- sanity check: ignore admin_level changes on places with too many active children
+       -- or we end up reindexing entire countries because somebody accidentally deleted admin_level
+       --LIMIT INDEXING: SELECT count(*) FROM (SELECT 'a' FROM placex , place_addressline where address_place_id = existingplacex.place_id and placex.place_id = place_addressline.place_id and indexed_status = 0 and place_addressline.isaddress LIMIT 100001) sub INTO i;
+       --LIMIT INDEXING: IF i > 100000 THEN
+       --LIMIT INDEXING:  RETURN null;
+       --LIMIT INDEXING: END IF;
+     END IF;
  
      IF existing.osm_type IS NOT NULL THEN
        -- pathological case caused by the triggerless copy into place during initial import
  
    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, '')
diff --combined utils/setup.php
index a5466432c8ae389d490b5449698bfc8532e297c4,d9c761b276920d2f75f4dbb660b2fb59546d8f23..e23a22111bacb33628054671845cce415d4f0655
                {
                        $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);
                $sTemplate = str_replace('{modulepath}', CONST_BasePath.'/module', $sTemplate);
                if ($aCMDResult['enable-diff-updates']) $sTemplate = str_replace('RETURN NEW; -- @DIFFUPDATES@', '--', $sTemplate);
                if ($aCMDResult['enable-debug-statements']) $sTemplate = str_replace('--DEBUG:', '', $sTemplate);
+               if (CONST_Limit_Reindexing) $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
                pgsqlRunScript($sTemplate);
        }
  
                $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) ";