]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #2303 from lonvia/remove-aux-support
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 30 Apr 2021 09:19:35 +0000 (11:19 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Apr 2021 09:19:35 +0000 (11:19 +0200)
Remove support for AUX housenumber tables

14 files changed:
lib-php/Geocode.php
lib-php/PlaceLookup.php
lib-php/Result.php
lib-php/SearchDescription.php
lib-php/admin/query.php
lib-php/admin/warm.php
lib-php/website/details.php
lib-sql/aux_tables.sql [deleted file]
lib-sql/functions/address_lookup.sql
lib-sql/functions/aux_property.sql [deleted file]
lib-sql/tables.sql
nominatim/tools/database_import.py
nominatim/tools/refresh.py
test/python/test_tools_database_import.py

index ec6876faa51bbd4b64402e1abaf3450993cdc81b..6cec6a85e088ee40c69917eb152e54bf571fc1a7 100644 (file)
@@ -829,7 +829,6 @@ class Geocode
                     foreach ($aResults as $oResult) {
                         if (($this->iMaxAddressRank == 30 &&
                              ($oResult->iTable == Result::TABLE_OSMLINE
-                              || $oResult->iTable == Result::TABLE_AUX
                               || $oResult->iTable == Result::TABLE_TIGER))
                             || in_array($oResult->iId, $aFilteredIDs)
                         ) {
index 6d7b6be1af4ed6dd04d5e1a6e79fb9050746252e..b9fa3b1c08c72b1ef200a426eb75f178dc709523 100644 (file)
@@ -373,42 +373,6 @@ class PlaceLookup
 
                 $aSubSelects[] = $sSQL;
             }
-
-            if (CONST_Use_Aux_Location_data) {
-                $sPlaceIDs = Result::joinIdsByTable($aResults, Result::TABLE_AUX);
-                if ($sPlaceIDs) {
-                    $sHousenumbers = Result::sqlHouseNumberTable($aResults, Result::TABLE_AUX);
-                    $sSQL = '  SELECT ';
-                    $sSQL .= "     'L' AS osm_type, ";
-                    $sSQL .= '     place_id AS osm_id, ';
-                    $sSQL .= "     'place' AS class,";
-                    $sSQL .= "     'house' AS type, ";
-                    $sSQL .= '     null::smallint AS admin_level, ';
-                    $sSQL .= '     30 AS rank_search,';
-                    $sSQL .= '     30 AS rank_address, ';
-                    $sSQL .= '     place_id,';
-                    $sSQL .= '     parent_place_id, ';
-                    $sSQL .= '     housenumber,';
-                    $sSQL .= "     'us' AS country_code, ";
-                    $sSQL .= $this->langAddressSql('-1');
-                    $sSQL .= '     null::text AS placename, ';
-                    $sSQL .= '     null::text AS ref, ';
-                    if ($this->bExtraTags) $sSQL .= 'null::text AS extra, ';
-                    if ($this->bNameDetails) $sSQL .= 'null::text AS names, ';
-                    $sSQL .= '     ST_X(centroid) AS lon, ';
-                    $sSQL .= '     ST_Y(centroid) AS lat, ';
-                    $sSQL .= '     -1.10 AS importance, ';
-                    $sSQL .= $this->addressImportanceSql(
-                        'centroid',
-                        'location_property_aux.parent_place_id'
-                    );
-                    $sSQL .= '     null::text AS extra_place ';
-                    $sSQL .= '  FROM location_property_aux ';
-                    $sSQL .= "  WHERE place_id in ($sPlaceIDs) ";
-
-                    $aSubSelects[] = $sSQL;
-                }
-            }
         }
 
         if (empty($aSubSelects)) {
index a7747ea34d6fee12e98b0a7eb31c9fbaccfb7fb8..be103074040da27e56dfc9a914baa868cc3da8e3 100644 (file)
@@ -13,8 +13,7 @@ class Result
     const TABLE_PLACEX = 0;
     const TABLE_POSTCODE = 1;
     const TABLE_OSMLINE = 2;
-    const TABLE_AUX = 3;
-    const TABLE_TIGER = 4;
+    const TABLE_TIGER = 3;
 
     /// Database table that contains the result.
     public $iTable;
index dd20550214325b952452ec98de3bf4a96351071e..189ffa74e99fbca744efc659f98f62426ca7afc2 100644 (file)
@@ -790,20 +790,6 @@ class SearchDescription
             }
         }
 
