From: Sarah Hoffmann Date: Thu, 19 Oct 2023 19:24:53 +0000 (+0200) Subject: restrict geometry size for SQLite X-Git-Tag: v4.4.0~87^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/a9ac68a729c8aff91a94dfc1d936534e0e89ccb7?ds=sidebyside;hp=84d6b481ae58bf3e998959eb74639e24e99341ea restrict geometry size for SQLite --- diff --git a/nominatim/tools/convert_sqlite.py b/nominatim/tools/convert_sqlite.py index d766c642..0702e5d8 100644 --- a/nominatim/tools/convert_sqlite.py +++ b/nominatim/tools/convert_sqlite.py @@ -138,6 +138,18 @@ class SqliteWriter: """ columns = self.src.t.meta.tables[table].c + if table == 'placex': + # SQLite struggles with Geometries that are larger than 5MB, + # so simplify those. + return sa.select(*(c for c in columns if not isinstance(c.type, Geometry)), + sa.func.ST_AsText(columns.centroid).label('centroid'), + sa.func.ST_AsText( + sa.case((sa.func.ST_MemSize(columns.geometry) < 5000000, + columns.geometry), + else_=sa.func.ST_SimplifyPreserveTopology( + columns.geometry, 0.0001) + )).label('geometry')) + sql = sa.select(*(sa.func.ST_AsText(c).label(c.name) if isinstance(c.type, Geometry) else c for c in columns))