![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
A map layer backed by a GDAL raster dataset. More...
#include <gisrasterlayer.h>
Classes | |
| struct | OpenResult |
Signals | |
| void | filePathChanged (const QString &path) |
| void | renderBandChanged (int band) |
| void | noDataValueChanged (double value) |
| void | rasterRendererChanged () |
| Emitted when setRasterRenderer() swaps the renderer pointer or notifyRasterRendererEdited() reports an in-place edit. | |
| void | openFinished (bool ok) |
| Emitted on the GUI thread when openAsync() completes. | |
| void | overviewBuildStarted (const QString &name) |
A background overview (.ovr pyramid) build has started for this raster. name is the display file name. | |
| void | overviewBuildFinished (bool ok) |
| The background overview build finished (ok ⇒ pyramids ready and the render will pick them up on the next repaint). | |
Signals inherited from OpenSWMMVisLayer | |
| void | nameChanged (const QString &newName) |
| void | layerTypeChanged (OpenSWMMVisLayerType newType) |
| void | visibilityChanged (bool visible) |
| void | opacityChanged (double opacity) |
| void | srsChanged (SpatialReferenceSystem *newSRS) |
| void | extentChanged (const MapExtent &newExtent) |
| void | childrenChanged () |
| void | repaintRequested () |
| void | temporalSpecChanged (const OpenSWMM::Render::TemporalSpec &spec) |
| void | maskSpecChanged (const OpenSWMM::Render::MaskSpec &spec) |
| void | auxStorageSpecChanged (const OpenSWMM::Render::AuxiliaryStorageSpec &spec) |
| void | joinsChanged (const QVector< OpenSWMM::Render::JoinSpec > &joins) |
| void | diagramSpecChanged (const OpenSWMM::Render::DiagramSpec &spec) |
| void | labelConfigChanged () |
Public Member Functions | |
| GISRasterLayer (const QString &filePath, OpenSWMMVisWorkspace *parent=nullptr) | |
| ~GISRasterLayer () override | |
| void | openAsync (const QString &filePath) |
Asynchronously open filePath. GDALOpenEx + metadata read + ComputeStatistics run on a worker thread; the layer is populated on the GUI thread and openFinished(bool) fires on completion (ok==false ⇒ open failed). Construct the layer with an empty path first, then call this; the synchronous openDataset path (used by tests / project restore) is unchanged. | |
| QString | filePath () const |
| int | bandCount () const |
| int | renderBand () const |
| double | noDataValue () const |
| QString | detectVerticalUnit () const |
| Heuristically detects the vertical unit of the raster's elevation values from the embedded CRS metadata. | |
| void | setRenderBand (int band) |
| Sets the 1-based band index to render on the single-band colour path. Re-reads that band's NoData value and, when the live renderer is a GraduatedRasterRenderer, re-seeds its data range and classification from the band's statistics / sample. | |
| bool | hasNoDataValue () const |
| Returns true when the dataset has a known no-data value. | |
| QString | sourceDescription () const override |
| Human-readable source of this layer: a file path, a service URL, or a description for in-memory / derived layers. | |
| QVector< QPair< QString, QString > > | extendedMetadata () const override |
| Ordered key→value pairs of TYPE-SPECIFIC metadata, rendered by the Metadata tab below the common block the dialog builds itself. | |
| QPair< double, double > | bandRange (int band) const |
Approximate (min, max) of band from GDAL statistics (PAM-cached when available). (NaN, NaN) when unavailable. | |
| QVector< double > | sampleValues (int band, int maxSamples=200000) const |
Decimated, overview-aware value sample of band — at most maxSamples finite, non-NoData values on a regular grid over the whole raster. Feeds Quantile / Jenks / StdDev classification and unique-value discovery. | |
| QList< int > | uniqueValues (int band, int cap=256) const |
Distinct integer values observed in sampleValues(band), ascending, truncated to cap entries. Decimated — rare classes may be missed. | |
| bool | hasColorTable () const |
| True when band 1 carries a GDAL colour table (paletted raster). | |
| QList< OpenSWMM::Render::PalettedRasterRenderer::Class > | colorTableClasses () const |
| Band 1's GDAL colour table as paletted classes (value, label = value, RGBA). Tables larger than 32 entries are filtered to the values actually observed in the band sample so unused palette slots do not flood the legend. | |
| bool | isByteRaster () const |
| True when band 1 is 8-bit (GDT_Byte) — the only type the RGB composite path renders without saturating. | |
| std::vector< std::unique_ptr< openswmmvis::ui::ILayerStyleSubject > > | styleSubjects () override |
| OpenSWMM::Render::IRasterRenderer * | rasterRenderer () const |
| The IRasterRenderer that will drive this layer's warp pass. | |
| void | setRasterRenderer (std::unique_ptr< OpenSWMM::Render::IRasterRenderer > r) |
| Replaces the current raster renderer. | |
| void | notifyRasterRendererEdited () |
| Call after mutating the live renderer in place (through its own setters) so cached tiles are dropped, rasterRendererChanged() fires and a repaint is requested — the same consequences as setRasterRenderer(). | |
| double | valueAt (double mapX, double mapY, const SpatialReferenceSystem *canvasSRS, int band=1, bool *ok=nullptr) const |
| Returns the pixel value at the given geographic coordinate. | |
| bool | isRasterLayer () const override |
| Returns true for layers that render into a raster buffer (WMS, WMTS, GISRaster) rather than populating QGraphicsItems. | |
| void | setIsBasemap (bool on) |
| Marks this raster as a basemap (added via Add Basemap ▸ Local File). Also retags the layer type to SWMMImageryLayer so it lands in the Basemaps layer-tree category. | |
| bool | isBasemapLayer () const override |
| Returns true for world-spanning basemap layers (XYZ tile providers, WMS/WMTS services covering the whole world) that should NOT be included when computing the data-driven full extent. | |
| void | fetchCache (const MapExtent &extent, const QSize &viewportSize, const SpatialReferenceSystem *srs) override |
| Triggers any asynchronous (or synchronous) tile/data fetch needed to populate this layer's internal cache for the given view state. | |
| void | render (QPainter *painter, const MapExtent &extent, const QSize &imageSize, const SpatialReferenceSystem *srs) override |
Renders this layer's content directly into painter. | |
| void | populateScene (QGraphicsScene *scene, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS) override |
| Creates / updates QGraphicsItems representing this layer in the scene. | |
| void | depopulateScene (QGraphicsScene *scene) override |
| Removes all QGraphicsItems belonging to this layer from the scene. | |
| void | refreshScene (QGraphicsScene *scene, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS) override |
| Smart scene refresh — updates existing items instead of destroying and recreating. | |
| void | onCanvasCRSChanged (const SpatialReferenceSystem *newCanvasSRS) override |
| Called when the user changes the canvas CRS so layers can pre-compute any CRS-dependent transform caches. | |
| bool | hillshadeEnabled () const |
| void | setHillshadeEnabled (bool on) |
| double | hillshadeAzimuthDeg () const |
| double | hillshadeAltitudeDeg () const |
| double | hillshadeZFactor () const |
| double | hillshadeStrength () const |
| void | setHillshadeParams (double azimuthDeg, double altitudeDeg, double zFactor, double strength) |
Public Member Functions inherited from TilePyramidLayer | |
| TilePyramidLayer (OpenSWMMVisWorkspace *parent=nullptr) | |
| ~TilePyramidLayer () override | |
Public Member Functions inherited from OpenSWMMVisLayer | |
| OpenSWMMVisLayer (OpenSWMMVisWorkspace *parent) | |
| OpenSWMMVisLayer (const QString &name="Unlabeled Layer", OpenSWMMVisWorkspace *parent=nullptr) | |
| virtual | ~OpenSWMMVisLayer () |
| QString | layerId () const |
| Returns the layer's immutable unique identifier (UUID). | |
| QString | name () const |
| Returns the user-visible name of this layer. | |
| void | setName (const QString &name) |
| Sets the user-visible name. | |
| OpenSWMMVisLayerType | layerType () const |
| Returns the layer type discriminator. | |
| bool | isVisible () const |
| Returns true when this layer should be drawn. | |
| void | setVisible (bool visible) |
| Shows or hides this layer. | |
| double | opacity () const |
| Returns the layer opacity in the range [0.0, 1.0]. 0.0 = fully transparent; 1.0 = fully opaque. | |
| void | setOpacity (double opacity) |
| Sets the layer opacity. Values are clamped to [0.0, 1.0]. | |
| SpatialReferenceSystem * | srs () const |
| Returns the spatial reference system for this layer, or nullptr if the layer has no known CRS. | |
| void | setSRS (SpatialReferenceSystem *srs, bool ownsSRS=false) |
| Sets (or replaces) the CRS for this layer. | |
| QString | crsDescription () const |
| Returns a human-readable summary of this layer's CRS for display in the Properties window. | |
| MapExtent | extent () const |
| Returns the layer extent in the layer's own CRS. | |
| void | setExtent (const MapExtent &extent) |
| Sets the layer spatial extent (in the layer's CRS). | |
| void | setViewportSize (int w, int h) |
| Called by MapCanvas before refreshScene so layers can request the correct pixel dimensions for tile/image requests. | |
| int | viewportWidth () const |
| int | viewportHeight () const |
| QVector< OpenSWMMVisLayer * > | children () const |
| Returns the ordered list of child layers. | |
| double | layerZValue () const |
| Returns the z-value base assigned to this layer by the canvas. Items within the layer should use z-values relative to this. | |
| void | setLayerZValue (double z) |
| Called by the canvas to set this layer's z-value band. | |
| virtual OpenSWMM::Render::IFeatureRenderer * | renderer () const |
| virtual void | setRenderer (std::unique_ptr< OpenSWMM::Render::IFeatureRenderer >) |
| virtual OpenSWMM::Render::RuleList * | ruleList () |
| virtual const OpenSWMM::Render::RuleList * | ruleList () const |
| const OpenSWMM::Render::TemporalSpec & | temporalSpec () const |
| void | setTemporalSpec (const OpenSWMM::Render::TemporalSpec &spec) |
| const OpenSWMM::Render::LabelConfig & | labelConfig () const |
| virtual void | setLabelConfig (const OpenSWMM::Render::LabelConfig &cfg) |
| const OpenSWMM::Render::MaskSpec & | maskSpec () const |
| void | setMaskSpec (const OpenSWMM::Render::MaskSpec &spec) |
| const OpenSWMM::Render::AuxiliaryStorageSpec & | auxStorageSpec () const |
| void | setAuxStorageSpec (const OpenSWMM::Render::AuxiliaryStorageSpec &spec) |
| const QVector< OpenSWMM::Render::JoinSpec > & | joins () const |
| void | setJoins (const QVector< OpenSWMM::Render::JoinSpec > &joins) |
| const OpenSWMM::Render::DiagramSpec & | diagramSpec () const |
| void | setDiagramSpec (const OpenSWMM::Render::DiagramSpec &spec) |
| OpenSWMMVisWorkspace * | workspace () const |
| void | setBasicAuth (const QString &username, const QString &password) |
| Sets HTTP Basic authentication for all subsequent network requests. | |
| void | setHttpHeaders (const BasemapHttpHeaders &headers) |
| Sets arbitrary extra HTTP headers applied to every request. | |
| BasemapHttpHeaders | httpHeaders () const |
Properties | |
| QString | filePath |
| int | bandCount |
| int | renderBand |
| double | noDataValue |
Properties inherited from OpenSWMMVisLayer | |
| QString | Name |
| bool | Visible |
| double | Opacity |
| QString | LayerId |
| OpenSWMMVisLayerType | LayerType |
| QVector< OpenSWMMVisLayer * > | Children |
| QString | CRS |
Additional Inherited Members | |
Public Types inherited from OpenSWMMVisLayer | |
| enum | OpenSWMMVisLayerType { SWMMDefaultLayer = 0 , SWMMModelLayer = 1 , SWMMResultsLayer = 2 , SWMMGISLayer = 3 , SWMMVectorLayer = 4 , SWMMRasterLayer = 5 , SWMMImageryLayer = 6 , SWMMTabularDataLayer = 7 , SWMMTabularyTimeSeriesLayer = 8 , SWMMSubProjectLayer = 9 , SWMMWMSLayer = 10 , SWMMWMTSLayer = 11 , SWMM2DMeshLayer = 12 , SWMM2DResultsLayer = 13 , SWMMAnnotationLayer = 14 , SWMMFeatureLayer = 15 } |
| Discriminator for the concrete layer class. More... | |
Protected Member Functions inherited from TilePyramidLayer | |
| void | cacheTile (const QString &key, const QImage &img, const MapExtent &extent, int level) |
Insert a produced tile (no-op for null images). extent is the tile's geographic extent in the subclass's tile CRS; level is the subclass's pyramid-level tag (metadata only — the fallback search is extent-based). | |
| bool | isTileCached (const QString &key) const |
True when key holds a non-null cached tile. Does not promote the entry in the LRU. | |
| QImage | cachedTileImage (const QString &key) const |
The cached image for key, or a null QImage. | |
| void | clearTiles () |
| Drop every cached tile (style / CRS / source change). | |
| void | setTileCacheCapacity (int maxTiles) |
| int | tileCacheCapacity () const |
| bool | resolveTileForDraw (const QString &key, const MapExtent &tileExtent, double maxSpanRatio, TileDraw &out) const |
Resolve the image + source sub-rect that should paint the tile key with geographic extent tileExtent. | |
Protected Member Functions inherited from OpenSWMMVisLayer | |
| bool | addChild (OpenSWMMVisLayer *child) |
| bool | removeChild (OpenSWMMVisLayer *child) |
| void | setLayerType (OpenSWMMVisLayerType type) |
Protected Attributes inherited from OpenSWMMVisLayer | |
| QByteArray | m_authHeader |
| "Basic <base64>" or empty | |
| BasemapHttpHeaders | m_httpHeaders |
| arbitrary headers (incl. "referer") | |
A map layer backed by a GDAL raster dataset.
Reads any GDAL-supported raster format (GeoTIFF, NetCDF, HDF5 …), warps the requested tile into the canvas CRS using GDALWarp, renders the result with a configurable colour ramp, and caches the warped tile until the extent or CRS changes.
Colouring is delegated to the layer's IRasterRenderer (see rasterRenderer()): a GraduatedRasterRenderer (continuous stretch or classified ramp over one band), a PalettedRasterRenderer (categorical values, incl. an embedded GDAL colour table) or a MultiBandColorRenderer (RGB(A) composite of three / four Byte bands).
|
explicit |
|
override |
| int GISRasterLayer::bandCount | ( | ) | const |
Approximate (min, max) of band from GDAL statistics (PAM-cached when available). (NaN, NaN) when unavailable.
| QList< PalettedRasterRenderer::Class > GISRasterLayer::colorTableClasses | ( | ) | const |
Band 1's GDAL colour table as paletted classes (value, label = value, RGBA). Tables larger than 32 entries are filtered to the values actually observed in the band sample so unused palette slots do not flood the legend.
|
overridevirtual |
Removes all QGraphicsItems belonging to this layer from the scene.
Reimplemented from OpenSWMMVisLayer.
| QString GISRasterLayer::detectVerticalUnit | ( | ) | const |
Heuristically detects the vertical unit of the raster's elevation values from the embedded CRS metadata.
"m" for metre-based or geographic CRS (most global DEMs), "ft" for US-customary projected CRS (state plane feet, etc.). Returns "m" when no CRS metadata is present.
|
overridevirtual |
Ordered key→value pairs of TYPE-SPECIFIC metadata, rendered by the Metadata tab below the common block the dialog builds itself.
Default empty. Subclasses add only what is unique to them (e.g. a mesh: vertices / cells / edges / elevation range). QVector<QPair> preserves insertion order without a new type.
Reimplemented from OpenSWMMVisLayer.
|
overridevirtual |
Triggers any asynchronous (or synchronous) tile/data fetch needed to populate this layer's internal cache for the given view state.
Called by MapCanvas::refreshLayerItems() for every visible raster layer BEFORE the MapRenderJob is started. This decouples tile-requesting (potentially async HTTP) from tile-drawing (synchronous, in the background render thread).
The default implementation is a no-op.
| extent | Visible geographic extent in canvas-CRS coordinates. |
| viewportSize | Pixel dimensions of the viewport. |
| srs | Canvas CRS. |
Reimplemented from OpenSWMMVisLayer.
| QString GISRasterLayer::filePath | ( | ) | const |
|
signal |
| bool GISRasterLayer::hasColorTable | ( | ) | const |
True when band 1 carries a GDAL colour table (paletted raster).
| bool GISRasterLayer::hasNoDataValue | ( | ) | const |
Returns true when the dataset has a known no-data value.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Returns true for world-spanning basemap layers (XYZ tile providers, WMS/WMTS services covering the whole world) that should NOT be included when computing the data-driven full extent.
MapCanvas::fullExtent() uses this to skip basemap layers so that "Zoom to Full Extent" zooms to the project's data (SWMM network, DTM, bounded WMS coverage) rather than the whole globe. Layers with a specific, bounded geographic footprint (GISRasterLayer, local WMS/WMTS with EX_GeographicBoundingBox) return false so they participate in the extent union.
Reimplemented from OpenSWMMVisLayer.
| bool GISRasterLayer::isByteRaster | ( | ) | const |
True when band 1 is 8-bit (GDT_Byte) — the only type the RGB composite path renders without saturating.
|
inlineoverridevirtual |
Returns true for layers that render into a raster buffer (WMS, WMTS, GISRaster) rather than populating QGraphicsItems.
The MapCanvas uses this to decide whether a layer participates in the background render job or in the QGraphicsScene overlay.
Reimplemented from OpenSWMMVisLayer.
| double GISRasterLayer::noDataValue | ( | ) | const |
|
signal |
| void GISRasterLayer::notifyRasterRendererEdited | ( | ) |
Call after mutating the live renderer in place (through its own setters) so cached tiles are dropped, rasterRendererChanged() fires and a repaint is requested — the same consequences as setRasterRenderer().
|
overridevirtual |
Called when the user changes the canvas CRS so layers can pre-compute any CRS-dependent transform caches.
| newCanvasSRS | The new canvas CRS. |
Reimplemented from OpenSWMMVisLayer.
| void GISRasterLayer::openAsync | ( | const QString & | filePath | ) |
Asynchronously open filePath. GDALOpenEx + metadata read + ComputeStatistics run on a worker thread; the layer is populated on the GUI thread and openFinished(bool) fires on completion (ok==false ⇒ open failed). Construct the layer with an empty path first, then call this; the synchronous openDataset path (used by tests / project restore) is unchanged.
|
signal |
Emitted on the GUI thread when openAsync() completes.
|
signal |
The background overview build finished (ok ⇒ pyramids ready and the render will pick them up on the next repaint).
|
signal |
A background overview (.ovr pyramid) build has started for this raster. name is the display file name.
|
overridevirtual |
Creates / updates QGraphicsItems representing this layer in the scene.
Derived classes override this to add their items to the scene. Items should be created in scene coordinates (= map CRS coordinates) after reprojecting from the layer's native CRS.
Called by the MapCanvas when:
| scene | The shared OpenSWMMVisScene to add items to. |
| canvasExtent | Visible extent in canvas-CRS coordinates. |
| canvasSRS | The CRS currently used by the MapCanvas. |
Implements OpenSWMMVisLayer.
| OpenSWMM::Render::IRasterRenderer * GISRasterLayer::rasterRenderer | ( | ) | const |
The IRasterRenderer that will drive this layer's warp pass.
Constructed eagerly as a default GraduatedRasterRenderer so callers never have to null-check. Owned by the layer; do not delete.
|
signal |
Emitted when setRasterRenderer() swaps the renderer pointer or notifyRasterRendererEdited() reports an in-place edit.
|
overridevirtual |
Smart scene refresh — updates existing items instead of destroying and recreating.
Override in subclasses to provide efficient incremental updates. The default implementation calls depopulateScene() then populateScene(), which is backward-compatible but causes flicker for raster/tile layers.
Raster/WMS layers should override to keep persistent scene items and update them in-place. Vector layers should override to skip rebuilding when only the view extent has changed (items are already in scene coords).
Reimplemented from OpenSWMMVisLayer.
|
overridevirtual |
Renders this layer's content directly into painter.
Called by the background MapRenderJob for raster layers. The painter is backed by a QImage of imageSize pixels spanning the geographic area described by extent in CRS srs. Pixel (0,0) maps to (extent.xMin, extent.yMax).
The default implementation is a no-op. Raster layer subclasses (WMS, WMTS, GISRaster) override this to paint their cached tile/image data without touching QGraphicsScene.
| painter | Target painter (backed by viewport-sized QImage). |
| extent | Visible geographic extent in canvas-CRS coordinates. |
| imageSize | Pixel dimensions of the target image. |
| srs | Canvas CRS. |
Reimplemented from OpenSWMMVisLayer.
| int GISRasterLayer::renderBand | ( | ) | const |
|
signal |
| QVector< double > GISRasterLayer::sampleValues | ( | int | band, |
| int | maxSamples = 200000 |
||
| ) | const |
Decimated, overview-aware value sample of band — at most maxSamples finite, non-NoData values on a regular grid over the whole raster. Feeds Quantile / Jenks / StdDev classification and unique-value discovery.
| void GISRasterLayer::setHillshadeEnabled | ( | bool | on | ) |
| void GISRasterLayer::setHillshadeParams | ( | double | azimuthDeg, |
| double | altitudeDeg, | ||
| double | zFactor, | ||
| double | strength | ||
| ) |
| void GISRasterLayer::setIsBasemap | ( | bool | on | ) |
Marks this raster as a basemap (added via Add Basemap ▸ Local File). Also retags the layer type to SWMMImageryLayer so it lands in the Basemaps layer-tree category.
| void GISRasterLayer::setRasterRenderer | ( | std::unique_ptr< OpenSWMM::Render::IRasterRenderer > | r | ) |
Replaces the current raster renderer.
The layer takes ownership. Null pointers are silently rejected (the method no-ops) so rasterRenderer() never returns null. Emits rasterRendererChanged() when the pointer actually changes.
| void GISRasterLayer::setRenderBand | ( | int | band | ) |
Sets the 1-based band index to render on the single-band colour path. Re-reads that band's NoData value and, when the live renderer is a GraduatedRasterRenderer, re-seeds its data range and classification from the band's statistics / sample.
|
overridevirtual |
Human-readable source of this layer: a file path, a service URL, or a description for in-memory / derived layers.
Default empty — the dialog shows "(none)". Concrete layers override to return their real origin (e.g. modelFilePath(), resultsFilePath(), serviceUrl(), or "(generated mesh)").
Reimplemented from OpenSWMMVisLayer.
|
overridevirtual |
Slice U-7 — surface this raster's Q_PROPERTYs as the single styleable subject for the unified LayerStyleDialog.
Reimplemented from OpenSWMMVisLayer.
| QList< int > GISRasterLayer::uniqueValues | ( | int | band, |
| int | cap = 256 |
||
| ) | const |
Distinct integer values observed in sampleValues(band), ascending, truncated to cap entries. Decimated — rare classes may be missed.
| double GISRasterLayer::valueAt | ( | double | mapX, |
| double | mapY, | ||
| const SpatialReferenceSystem * | canvasSRS, | ||
| int | band = 1, |
||
| bool * | ok = nullptr |
||
| ) | const |
Returns the pixel value at the given geographic coordinate.
| mapX | X in canvas CRS. |
| mapY | Y in canvas CRS. |
| canvasSRS | Canvas CRS. |
| band | 1-based band index. |
| ok | Set to true if a valid value was found. |
|
read |
|
read |
|
read |
|
readwrite |