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

Raster labeling #59753

Merged
merged 25 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
328e473
Expose method as protected
nyalldawson Dec 3, 2024
0303fca
Remove duplicate map canvas member in subclass, use base class member…
nyalldawson Dec 3, 2024
e3b7ee3
Cleanup construction of QgsLabelingGui to make it more accessible for…
nyalldawson Dec 3, 2024
edc13bf
Improve docs
nyalldawson Dec 3, 2024
8094386
[API] Add framework for raster labeling
nyalldawson Dec 5, 2024
01dfb5f
Add GUI for configuring raster labeling
nyalldawson Dec 5, 2024
04b73ed
Fix default settings are not shown in widget
nyalldawson Dec 5, 2024
0ba34ff
Fix documentation
nyalldawson Dec 5, 2024
ea762b6
Fix mode for script
nyalldawson Dec 5, 2024
962c05a
Add missing moc
nyalldawson Dec 5, 2024
f2e1367
Fix build
nyalldawson Dec 5, 2024
bb4289a
Fix see also link
nyalldawson Dec 5, 2024
8677eea
Remove unused
nyalldawson Dec 5, 2024
72712de
Only write labelsEnabled attribute when labels are enabled
nyalldawson Dec 6, 2024
05c97be
Stablise transform for test
nyalldawson Dec 6, 2024
785c083
Add test masks
nyalldawson Dec 6, 2024
283037e
Fix clang tidy warning
nyalldawson Dec 6, 2024
6a4e423
Style
nyalldawson Dec 8, 2024
3234249
Move resampling method enum to Qgis, promote to enum class
nyalldawson Dec 9, 2024
2d413e7
Support raster labels for resampled values across neighboring pixels
nyalldawson Dec 9, 2024
0977170
Add test mask
nyalldawson Dec 9, 2024
99f477d
Fix clang-tidy warning
nyalldawson Dec 9, 2024
b02f2a7
Address review
nyalldawson Dec 18, 2024
82bf66f
Remove a lot of hardcoded tab indexes
nyalldawson Dec 18, 2024
236dbd6
Show labeling in raster layer properties dialog
nyalldawson Dec 18, 2024
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
54 changes: 50 additions & 4 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2716,20 +2716,66 @@
# monkey patching scoped based enum
QgsRasterPipe.ResampleFilter = Qgis.RasterResamplingStage.ResampleFilter
QgsRasterPipe.ResampleFilter.is_monkey_patched = True
QgsRasterPipe.ResampleFilter.__doc__ = ""
QgsRasterPipe.ResampleFilter.__doc__ = "Resampling occurs in ResamplingFilter"
QgsRasterPipe.Provider = Qgis.RasterResamplingStage.Provider
QgsRasterPipe.Provider.is_monkey_patched = True
QgsRasterPipe.Provider.__doc__ = ""
QgsRasterPipe.Provider.__doc__ = "Resampling occurs in Provider"
Qgis.RasterResamplingStage.__doc__ = """Stage at which raster resampling occurs.

.. versionadded:: 3.22

* ``ResampleFilter``:
* ``Provider``:
* ``ResampleFilter``: Resampling occurs in ResamplingFilter
* ``Provider``: Resampling occurs in Provider

"""
# --
Qgis.RasterResamplingStage.baseClass = Qgis
QgsRasterDataProvider.ResamplingMethod = Qgis.RasterResamplingMethod
# monkey patching scoped based enum
QgsRasterDataProvider.Nearest = Qgis.RasterResamplingMethod.Nearest
QgsRasterDataProvider.Nearest.is_monkey_patched = True
QgsRasterDataProvider.Nearest.__doc__ = "Nearest-neighbour resampling"
QgsRasterDataProvider.Bilinear = Qgis.RasterResamplingMethod.Bilinear
QgsRasterDataProvider.Bilinear.is_monkey_patched = True
QgsRasterDataProvider.Bilinear.__doc__ = "Bilinear (2x2 kernel) resampling"
QgsRasterDataProvider.Cubic = Qgis.RasterResamplingMethod.Cubic
QgsRasterDataProvider.Cubic.is_monkey_patched = True
QgsRasterDataProvider.Cubic.__doc__ = "Cubic Convolution Approximation (4x4 kernel) resampling"
QgsRasterDataProvider.CubicSpline = Qgis.RasterResamplingMethod.CubicSpline
QgsRasterDataProvider.CubicSpline.is_monkey_patched = True
QgsRasterDataProvider.CubicSpline.__doc__ = "Cubic B-Spline Approximation (4x4 kernel)"
QgsRasterDataProvider.Lanczos = Qgis.RasterResamplingMethod.Lanczos
QgsRasterDataProvider.Lanczos.is_monkey_patched = True
QgsRasterDataProvider.Lanczos.__doc__ = "Lanczos windowed sinc interpolation (6x6 kernel)"
QgsRasterDataProvider.Average = Qgis.RasterResamplingMethod.Average
QgsRasterDataProvider.Average.is_monkey_patched = True
QgsRasterDataProvider.Average.__doc__ = "Average resampling"
QgsRasterDataProvider.Mode = Qgis.RasterResamplingMethod.Mode
QgsRasterDataProvider.Mode.is_monkey_patched = True
QgsRasterDataProvider.Mode.__doc__ = "Mode (selects the value which appears most often of all the sampled points)"
QgsRasterDataProvider.Gauss = Qgis.RasterResamplingMethod.Gauss
QgsRasterDataProvider.Gauss.is_monkey_patched = True
QgsRasterDataProvider.Gauss.__doc__ = "Gauss blurring"
Qgis.RasterResamplingMethod.__doc__ = """Resampling method for raster provider-level resampling.

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterDataProvider`.ResamplingMethod

.. versionadded:: 3.42

* ``Nearest``: Nearest-neighbour resampling
* ``Bilinear``: Bilinear (2x2 kernel) resampling
* ``Cubic``: Cubic Convolution Approximation (4x4 kernel) resampling
* ``CubicSpline``: Cubic B-Spline Approximation (4x4 kernel)
* ``Lanczos``: Lanczos windowed sinc interpolation (6x6 kernel)
* ``Average``: Average resampling
* ``Mode``: Mode (selects the value which appears most often of all the sampled points)
* ``Gauss``: Gauss blurring

"""
# --
Qgis.RasterResamplingMethod.baseClass = Qgis
# monkey patching scoped based enum
Qgis.RasterRendererFlag.InternalLayerOpacityHandling.__doc__ = "The renderer internally handles the raster layer's opacity, so the default layer level opacity handling should not be applied."
Qgis.RasterRendererFlag.UseNoDataForOutOfRangePixels.__doc__ = "Out of range pixels (eg those values outside of the rendered map's z range filter) should be set using additional nodata values instead of additional transparency values \n.. versionadded:: 3.38"
Expand Down
24 changes: 0 additions & 24 deletions python/PyQt6/core/auto_additions/qgsrasterdataprovider.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
# The following has been generated automatically from src/core/raster/qgsrasterdataprovider.h
QgsRasterDataProvider.TransformImageToLayer = QgsRasterDataProvider.TransformType.TransformImageToLayer
QgsRasterDataProvider.TransformLayerToImage = QgsRasterDataProvider.TransformType.TransformLayerToImage
# monkey patching scoped based enum
QgsRasterDataProvider.ResamplingMethod.Nearest.__doc__ = "Nearest-neighbour resampling"
QgsRasterDataProvider.ResamplingMethod.Bilinear.__doc__ = "Bilinear (2x2 kernel) resampling"
QgsRasterDataProvider.ResamplingMethod.Cubic.__doc__ = "Cubic Convolution Approximation (4x4 kernel) resampling"
QgsRasterDataProvider.ResamplingMethod.CubicSpline.__doc__ = "Cubic B-Spline Approximation (4x4 kernel)"
QgsRasterDataProvider.ResamplingMethod.Lanczos.__doc__ = "Lanczos windowed sinc interpolation (6x6 kernel)"
QgsRasterDataProvider.ResamplingMethod.Average.__doc__ = "Average resampling"
QgsRasterDataProvider.ResamplingMethod.Mode.__doc__ = "Mode (selects the value which appears most often of all the sampled points)"
QgsRasterDataProvider.ResamplingMethod.Gauss.__doc__ = "Gauss blurring"
QgsRasterDataProvider.ResamplingMethod.__doc__ = """Resampling method for provider-level resampling.

.. versionadded:: 3.16

* ``Nearest``: Nearest-neighbour resampling
* ``Bilinear``: Bilinear (2x2 kernel) resampling
* ``Cubic``: Cubic Convolution Approximation (4x4 kernel) resampling
* ``CubicSpline``: Cubic B-Spline Approximation (4x4 kernel)
* ``Lanczos``: Lanczos windowed sinc interpolation (6x6 kernel)
* ``Average``: Average resampling
* ``Mode``: Mode (selects the value which appears most often of all the sampled points)
* ``Gauss``: Gauss blurring

"""
# --
try:
QgsImageFetcher.__attribute_docs__ = {'finish': 'Emitted when the download completes\n\n:param legend: The downloaded legend image\n', 'progress': 'Emitted to report progress\n', 'error': 'Emitted when an error occurs\n'}
QgsImageFetcher.__signal_arguments__ = {'finish': ['legend: QImage'], 'progress': ['received: int', 'total: int'], 'error': ['msg: str']}
Expand Down
12 changes: 12 additions & 0 deletions python/PyQt6/core/auto_additions/qgsrasterlabeling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# The following has been generated automatically from src/core/raster/qgsrasterlabeling.h
try:
QgsAbstractRasterLayerLabeling.defaultLabelingForLayer = staticmethod(QgsAbstractRasterLayerLabeling.defaultLabelingForLayer)
QgsAbstractRasterLayerLabeling.createFromElement = staticmethod(QgsAbstractRasterLayerLabeling.createFromElement)
QgsAbstractRasterLayerLabeling.__group__ = ['raster']
except (NameError, AttributeError):
pass
try:
QgsRasterLayerSimpleLabeling.create = staticmethod(QgsRasterLayerSimpleLabeling.create)
QgsRasterLayerSimpleLabeling.__group__ = ['raster']
except (NameError, AttributeError):
pass
2 changes: 1 addition & 1 deletion python/PyQt6/core/auto_additions/qgsrasterviewport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The following has been generated automatically from src/core/raster/qgsrasterviewport.h
try:
QgsRasterViewPort.__attribute_docs__ = {'mTopLeftPoint': 'Coordinate (in output device coordinate system) of top left corner\nof the part of the raster that is to be rendered.', 'mBottomRightPoint': 'Coordinate (in output device coordinate system) of bottom right corner\nof the part of the raster that is to be rendered.', 'mWidth': 'Width, number of columns to be rendered', 'mHeight': 'Height, number of rows to be rendered', 'mDrawnExtent': 'Intersection of current map extent and layer extent', 'mSrcCRS': 'Source coordinate system', 'mDestCRS': 'Target coordinate system', 'mTransformContext': 'Coordinate transform context'}
QgsRasterViewPort.__attribute_docs__ = {'mTopLeftPoint': 'Coordinate (in output device coordinate system) of top left corner\nof the part of the raster that is to be rendered.', 'mBottomRightPoint': 'Coordinate (in output device coordinate system) of bottom right corner\nof the part of the raster that is to be rendered.', 'mWidth': 'Width, number of columns to be rendered', 'mHeight': 'Height, number of rows to be rendered', 'mDrawnExtent': 'Intersection of current map extent and layer extent, in map (destination) CRS', 'mSrcCRS': 'Source (layer) coordinate system', 'mDestCRS': 'Target (map) coordinate system', 'mTransformContext': 'Coordinate transform context'}
QgsRasterViewPort.__doc__ = """This class provides details of the viewable area that a raster will
be rendered into.

Expand Down
16 changes: 13 additions & 3 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,20 @@ The development version

enum class RasterResamplingStage /BaseType=IntEnum/
{
//! Resampling occurs in ResamplingFilter
ResampleFilter,
//! Resampling occurs in Provider
Provider
Provider,
};

enum class RasterResamplingMethod /BaseType=IntEnum/
{
Nearest,
Bilinear,
Cubic,
CubicSpline,
Lanczos,
Average,
Mode,
Gauss
};

enum class RasterRendererFlag /BaseType=IntFlag/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,19 +627,7 @@ Returns whether provider-level resampling is enabled.
.. versionadded:: 3.16
%End

enum class ResamplingMethod
{
Nearest,
Bilinear,
Cubic,
CubicSpline,
Lanczos,
Average,
Mode,
Gauss
};

virtual bool setZoomedInResamplingMethod( ResamplingMethod method );
virtual bool setZoomedInResamplingMethod( Qgis::RasterResamplingMethod method );
%Docstring
Set resampling method to apply for zoomed-in operations.

Expand All @@ -648,14 +636,14 @@ Set resampling method to apply for zoomed-in operations.
.. versionadded:: 3.16
%End

ResamplingMethod zoomedInResamplingMethod() const;
Qgis::RasterResamplingMethod zoomedInResamplingMethod() const;
%Docstring
Returns resampling method for zoomed-in operations.

.. versionadded:: 3.16
%End

virtual bool setZoomedOutResamplingMethod( ResamplingMethod method );
virtual bool setZoomedOutResamplingMethod( Qgis::RasterResamplingMethod method );
%Docstring
Set resampling method to apply for zoomed-out operations.

Expand All @@ -664,7 +652,7 @@ Set resampling method to apply for zoomed-out operations.
.. versionadded:: 3.16
%End

ResamplingMethod zoomedOutResamplingMethod() const;
Qgis::RasterResamplingMethod zoomedOutResamplingMethod() const;
%Docstring
Returns resampling method for zoomed-out operations.

Expand Down
Loading
Loading