From: Sarah Hoffmann Date: Tue, 14 May 2024 14:40:54 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~7 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/0278ab7f41bf9bc96a87084c04bfec263c6acc40?hp=0eddfe588069fc8833d6948d01e07bd055e4c3bc Merge remote-tracking branch 'upstream/master' --- diff --git a/.pylintrc b/.pylintrc index 27214bae..d47a1693 100644 --- a/.pylintrc +++ b/.pylintrc @@ -13,6 +13,6 @@ ignored-classes=NominatimArgs,closing # 'too-many-ancestors' is triggered already by deriving from UserDict # 'not-context-manager' disabled because it causes false positives once # typed Python is enabled. See also https://github.com/PyCQA/pylint/issues/5273 -disable=too-few-public-methods,duplicate-code,too-many-ancestors,bad-option-value,no-self-use,not-context-manager,use-dict-literal,chained-comparison,attribute-defined-outside-init,too-many-boolean-expressions +disable=too-few-public-methods,duplicate-code,too-many-ancestors,bad-option-value,no-self-use,not-context-manager,use-dict-literal,chained-comparison,attribute-defined-outside-init,too-many-boolean-expressions,contextmanager-generator-missing-cleanup good-names=i,j,x,y,m,t,fd,db,cc,x1,x2,y1,y2,pt,k,v,nr diff --git a/docs/admin/Import.md b/docs/admin/Import.md index 5e9d6d7f..38cd0b74 100644 --- a/docs/admin/Import.md +++ b/docs/admin/Import.md @@ -75,14 +75,17 @@ This data is available as a binary download. Put it into your project directory: cd $PROJECT_DIR wget https://nominatim.org/data/wikimedia-importance.sql.gz + wget -O secondary_importance.sql.gz https://nominatim.org/data/wikimedia-secondary-importance.sql.gz -The file is about 400MB and adds around 4GB to the Nominatim database. +The files are about 400MB and add around 4GB to the Nominatim database. For +more information about importance, +see [Importance Customization](../customize/Importance.md). !!! tip If you forgot to download the wikipedia rankings, then you can also add importances after the import. Download the SQL files, then - run `nominatim refresh --wiki-data --importance`. Updating - importances for a planet will take a couple of hours. + run `nominatim refresh --wiki-data --secondary-importance --importance`. + Updating importances for a planet will take a couple of hours. ### External postcodes diff --git a/docs/customize/Importance.md b/docs/customize/Importance.md index 5c271ed8..f192d265 100644 --- a/docs/customize/Importance.md +++ b/docs/customize/Importance.md @@ -12,7 +12,7 @@ customize them. The main value for importance is derived from page ranking values for Wikipedia pages for a place. For places that do not have their own Wikipedia page, a formula is used that derives a static importance from the -places [search rank](../customize/Ranking.md#search-rank). +place's [search rank](../customize/Ranking.md#search-rank). In a second step, a secondary importance value is added which is meant to represent how well-known the general area is where the place is located. It @@ -21,7 +21,13 @@ importance values. nominatim.org has preprocessed importance tables for the [primary Wikipedia rankings](https://nominatim.org/data/wikimedia-importance.sql.gz) -and for a secondary importance based on the number of tile views on openstreetmap.org. +and for [secondary importance](https://nominatim.org/data/wikimedia-secondary-importance.sql.gz) +based on Wikipedia importance of the administrative areas. + +The source code for creating these files is avaible in the Github projects +[osm-search/wikipedia-wikidata](https://github.com/osm-search/wikipedia-wikidata) +and +[osm-search/secondary-importance](https://github.com/osm-search/secondary-importance). ### Customizing secondary importance @@ -41,8 +47,8 @@ table will be ignored. You must furthermore create an index as follows: CREATE INDEX ON secondary_importance USING gist(ST_ConvexHull(gist)) ``` -The following raster2pgsql command will create a table that conforms to -the requirements: +The following raster2pgsql command will create a table from a tiff file +that conforms to the requirements: ``` raster2pgsql -I -C -Y -d -t 128x128 input.tiff public.secondary_importance diff --git a/docs/customize/Special-Phrases.md b/docs/customize/Special-Phrases.md index f6f73442..abbe03d1 100644 --- a/docs/customize/Special-Phrases.md +++ b/docs/customize/Special-Phrases.md @@ -11,16 +11,31 @@ nominatim special-phrases --import-from-wiki ## Importing custom special phrases -But, it is also possible to import some phrases from a csv file. -To do so, you have access to the following command: +Special phrases may also be imported from any custom CSV file. The file needs +to have a header line, use comma as delimiter and define the following +columns: + + * **phrase**: the keyword to look for + * **class**: key of the main tag of the place to find + (see [principal tags in import style](../Import-Styles.md#set_main_tags-principal-tags) + * **type**: value of the main tag + * **operator**: type of special phrase, may be one of: + * *in*: place is within the place defined by the search term (e.g. "_Hotels in_ Berlin") + * *near*: place is near the place defined by the search term (e.g. "_bus stops near_ Big Ben") + * *named*: special phrase is a classifier (e.g. "_hotel_ California") + * *-*: unspecified, can be any of the above + +If the file contains any other columns, then they are silently ignored + +To import the CSV file, use the following command: ```sh nominatim special-phrases --import-from-csv ``` Note that the two previous import commands will update the phrases from your database. -This means that if you import some phrases from a csv file, only the phrases -present in the csv file will be kept into the database. All other phrases will +This means that if you import some phrases from a CSV file, only the phrases +present in the CSV file will be kept in the database. All other phrases will be removed. If you want to only add new phrases and not update the other ones you can add @@ -30,5 +45,5 @@ the argument `--no-replace` to the import command. For example: nominatim special-phrases --import-from-csv --no-replace ``` -This will add the phrases present in the csv file into the database without +This will add the phrases present in the CSV file into the database without removing the other ones. diff --git a/docs/library/Getting-Started.md b/docs/library/Getting-Started.md index dd16b11d..2ae17e87 100644 --- a/docs/library/Getting-Started.md +++ b/docs/library/Getting-Started.md @@ -103,7 +103,7 @@ You should have set up this directory as part of the Nominatim import. Any configuration found in the `.env` file in this directory will automatically used. -Yo may also configure Nominatim be setting environment variables. +You may also configure Nominatim by setting environment variables. Normally, Nominatim will check the operating system environment. This can be overwritten by giving the constructor a dictionary of configuration parameters. diff --git a/lib-sql/functions/interpolation.sql b/lib-sql/functions/interpolation.sql index 928d55c5..8bc9ad42 100644 --- a/lib-sql/functions/interpolation.sql +++ b/lib-sql/functions/interpolation.sql @@ -67,10 +67,6 @@ BEGIN END LOOP; END IF; - IF parent_place_id is null THEN - RETURN 0; - END IF; - RETURN parent_place_id; END; $$ @@ -183,6 +179,13 @@ BEGIN ST_PointOnSurface(NEW.linegeo), NEW.linegeo); + -- Cannot find a parent street. We will not be able to display a reliable + -- address, so drop entire interpolation. + IF NEW.parent_place_id is NULL THEN + DELETE FROM location_property_osmline where place_id = OLD.place_id; + RETURN NULL; + END IF; + NEW.token_info := token_strip_info(NEW.token_info); IF NEW.address ? '_inherited' THEN NEW.address := hstore('interpolation', NEW.address->'interpolation'); diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 681c302d..a40923b0 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -1399,6 +1399,8 @@ BEGIN {% if debug %}RAISE WARNING 'placex_delete:12 % %',OLD.osm_type,OLD.osm_id;{% endif %} + UPDATE location_postcode SET indexed_status = 2 WHERE parent_place_id = OLD.place_id; + RETURN OLD; END; diff --git a/lib-sql/indices.sql b/lib-sql/indices.sql index 9c31f556..8c176fdf 100644 --- a/lib-sql/indices.sql +++ b/lib-sql/indices.sql @@ -81,6 +81,9 @@ CREATE INDEX IF NOT EXISTS idx_postcode_postcode type TEXT, deferred BOOLEAN ); +--- + CREATE INDEX IF NOT EXISTS idx_location_postcode_parent_place_id + ON location_postcode USING BTREE (parent_place_id) {{db.tablespace.address_index}}; {% endif %} -- Indices only needed for search. diff --git a/nominatim/clicmd/index.py b/nominatim/clicmd/index.py index 16b5311c..86a504e7 100644 --- a/nominatim/clicmd/index.py +++ b/nominatim/clicmd/index.py @@ -56,6 +56,7 @@ class UpdateIndex: indexer.index_boundaries(args.minrank, args.maxrank) if not args.boundaries_only: indexer.index_by_rank(args.minrank, args.maxrank) + indexer.index_postcodes() if not args.no_boundaries and not args.boundaries_only \ and args.minrank == 0 and args.maxrank == 30: diff --git a/nominatim/clicmd/replication.py b/nominatim/clicmd/replication.py index b7956506..192a9314 100644 --- a/nominatim/clicmd/replication.py +++ b/nominatim/clicmd/replication.py @@ -142,7 +142,7 @@ class UpdateReplication: if not args.do_index: LOG.fatal("Indexing cannot be disabled when running updates continuously.") raise UsageError("Bad argument '--no-index'.") - recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL') + recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL') tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config) indexer = Indexer(args.config.get_libpq_dsn(), tokenizer, args.threads or 1) diff --git a/nominatim/tools/migration.py b/nominatim/tools/migration.py index e864ce52..02b7d19a 100644 --- a/nominatim/tools/migration.py +++ b/nominatim/tools/migration.py @@ -384,7 +384,7 @@ def add_improved_geometry_reverse_placenode_index(conn: Connection, **_: Any) -> """) @_migration(4, 4, 99, 0) -def create_postcode_ara_lookup_index(conn: Connection, **_: Any) -> None: +def create_postcode_area_lookup_index(conn: Connection, **_: Any) -> None: """ Create index needed for looking up postcode areas from postocde points. """ with conn.cursor() as cur: @@ -392,3 +392,14 @@ def create_postcode_ara_lookup_index(conn: Connection, **_: Any) -> None: ON placex USING BTREE (country_code, postcode) WHERE osm_type = 'R' AND class = 'boundary' AND type = 'postal_code' """) + + +@_migration(4, 4, 99, 1) +def create_postcode_parent_index(conn: Connection, **_: Any) -> None: + """ Create index needed for updating postcodes when a parent changes. + """ + if conn.table_exists('planet_osm_ways'): + with conn.cursor() as cur: + cur.execute("""CREATE INDEX IF NOT EXISTS + idx_location_postcode_parent_place_id + ON location_postcode USING BTREE (parent_place_id)""") diff --git a/nominatim/version.py b/nominatim/version.py index 76da1dbd..9ef22a87 100644 --- a/nominatim/version.py +++ b/nominatim/version.py @@ -34,7 +34,7 @@ class NominatimVersion(NamedTuple): return f"{self.major}.{self.minor}.{self.patch_level}-{self.db_patch_level}" -NOMINATIM_VERSION = NominatimVersion(4, 4, 99, 0) +NOMINATIM_VERSION = NominatimVersion(4, 4, 99, 1) POSTGRESQL_REQUIRED_VERSION = (9, 6) POSTGIS_REQUIRED_VERSION = (2, 2) diff --git a/settings/import-address.lua b/settings/import-address.lua index 43248b02..b177b73c 100644 --- a/settings/import-address.lua +++ b/settings/import-address.lua @@ -1,9 +1,16 @@ local flex = require('flex-base') flex.set_main_tags{ - highway = {'always', - street_lamp = 'named', - traffic_signals = 'named', + highway = {motorway = 'always', + trunk = 'always', + primary = 'always', + secondary = 'always', + tertiary = 'always', + unclassified = 'always', + residential = 'always', + road = 'always', + living_street = 'always', + pedestrian = 'always', service = 'named', cycleway = 'named', path = 'named', @@ -28,9 +35,7 @@ flex.set_prefilters{delete_keys = {'building', 'source', '*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*', 'name:etymology', 'name:signed', 'name:botanical', 'addr:street:name', 'addr:street:type'}, - delete_tags = {highway = {'no', 'turning_circle', 'mini_roundabout', - 'noexit', 'crossing', 'give_way', 'stop'}, - landuse = {'cemetry', 'no'}, + delete_tags = {landuse = {'cemetry', 'no'}, boundary = {'place'}}, extra_keys = {'wikipedia', 'wikipedia:*', 'wikidata', 'capital', 'area'} } diff --git a/settings/import-street.lua b/settings/import-street.lua index 68ad48bd..60b76dfb 100644 --- a/settings/import-street.lua +++ b/settings/import-street.lua @@ -1,9 +1,16 @@ local flex = require('flex-base') flex.set_main_tags{ - highway = {'always', - street_lamp = 'named', - traffic_signals = 'named', + highway = {motorway = 'always', + trunk = 'always', + primary = 'always', + secondary = 'always', + tertiary = 'always', + unclassified = 'always', + residential = 'always', + road = 'always', + living_street = 'always', + pedestrian = 'always', service = 'named', cycleway = 'named', path = 'named', @@ -29,9 +36,7 @@ flex.set_prefilters{delete_keys = {'building', 'source', '*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*', 'name:etymology', 'name:signed', 'name:botanical', 'addr:street:name', 'addr:street:type'}, - delete_tags = {highway = {'no', 'turning_circle', 'mini_roundabout', - 'noexit', 'crossing', 'give_way', 'stop'}, - landuse = {'cemetry', 'no'}, + delete_tags = {landuse = {'cemetry', 'no'}, boundary = {'place'}}, extra_keys = {'wikipedia', 'wikipedia:*', 'wikidata', 'capital', 'area'} } diff --git a/test/bdd/db/import/interpolation.feature b/test/bdd/db/import/interpolation.feature index 3c67d652..6b784b78 100644 --- a/test/bdd/db/import/interpolation.feature +++ b/test/bdd/db/import/interpolation.feature @@ -2,9 +2,26 @@ Feature: Import of address interpolations Tests that interpolated addresses are added correctly + Scenario: Simple even interpolation line with two points and no street nearby + Given the grid with origin 1,1 + | 1 | | 9 | | 2 | + Given the places + | osm | class | type | housenr | + | N1 | place | house | 2 | + | N2 | place | house | 6 | + And the places + | osm | class | type | addr+interpolation | geometry | + | W1 | place | houses | even | 1,2 | + And the ways + | id | nodes | + | 1 | 1,2 | + When importing + Then W1 expands to no interpolation + Scenario: Simple even interpolation line with two points Given the grid with origin 1,1 | 1 | | 9 | | 2 | + | 4 | | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 2 | @@ -12,6 +29,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,2 | @@ -23,6 +43,7 @@ Feature: Import of address interpolations Scenario: Backwards even two point interpolation line Given the grid with origin 1,1 | 1 | 8 | 9 | 2 | + | 4 | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 2 | @@ -30,6 +51,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 2,1 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 2,1 | @@ -41,6 +65,7 @@ Feature: Import of address interpolations Scenario: Simple odd two point interpolation Given the grid with origin 1,1 | 1 | 8 | | | 9 | 2 | + | 4 | | | | 5 | | Given the places | osm | class | type | housenr | | N1 | place | house | 1 | @@ -48,6 +73,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | odd | 1,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,2 | @@ -59,6 +87,7 @@ Feature: Import of address interpolations Scenario: Simple all two point interpolation Given the grid with origin 1,1 | 1 | 8 | 9 | 2 | + | 4 | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 1 | @@ -66,6 +95,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | all | 1,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,2 | @@ -77,6 +109,7 @@ Feature: Import of address interpolations Scenario: Even two point interpolation line with intermediate empty node Given the grid | 1 | 8 | | 3 | 9 | 2 | + | 4 | | | | 5 | | Given the places | osm | class | type | housenr | | N1 | place | house | 2 | @@ -84,6 +117,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,3,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,3,2 | @@ -94,6 +130,7 @@ Feature: Import of address interpolations Scenario: Even two point interpolation line with intermediate duplicated empty node Given the grid + | 4 | | | | 5 | | 1 | 8 | 3 | 9 | 2 | Given the places | osm | class | type | housenr | @@ -102,6 +139,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,3,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,3,3,2 | @@ -112,6 +152,7 @@ Feature: Import of address interpolations Scenario: Simple even three point interpolation line Given the grid + | 4 | | | | | | 5 | | 1 | 8 | | 9 | 3 | 7 | 2 | Given the places | osm | class | type | housenr | @@ -121,6 +162,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,3,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,3,2 | @@ -144,6 +188,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,3,2,4 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 1,3,2,4 | And the ways | id | nodes | | 1 | 1,3,2,4 | @@ -157,6 +204,7 @@ Feature: Import of address interpolations Scenario: Reverse simple even three point interpolation line Given the grid | 1 | 8 | | 9 | 3 | 7 | 2 | + | 4 | | | | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 2 | @@ -165,6 +213,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 2,3,1 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 2,3,1 | @@ -177,6 +228,7 @@ Feature: Import of address interpolations Scenario: Even three point interpolation line with odd center point Given the grid | 1 | | 10 | | | 11 | 3 | 2 | + | 4 | | | | | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 2 | @@ -185,6 +237,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,3,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,3,2 | @@ -206,6 +261,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,2,3,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 1,2,3 | And the ways | id | nodes | | 1 | 1,2,3,2 | @@ -227,6 +285,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,2,3,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 1,2,3 | And the ways | id | nodes | | 1 | 1,2,3,2 | @@ -334,6 +395,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 144.9632341 -37.76163,144.9630541 -37.7628172,144.9629794 -37.7630755 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 144.9632341 -37.76163,144.9629794 -37.7630755 | And the ways | id | nodes | | 1 | 1,2,3 | @@ -346,6 +410,7 @@ Feature: Import of address interpolations Scenario: Place with missing address information Given the grid | 1 | | 2 | | | 3 | + | 4 | | | | | 5 | And the places | osm | class | type | housenr | | N1 | place | house | 23 | @@ -354,6 +419,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | odd | 1,2,3 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,2,3 | @@ -366,12 +434,16 @@ Feature: Import of address interpolations Given the places | osm | class | type | housenr | geometry | | W1 | place | houses | even | 1 1, 1 1.001 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 1 1, 1 1.001 | When importing Then W1 expands to no interpolation Scenario: Ways with nodes without housenumbers are ignored Given the grid - | 1 | | 2 | + | 1 | | 2 | + | 4 | | 5 | Given the places | osm | class | type | | N1 | place | house | @@ -379,12 +451,16 @@ Feature: Import of address interpolations Given the places | osm | class | type | housenr | geometry | | W1 | place | houses | even | 1,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | When importing Then W1 expands to no interpolation Scenario: Two point interpolation starting at 0 Given the grid with origin 1,1 | 1 | 10 | | | 11 | 2 | + | 4 | | | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 0 | @@ -392,6 +468,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,2 | + And the places + | osm | class | type | name | geometry | + | W10 | highway | residential | London Road |4,5 | And the ways | id | nodes | | 1 | 1,2 | @@ -402,7 +481,7 @@ Feature: Import of address interpolations When sending v1/reverse at 1,1 Then results contain | ID | osm | type | display_name | - | 0 | N1 | house | 0 | + | 0 | N1 | house | 0, London Road | Scenario: Parenting of interpolation with additional tags Given the grid @@ -438,6 +517,7 @@ Feature: Import of address interpolations Scenario Outline: Bad interpolation values are ignored Given the grid with origin 1,1 | 1 | | 9 | | 2 | + | 4 | | | | 5 | Given the places | osm | class | type | housenr | | N1 | place | house | 2 | @@ -445,6 +525,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | | 1,2 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,2 | @@ -470,6 +553,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 1,2,3,4 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 1,4 | And the ways | id | nodes | | 1 | 1,2,3,4 | @@ -484,6 +570,7 @@ Feature: Import of address interpolations Scenario: Interpolation line with duplicated points Given the grid | 7 | 10 | 8 | 11 | 9 | + | 4 | | | | 5 | Given the places | osm | class | type | housenr | geometry | | N1 | place | house | 2 | 7 | @@ -493,6 +580,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 7,8,8,9 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 4,5 | And the ways | id | nodes | | 1 | 1,2,3,4 | @@ -515,6 +605,9 @@ Feature: Import of address interpolations And the places | osm | class | type | addr+interpolation | geometry | | W1 | place | houses | even | 8,9 | + And the named places + | osm | class | type | geometry | + | W10 | highway | residential | 1,4 | And the ways | id | nodes | | 1 | 1,8,9,2,3,4 | diff --git a/test/bdd/db/update/postcode.feature b/test/bdd/db/update/postcode.feature index c6696dda..39318101 100644 --- a/test/bdd/db/update/postcode.feature +++ b/test/bdd/db/update/postcode.feature @@ -102,3 +102,25 @@ Feature: Update of postcode | country | postcode | geometry | | de | 01982 | country:de | And there are word tokens for postcodes 01982 + + Scenario: When a parent is deleted, the postcode gets a new parent + Given the grid with origin DE + | 1 | | 3 | 4 | + | | 9 | | | + | 2 | | 5 | 6 | + Given the places + | osm | class | type | name | admin | geometry | + | R1 | boundary | administrative | Big | 6 | (1,4,6,2,1) | + | R2 | boundary | administrative | Small | 6 | (1,3,5,2,1) | + Given the named places + | osm | class | type | addr+postcode | geometry | + | N9 | place | postcode | 12345 | 9 | + When importing + And updating postcodes + Then location_postcode contains exactly + | country | postcode | geometry | parent_place_id | + | de | 12345 | 9 | R2 | + When marking for delete R2 + Then location_postcode contains exactly + | country | postcode | geometry | parent_place_id | + | de | 12345 | 9 | R1 | diff --git a/test/bdd/osm2pgsql/update/interpolations.feature b/test/bdd/osm2pgsql/update/interpolations.feature index dae5168b..9ca26285 100644 --- a/test/bdd/osm2pgsql/update/interpolations.feature +++ b/test/bdd/osm2pgsql/update/interpolations.feature @@ -13,6 +13,7 @@ Feature: Updates of address interpolation objects """ n1 Taddr:housenumber=3 n2 Taddr:housenumber=17 + w33 Thighway=residential,name=Tao Nn1,n2 """ Then place contains | object | type | @@ -33,6 +34,7 @@ Feature: Updates of address interpolation objects | object | type | | N1:place | house | | N2:place | house | + | W33:highway | residential | Then location_property_osmline contains exactly | object | | 99:5 | @@ -73,6 +75,7 @@ Feature: Updates of address interpolation objects """ n1 Taddr:housenumber=3 n2 Taddr:housenumber=17 + w33 Thighway=residential Nn1,n2 w99 Thighway=residential Nn1,n2 """ Then place contains @@ -95,6 +98,7 @@ Feature: Updates of address interpolation objects | object | type | | N1:place | house | | N2:place | house | + | W33:highway | residential | And location_property_osmline contains exactly | object | | 99:5 | diff --git a/test/bdd/osm2pgsql/update/postcodes.feature b/test/bdd/osm2pgsql/update/postcodes.feature index 23f86f76..6bd61af7 100644 --- a/test/bdd/osm2pgsql/update/postcodes.feature +++ b/test/bdd/osm2pgsql/update/postcodes.feature @@ -136,12 +136,14 @@ Feature: Update of postcode only objects """ n1 Taddr:housenumber=3 n2 Taddr:housenumber=17 + w33 Thighway=residential Nn1,n2 w34 Tpostcode=4456 Nn1,n2 """ Then place contains exactly | object | type | | N1:place | house | | N2:place | house | + | W33:highway | residential | | W34:place | postcode | When updating osm data @@ -152,6 +154,7 @@ Feature: Update of postcode only objects | object | type | | N1:place | house | | N2:place | house | + | W33:highway | residential | | W34:place | houses | When indexing Then location_property_osmline contains exactly @@ -161,3 +164,4 @@ Feature: Update of postcode only objects | object | type | | N1:place | house | | N2:place | house | + | W33:highway | residential | diff --git a/test/python/cli/test_cli.py b/test/python/cli/test_cli.py index 998bccb4..12a58d07 100644 --- a/test/python/cli/test_cli.py +++ b/test/python/cli/test_cli.py @@ -129,11 +129,13 @@ class TestCliWithDb: table_factory('import_status', 'indexed bool') bnd_mock = mock_func_factory(nominatim.indexer.indexer.Indexer, 'index_boundaries') rank_mock = mock_func_factory(nominatim.indexer.indexer.Indexer, 'index_by_rank') + postcode_mock = mock_func_factory(nominatim.indexer.indexer.Indexer, 'index_postcodes') assert self.call_nominatim('index', *params) == 0 assert bnd_mock.called == do_bnds assert rank_mock.called == do_ranks + assert postcode_mock.called == do_ranks def test_special_phrases_wiki_command(self, mock_func_factory):