Skip to content

Commit

Permalink
Add missing pyramid check on a raster
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Jan 11, 2024
1 parent fa3f1d1 commit d1f0b07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lizmap/project_checker_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from lizmap.qgis_plugin_tools.tools.i18n import tr
from lizmap.tools import cast_to_group, cast_to_layer, is_vector_pg, update_uri
from lizmap.widgets.check_project import (
RASTER_COUNT_CELL,
Checks,
Error,
SourceGroup,
Expand Down Expand Up @@ -132,6 +133,12 @@ def project_safeguards_checks(
if '..' in relative_path:
results[SourceLayer(layer.name(), layer.id())] = checks.PreventParentFolder

if isinstance(layer, QgsRasterLayer):
# Only file based raster
if not layer.dataProvider().hasPyramids():
if layer.width() * layer.height() >= RASTER_COUNT_CELL:
results[SourceLayer(layer.name(), layer.id())] = checks.RasterWithoutPyramid

return results


Expand Down
23 changes: 23 additions & 0 deletions lizmap/widgets/check_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from lizmap.qgis_plugin_tools.tools.i18n import tr
from lizmap.tools import qgis_version

# 10 000 * 10 000
RASTER_COUNT_CELL = 100000000


class Header:

Expand Down Expand Up @@ -397,6 +400,26 @@ def __init__(self):
Severities().blocking if qgis_version() >= 32200 else Severities().important,
QIcon(':/images/themes/default/mIconGeometryCollectionLayer.svg'),
)
self.RasterWithoutPyramid = Check(
'raster_without_pyramid',
tr('Raster is missing a pyramid'),
tr(
"The raster has more than {} cells and is missing a pyramid. A pyramid is important for performances "
"for this raster."
).format(RASTER_COUNT_CELL),
(
'<ul>'
'<li>{help}</li>'
'</ul>'
).format(
help=tr(
"In the raster properties, pyramids tab, it's possible to create it."
),
),
Levels.Layer,
Severities().important,
QIcon(':/images/themes/default/propertyicons/pyramids.svg'),
)
self.DuplicatedLayerNameOrGroup = Check(
'duplicated_layer_name_or_group',
tr('Duplicated layer name or group'),
Expand Down

0 comments on commit d1f0b07

Please sign in to comment.