Skip to content

Commit

Permalink
LVBAG: honour IsSingleAllowedDriver()
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 15, 2024
1 parent a763a24 commit 4216271
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions autotest/ogr/ogr_lvbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,14 @@ def test_ogr_lvbag_test_ogrsf_num():
)

assert "INFO" in ret and "ERROR" not in ret


###############################################################################
# Test force opening


def test_ogr_lvbag_force_opening():

# Would be opened by GML driver if not forced
ds = gdal.OpenEx("data/gml/empty.gml", allowed_drivers=["LVBAG"])
assert ds.GetDriver().GetDescription() == "LVBAG"
7 changes: 5 additions & 2 deletions ogr/ogrsf_frmts/lvbag/ogrlvbagdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ static int OGRLVBAGDriverIdentify(GDALOpenInfo *poOpenInfo)
return FALSE;
if (poOpenInfo->bIsDirectory)
return -1; // Check later
if (poOpenInfo->fpL == nullptr)
if (poOpenInfo->fpL == nullptr || poOpenInfo->nHeaderBytes == 0)
return FALSE;

auto pszPtr = reinterpret_cast<const char *>(poOpenInfo->pabyHeader);
if (poOpenInfo->nHeaderBytes == 0 || pszPtr[0] != '<')
if (pszPtr[0] != '<')
return FALSE;

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

// Can't handle mutations just yet
if (strstr(pszPtr,
"http://www.kadaster.nl/schemas/mutatielevering-generiek/1.0") !=
Expand Down

0 comments on commit 4216271

Please sign in to comment.