6
6
7
7
"""
8
8
import json
9
+ import sqlite3
9
10
from pathlib import Path
10
11
from typing import Dict , List , Tuple
11
12
@@ -202,8 +203,16 @@ def fix_src_geometry(src_table: str, tmp_geom: str, radius_expr: str):
202
203
srid = get_global_srid ()
203
204
# create columns to store the derived geometries to
204
205
op .execute (sa .text (f"SELECT AddGeometryColumn('{ src_table } ', '{ tmp_geom } ', 4326, 'POLYGON', 'XY', 0);" ))
205
- # copy existing geometries to new columns
206
206
op .execute (sa .text (f"UPDATE { src_table } SET { tmp_geom } = the_geom;" ))
207
+ # copy existing geometries to new columns
208
+ # try:
209
+ # op.execute(sa.text(f"UPDATE {src_table} SET {tmp_geom} = the_geom;"))
210
+ # except:
211
+ # op.execute(sa.text(f"UPDATE {src_table} SET {tmp_geom} = NULL;"))
212
+ # except:
213
+ # print('Could not copy existing geometries')
214
+ # op.execute(sa.text(f"UPDATE {src_table} SET {tmp_geom} = NULL;"))
215
+
207
216
# create missing geometries
208
217
query_str = f"""
209
218
UPDATE { src_table } AS surface
@@ -215,7 +224,7 @@ def fix_src_geometry(src_table: str, tmp_geom: str, radius_expr: str):
215
224
FROM { src_table } _map
216
225
JOIN { src_table } ON { src_table } _map.{ src_table .strip ('v2_' )} _id = { src_table } .id
217
226
JOIN v2_connection_nodes ON v2_connection_nodes.id = { src_table } _map.connection_node_id
218
- WHERE { src_table } .sur_geom IS NULL
227
+ WHERE { src_table } .{ tmp_geom } IS NULL
219
228
GROUP BY { src_table } .id, { src_table } .area
220
229
) AS subquery
221
230
WHERE surface.id = subquery.surface_id
0 commit comments