mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
change updates to handle delete/insert workflow
This makes Nominatim compatible with osm2pgsql's default update modus operandi of deleting and reinserting data. Deletes are diverted into a TODO table instead of executing them. When data is reinserted, the corresponding entry in the TODO table is deleted. After updates are finished, the remaining entries in the TODO table are executed, doing the same work as the delete trigger did before. The new behaviour also works against the gazetteer output with its insert-only mechanism.
This commit is contained in:
@@ -118,7 +118,10 @@ def update_place_table(context):
|
||||
context.nominatim.run_nominatim('refresh', '--functions')
|
||||
with context.db.cursor() as cur:
|
||||
for row in context.table:
|
||||
PlaceColumn(context).add_row(row, False).db_insert(cur)
|
||||
col = PlaceColumn(context).add_row(row, False)
|
||||
col.db_delete(cur)
|
||||
col.db_insert(cur)
|
||||
cur.execute('SELECT flush_deleted_places()')
|
||||
|
||||
context.nominatim.reindex_placex(context.db)
|
||||
check_database_integrity(context)
|
||||
@@ -143,8 +146,10 @@ def delete_places(context, oids):
|
||||
"""
|
||||
context.nominatim.run_nominatim('refresh', '--functions')
|
||||
with context.db.cursor() as cur:
|
||||
cur.execute('TRUNCATE place_to_be_deleted')
|
||||
for oid in oids.split(','):
|
||||
NominatimID(oid).query_osm_id(cur, 'DELETE FROM place WHERE {}')
|
||||
cur.execute('SELECT flush_deleted_places()')
|
||||
|
||||
context.nominatim.reindex_placex(context.db)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user