Skip to content

Commit 825405a

Browse files
committed
Revert geofilter clip
Cannot make it work so we just use the old bbox method
1 parent 68423bc commit 825405a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

packages/core/src/bag3d/core/assets/bag/download.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime
22
from typing import Tuple
33
from copy import deepcopy
4-
import csv
54

65
from dagster import (
76
asset,
@@ -13,6 +12,7 @@
1312
)
1413
from lxml import objectify
1514

15+
from bag3d.common.utils.geodata import bbox_from_wkt
1616
from bag3d.common.utils.files import unzip
1717
from bag3d.common.utils.requests import download_file
1818
from bag3d.common.utils.database import (
@@ -291,7 +291,6 @@ def load_bag_layer(
291291
"new_table": new_table,
292292
"dsn": context.resources.db_connection.connect.dsn,
293293
}
294-
wkt_path = Path("/tmp/wkt.csv")
295294

296295
# Create the ogr2ogr command. The order of parameters is important!
297296
if context.op_config.get("with_parallel"):
@@ -327,11 +326,9 @@ def load_bag_layer(
327326
]
328327
geofilter = context.op_config.get("geofilter")
329328
if geofilter:
330-
with wkt_path.open("w") as f:
331-
csvwriter = csv.writer(f, quoting=csv.QUOTE_STRINGS)
332-
csvwriter.writerow(["WKT",])
333-
csvwriter.writerow([geofilter,])
334-
cmd.append(f"-clipsrc {wkt_path}")
329+
bbox = bbox_from_wkt(geofilter)
330+
cmd.append("-spat {bbox}")
331+
kwargs["bbox"] = " ".join(map(str, bbox))
335332
cmd.append("-f PostgreSQL PG:'{dsn}'")
336333
cmd.append('{{}}"')
337334
cmd.append(f"::: {layer_dir}/*.xml")
@@ -357,7 +354,6 @@ def load_bag_layer(
357354
return_code, output = context.resources.gdal.app.execute(
358355
"ogr2ogr", cmd, kwargs=kwargs, local_path=extract_dir
359356
)
360-
wkt_path.unlink(missing_ok=True)
361357
return True if return_code == 0 else False
362358

363359

0 commit comments

Comments
 (0)