273 changes: 164 additions & 109 deletions src/mapserver/qgsconfigparser.cpp

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/mapserver/qgsconfigparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class QgsConfigParser
virtual QDomDocument getStyle( const QString& styleName, const QString& layerName ) const = 0;

/**Possibility to add a parameter map to the config parser. This is used by the SLD parser. Default implementation does nothing*/
virtual void setParameterMap( const std::map<QString, QString>& parameterMap )
virtual void setParameterMap( const QMap<QString, QString>& parameterMap )
{ Q_UNUSED( parameterMap ); }

/**Returns if output are MM or PIXEL*/
Expand Down Expand Up @@ -152,11 +152,15 @@ class QgsConfigParser

/**Transforms layer extent to epsg 4326 and appends ExGeographicBoundingBox and BoundingBox elements to the layer element*/
void appendLayerBoundingBoxes( QDomElement& layerElem, QDomDocument& doc, const QgsRectangle& layerExtent, const QgsCoordinateReferenceSystem& layerCRS ) const;

#if 0
/**Returns the <Ex_GeographicalBoundingBox of a layer element as a rectangle
@param layerElement <Layer> element in capabilities
@param rect out: bounding box as rectangle
@return true in case of success*/
@param layerElement <Layer> element in capabilities
@param rect out: bounding box as rectangle
@return true in case of success*/
bool exGeographicBoundingBox( const QDomElement& layerElement, QgsRectangle& rect ) const;
bool latlonGeographicBoundingBox( const QDomElement& layerElement, QgsRectangle& rect ) const;
#endif

/**Returns a list of supported EPSG coordinate system numbers from a layer*/
QStringList createCRSListForLayer( QgsMapLayer* theMapLayer ) const;
Expand Down
8 changes: 1 addition & 7 deletions src/mapserver/qgsfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ QgsFilter::~QgsFilter()

QVariant QgsFilter::propertyIndexValue( const QgsFeature& f ) const
{
QgsAttributeMap featureAttributes = f.attributeMap();
QgsAttributeMap::const_iterator f_it = featureAttributes.find( mPropertyIndex );
if ( f_it == featureAttributes.constEnd() )
{
return QVariant();
}
return f_it.value();
return f.attributeMap().value( mPropertyIndex );
}

QList<int> QgsFilter::attributeIndices() const
Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgsgetrequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ QgsGetRequestHandler::QgsGetRequestHandler(): QgsHttpRequestHandler()
{
}

