enforce presence of importance value in placex

This commit is contained in:
Sarah Hoffmann
2026-03-02 09:57:34 +01:00
parent d43e95f177
commit a16c698fb2
4 changed files with 11 additions and 7 deletions

View File

@@ -731,6 +731,10 @@ BEGIN
END IF; 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 debug %}RAISE WARNING 'placex_insert:END: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;{% endif %}
{% if not disable_diff_updates %} {% if not disable_diff_updates %}
@@ -1076,10 +1080,8 @@ BEGIN
{% if debug %}RAISE WARNING 'Waterway processed';{% endif %} {% if debug %}RAISE WARNING 'Waterway processed';{% endif %}
END IF; END IF;
NEW.importance := null; SELECT wikipedia, importance INTO NEW.wikipedia, NEW.importance
SELECT wikipedia, importance FROM compute_importance(NEW.extratags, NEW.country_code, NEW.rank_search, NEW.centroid);
FROM compute_importance(NEW.extratags, NEW.country_code, NEW.rank_search, NEW.centroid)
INTO NEW.wikipedia,NEW.importance;
{% if debug %}RAISE WARNING 'Importance computed from wikipedia: %', NEW.importance;{% endif %} {% if debug %}RAISE WARNING 'Importance computed from wikipedia: %', NEW.importance;{% endif %}

View File

@@ -12,7 +12,7 @@ CREATE TABLE placex (
place_id BIGINT NOT NULL, place_id BIGINT NOT NULL,
parent_place_id BIGINT, parent_place_id BIGINT,
linked_place_id BIGINT, linked_place_id BIGINT,
importance FLOAT, importance FLOAT NOT NULL,
indexed_date TIMESTAMP, indexed_date TIMESTAMP,
geometry_sector INTEGER NOT NULL, geometry_sector INTEGER NOT NULL,
rank_address SMALLINT NOT NULL, rank_address SMALLINT NOT NULL,

View File

@@ -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, 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)', admin_level=None, address=None, extratags=None, geom='POINT(10 4)',
country=None, housenumber=None, rank_search=30, rank_address=30, 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')"), args = {'place_id': pysql.SQL("nextval('seq_place')"),
'osm_type': osm_type, 'osm_id': osm_id or next(idseq), 'osm_type': osm_type, 'osm_id': osm_id or next(idseq),
'class': cls, 'type': typ, 'name': names, 'admin_level': admin_level, 'class': cls, 'type': typ, 'name': names, 'admin_level': admin_level,
'address': address, 'housenumber': housenumber, 'address': address, 'housenumber': housenumber,
'rank_search': rank_search, 'rank_address': rank_address, 'rank_search': rank_search, 'rank_address': rank_address,
'extratags': extratags, 'extratags': extratags, 'importance': importance,
'centroid': _with_srid(centroid), 'geometry': _with_srid(geom), 'centroid': _with_srid(centroid), 'geometry': _with_srid(geom),
'country_code': country, 'country_code': country,
'indexed_status': indexed_status, 'indexed_date': indexed_date, 'indexed_status': indexed_status, 'indexed_date': indexed_date,

View File

@@ -176,6 +176,7 @@ async def test_load_data(dsn, place_row, place_interpolation_row, placex_table,
BEGIN BEGIN
NEW.place_id := nextval('seq_place'); NEW.place_id := nextval('seq_place');
NEW.indexed_status := 1; NEW.indexed_status := 1;
NEW.importance := 0.00001;
NEW.centroid := ST_Centroid(NEW.geometry); NEW.centroid := ST_Centroid(NEW.geometry);
NEW.partition := 0; NEW.partition := 0;
NEW.geometry_sector := 2424; NEW.geometry_sector := 2424;