Skip to content

Commit 2573cc2

Browse files
committed
[FEATURE][QGIS-Server] Add Web Coverage Service support : funded Ifremer
QGIS-Server already supports standards : Web Map Service (WMS version 1.3.0 and 1.1.1) and Web Feature Service (WFS version 1.0.0) and Web Feature Service with Transaction (WFS-T). The French Research Institute, Ifremer, would like that QGIS-Server supports all the OGC standards. We (3Liz) are implementing the Web Coverage Service (WCS version 1.0.0) support in QGIS-Server.
1 parent 4bbce14 commit 2573cc2

11 files changed

+952
-1
lines changed

src/mapserver/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ SET ( qgis_mapserv_SRCS
2626
qgssldparser.cpp
2727
qgswmsserver.cpp
2828
qgswfsserver.cpp
29+
qgswcsserver.cpp
2930
qgsmapserviceexception.cpp
3031
qgsmslayercache.cpp
3132
qgsfilter.cpp

src/mapserver/qgis_map_serv.cpp

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ map service syntax for SOAP/HTTP POST
2727
#include "qgslogger.h"
2828
#include "qgswmsserver.h"
2929
#include "qgswfsserver.h"
30+
#include "qgswcsserver.h"
3031
#include "qgsmaprenderer.h"
3132
#include "qgsmapserviceexception.h"
3233
#include "qgspallabeling.h"
@@ -346,7 +347,99 @@ int main( int argc, char * argv[] )
346347
}
347348

348349
QgsWMSServer* theServer = 0;
349-
if ( serviceString == "WFS" )
350+
if ( serviceString == "WCS" )
351+
{
352+
delete theServer;
353+
QgsWCSServer* theServer = 0;
354+
try
355+
{
356+
theServer = new QgsWCSServer( parameterMap );
357+
}
358+
catch ( QgsMapServiceException e ) //admin.sld may be invalid
359+
{
360+
theRequestHandler->sendServiceException( e );
361+
continue;
362+
}
363+
364+
theServer->setAdminConfigParser( adminConfigParser );
365+
366+
367+
//request type
368+
QString request = parameterMap.value( "REQUEST" );
369+
if ( request.isEmpty() )
370+
{
371+
//do some error handling
372+
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
373+
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
374+
delete theRequestHandler;
375+
delete theServer;
376+
continue;
377+
}
378+
379+
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
380+
{
381+
QDomDocument capabilitiesDocument;
382+
try
383+
{
384+
capabilitiesDocument = theServer->getCapabilities();
385+
}
386+
catch ( QgsMapServiceException& ex )
387+
{
388+
theRequestHandler->sendServiceException( ex );
389+
delete theRequestHandler;
390+
delete theServer;
391+
continue;
392+
}
393+
QgsDebugMsg( "sending GetCapabilities response" );
394+
theRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
395+
delete theRequestHandler;
396+
delete theServer;
397+
continue;
398+
}
399+
else if ( request.compare( "DescribeCoverage", Qt::CaseInsensitive ) == 0 )
400+
{
401+
QDomDocument describeDocument;
402+
try
403+
{
404+
describeDocument = theServer->describeCoverage();
405+
}
406+
catch ( QgsMapServiceException& ex )
407+
{
408+
theRequestHandler->sendServiceException( ex );
409+
delete theRequestHandler;
410+
delete theServer;
411+
continue;
412+
}
413+
QgsDebugMsg( "sending GetCapabilities response" );
414+
theRequestHandler->sendGetCapabilitiesResponse( describeDocument );
415+
delete theRequestHandler;
416+
delete theServer;
417+
continue;
418+
}
419+
else if ( request.compare( "GetCoverage", Qt::CaseInsensitive ) == 0 )
420+
{
421+
QByteArray* coverageOutput;
422+
try
423+
{
424+
coverageOutput = theServer->getCoverage();
425+
}
426+
catch ( QgsMapServiceException& ex )
427+
{
428+
theRequestHandler->sendServiceException( ex );
429+
delete theRequestHandler;
430+
delete theServer;
431+
continue;
432+
}
433+
if ( coverageOutput )
434+
{
435+
theRequestHandler->sendGetCoverageResponse( coverageOutput );
436+
}
437+
delete theRequestHandler;
438+
delete theServer;
439+
continue;
440+
}
441+
}
442+
else if ( serviceString == "WFS" )
350443
{
351444
delete theServer;
352445
QgsWFSServer* theServer = 0;

src/mapserver/qgsconfigparser.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,19 @@ class QgsConfigParser
4949

5050
virtual void featureTypeList( QDomElement& parentElement, QDomDocument& doc ) const = 0;
5151

52+
virtual void wcsContentMetadata( QDomElement& parentElement, QDomDocument& doc ) const = 0;
53+
5254
virtual void owsGeneralAndResourceList( QDomElement& parentElement, QDomDocument& doc, const QString& strHref ) const = 0;
5355

5456
virtual void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const = 0;
57+
58+
virtual void describeCoverage( const QString& aCoveName, QDomElement& parentElement, QDomDocument& doc ) const = 0;
5559
/**Returns one or possibly several maplayers for a given type name. If no layers are found, an empty list is returned*/
5660
virtual QList<QgsMapLayer*> mapLayerFromTypeName( const QString& tName, bool useCache = true ) const = 0;
5761

62+
/**Returns one or possibly several maplayers for a given type name. If no layers are found, an empty list is returned*/
63+
virtual QList<QgsMapLayer*> mapLayerFromCoverage( const QString& cName, bool useCache = true ) const = 0;
64+
5865
/**Returns one or possibly several maplayers for a given layer name and style. If there are several layers, the layers should be drawn in inverse list order.
5966
If no layers/style are found, an empty list is returned
6067
@param allowCache true if layer can be read from / written to cache*/

src/mapserver/qgshttprequesthandler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ void QgsHttpRequestHandler::endGetFeatureResponse( QByteArray* ba ) const
362362
fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
363363
}
364364

365+
void QgsHttpRequestHandler::sendGetCoverageResponse( QByteArray* ba ) const
366+
{
367+
sendHttpResponse( ba, "image/tiff" );
368+
}
369+
365370
void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request, QMap<QString, QString>& parameters )
366371
{
367372
parameters.clear();

src/mapserver/qgshttprequesthandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class QgsHttpRequestHandler: public QgsRequestHandler
4242
virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) const;
4343
virtual void sendGetFeatureResponse( QByteArray* ba ) const;
4444
virtual void endGetFeatureResponse( QByteArray* ba ) const;
45+
virtual void sendGetCoverageResponse( QByteArray* ba ) const;
4546

4647
protected:
4748
void sendHttpResponse( QByteArray* ba, const QString& format ) const;

0 commit comments

Comments
 (0)