QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
20 #include <QTemporaryFile>
46 response.
setHeader(
"Content-Type",
"image/tiff" );
53 #ifdef HAVE_SERVER_PYTHON_PLUGINS
61 const QMap<QString, QString>::const_iterator cove_name_it = parameters.constFind( QStringLiteral(
"COVERAGE" ) );
62 if ( cove_name_it != parameters.constEnd() )
64 coveName = cove_name_it.value();
66 if ( coveName.isEmpty() )
68 const QMap<QString, QString>::const_iterator cove_name_it = parameters.constFind( QStringLiteral(
"IDENTIFIER" ) );
69 if ( cove_name_it != parameters.constEnd() )
71 coveName = cove_name_it.value();
75 if ( coveName.isEmpty() )
77 throw QgsRequestNotWellFormedException( QStringLiteral(
"COVERAGE is mandatory" ) );
84 for (
int i = 0; i < wcsLayersId.size(); ++i )
95 #ifdef HAVE_SERVER_PYTHON_PLUGINS
101 QString name = layer->
name();
104 name = name.replace( QLatin1String(
" " ), QLatin1String(
"_" ) );
106 if ( name == coveName )
108 rLayer = qobject_cast<QgsRasterLayer *>( layer );
114 throw QgsRequestNotWellFormedException( QStringLiteral(
"The layer for the COVERAGE '%1' is not found" ).arg( coveName ) );
117 double minx = 0.0, miny = 0.0, maxx = 0.0, maxy = 0.0;
119 int width = 0, height = 0;
134 throw QgsRequestNotWellFormedException( QStringLiteral(
"The BBOX is mandatory and has to be xx.xxx,yy.yyy,xx.xxx,yy.yyy" ) );
138 bool conversionSuccess =
false;
139 width = parameters.value( QStringLiteral(
"WIDTH" ), QStringLiteral(
"0" ) ).toInt( &conversionSuccess );
140 if ( !conversionSuccess )
145 height = parameters.value( QStringLiteral(
"HEIGHT" ), QStringLiteral(
"0" ) ).toInt( &conversionSuccess );
146 if ( !conversionSuccess )
151 if ( width < 0 || height < 0 )
153 throw QgsRequestNotWellFormedException( QStringLiteral(
"The WIDTH and HEIGHT are mandatory and have to be integer" ) );
156 crs = parameters.value( QStringLiteral(
"CRS" ) );
159 throw QgsRequestNotWellFormedException( QStringLiteral(
"The CRS is mandatory" ) );
165 throw QgsRequestNotWellFormedException( QStringLiteral(
"Invalid CRS" ) );
171 if ( requestCRS != rLayer->
crs() )
174 rect = t.transformBoundingBox( rect );
179 crs = parameters.value( QStringLiteral(
"RESPONSE_CRS" ) );
180 if ( !
crs.isEmpty() )
185 responseCRS = rLayer->
crs();
189 QTemporaryFile tempFile;
197 throw QgsRequestNotWellFormedException( QStringLiteral(
"Cannot set pipe provider" ) );
201 if ( responseCRS != rLayer->
crs() )
205 if ( !pipe.
insert( 2, projector ) )
207 throw QgsRequestNotWellFormedException( QStringLiteral(
"Cannot set pipe projector" ) );
214 throw QgsRequestNotWellFormedException( QStringLiteral(
"Cannot write raster error code: %1" ).arg( err ) );
216 return tempFile.readAll();
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QgsCoordinateReferenceSystem crs
bool insert(int idx, QgsRasterInterface *interface)
Attempts to insert interface at specified index and connect if connection would fail,...
const QgsCoordinateReferenceSystem & crs
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
bool set(QgsRasterInterface *interface)
Inserts a new known interface in default place or replace interface of the same role if it already ex...
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Contains a pipeline of raster interfaces for sequential raster processing.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
A rectangle specified with double values.
SERVER_EXPORT QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QMap< QString, QString > Parameters
QgsRasterDataProvider * clone() const override=0
Clone itself, create deep copy.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
@ RasterLayer
Raster layer.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Q_DECL_DEPRECATED void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Represents a raster layer.
This class represents a coordinate reference system (CRS).
A helper class that centralizes restrictions given by all the access control filter plugins.
The raster file writer which allows you to save a raster to a new file.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
void writeGetCoverage(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WCS DescribeCoverage response.
Base class for all map layer types. This is the base class for all map layer types (vector,...
QByteArray getCoverageData(QgsServerInterface *serverIface, const QgsProject *project, const QgsServerRequest &request)
Compute coverage data.
bool isEmpty() const
Returns true if the rectangle is empty.
QgsRectangle parseBbox(const QString &bboxStr)
Parse bounding box.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...