std::map<QString, QString> QgsGetRequestHandler::parseInput()
QMap<QString, QString> QgsGetRequestHandler::parseInput()
{
QString queryString;
std::map<QString, QString> parameters;
QMap<QString, QString> parameters;

const char* qs = getenv( "QUERY_STRING" );
if ( qs )
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgsgetrequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ class QgsGetRequestHandler: public QgsHttpRequestHandler
{
public:
QgsGetRequestHandler();
std::map<QString, QString> parseInput();
QMap<QString, QString> parseInput();
};
46 changes: 19 additions & 27 deletions src/mapserver/qgshttprequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ QgsHttpRequestHandler::~QgsHttpRequestHandler()

void QgsHttpRequestHandler::sendHttpResponse( QByteArray* ba, const QString& format ) const
{
QgsDebugMsg("Checking byte array is ok to send...");
QgsDebugMsg( "Checking byte array is ok to send..." );
if ( !ba )
{
return;
Expand All @@ -54,16 +54,16 @@ void QgsHttpRequestHandler::sendHttpResponse( QByteArray* ba, const QString& for
return;
}

QgsDebugMsg("Byte array looks good, returning response...");
QgsDebugMsg(QString("Content size: %1").arg(ba->size()));
QgsDebugMsg(QString("Content format: %1").arg(format));
QgsDebugMsg( "Byte array looks good, returning response..." );
QgsDebugMsg( QString( "Content size: %1" ).arg( ba->size() ) );
QgsDebugMsg( QString( "Content format: %1" ).arg( format ) );
printf( "Content-Type: " );
printf( format.toLocal8Bit() );
printf( "\n" );
printf( "Content-Length: %d\n", ba->size() );
printf( "\n" );
int result=fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
QgsDebugMsg(QString("Sent %1 bytes").arg(result));
int result = fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
QgsDebugMsg( QString( "Sent %1 bytes" ).arg( result ) );
}

QString QgsHttpRequestHandler::formatToMimeType( const QString& format ) const
Expand All @@ -90,12 +90,12 @@ QString QgsHttpRequestHandler::formatToMimeType( const QString& format ) const
void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage* img ) const
{
Q_UNUSED( service );
QgsDebugMsg("Sending getmap response...");
QgsDebugMsg( "Sending getmap response..." );
if ( img )
{
if ( mFormat != "PNG" && mFormat != "JPG" )
{
QgsDebugMsg("service exception - incorrect image format requested...");
QgsDebugMsg( "service exception - incorrect image format requested..." );
sendServiceException( QgsMapServiceException( "InvalidFormat", "Output format '" + mFormat + "' is not supported in the GetMap request" ) );
return;
}
Expand Down Expand Up @@ -273,31 +273,25 @@ void QgsHttpRequestHandler::sendGetPrintResponse( QByteArray* ba ) const
sendHttpResponse( ba, formatToMimeType( mFormat ) );
}

void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request, std::map<QString, QString>& parameters )
void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request, QMap<QString, QString>& parameters )
{
parameters.clear();

//parameters are separated by &
QStringList elements = request.split( "&" );

QString element, key, value;

//insert key and value into the map
for ( QStringList::const_iterator it = elements.begin(); it != elements.end(); ++it )
//insert key and value into the map (parameters are separated by &
foreach( QString element, request.split( "&" ) )
{
element = *it;
int sepidx = element.indexOf( "=", 0, Qt::CaseSensitive );
if ( sepidx == -1 )
{
continue;
}

key = element.left( sepidx );
value = element.mid( sepidx + 1 );
QString key = element.left( sepidx );
QString value = element.mid( sepidx + 1 );
value.replace( "+", " " );
value = QUrl::fromPercentEncoding( value.toLocal8Bit() ); //replace encoded special caracters and utf-8 encodings


if ( key.compare( "SLD_BODY", Qt::CaseInsensitive ) == 0 )
{
key = "SLD";
Expand Down Expand Up @@ -329,23 +323,21 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
value = QUrl::fromPercentEncoding( fileContents );

}
parameters.insert( std::make_pair( key.toUpper(), value ) );
parameters.insert( key.toUpper(), value );
QgsDebugMsg( "inserting pair " + key.toUpper() + " // " + value + " into the parameter map" );
}

//feature info format?
std::map<QString, QString>::const_iterator info_format_it = parameters.find( "INFO_FORMAT" );
if ( info_format_it != parameters.end() )
QString infoFormat = parameters.value( "INFO_FORMAT" );
if ( !infoFormat.isEmpty() )
{
mFormat = info_format_it->second;
mFormat = infoFormat;
}
else //capabilities format or GetMap format
{
std::map<QString, QString>::const_iterator formatIt = parameters.find( "FORMAT" );
if ( formatIt != parameters.end() )
QString formatString = parameters.value( "FORMAT" );
if ( !formatString.isEmpty() )
{
QString formatString = formatIt->second;

QgsDebugMsg( QString( "formatString is: %1" ).arg( formatString ) );

//remove the image/ in front of the format
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgshttprequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QgsHttpRequestHandler: public QgsRequestHandler
@return mime string (or the entered string if not found)*/
QString formatToMimeType( const QString& format ) const;

void requestStringToParameterMap( const QString& request, std::map<QString, QString>& parameters );
void requestStringToParameterMap( const QString& request, QMap<QString, QString>& parameters );
/**Read CONTENT_LENGTH characters from stdin*/
QString readPostBody() const;
};
Expand Down
8 changes: 3 additions & 5 deletions src/mapserver/qgsmslayerbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ QString QgsMSLayerBuilder::layerNameFromUri( const QString& uri ) const
if ( uri.contains( "dbname" ) )
{
//take tablename
QStringList spaceSplit = uri.split( " " );
QStringList::const_iterator slIt;
for ( slIt = spaceSplit.constBegin(); slIt != spaceSplit.constEnd(); ++slIt )
foreach( QString token, uri.split( " " ) )
{
if ( slIt->startsWith( "table" ) )
if ( token.startsWith( "table" ) )
{
return slIt->section( "=", 1, 1 );
return token.section( "=", 1, 1 );
}
}
}
Expand Down
31 changes: 14 additions & 17 deletions src/mapserver/qgsmslayercache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ QgsMSLayerCache* QgsMSLayerCache::instance()

QgsMSLayerCache::QgsMSLayerCache()
{

}

QgsMSLayerCache::~QgsMSLayerCache()
{
QgsDebugMsg( "removing all entries" );
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
for ( it = mEntries.begin(); it != mEntries.end(); ++it )
foreach( QgsMSLayerCacheEntry entry, mEntries )
{
delete it->layerPointer;
delete entry.layerPointer;
}
delete mInstance;
}
Expand All @@ -59,10 +57,9 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
}

QPair<QString, QString> urlLayerPair = qMakePair( url, layerName );
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
if ( it != mEntries.end() )
if ( mEntries.contains( urlLayerPair ) )
{
delete it->layerPointer;
delete mEntries[ urlLayerPair ].layerPointer;
}

QgsMSLayerCacheEntry newEntry;
Expand All @@ -72,31 +69,31 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
newEntry.lastUsedTime = time( NULL );
newEntry.temporaryFiles = tempFiles;

mEntries.insert( qMakePair( url, layerName ), newEntry );
mEntries.insert( urlLayerPair, newEntry );
}

