Skip to content

Commit

Permalink
Merge pull request #1025 from rldhont/wcs
Browse files Browse the repository at this point in the history
[FEATURE][QGIS-Server] Add Web Coverage Service support : funded Ifremer
  • Loading branch information
mhugent committed Dec 16, 2013
2 parents b192f64 + 2573cc2 commit c034a4d
Show file tree
Hide file tree
Showing 11 changed files with 952 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mapserver/CMakeLists.txt
Expand Up @@ -26,6 +26,7 @@ SET ( qgis_mapserv_SRCS
qgssldparser.cpp
qgswmsserver.cpp
qgswfsserver.cpp
qgswcsserver.cpp
qgsmapserviceexception.cpp
qgsmslayercache.cpp
qgsfilter.cpp
Expand Down
95 changes: 94 additions & 1 deletion src/mapserver/qgis_map_serv.cpp
Expand Up @@ -27,6 +27,7 @@ map service syntax for SOAP/HTTP POST
#include "qgslogger.h"
#include "qgswmsserver.h"
#include "qgswfsserver.h"
#include "qgswcsserver.h"
#include "qgsmaprenderer.h"
#include "qgsmapserviceexception.h"
#include "qgspallabeling.h"
Expand Down Expand Up @@ -348,7 +349,99 @@ int main( int argc, char * argv[] )
}

QgsWMSServer* theServer = 0;
if ( serviceString == "WFS" )
if ( serviceString == "WCS" )
{
delete theServer;
QgsWCSServer* theServer = 0;
try
{
theServer = new QgsWCSServer( parameterMap );
}
catch ( QgsMapServiceException e ) //admin.sld may be invalid
{
theRequestHandler->sendServiceException( e );
continue;
}

theServer->setAdminConfigParser( adminConfigParser );


//request type
QString request = parameterMap.value( "REQUEST" );
if ( request.isEmpty() )
{
//do some error handling
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
delete theRequestHandler;
delete theServer;
continue;
}

if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
{
QDomDocument capabilitiesDocument;
try
{
capabilitiesDocument = theServer->getCapabilities();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending GetCapabilities response" );
theRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "DescribeCoverage", Qt::CaseInsensitive ) == 0 )
{
QDomDocument describeDocument;
try
{
describeDocument = theServer->describeCoverage();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending GetCapabilities response" );
theRequestHandler->sendGetCapabilitiesResponse( describeDocument );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetCoverage", Qt::CaseInsensitive ) == 0 )
{
QByteArray* coverageOutput;
try
{
coverageOutput = theServer->getCoverage();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
if ( coverageOutput )
{
theRequestHandler->sendGetCoverageResponse( coverageOutput );
}
delete theRequestHandler;
delete theServer;
continue;
}
}
else if ( serviceString == "WFS" )
{
delete theServer;
QgsWFSServer* theServer = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/mapserver/qgsconfigparser.h
Expand Up @@ -49,12 +49,19 @@ class QgsConfigParser

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

virtual void wcsContentMetadata( QDomElement& parentElement, QDomDocument& doc ) const = 0;

virtual void owsGeneralAndResourceList( QDomElement& parentElement, QDomDocument& doc, const QString& strHref ) const = 0;

virtual void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const = 0;

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

/**Returns one or possibly several maplayers for a given type name. If no layers are found, an empty list is returned*/
virtual QList<QgsMapLayer*> mapLayerFromCoverage( const QString& cName, bool useCache = true ) const = 0;

/**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.
If no layers/style are found, an empty list is returned
@param allowCache true if layer can be read from / written to cache*/
Expand Down
5 changes: 5 additions & 0 deletions src/mapserver/qgshttprequesthandler.cpp
Expand Up @@ -362,6 +362,11 @@ void QgsHttpRequestHandler::endGetFeatureResponse( QByteArray* ba ) const
fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
}

void QgsHttpRequestHandler::sendGetCoverageResponse( QByteArray* ba ) const
{
sendHttpResponse( ba, "image/tiff" );
}

void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request, QMap<QString, QString>& parameters )
{
parameters.clear();
Expand Down
1 change: 1 addition & 0 deletions src/mapserver/qgshttprequesthandler.h
Expand Up @@ -42,6 +42,7 @@ class QgsHttpRequestHandler: public QgsRequestHandler
virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) const;
virtual void sendGetFeatureResponse( QByteArray* ba ) const;
virtual void endGetFeatureResponse( QByteArray* ba ) const;
virtual void sendGetCoverageResponse( QByteArray* ba ) const;

protected:
void sendHttpResponse( QByteArray* ba, const QString& format ) const;
Expand Down

0 comments on commit c034a4d

Please sign in to comment.