From: Sarah Hoffmann Date: Sat, 4 Aug 2018 21:19:32 +0000 (+0200) Subject: Merge pull request #1110 from lonvia/remove-address-check-for-long-lines X-Git-Tag: v3.2.0~34 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/9bdbbec0c8141bdcb22fb562b4e1235dadcc446c?hp=8f0b3cb00f0d3f7b101a742e7480903ff0e89a2a Merge pull request #1110 from lonvia/remove-address-check-for-long-lines Remove special search for address part for long ways --- diff --git a/sql/functions.sql b/sql/functions.sql index 7c62bc93..ae6c73df 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -1897,33 +1897,6 @@ BEGIN END LOOP; --DEBUG: RAISE WARNING 'address computed'; - -- for long ways we should add search terms for the entire length - IF st_length(NEW.geometry) > 0.05 THEN - - location_rank_search := 0; - location_distance := 0; - - FOR location IN SELECT * from getNearFeatures(NEW.partition, NEW.geometry, search_maxrank, isin_tokens) LOOP - - IF location.rank_address != location_rank_search THEN - location_rank_search := location.rank_address; - location_distance := location.distance * 1.5; - END IF; - - IF location.rank_search > 4 AND location.distance < location_distance THEN - - -- Add it to the list of search terms - nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]); - INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address) - VALUES (NEW.place_id, location.place_id, true, false, location.distance, location.rank_address); - - END IF; - - END LOOP; - - END IF; - --DEBUG: RAISE WARNING 'search terms for long ways added'; - IF NEW.address is not null AND NEW.address ? 'postcode' AND NEW.address->'postcode' not similar to '%(,|;)%' THEN NEW.postcode := upper(trim(NEW.address->'postcode')); diff --git a/test/bdd/steps/db_ops.py b/test/bdd/steps/db_ops.py index 80f92222..a0924840 100644 --- a/test/bdd/steps/db_ops.py +++ b/test/bdd/steps/db_ops.py @@ -132,6 +132,18 @@ def compare_place_id(expected, result, column, context): LazyFmt("Bad place id in column %s. Expected: %s, got: %s.", column, expected, PlaceObjName(result, context.db))) +def check_database_integrity(context): + """ Check some generic constraints on the tables. + """ + # place_addressline should not have duplicate (place_id, address_place_id) + cur = context.db.cursor() + cur.execute("""SELECT count(*) FROM + (SELECT place_id, address_place_id, count(*) as c + FROM place_addressline GROUP BY place_id, address_place_id) x + WHERE c > 1""") + eq_(0, cur.fetchone()[0], "Duplicates found in place_addressline") + + class NominatimID: """ Splits a unique identifier for places into its components. As place_ids cannot be used for testing, we use a unique @@ -290,6 +302,7 @@ def import_and_index_data_from_place_table(context): and ST_GeometryType(geometry) = 'ST_LineString'""") context.db.commit() context.nominatim.run_setup_script('calculate-postcodes', 'index', 'index-noanalyse') + check_database_integrity(context) @when("updating places") def update_place_table(context): @@ -314,6 +327,8 @@ def update_place_table(context): if cur.rowcount == 0: break + check_database_integrity(context) + @when("marking for delete (?P.*)") def delete_places(context, oids): context.nominatim.run_setup_script(