Skip to content

Commit c034a4d

Browse files
committed
Merge pull request #1025 from rldhont/wcs
[FEATURE][QGIS-Server] Add Web Coverage Service support : funded Ifremer
2 parents b192f64 + 2573cc2 commit c034a4d

11 files changed

+952
-1
lines changed

src/mapserver/CMakeLists.txt

+1
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

+94-1
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"
@@ -348,7 +349,99 @@ int main( int argc, char * argv[] )
348349
}
349350

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

src/mapserver/qgsconfigparser.h

+7
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

+5
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

+1
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)