Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from OSGeo:master #173

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class OGRMVTDataset final : public GDALDataset
}

static GDALDataset *Open(GDALOpenInfo *);
static GDALDataset *Open(GDALOpenInfo *, bool bRecurseAllowed);

OGRSpatialReference *GetSRS()
{
Expand Down Expand Up @@ -1637,7 +1638,8 @@ void OGRMVTDirectoryLayer::OpenTile()
m_bJsonField ? "" : m_poDS->m_osMetadataMemFilename.c_str());
oOpenInfo.papszOpenOptions = CSLSetNameValue(
oOpenInfo.papszOpenOptions, "DO_NOT_ERROR_ON_MISSING_TILE", "YES");
m_poCurrentTile = OGRMVTDataset::Open(&oOpenInfo);
m_poCurrentTile =
OGRMVTDataset::Open(&oOpenInfo, /* bRecurseAllowed = */ false);
CSLDestroy(oOpenInfo.papszOpenOptions);

int nX = (m_bUseReadDir || !m_aosDirContent.empty())
Expand Down Expand Up @@ -1859,7 +1861,8 @@ OGRFeature *OGRMVTDirectoryLayer::GetFeature(GIntBig nFID)
m_bJsonField ? "" : m_poDS->m_osMetadataMemFilename.c_str());
oOpenInfo.papszOpenOptions = CSLSetNameValue(
oOpenInfo.papszOpenOptions, "DO_NOT_ERROR_ON_MISSING_TILE", "YES");
GDALDataset *poTile = OGRMVTDataset::Open(&oOpenInfo);
GDALDataset *poTile =
OGRMVTDataset::Open(&oOpenInfo, /* bRecurseAllowed = */ false);
CSLDestroy(oOpenInfo.papszOpenOptions);
OGRFeature *poFeature = nullptr;
if (poTile)
Expand Down Expand Up @@ -2687,7 +2690,8 @@ GDALDataset *OGRMVTDataset::OpenDirectory(GDALOpenInfo *poOpenInfo)
oOpenInfo.papszOpenOptions =
CSLSetNameValue(oOpenInfo.papszOpenOptions,
"DO_NOT_ERROR_ON_MISSING_TILE", "YES");
auto poTileDS = OGRMVTDataset::Open(&oOpenInfo);
auto poTileDS = OGRMVTDataset::Open(
&oOpenInfo, /* bRecurseAllowed = */ false);
if (poTileDS)
{
if (poDS == nullptr)
Expand Down Expand Up @@ -2880,6 +2884,11 @@ GDALDataset *OGRMVTDataset::OpenDirectory(GDALOpenInfo *poOpenInfo)
/************************************************************************/

GDALDataset *OGRMVTDataset::Open(GDALOpenInfo *poOpenInfo)
{
return Open(poOpenInfo, true);
}

GDALDataset *OGRMVTDataset::Open(GDALOpenInfo *poOpenInfo, bool bRecurseAllowed)

{
if (!OGRMVTDriverIdentify(poOpenInfo) || poOpenInfo->eAccess == GA_Update)
Expand All @@ -2899,7 +2908,7 @@ GDALDataset *OGRMVTDataset::Open(GDALOpenInfo *poOpenInfo)
// If the filename has no extension and is a directory, consider
// we open a directory
VSIStatBufL sStat;
if (!STARTS_WITH(osFilename, "/vsigzip/") &&
if (bRecurseAllowed && !STARTS_WITH(osFilename, "/vsigzip/") &&
strchr((CPLGetFilename(osFilename)), '.') == nullptr &&
VSIStatL(osFilename, &sStat) == 0 && VSI_ISDIR(sStat.st_mode))
{
Expand All @@ -2913,7 +2922,8 @@ GDALDataset *OGRMVTDataset::Open(GDALOpenInfo *poOpenInfo)

// For a network resource, if the filename is an integer, consider it
// is a directory and open as such
if ((STARTS_WITH(osFilename, "/vsicurl") ||
if (bRecurseAllowed &&
(STARTS_WITH(osFilename, "/vsicurl") ||
STARTS_WITH(osFilename, "http://") ||
STARTS_WITH(osFilename, "https://")) &&
CPLGetValueType(CPLGetFilename(osFilename)) == CPL_VALUE_INTEGER)
Expand Down Expand Up @@ -2947,10 +2957,11 @@ GDALDataset *OGRMVTDataset::Open(GDALOpenInfo *poOpenInfo)
}
}
}
else if (poOpenInfo->bIsDirectory ||
(STARTS_WITH(poOpenInfo->pszFilename, "/vsicurl") &&
CPLGetValueType(CPLGetFilename(poOpenInfo->pszFilename)) ==
CPL_VALUE_INTEGER))
else if (bRecurseAllowed &&
(poOpenInfo->bIsDirectory ||
(STARTS_WITH(poOpenInfo->pszFilename, "/vsicurl") &&
CPLGetValueType(CPLGetFilename(poOpenInfo->pszFilename)) ==
CPL_VALUE_INTEGER)))
{
return OpenDirectory(poOpenInfo);
}
Expand Down
Loading