QgsMapLayer* QgsMSLayerCache::searchLayer( const QString& url, const QString& layerName )
{
QPair<QString, QString> urlNamePair = qMakePair( url, layerName );
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
if ( it == mEntries.end() )
if ( !mEntries.contains( urlNamePair ) )
{
QgsDebugMsg( "Layer not found in cache" );
return 0;
}
else
{
it->lastUsedTime = time( NULL );
QgsMSLayerCacheEntry &entry = mEntries[ urlNamePair ];
entry.lastUsedTime = time( NULL );
#ifdef DIAGRAMSERVER
//delete any existing diagram overlays in vectorlayers
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( it->layerPointer );
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( entry.layerPointer );
if ( vl )
{
vl->removeOverlay( "diagram" );
}
#endif //DIAGRAMSERVER
QgsDebugMsg( "Layer found in cache" );
return it->layerPointer;
return entry.layerPointer;
}
}

Expand Down Expand Up @@ -143,15 +140,15 @@ void QgsMSLayerCache::removeLeastUsedEntry()
void QgsMSLayerCache::freeEntryRessources( QgsMSLayerCacheEntry& entry )
{
delete entry.layerPointer;

//todo: remove the temporary files of a layer
QList<QString>::const_iterator it = entry.temporaryFiles.constBegin();
for ( ; it != entry.temporaryFiles.constEnd(); ++it )
foreach( QString file, entry.temporaryFiles )
{
//remove the temporary file
QFile removeFile( *it );
QFile removeFile( file );
if ( !removeFile.remove() )
{
QgsDebugMsg( "could not remove file: " + *it );
QgsDebugMsg( "could not remove file: " + file );
QgsDebugMsg( removeFile.errorString() );
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgspostrequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ QgsPostRequestHandler::~QgsPostRequestHandler()
{
}

std::map<QString, QString> QgsPostRequestHandler::parseInput()
QMap<QString, QString> QgsPostRequestHandler::parseInput()
{
QgsDebugMsg( "QgsPostRequestHandler::parseInput" );
std::map<QString, QString> parameters;
QMap<QString, QString> parameters;
QString inputString = readPostBody();
QgsDebugMsg( inputString );
requestStringToParameterMap( inputString, parameters );
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgspostrequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class QgsPostRequestHandler: public QgsHttpRequestHandler
~QgsPostRequestHandler();

/**Parses the input and creates a request neutral Parameter/Value map*/
std::map<QString, QString> parseInput();
QMap<QString, QString> parseInput();
};

#endif // QGSPOSTREQUESTHANDLER_H
23 changes: 10 additions & 13 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement,

QMap<QString, QgsMapLayer *> layerMap;

QList<QDomElement>::const_iterator layerIt = mProjectLayerElements.constBegin();
for ( ; layerIt != mProjectLayerElements.constEnd(); ++layerIt )
foreach( const QDomElement &elem, mProjectLayerElements )
{
QgsMapLayer *layer = createLayerFromElement( *layerIt );
QgsMapLayer *layer = createLayerFromElement( elem );
if ( layer )
{
QgsDebugMsg( QString( "add layer %1 to map" ).arg( layer->id() ) );
Expand All @@ -111,7 +110,7 @@ void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement,
{
QString buf;
QTextStream s( &buf );
layerIt->save( s, 0 );
elem.save( s, 0 );
QgsDebugMsg( QString( "layer %1 not found" ).arg( buf ) );
}
#endif
Expand Down Expand Up @@ -173,28 +172,26 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
QgsDebugMsg( QString( "Project path: %1" ).arg( project ) );
QString embeddedGroupName = currentChildElem.attribute( "name" );
QgsProjectParser* p = dynamic_cast<QgsProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project ) );
QList<QDomElement> embededGroupElements = p->mLegendGroupElements;
QList<QDomElement> embeddedGroupElements = p->mLegendGroupElements;
if ( p )
{
QStringList pIdDisabled = p->identifyDisabledLayers();

QDomElement embeddedGroupElem;
QList<QDomElement>::const_iterator pLegendIt = embededGroupElements.constBegin();
for ( ; pLegendIt != embededGroupElements.constEnd(); ++pLegendIt )
foreach( const QDomElement &elem, embeddedGroupElements )
{
if ( pLegendIt->attribute( "name" ) == embeddedGroupName )
if ( elem.attribute( "name" ) == embeddedGroupName )
{
embeddedGroupElem = *pLegendIt;
embeddedGroupElem = elem;
break;
}
}

QMap<QString, QgsMapLayer *> pLayerMap;
QList<QDomElement> embededProjectLayerElements = p->mProjectLayerElements;
QList<QDomElement>::const_iterator pLayerIt = embededProjectLayerElements.constBegin();
for ( ; pLayerIt != embededProjectLayerElements.constEnd(); ++pLayerIt )
QList<QDomElement> embeddedProjectLayerElements = p->mProjectLayerElements;
foreach( const QDomElement &elem, embeddedProjectLayerElements )
{
pLayerMap.insert( layerId( *pLayerIt ), p->createLayerFromElement( *pLayerIt ) );
pLayerMap.insert( layerId( elem ), p->createLayerFromElement( elem ) );
}

p->addLayers( doc, layerElem, embeddedGroupElem, pLayerMap, pIdDisabled );
Expand Down
38 changes: 15 additions & 23 deletions src/mapserver/qgsremoteowsbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <QDomElement>
#include <QTemporaryFile>

QgsRemoteOWSBuilder::QgsRemoteOWSBuilder( const std::map<QString, QString>& parameterMap ): QgsMSLayerBuilder(), mParameterMap( parameterMap )
QgsRemoteOWSBuilder::QgsRemoteOWSBuilder( const QMap<QString, QString>& parameterMap ): QgsMSLayerBuilder(), mParameterMap( parameterMap )
{

}
Expand Down Expand Up @@ -289,48 +289,40 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wcsLayerFromUrl( const QString &url,
QString wcsRequest = serverUrl + "?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&COVERAGE=" + coverageName + "&FORMAT=" + format;

//CRS (or SRS)
std::map<QString, QString>::const_iterator crsIt = mParameterMap.find( "CRS" );
if ( crsIt == mParameterMap.end() )
QString crs = mParameterMap.value( "CRS", mParameterMap.value( "SRS" ) );
if ( crs.isEmpty() )
{
crsIt = mParameterMap.find( "SRS" );
if ( crsIt == mParameterMap.end() )
{
QgsDebugMsg( "No CRS or SRS parameter found for wcs layer, returning 0" );
return 0;
}
QgsDebugMsg( "No CRS or SRS parameter found for wcs layer, returning 0" );
return 0;
}
wcsRequest += "&CRS=";
wcsRequest += crsIt->second;
wcsRequest += "&CRS=" + crs;

//width
std::map<QString, QString>::const_iterator widthIt = mParameterMap.find( "WIDTH" );
if ( widthIt == mParameterMap.end() )
QString width = mParameterMap.value( "WIDTH" );
if ( width.isEmpty() )
{
QgsDebugMsg( "No WIDTH parameter found for wcs layer, returning 0" );
return 0;
}
wcsRequest += "&WIDTH=";
wcsRequest += widthIt->second;
wcsRequest += "&WIDTH=" + width;

//height
std::map<QString, QString>::const_iterator heightIt = mParameterMap.find( "HEIGHT" );
if ( heightIt == mParameterMap.end() )
QString height = mParameterMap.value( "HEIGHT" );
if ( height.isEmpty() )
{
QgsDebugMsg( "No HEIGHT parameter found for wcs layer, returning 0" );
return 0;
}
wcsRequest += "&HEIGHT=";
wcsRequest += heightIt->second;
wcsRequest += "&HEIGHT=" + height;

//bbox
std::map<QString, QString>::const_iterator bboxIt = mParameterMap.find( "BBOX" );
if ( bboxIt == mParameterMap.end() )
QString bbox = mParameterMap.value( "BBOX" );
if ( bbox.isEmpty() )
{
QgsDebugMsg( "No BBOX parameter found for wcs layer, returning 0" );
return 0;
}
wcsRequest += "&BBOX=";
wcsRequest += bboxIt->second;
wcsRequest += "&BBOX=" + bbox;

QgsDebugMsg( "WCS request is: " + wcsRequest );

Expand Down
6 changes: 3 additions & 3 deletions src/mapserver/qgsremoteowsbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define QGSREMOTEOWSBUILDER_H

#include "qgsmslayerbuilder.h"
#include <map>
#include <QMap>

class QgsRasterLayer;
class QgsVectorLayer;
Expand All @@ -28,7 +28,7 @@ class QgsVectorLayer;
class QgsRemoteOWSBuilder: public QgsMSLayerBuilder
{
public:
QgsRemoteOWSBuilder( const std::map<QString, QString>& parameterMap );
QgsRemoteOWSBuilder( const QMap<QString, QString>& parameterMap );
~QgsRemoteOWSBuilder();

QgsMapLayer* createMapLayer( const QDomElement& elem, const QString& layerName, QList<QTemporaryFile*>& filesToRemove, QList<QgsMapLayer*>& layersToRemove, bool allowCaching = true ) const;
Expand All @@ -42,7 +42,7 @@ class QgsRemoteOWSBuilder: public QgsMSLayerBuilder
/**Creates sos layer by analizing server url and LayerSensorObservationConstraints*/
QgsVectorLayer* sosLayer( const QDomElement& remoteOWSElem, const QString& url, const QString& layerName, QList<QgsMapLayer*>& layersToRemove, bool allowCaching = true ) const;

std::map<QString, QString> mParameterMap;
QMap<QString, QString> mParameterMap;
};

#endif
4 changes: 2 additions & 2 deletions src/mapserver/qgsrequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef QGSWMSREQUESTHANDLER
#define QGSWMSREQUESTHANDLER

#include <map>
#include <QMap>
#include <QString>
class QDomDocument;
class QgsMapServiceException;
Expand All @@ -33,7 +33,7 @@ class QgsRequestHandler
QgsRequestHandler() {}
virtual ~QgsRequestHandler() {}
/**Parses the input and creates a request neutral Parameter/Value map*/
virtual std::map<QString, QString> parseInput() = 0;
virtual QMap<QString, QString> parseInput() = 0;
/**Sends the map image back to the client*/
virtual void sendGetMapResponse( const QString& service, QImage* img ) const = 0;
virtual void sendGetCapabilitiesResponse( const QDomDocument& doc ) const = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgssldparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class QgsSLDParser: public QgsConfigParser
/**Returns the xml fragment of a style*/
QDomDocument getStyle( const QString& styleName, const QString& layerName ) const;

virtual void setParameterMap( const std::map<QString, QString>& parameterMap ) { mParameterMap = parameterMap; }
virtual void setParameterMap( const QMap<QString, QString>& parameterMap ) { mParameterMap = parameterMap; }

/**Creates a composition from the project file (delegated to the fallback parser)*/
QgsComposition* initComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, QList< QgsComposerMap*>& mapList, QList< QgsComposerLabel* >& labelList ) const;
Expand Down Expand Up @@ -147,7 +147,7 @@ class QgsSLDParser: public QgsConfigParser
QDomDocument* mXMLDoc;

/**Map containing the WMS parameters of the request*/
std::map<QString, QString> mParameterMap;
QMap<QString, QString> mParameterMap;

QString mSLDNamespace;
};
Expand Down
64 changes: 32 additions & 32 deletions src/mapserver/qgssoaprequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ QgsSOAPRequestHandler::~QgsSOAPRequestHandler()

}

std::map<QString, QString> QgsSOAPRequestHandler::parseInput()
QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
{
std::map<QString, QString> result;
QMap<QString, QString> result;
QString inputString = readPostBody();

//QgsDebugMsg("input string is: " + inputString)
Expand Down Expand Up @@ -84,27 +84,27 @@ std::map<QString, QString> QgsSOAPRequestHandler::parseInput()
if ( serviceString == "MS" )
{
QgsDebugMsg( "service = MS " );
result.insert( std::make_pair( "SERVICE", "MS" ) );
result.insert( "SERVICE", "MS" );
mService = "MS";
}
else if ( serviceString == "WMS" )
{
result.insert( std::make_pair( "SERVICE", "WMS" ) );
result.insert( "SERVICE", "WMS" );
mService = "WMS";
}
else if ( serviceString == "MDS" )
{
result.insert( std::make_pair( "SERVICE", "MDS" ) );
result.insert( "SERVICE", "MDS" );
mService = "MDS";
}
else if ( serviceString == "MAS" )
{
result.insert( std::make_pair( "SERVICE", "MAS" ) );
result.insert( "SERVICE", "MAS" );
mService = "MAS";
}
else
{
result.insert( std::make_pair( "SERVICE", "DISCOVERY" ) );
result.insert( "SERVICE", "DISCOVERY" );
mService = "DISCOVERY";
}

Expand All @@ -113,34 +113,33 @@ std::map<QString, QString> QgsSOAPRequestHandler::parseInput()
//if(firstChildElement.localName().compare("getCapabilities", Qt::CaseInsensitive) == 0)
if ( firstChildElement.localName() == "GetCapabilities" || firstChildElement.localName() == "getCapabilities" )
{
result.insert( std::make_pair( "REQUEST", "GetCapabilities" ) );
result.insert( "REQUEST", "GetCapabilities" );
}
//GetMap request
//else if(firstChildElement.tagName().compare("getMap",Qt::CaseInsensitive) == 0)
else if ( firstChildElement.localName() == "GetMap" || firstChildElement.localName() == "getMap" )
{
result.insert( std::make_pair( "REQUEST", "GetMap" ) );
result.insert( "REQUEST", "GetMap" );
parseGetMapElement( result, firstChildElement );
}
//GetDiagram request
//else if(firstChildElement.tagName().compare("getDiagram", Qt::CaseInsensitive) == 0)
else if ( firstChildElement.localName() == "GetDiagram" )
{
result.insert( std::make_pair( "REQUEST", "GetDiagram" ) );
result.insert( "REQUEST", "GetDiagram" );
parseGetMapElement( result, firstChildElement ); //reuse the method for GetMap
}
//GetFeatureInfo request
else if ( firstChildElement.localName() == "GetFeatureInfo" )
{
result.insert( std::make_pair( "REQUEST", "GetFeatureInfo" ) );
result.insert( "REQUEST", "GetFeatureInfo" );
parseGetFeatureInfoElement( result, firstChildElement );
}

//set mFormat
std::map<QString, QString>::const_iterator formatIt = result.find( "FORMAT" );
if ( formatIt != result.end() )
QString formatString = result.value( "FORMAT" );
if ( !formatString.isEmpty() )
{
QString formatString = formatIt->second;
//remove the image/ in front of the format
if ( formatString == "image/jpeg" || formatString == "JPG" || formatString == "jpg" )
{
Expand All @@ -156,8 +155,9 @@ std::map<QString, QString> QgsSOAPRequestHandler::parseInput()
}
else
{
throw QgsMapServiceException( "InvalidFormat", "Invalid format, only jpg and png are supported" );
throw QgsMapServiceException( "InvalidFormat", "Invalid format " + formatString + ", only jpg and png are supported" );
}

mFormat = formatString;
}

Expand Down Expand Up @@ -452,7 +452,7 @@ void QgsSOAPRequestHandler::sendServiceException( const QgsMapServiceException&
sendHttpResponse( &ba, "text/xml" );
}

int QgsSOAPRequestHandler::parseGetMapElement( std::map<QString, QString>& parameterMap, const QDomElement& getMapElement ) const
int QgsSOAPRequestHandler::parseGetMapElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const
{
QDomNodeList boundingBoxList = getMapElement.elementsByTagName( "BoundingBox" );
if ( boundingBoxList.size() > 0 )
Expand All @@ -472,15 +472,15 @@ int QgsSOAPRequestHandler::parseGetMapElement( std::map<QString, QString>& param
{
epsgNumber = crsText.replace( 4, 1, ":" );//replace the underscore with a ':' to make it WMS compatible
}
parameterMap.insert( std::make_pair( "CRS", epsgNumber ) );
parameterMap.insert( "CRS", epsgNumber );
}
QDomNodeList GMLList = getMapElement.elementsByTagNameNS( "http://www.eu-orchestra.org/services/ms", "GML" );
if ( GMLList.size() > 0 )
{
QString gmlText;
QTextStream gmlStream( &gmlText );
GMLList.at( 0 ).save( gmlStream, 2 );
parameterMap.insert( std::make_pair( "GML", gmlText ) );
parameterMap.insert( "GML", gmlText );
}

//outputAttributes
Expand All @@ -500,13 +500,13 @@ int QgsSOAPRequestHandler::parseGetMapElement( std::map<QString, QString>& param
//Replace some special characters
sldString.replace( "&lt;", "<" );
sldString.replace( "&gt;", ">" );
parameterMap.insert( std::make_pair( "SLD", sldString ) );
parameterMap.insert( "SLD", sldString );
}

return 0;
}

int QgsSOAPRequestHandler::parseGetFeatureInfoElement( std::map<QString, QString>& parameterMap, const QDomElement& getFeatureInfoElement ) const
int QgsSOAPRequestHandler::parseGetFeatureInfoElement( QMap<QString, QString>& parameterMap, const QDomElement& getFeatureInfoElement ) const
{
QDomNodeList queryList = getFeatureInfoElement.elementsByTagName( "Query" );
if ( queryList.size() < 1 )
Expand All @@ -522,7 +522,7 @@ int QgsSOAPRequestHandler::parseGetFeatureInfoElement( std::map<QString, QString
return 0; //no error, but nothing to do
}
QString queryLayerString = queryLayerList.at( 0 ).toElement().text();
parameterMap.insert( std::make_pair( "QUERY_LAYERS", queryLayerString ) );
parameterMap.insert( "QUERY_LAYERS", queryLayerString );

//find <XImagePoint>
QDomNodeList xImageList = queryElem.elementsByTagName( "XImagePoint" );
Expand All @@ -536,7 +536,7 @@ int QgsSOAPRequestHandler::parseGetFeatureInfoElement( std::map<QString, QString
{
return 4;
}
parameterMap.insert( std::make_pair( "I", QString::number( xPoint ) ) );
parameterMap.insert( "I", QString::number( xPoint ) );

//find <YImagePoint>
QDomNodeList yImageList = queryElem.elementsByTagName( "YImagePoint" );
Expand All @@ -549,7 +549,7 @@ int QgsSOAPRequestHandler::parseGetFeatureInfoElement( std::map<QString, QString
{
return 6;
}
parameterMap.insert( std::make_pair( "J", QString::number( yPoint ) ) );
parameterMap.insert( "J", QString::number( yPoint ) );

//find <FeatureCount>
QDomNodeList featureCountList = queryElem.elementsByTagName( "FeatureCount" );
Expand All @@ -558,7 +558,7 @@ int QgsSOAPRequestHandler::parseGetFeatureInfoElement( std::map<QString, QString
int featureCount = featureCountList.at( 0 ).toElement().text().toInt( &conversionSuccess );
if ( conversionSuccess )
{
parameterMap.insert( std::make_pair( "FEATURE_COUNT", QString::number( featureCount ) ) );
parameterMap.insert( "FEATURE_COUNT", QString::number( featureCount ) );
}
}

Expand All @@ -577,7 +577,7 @@ int QgsSOAPRequestHandler::parseGetFeatureInfoElement( std::map<QString, QString
return 0;
}

int QgsSOAPRequestHandler::parseBoundingBoxElement( std::map<QString, QString>& parameterMap, const QDomElement& boundingBoxElement ) const
int QgsSOAPRequestHandler::parseBoundingBoxElement( QMap<QString, QString>& parameterMap, const QDomElement& boundingBoxElement ) const
{
QString minx, miny, maxx, maxy;

Expand Down Expand Up @@ -608,34 +608,34 @@ int QgsSOAPRequestHandler::parseBoundingBoxElement( std::map<QString, QString>&
{
maxy = upperBoundList.item( 0 ).toElement().text();
}
parameterMap.insert( std::make_pair( "BBOX", minx + "," + miny + "," + maxx + "," + maxy ) );
parameterMap.insert( "BBOX", minx + "," + miny + "," + maxx + "," + maxy );
return 0;
}

int QgsSOAPRequestHandler::parseOutputAttributesElement( std::map<QString, QString>& parameterMap, const QDomElement& outputAttributesElement ) const
int QgsSOAPRequestHandler::parseOutputAttributesElement( QMap<QString, QString>& parameterMap, const QDomElement& outputAttributesElement ) const
{
//height
QDomNodeList heightList = outputAttributesElement.elementsByTagName( "Height" );
if ( heightList.size() > 0 )
{
QString heightString = heightList.item( 0 ).toElement().text();
parameterMap.insert( std::make_pair( "HEIGHT", heightString ) );
parameterMap.insert( "HEIGHT", heightString );
}

//width
QDomNodeList widthList = outputAttributesElement.elementsByTagName( "Width" );
if ( widthList.size() > 0 )
{
QString widthString = widthList.item( 0 ).toElement().text();
parameterMap.insert( std::make_pair( "WIDTH", widthString ) );
parameterMap.insert( "WIDTH", widthString );
}

//format
QDomNodeList formatList = outputAttributesElement.elementsByTagName( "Format" );
if ( formatList.size() > 0 )
{
QString formatString = formatList.item( 0 ).toElement().text();
parameterMap.insert( std::make_pair( "FORMAT", formatString ) );
parameterMap.insert( "FORMAT", formatString );
}

//background transparendy
Expand All @@ -646,11 +646,11 @@ int QgsSOAPRequestHandler::parseOutputAttributesElement( std::map<QString, QStri
if ( bgTransparencyString.compare( "true", Qt::CaseInsensitive ) == 0
|| bgTransparencyString == "1" )
{
parameterMap.insert( std::make_pair( "TRANSPARENT", "TRUE" ) );
parameterMap.insert( "TRANSPARENT", "TRUE" );
}
else
{
parameterMap.insert( std::make_pair( "TRANSPARENT", "FALSE" ) );
parameterMap.insert( "TRANSPARENT", "FALSE" );
}
}
return 0;
Expand Down
10 changes: 5 additions & 5 deletions src/mapserver/qgssoaprequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class QgsSOAPRequestHandler: public QgsHttpRequestHandler
public:
QgsSOAPRequestHandler();
~QgsSOAPRequestHandler();
std::map<QString, QString> parseInput();
QMap<QString, QString> parseInput();
void sendGetMapResponse( const QString& service, QImage* img ) const;
void sendGetCapabilitiesResponse( const QDomDocument& doc ) const;
void sendGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) const;
Expand All @@ -37,11 +37,11 @@ class QgsSOAPRequestHandler: public QgsHttpRequestHandler
void sendGetPrintResponse( QByteArray* ba ) const;
private:
/**Parses the xml of a getMap request and fills the parameters into the map. Returns 0 in case of success*/
int parseGetMapElement( std::map<QString, QString>& parameterMap, const QDomElement& getMapElement ) const;
int parseGetMapElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const;
/**Parses the xml of a feature info request and fills the parameters into the map. Returns 0 in case of success*/
int parseGetFeatureInfoElement( std::map<QString, QString>& parameterMap, const QDomElement& getMapElement ) const;
int parseBoundingBoxElement( std::map<QString, QString>& parameterMap, const QDomElement& boundingBoxElement ) const;
int parseOutputAttributesElement( std::map<QString, QString>& parameterMap, const QDomElement& outputAttributesElement ) const;
int parseGetFeatureInfoElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const;
int parseBoundingBoxElement( QMap<QString, QString>& parameterMap, const QDomElement& boundingBoxElement ) const;
int parseOutputAttributesElement( QMap<QString, QString>& parameterMap, const QDomElement& outputAttributesElement ) const;
int sendSOAPWithAttachments( QImage* img ) const;
int sendUrlToFile( QImage* img ) const;
/**Reads the file wms_metadata.xml and extract the OnlineResource href. Returns 0 in case of success.*/
Expand Down
334 changes: 124 additions & 210 deletions src/mapserver/qgswmsserver.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/mapserver/qgswmsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class QgsWMSServer
{
public:
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
QgsWMSServer( std::map<QString, QString> parameters, QgsMapRenderer* renderer );
QgsWMSServer( QMap<QString, QString> parameters, QgsMapRenderer* renderer );
~QgsWMSServer();
/**Returns an XML file with the capabilities description (as described in the WMS specs)*/
QDomDocument getCapabilities();
QDomDocument getCapabilities( QString version = "1.3.0" );
/**Returns the map legend as an image (or a null pointer in case of error). The caller takes ownership
of the image object*/
QImage* getLegendGraphics();
Expand All @@ -69,7 +69,7 @@ class QgsWMSServer

/**Creates an xml document that describes the result of the getFeatureInfo request.
@return 0 in case of success*/
int getFeatureInfo( QDomDocument& result );
int getFeatureInfo( QDomDocument& result, QString version = "1.3.0" );

/**Sets configuration parser for administration settings. Does not take ownership*/
void setAdminConfigParser( QgsConfigParser* parser ) { mConfigParser = parser; }
Expand Down Expand Up @@ -113,9 +113,9 @@ class QgsWMSServer
@param featureBBox the bounding box of the selected features in output CRS
@return 0 in case of success*/
int featureInfoFromVectorLayer( QgsVectorLayer* layer, const QgsPoint* infoPoint, int nFeatures, QDomDocument& infoDocument, QDomElement& layerElement, QgsMapRenderer* mapRender,
QMap<int, QString>& aliasMap, QSet<QString>& hiddenAttributes, QgsRectangle* featureBBox = 0 ) const;
QMap<int, QString>& aliasMap, QSet<QString>& hiddenAttributes, QString version, QgsRectangle* featureBBox = 0 ) const;
/**Appends feature info xml for the layer to the layer element of the dom document*/
int featureInfoFromRasterLayer( QgsRasterLayer* layer, const QgsPoint* infoPoint, QDomDocument& infoDocument, QDomElement& layerElement ) const;
int featureInfoFromRasterLayer( QgsRasterLayer* layer, const QgsPoint* infoPoint, QDomDocument& infoDocument, QDomElement& layerElement, QString version ) const;

/**Creates a layer set and returns a stringlist with layer ids that can be passed to a QgsMapRenderer. Usually used in conjunction with readLayersAndStyles*/
QStringList layerSet( const QStringList& layersList, const QStringList& stylesList, const QgsCoordinateReferenceSystem& destCRS ) const;
Expand Down Expand Up @@ -156,7 +156,7 @@ class QgsWMSServer
void clearFeatureSelections( const QStringList& layerIds ) const;

/**Map containing the WMS parameters*/
std::map<QString, QString> mParameterMap;
QMap<QString, QString> mParameterMap;
QgsConfigParser* mConfigParser;
QgsMapRenderer* mMapRenderer;
};
Expand Down