Skip to content

Commit

Permalink
ILI2: emit an error and not just a warning when creating a dataset wi…
Browse files Browse the repository at this point in the history
…thout a model file

Refs OSGeo#9351 / qgis/QGIS#56588
  • Loading branch information
rouault committed Feb 29, 2024
1 parent 8f72c60 commit 6f03818
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions autotest/ogr/ogr_ili.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

pytestmark = [
pytest.mark.require_driver("Interlis 1"),
pytest.mark.require_driver("Interlis 2"),
pytest.mark.random_order(disabled=True),
]

Expand Down Expand Up @@ -1197,3 +1198,22 @@ def test_ogr_interlis_arc2():
for i in range(feat.GetGeomFieldCount()):
geom = feat.GetGeomFieldRef(i)
ogrtest.check_feature_geometry(geom, geom_field_values[i])


###############################################################################
# Test failure in creation of ILI2 dataset


def test_ogr_interlis2_create_file_error():

with pytest.raises(
Exception, match="model file not specified in destination filename"
):
ogr.GetDriverByName("Interlis 2").CreateDataSource("tmp/out.xtf")

with pytest.raises(
Exception, match="Failed to create XTF file /i_do/not/exist/out.xtf"
):
ogr.GetDriverByName("Interlis 2").CreateDataSource(
"/i_do/not/exist/out.xtf,data/ili/ch.bazl.sicherheitszonenplan.oereb_20131118.imd"
)
4 changes: 3 additions & 1 deletion ogr/ogrsf_frmts/ili/ogrili2datasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ int OGRILI2DataSource::Create(const char *pszFilename,

if (pszModelFilename == nullptr)
{
CPLError(CE_Warning, CPLE_AppDefined, "Model file not specified.");
CPLError(
CE_Failure, CPLE_AppDefined,
"ILI2 Create(): model file not specified in destination filename.");
CSLDestroy(filenames);
return FALSE;
}
Expand Down

0 comments on commit 6f03818

Please sign in to comment.