Skip to content

Commit

Permalink
Merge pull request #107 from IGNF/fix-empty-query
Browse files Browse the repository at this point in the history
Fix case when BDUni query returns empty result
  • Loading branch information
leavauchier authored Apr 15, 2024
2 parents 424d30c + 9fcb85a commit 96de26f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# main

- Update pdal version to 2.6
- code and packaging cleanup
### 1.10.1
- Fix edge case when BD uni does not have data for the requested bbox

## 1.10.0
- Add support for EPSG reference other than 2154
- Update pdal version to 2.6
- code and packaging cleanup

### 1.9.14
- Be robust to pgsql2shp warnings when dealing with empty tables (i;e. no buildings).
Expand Down
2 changes: 1 addition & 1 deletion lidar_prod/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def request_bd_uni_for_building_shapefile(
except subprocess.CalledProcessError as e:
# In empty zones, pgsql2shp does not create a shapefile
if (
b"Initializing... \nERROR: Could not determine table metadata (empty table)\n"
"Initializing... \nERROR: Could not determine table metadata (empty table)\n"
in e.output
):
# write empty shapefile
Expand Down
2 changes: 1 addition & 1 deletion lidar_prod/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "V1.10.0"
__version__ = "V1.10.1"


if __name__ == "__main__":
Expand Down
15 changes: 12 additions & 3 deletions tests/lidar_prod/tasks/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,32 @@ def test_check_bbox_intersects_territoire_with_srid(hydra_cfg, bbox, srid, expec


@pytest.mark.parametrize(
"bbox,epsg,out_shp",
"bbox,epsg,out_shp,is_empty",
[
(
# Bbox in Metropolitan France, with correct epsg => output should not be empty
dict(x_min=870150, y_min=6616950, x_max=870350, y_max=6617200),
2154,
"metropolitan_ok.shp",
False,
),
(
# Bbox in St Barthelemy with correct epsg => output should not be empty
dict(x_min=515000, y_min=1981000, x_max=515100, y_max=1981100),
5490,
"st_barth_ok.shp",
False,
),
(
# Bbox in Reunion with correct epsg with no building or reservoir
dict(x_min=378000, y_min=7654000, x_max=379000, y_max=7655000),
2975,
"reunion_empty_ok.shp",
True,
),
],
)
def test_request_bd_uni_for_building_shapefile(hydra_cfg, bbox, epsg, out_shp):
def test_request_bd_uni_for_building_shapefile(hydra_cfg, bbox, epsg, out_shp, is_empty):
out_path = TMP_DIR / out_shp
request_bd_uni_for_building_shapefile(
hydra_cfg.bd_uni_connection_params,
Expand All @@ -134,7 +143,7 @@ def test_request_bd_uni_for_building_shapefile(hydra_cfg, bbox, epsg, out_shp):
)
assert out_path.is_file()
gdf = gdb.read_file(out_path)
assert bool(len(gdf.index))
assert bool(len(gdf.index)) != is_empty


def test_request_bd_uni_for_building_shapefile_fail(hydra_cfg):
Expand Down

0 comments on commit 96de26f

Please sign in to comment.