-        // If nothing found try the aux fallback table
-        if (CONST_Use_Aux_Location_data && empty($aResults)) {
-            $sSQL = 'SELECT place_id FROM location_property_aux';
-            $sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.')';
-            $sSQL .= " AND housenumber = '".$this->sHouseNumber."'";
-            $sSQL .= $this->oContext->excludeSQL(' AND place_id');
-
-            Debug::printSQL($sSQL);
-
-            foreach ($oDB->getCol($sSQL) as $iPlaceId) {
-                $aResults[$iPlaceId] = new Result($iPlaceId, Result::TABLE_AUX);
-            }
-        }
-
         // If nothing found then search in Tiger data (location_property_tiger)
         if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && empty($aResults)) {
             $sSQL = 'SELECT place_id FROM location_property_tiger';
index 35fd1184a579e7ebc0219b93a32c240465323c94..268b87cc0e0bbe1e2e895cf655736e5cb53c80d9 100644 (file)
@@ -48,7 +48,6 @@ loadSettings($aCMDResult['project-dir'] ?? getcwd());
 @define('CONST_Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
 @define('CONST_Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
 @define('CONST_Term_Normalization_Rules', getSetting('TERM_NORMALIZATION'));
-@define('CONST_Use_Aux_Location_data', getSettingBool('USE_AUX_LOCATION_DATA'));
 @define('CONST_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
 @define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
 
index 827fd9868780214912e39fd0bac1d0184e34d612..d7950af9b1912b91d70c2f29b691c06a328fa15c 100644 (file)
@@ -33,7 +33,6 @@ loadSettings($aCMDResult['project-dir'] ?? getcwd());
 @define('CONST_Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
 @define('CONST_Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
 @define('CONST_Term_Normalization_Rules', getSetting('TERM_NORMALIZATION'));
-@define('CONST_Use_Aux_Location_data', getSettingBool('USE_AUX_LOCATION_DATA'));
 @define('CONST_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
 @define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
 
index bd7df12c23a7cc936423d930335458e27c187860..55a088d1994ab8ee9555211c4d9927d78c910d6b 100644 (file)
@@ -106,11 +106,6 @@ if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
 $iParentPlaceID = $oDB->getOne('SELECT parent_place_id FROM location_postcode WHERE place_id = '.$iPlaceID);
 if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
 
-if (CONST_Use_Aux_Location_data) {
-    $iParentPlaceID = $oDB->getOne('SELECT parent_place_id FROM location_property_aux WHERE place_id = '.$iPlaceID);
-    if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
-}
-
 $hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
 // Get the details for this point
diff --git a/lib-sql/aux_tables.sql b/lib-sql/aux_tables.sql
deleted file mode 100644 (file)
index 8105473..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE location_property_aux () INHERITS (location_property);
-CREATE INDEX idx_location_property_aux_place_id ON location_property_aux USING BTREE (place_id);
-CREATE INDEX idx_location_property_aux_parent_place_id ON location_property_aux USING BTREE (parent_place_id);
-CREATE INDEX idx_location_property_aux_housenumber_parent_place_id ON location_property_aux USING BTREE (parent_place_id, housenumber);
-GRANT SELECT ON location_property_aux TO "{www-user}";
-
index 5ec977d17552d7434bde9dc7fe88db9555b12c6c..45e497507a8b21915280c2da8de2835293e7e2e2 100644 (file)
@@ -135,20 +135,6 @@ BEGIN
   END IF;
   {% endif %}
 
-  -- then additional data
-  {% if config.get_bool('USE_AUX_LOCATION_DATA') %}
-  IF place IS NULL THEN
-    SELECT parent_place_id as place_id, 'us' as country_code,
-           housenumber, postcode,
-           'place' as class, 'house' as type,
-           null as name, null as address,
-           centroid
-      INTO place
-      FROM location_property_aux
-      WHERE place_id = in_place_id;
-  END IF;
-  {% endif %}
-
   -- postcode table
   IF place IS NULL THEN
     SELECT parent_place_id as place_id, country_code,
diff --git a/lib-sql/functions/aux_property.sql b/lib-sql/functions/aux_property.sql
deleted file mode 100644 (file)
index 6dd99eb..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
--- Functions for adding external data (currently unused).
-
-CREATE OR REPLACE FUNCTION aux_create_property(pointgeo GEOMETRY, in_housenumber TEXT,
-                                               in_street TEXT, in_isin TEXT,
-                                               in_postcode TEXT, in_countrycode char(2))
-  RETURNS INTEGER
-  AS $$
-DECLARE
-
-  newpoints INTEGER;
-  place_centroid GEOMETRY;
-  out_partition INTEGER;
-  out_parent_place_id BIGINT;
-  location RECORD;
-  address_street_word_ids INTEGER[];
-  out_postcode TEXT;
-
-BEGIN
-
-  place_centroid := ST_Centroid(pointgeo);
-  out_partition := get_partition(in_countrycode);
-  out_parent_place_id := null;
-
-  address_street_word_ids := word_ids_from_name(in_street);
-  IF address_street_word_ids IS NOT NULL THEN
-    out_parent_place_id := getNearestNamedRoadPlaceId(out_partition, place_centroid,
-                                                      address_street_word_ids);
-  END IF;
-
-  IF out_parent_place_id IS NULL THEN
-    SELECT getNearestRoadPlaceId(out_partition, place_centroid)
-      INTO out_parent_place_id;
-    END LOOP;
-  END IF;
-
-  out_postcode := in_postcode;
-  IF out_postcode IS NULL THEN
-    SELECT postcode from placex where place_id = out_parent_place_id INTO out_postcode;
-  END IF;
-  -- XXX look into postcode table
-
-  newpoints := 0;
-  insert into location_property_aux (place_id, partition, parent_place_id,
-                                     housenumber, postcode, centroid)
-    values (nextval('seq_place'), out_partition, out_parent_place_id,
-            in_housenumber, out_postcode, place_centroid);
-  newpoints := newpoints + 1;
-
-  RETURN newpoints;
-END;
-$$
-LANGUAGE plpgsql;
-
index aa213dbaccb4ebd49436fc68853ed0ab8d9c6789..609472ecb78f9bdbaecf2414fc8ec00fa47d368b 100644 (file)
@@ -84,22 +84,6 @@ CREATE TABLE location_area_country (
 CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry) {{db.tablespace.address_index}};
 
 
-drop table IF EXISTS location_property CASCADE;
-CREATE TABLE location_property (
-  place_id BIGINT,
-  parent_place_id BIGINT,
-  partition SMALLINT,
-  housenumber TEXT,
-  postcode TEXT,
-  centroid GEOMETRY(Point, 4326)
-  );
-
-CREATE TABLE location_property_aux () INHERITS (location_property);
-CREATE INDEX idx_location_property_aux_place_id ON location_property_aux USING BTREE (place_id);
-CREATE INDEX idx_location_property_aux_parent_place_id ON location_property_aux USING BTREE (parent_place_id);
-CREATE INDEX idx_location_property_aux_housenumber_parent_place_id ON location_property_aux USING BTREE (parent_place_id, housenumber);
-GRANT SELECT ON location_property_aux TO "{{config.DATABASE_WEBUSER}}";
-
 CREATE TABLE location_property_tiger (
   place_id BIGINT,
   parent_place_id BIGINT,
index 25efedb9a9a6a5ffb2c165df73e2c8a51f4431b4..3618ed28e14416d412f4033d6130bc4593d3aa38 100644 (file)
@@ -214,7 +214,6 @@ def truncate_data_tables(conn, max_word_frequency=None):
         cur.execute('TRUNCATE place_addressline')
         cur.execute('TRUNCATE location_area')
         cur.execute('TRUNCATE location_area_country')
-        cur.execute('TRUNCATE location_property')
         cur.execute('TRUNCATE location_property_tiger')
         cur.execute('TRUNCATE location_property_osmline')
         cur.execute('TRUNCATE location_postcode')
index d38cb216865003c0ce75a9f1f735c3db18a49e19..8fc0c69dd16dca16ec680daebf6544d25f50d847 100644 (file)
@@ -111,7 +111,6 @@ PHP_CONST_DEFS = (
     ('Search_BatchMode', 'SEARCH_BATCH_MODE', bool),
     ('Search_NameOnlySearchFrequencyThreshold', 'SEARCH_NAME_ONLY_THRESHOLD', str),
     ('Term_Normalization_Rules', 'TERM_NORMALIZATION', str),
-    ('Use_Aux_Location_data', 'USE_AUX_LOCATION_DATA', bool),
     ('Use_US_Tiger_Data', 'USE_US_TIGER_DATA', bool),
     ('MapIcon_URL', 'MAPICON_URL', str),
 )
index 1311ef5dc052dc3168f5ba7e9789a639adcce61c..280ca704ce7c8419b6b745390401d285ef29bf16 100644 (file)
@@ -172,7 +172,7 @@ def test_import_osm_data_default_cache(temp_db_cursor,osm2pgsql_options):
 
 def test_truncate_database_tables(temp_db_conn, temp_db_cursor, table_factory):
     tables = ('word', 'placex', 'place_addressline', 'location_area',
-              'location_area_country', 'location_property',
+              'location_area_country',
               'location_property_tiger', 'location_property_osmline',
               'location_postcode', 'search_name', 'location_road_23')
     for table in tables: