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

GeoRaster: Added GENSTATS options, security fixes, and prevent failing when password is near expiration #9290

Merged
merged 37 commits into from
Feb 29, 2024

Conversation

Alan5142
Copy link
Contributor

No description provided.

Alan5142 and others added 30 commits July 14, 2023 19:25
GeoRaster: Added generate statistics option for GeoRaster driver
Statistics and general use fix
GeoRaster: fixed docs for GENSTATS_SAMPLINGWINDOW and GENSTATS_BINFUNCTION
initialized dfGenStatsBinFunction dfGenStatsSamplingWindow
added table prefix to columns in georaster_wrapper when generating statistics
added code to ignore error ORA-28002
add documentation about GENSTATS must be set to true even if other options are set to false
added warning log when GENSTATS options are set but GENSTATS is false
@rouault
Copy link
Member

rouault commented Feb 23, 2024

@fechen123 Are you still involved with the GeoRaster driver? If so, can you give this some review?

@rouault
Copy link
Member

rouault commented Feb 23, 2024

Some XML invalidity found in the creation options: E lxml.etree.XMLSyntaxError: line 1: b"Couldn't find end of Start Tag Option line 1"

@coveralls
Copy link
Collaborator

coveralls commented Feb 23, 2024

Coverage Status

coverage: 68.823% (+0.01%) from 68.813%
when pulling 7a3e52d on Alan5142:master
into 48ddaf2 on OSGeo:master.

@fechen123
Copy link
Contributor

@fechen123 Are you still involved with the GeoRaster driver? If so, can you give this some review?

Yes, Alan is helping us to add some features. I have reviewed the changes and they look good to me.

Comment on lines +1270 to +1275
pszFetched = CSLFetchNameValue(papszOptions, "GENSTATS");

