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

VRT: advertize expression dialects in 'ExpressionDialects' driver metadata item #11656

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
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
18 changes: 1 addition & 17 deletions autotest/pymod/gdaltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,20 +2140,4 @@ def handler(lvl, no, msg):

@functools.lru_cache()
def gdal_has_vrt_expression_dialect(dialect):
with disable_exceptions(), gdal.quiet_errors():
vrt = f"""<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<PixelFunctionType>expression</PixelFunctionType>
<PixelFunctionArguments expression="B1 + 5" dialect="{dialect}"/>
<ArraySource>
<Array name="test">
<DataType>Float64</DataType>
<Dimension name="Y" size="20"/>
<Dimension name="X" size="20"/>
<ConstantValue>10</ConstantValue>
</Array>
</ArraySource>
</VRTRasterBand>
</VRTDataset>"""
ds = gdal.Open(vrt)
return ds.ReadRaster() is not None
return dialect in gdal.GetDriverByName("VRT").GetMetadataItem("ExpressionDialects")
11 changes: 11 additions & 0 deletions frmts/vrt/vrtdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,17 @@ void GDALRegister_VRT()
poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
poDriver->SetMetadataItem(GDAL_DCAP_COORDINATE_EPOCH, "YES");

const char *pszExpressionDialects = "ExpressionDialects";
#if defined(GDAL_VRT_ENABLE_MUPARSER) && defined(GDAL_VRT_ENABLE_EXPRTK)
poDriver->SetMetadataItem(pszExpressionDialects, "muparser,exprtk");
#elif defined(GDAL_VRT_ENABLE_MUPARSER)
poDriver->SetMetadataItem(pszExpressionDialects, "muparser");
#elif defined(GDAL_VRT_ENABLE_EXPRTK)
poDriver->SetMetadataItem(pszExpressionDialects, "exprtk");
#else
poDriver->SetMetadataItem(pszExpressionDialects, "none");
#endif

poDriver->AddSourceParser("SimpleSource", VRTParseCoreSources);
poDriver->AddSourceParser("ComplexSource", VRTParseCoreSources);
poDriver->AddSourceParser("AveragedSource", VRTParseCoreSources);
Expand Down
Loading