Skip to content

Commit

Permalink
GML: honour IsSingleAllowedDriver()
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 15, 2024
1 parent 07dae65 commit a763a24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions autotest/ogr/ogr_gml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4626,3 +4626,18 @@ def test_ogr_gml_get_layers_by_name_from_imported_schema_more_tests(tmp_path):
assert isinstance(
dat_erst, list
), f"Expected 'dat_erst' to be of type 'list', but got {type(dat_erst)}"


###############################################################################
# Test force opening a GML file


def test_ogr_gml_force_opening(tmp_vsimem):

filename = str(tmp_vsimem / "test.gml")
gdal.FileFromMemBuffer(filename, open("data/nas/empty_nas.xml", "rb").read())

# Would be opened by NAS driver if not forced
with gdal.config_option("NAS_GFS_TEMPLATE", ""):
ds = gdal.OpenEx(filename, allowed_drivers=["GML"])
assert ds.GetDriver().GetDescription() == "GML"
3 changes: 3 additions & 0 deletions ogr/ogrsf_frmts/gml/ogrgmldriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ static int OGRGMLDriverIdentify(GDALOpenInfo *poOpenInfo)
if (!poOpenInfo->TryToIngest(4096))
return FALSE;

if (poOpenInfo->IsSingleAllowedDriver("GML"))
return TRUE;

return OGRGMLDataSource::CheckHeader(
reinterpret_cast<const char *>(poOpenInfo->pabyHeader));
}
Expand Down

0 comments on commit a763a24

Please sign in to comment.