if (pszFetched != nullptr)
{
poGRD->poGeoRaster->bGenStats = EQUAL(pszFetched, "TRUE");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified as:

Suggested change
pszFetched = CSLFetchNameValue(papszOptions, "GENSTATS");
if (pszFetched != nullptr)
{
poGRD->poGeoRaster->bGenStats = EQUAL(pszFetched, "TRUE");
}
poGRD->poGeoRaster->bGenStats = CPLFetchBool(papszOptions, "GENSTATS", FALSE);

similar occurrences below

Comment on lines 617 to 622
const char *rgpszInvalidChars[] = {";", "--", "/*", "*/", "//"};
const size_t nInvalidCharsSize = 5;

for (size_t nPos = 0; nPos < nInvalidCharsSize; ++nPos)
{
const char *pszInvalidChar = rgpszInvalidChars[nPos];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified as:

Suggested change
const char *rgpszInvalidChars[] = {";", "--", "/*", "*/", "//"};
const size_t nInvalidCharsSize = 5;
for (size_t nPos = 0; nPos < nInvalidCharsSize; ++nPos)
{
const char *pszInvalidChar = rgpszInvalidChars[nPos];
const char *rgpszInvalidChars[] = {";", "--", "/*", "*/", "//"};
for (const char *pszInvalidChar: rgpszInvalidChars)
{

@@ -100,6 +100,33 @@ void GEORDriverSetCommonMetadata(GDALDriver *poDriver)
" </Option>"
" <Option name='GENPYRLEVELS' type='int' description='Number of "
"pyramid level to generate'/>"
" <Option name='GENSTATS' type='boolean'"
"description='Generate statistics from the given rasters'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect missing spaces cause XML validation issues:

Suggested change
"description='Generate statistics from the given rasters'"
"description='Generate statistics from the given rasters' "

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I might missed those when merging with the latest main changes, I'm going to make a commit with those fixes.

" <Option name='GENSTATS' type='boolean'"
"description='Generate statistics from the given rasters'"
"default='FALSE' />"
" <Option name='GENSTATS_SAMPLINGFACTOR' type='int'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_SAMPLINGFACTOR' type='int'"
" <Option name='GENSTATS_SAMPLINGFACTOR' type='int' "

" <Option name='GENSTATS_SAMPLINGFACTOR' type='int'"
"description='Number of cells skipped in both row and column "
"dimensions when "
"the statistics are computed'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"the statistics are computed'"
"the statistics are computed' "

"dimensions when "
"the statistics are computed'"
"default='1' />"
" <Option name='GENSTATS_SAMPLINGWINDOW' type='string'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_SAMPLINGWINDOW' type='string'"
" <Option name='GENSTATS_SAMPLINGWINDOW' type='string' "

" <Option name='GENSTATS_SAMPLINGWINDOW' type='string'"
"description='Coordinates (4 numbers) of a rectangular "
"window to be used to sample the raster when generating statistics' />"
" <Option name='GENSTATS_HISTOGRAM' type='boolean'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_HISTOGRAM' type='boolean'"
" <Option name='GENSTATS_HISTOGRAM' type='boolean' "

"window to be used to sample the raster when generating statistics' />"
" <Option name='GENSTATS_HISTOGRAM' type='boolean'"
"description='Compute a histogram for the raster' default='FALSE' />"
" <Option name='GENSTATS_LAYERNUMBERS' type='string'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_LAYERNUMBERS' type='string'"
" <Option name='GENSTATS_LAYERNUMBERS' type='string' "

" <Option name='GENSTATS_LAYERNUMBERS' type='string'"
"description='Layer numbers and/or ranges for which to compute "
"the statistics' />"
" <Option name='GENSTATS_USEBIN' type='boolean'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_USEBIN' type='boolean'"
" <Option name='GENSTATS_USEBIN' type='boolean' "

"description='Specifies if the statistics should use the bin function "
"provided by GENSTATS_USEBIN "
"to compute the statistics' default='TRUE' />"
" <Option name='GENSTATS_BINFUNCTION' type='string'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_BINFUNCTION' type='string'"
" <Option name='GENSTATS_BINFUNCTION' type='string' "

" <Option name='GENSTATS_BINFUNCTION' type='string'"
"description='Array to specify the bin function (type, total number of "
"bins, first bin number, minimum, cell value, maximum cell value)' />"
" <Option name='GENSTATS_NODATA' type='boolean'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" <Option name='GENSTATS_NODATA' type='boolean'"
" <Option name='GENSTATS_NODATA' type='boolean' "

Copy link
Member

@rouault rouault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplified boolean value retrieval with CPLFetchBool
simplified for loop iteration in ValidateDescriptionExpression
bGenStatsOptionsUsed = true;
poGRD->poGeoRaster->bGenStatsHistogram = EQUAL(pszFetched, "TRUE");
}
poGRD->poGeoRaster->bGenStatsHistogram = CPLFetchBool(papszOptions, "GENSTATS_HISTOGRAM", FALSE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum I realize my suggestion to use CPLFetchBool might cause issues here as bGenStatsOptionsUsed = true will no longer be set.

But I also realize that autotest/gdrivers/georaster.py hasn't been updated. It could make sense for long-term maintenance to test that new functionality

@rouault
Copy link
Member

rouault commented Feb 26, 2024

code formatting issues (https://github.com/OSGeo/gdal/actions/runs/8052255527/job/21996379266?pr=9290) and still XML invalidity

@rouault
Copy link
Member

rouault commented Feb 26, 2024

see https://gdal.org/development/dev_practices.html#commit-hooks how to set up pre-commit to get auto formatting

restore previous code in georaster_dataset.cpp
format in ValidateDescriptionExpression
change name in XML
@rouault
Copy link
Member

rouault commented Feb 28, 2024

@rouault
Copy link
Member

rouault commented Feb 28, 2024

There are still XML errors.
You can diagnose them locally with python3 -m pytest autotest/gcore/test_driver_metadata.py::test_metadata_creationoptionslist

@rouault rouault added this to the 3.9.0 milestone Feb 29, 2024
@rouault rouault merged commit 1841a93 into OSGeo:master Feb 29, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants