diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 19764ed9..4e27058c 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -731,6 +731,10 @@ BEGIN END IF; + IF NEW.importance IS NULL THEN + NEW.importance := 0.40001 - (NEW.rank_search::float / 75); + END IF; + {% if debug %}RAISE WARNING 'placex_insert:END: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;{% endif %} {% if not disable_diff_updates %} @@ -1076,10 +1080,8 @@ BEGIN {% if debug %}RAISE WARNING 'Waterway processed';{% endif %} END IF; - NEW.importance := null; - SELECT wikipedia, importance - FROM compute_importance(NEW.extratags, NEW.country_code, NEW.rank_search, NEW.centroid) - INTO NEW.wikipedia,NEW.importance; + SELECT wikipedia, importance INTO NEW.wikipedia, NEW.importance + FROM compute_importance(NEW.extratags, NEW.country_code, NEW.rank_search, NEW.centroid); {% if debug %}RAISE WARNING 'Importance computed from wikipedia: %', NEW.importance;{% endif %} diff --git a/lib-sql/tables/placex.sql b/lib-sql/tables/placex.sql index 590f734e..db604f4e 100644 --- a/lib-sql/tables/placex.sql +++ b/lib-sql/tables/placex.sql @@ -12,7 +12,7 @@ CREATE TABLE placex ( place_id BIGINT NOT NULL, parent_place_id BIGINT, linked_place_id BIGINT, - importance FLOAT, + importance FLOAT NOT NULL, indexed_date TIMESTAMP, geometry_sector INTEGER NOT NULL, rank_address SMALLINT NOT NULL, diff --git a/test/python/conftest.py b/test/python/conftest.py index fbfda1de..2149cb9d 100644 --- a/test/python/conftest.py +++ b/test/python/conftest.py @@ -293,13 +293,14 @@ def placex_row(placex_table, temp_db_cursor): def _add(osm_type='N', osm_id=None, cls='amenity', typ='cafe', names=None, admin_level=None, address=None, extratags=None, geom='POINT(10 4)', country=None, housenumber=None, rank_search=30, rank_address=30, - centroid='POINT(10 4)', indexed_status=0, indexed_date=None): + centroid='POINT(10 4)', indexed_status=0, indexed_date=None, + importance=0.00001): args = {'place_id': pysql.SQL("nextval('seq_place')"), 'osm_type': osm_type, 'osm_id': osm_id or next(idseq), 'class': cls, 'type': typ, 'name': names, 'admin_level': admin_level, 'address': address, 'housenumber': housenumber, 'rank_search': rank_search, 'rank_address': rank_address, - 'extratags': extratags, + 'extratags': extratags, 'importance': importance, 'centroid': _with_srid(centroid), 'geometry': _with_srid(geom), 'country_code': country, 'indexed_status': indexed_status, 'indexed_date': indexed_date, diff --git a/test/python/tools/test_database_import.py b/test/python/tools/test_database_import.py index 3e98b575..1d50df1c 100644 --- a/test/python/tools/test_database_import.py +++ b/test/python/tools/test_database_import.py @@ -176,6 +176,7 @@ async def test_load_data(dsn, place_row, place_interpolation_row, placex_table, BEGIN NEW.place_id := nextval('seq_place'); NEW.indexed_status := 1; + NEW.importance := 0.00001; NEW.centroid := ST_Centroid(NEW.geometry); NEW.partition := 0; NEW.geometry_sector := 2424;