Merge pull request #4683 from rldhont/server-string-list-exceptions

[Server] bulk enhancements: string, list and exceptions
This commit is contained in:
rldhont 2017-06-06 10:09:52 +02:00 committed by GitHub
commit dbedd7e190
17 changed files with 94 additions and 84 deletions

View File

@ -52,7 +52,7 @@ QgsMapLayer *QgsInterpolationLayerBuilder::createMapLayer( const QDomElement &el
}
QDomNodeList interpolationList = elem.elementsByTagName( QStringLiteral( "Interpolation" ) );
if ( interpolationList.size() < 1 )
if ( interpolationList.isEmpty() )
{
QgsDebugMsg( "No Interpolation element found" );
return nullptr;
@ -68,7 +68,7 @@ QgsMapLayer *QgsInterpolationLayerBuilder::createMapLayer( const QDomElement &el
QgsInterpolator::LayerData currentLayerData;
currentLayerData.vectorLayer = mVectorLayer;
QDomNodeList propertyNameList = interpolationElem.elementsByTagName( QStringLiteral( "PropertyName" ) );
if ( propertyNameList.size() < 1 )
if ( propertyNameList.isEmpty() )
{
currentLayerData.zCoordInterpolation = true;
}
@ -110,7 +110,7 @@ QgsMapLayer *QgsInterpolationLayerBuilder::createMapLayer( const QDomElement &el
int nCols, nRows;
QDomNodeList resolutionNodeList = elem.elementsByTagName( QStringLiteral( "Resolution" ) );
if ( resolutionNodeList.size() < 1 )
if ( resolutionNodeList.isEmpty() )
{
//use default values...
nCols = 100;

View File

@ -124,7 +124,7 @@ QFileInfo QgsServer::defaultProjectFile()
{
QgsMessageLog::logMessage( projectFiles.at( x ).absoluteFilePath(), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( projectFiles.size() < 1 )
if ( projectFiles.isEmpty() )
{
return QFileInfo();
}

View File

@ -87,7 +87,7 @@ namespace QgsWcs
QStringList coveNameList;
if ( !coveNames.isEmpty() )
{
coveNameList = coveNames.split( QStringLiteral( "," ) );
coveNameList = coveNames.split( ',' );
for ( int i = 0; i < coveNameList.size(); ++i )
{
coveNameList.replace( i, coveNameList.at( i ).trimmed() );
@ -111,7 +111,7 @@ namespace QgsWcs
QString name = layer->name();
if ( !layer->shortName().isEmpty() )
name = layer->shortName();
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
name = name.replace( ' ', '_' );
if ( coveNameList.size() == 0 || coveNameList.contains( name ) )
{

View File

@ -45,7 +45,7 @@ namespace QgsWcs
QString name = layer->name();
if ( !layer->shortName().isEmpty() )
name = layer->shortName();
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
name = name.replace( ' ', '_' );
QDomText nameText = doc.createTextNode( name );
nameElem.appendChild( nameText );
layerElem.appendChild( nameElem );
@ -260,7 +260,7 @@ namespace QgsWcs
QgsRectangle parseBbox( const QString &bboxStr )
{
QStringList lst = bboxStr.split( QStringLiteral( "," ) );
QStringList lst = bboxStr.split( ',' );
if ( lst.count() != 4 )
return QgsRectangle();
@ -268,7 +268,7 @@ namespace QgsWcs
bool ok;
for ( int i = 0; i < 4; i++ )
{
lst[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
lst[i].replace( ' ', '+' );
d[i] = lst[i].toDouble( &ok );
if ( !ok )
return QgsRectangle();

View File

@ -90,8 +90,8 @@ namespace QgsWfs
if ( docChildElem.tagName() == QLatin1String( "TypeName" ) )
{
QString typeName = docChildElem.text().trimmed();
if ( typeName.contains( QLatin1String( ":" ) ) )
typeNameList << typeName.section( QStringLiteral( ":" ), 1, 1 );
if ( typeName.contains( ':' ) )
typeNameList << typeName.section( ':', 1, 1 );
else
typeNameList << typeName;
}
@ -103,12 +103,12 @@ namespace QgsWfs
QString typeNames = request.parameter( QStringLiteral( "TYPENAME" ) );
if ( !typeNames.isEmpty() )
{
QStringList typeNameSplit = typeNames.split( QStringLiteral( "," ) );
QStringList typeNameSplit = typeNames.split( ',' );
for ( int i = 0; i < typeNameSplit.size(); ++i )
{
QString typeName = typeNameSplit.at( i ).trimmed();
if ( typeName.contains( QLatin1String( ":" ) ) )
typeNameList << typeName.section( QStringLiteral( ":" ), 1, 1 );
if ( typeName.contains( ':' ) )
typeNameList << typeName.section( ':', 1, 1 );
else
typeNameList << typeName;
}
@ -127,7 +127,7 @@ namespace QgsWfs
QString name = layer->name();
if ( !layer->shortName().isEmpty() )
name = layer->shortName();
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
name = name.replace( ' ', '_' );
if ( !typeNameList.isEmpty() && !typeNameList.contains( name ) )
{
@ -168,7 +168,7 @@ namespace QgsWfs
QString typeName = layer->name();
if ( !layer->shortName().isEmpty() )
typeName = layer->shortName();
typeName = typeName.replace( QLatin1String( " " ), QLatin1String( "_" ) );
typeName = typeName.replace( ' ', '_' );
//xsd:element
QDomElement elementElem = doc.createElement( QStringLiteral( "element" )/*xsd:element*/ );

View File

@ -121,7 +121,7 @@ namespace QgsWfs
QString name = layer->name();
if ( !layer->shortName().isEmpty() )
name = layer->shortName();
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
name = name.replace( ' ', '_' );
if ( typeNameList.contains( name ) )
{
@ -387,7 +387,7 @@ namespace QgsWfs
// parse FEATUREID
if ( parameters.contains( QStringLiteral( "FEATUREID" ) ) )
{
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( QStringLiteral( "," ) );
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( ',' );
// Verifying the 1:1 mapping between FEATUREID and PROPERTYNAME
if ( !propertyNameList.isEmpty() && propertyNameList.size() != fidList.size() )
{
@ -417,13 +417,13 @@ namespace QgsWfs
propertyName = *propertyNameIt;
}
// testing typename in the WFS featureID
if ( !fid.contains( QLatin1String( "." ) ) )
if ( !fid.contains( '.' ) )
{
throw QgsRequestNotWellFormedException( QStringLiteral( "FEATUREID has to have TYPENAME in the values" ) );
}
QString typeName = fid.section( QStringLiteral( "." ), 0, 0 );
fid = fid.section( QStringLiteral( "." ), 1, 1 );
QString typeName = fid.section( '.', 0, 0 );
fid = fid.section( '.', 1, 1 );
if ( !typeNameList.contains( typeName ) )
{
typeNameList << typeName;
@ -467,23 +467,23 @@ namespace QgsWfs
{
QStringList propertyList;
QStringList attrList = propertyName.split( QStringLiteral( "," ) );
QStringList attrList = propertyName.split( ',' );
QStringList::const_iterator alstIt;
for ( alstIt = attrList.begin(); alstIt != attrList.end(); ++alstIt )
{
QString fieldName = *alstIt;
fieldName = fieldName.trimmed();
if ( fieldName.contains( QLatin1String( ":" ) ) )
if ( fieldName.contains( ':' ) )
{
fieldName = fieldName.section( QStringLiteral( ":" ), 1, 1 );
fieldName = fieldName.section( ':', 1, 1 );
}
if ( fieldName.contains( QLatin1String( "/" ) ) )
if ( fieldName.contains( '/' ) )
{
if ( fieldName.section( QStringLiteral( "/" ), 0, 0 ) != typeName )
if ( fieldName.section( '/', 0, 0 ) != typeName )
{
throw QgsRequestNotWellFormedException( QStringLiteral( "PropertyName text '%1' has to contain TypeName '%2'" ).arg( fieldName ).arg( typeName ) );
}
fieldName = fieldName.section( QStringLiteral( "/" ), 1, 1 );
fieldName = fieldName.section( '/', 1, 1 );
}
propertyList.append( fieldName );
}
@ -513,7 +513,7 @@ namespace QgsWfs
throw QgsRequestNotWellFormedException( QStringLiteral( "TYPENAME is mandatory except if FEATUREID is used" ) );
}
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( QStringLiteral( "," ) );
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( ',' );
// Verifying the 1:1 mapping between TYPENAME and PROPERTYNAME
if ( !propertyNameList.isEmpty() && typeNameList.size() != propertyNameList.size() )
{
@ -549,23 +549,23 @@ namespace QgsWfs
{
QStringList propertyList;
QStringList attrList = propertyName.split( QStringLiteral( "," ) );
QStringList attrList = propertyName.split( ',' );
QStringList::const_iterator alstIt;
for ( alstIt = attrList.begin(); alstIt != attrList.end(); ++alstIt )
{
QString fieldName = *alstIt;
fieldName = fieldName.trimmed();
if ( fieldName.contains( QLatin1String( ":" ) ) )
if ( fieldName.contains( ':' ) )
{
fieldName = fieldName.section( QStringLiteral( ":" ), 1, 1 );
fieldName = fieldName.section( ':', 1, 1 );
}
if ( fieldName.contains( QLatin1String( "/" ) ) )
if ( fieldName.contains( '/' ) )
{
if ( fieldName.section( QStringLiteral( "/" ), 0, 0 ) != typeName )
if ( fieldName.section( '/', 0, 0 ) != typeName )
{
throw QgsRequestNotWellFormedException( QStringLiteral( "PropertyName text '%1' has to contain TypeName '%2'" ).arg( fieldName ).arg( typeName ) );
}
fieldName = fieldName.section( QStringLiteral( "/" ), 1, 1 );
fieldName = fieldName.section( '/', 1, 1 );
}
propertyList.append( fieldName );
}
@ -660,7 +660,7 @@ namespace QgsWfs
bool ok;
for ( int i = 0; i < 4; i++ )
{
corners[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
corners[i].replace( ' ', '+' );
d[i] = corners[i].toDouble( &ok );
if ( !ok )
{
@ -769,9 +769,9 @@ namespace QgsWfs
getFeatureQuery parseQueryElement( QDomElement &queryElem )
{
QString typeName = queryElem.attribute( QStringLiteral( "typeName" ), QLatin1String( "" ) );
if ( typeName.contains( QLatin1String( ":" ) ) )
if ( typeName.contains( ':' ) )
{
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
typeName = typeName.section( ':', 1, 1 );
}
QgsFeatureRequest featureRequest;
@ -785,17 +785,17 @@ namespace QgsWfs
if ( queryChildElem.tagName() == QLatin1String( "PropertyName" ) )
{
QString fieldName = queryChildElem.text().trimmed();
if ( fieldName.contains( QLatin1String( ":" ) ) )
if ( fieldName.contains( ':' ) )
{
fieldName = fieldName.section( QStringLiteral( ":" ), 1, 1 );
fieldName = fieldName.section( ':', 1, 1 );
}
if ( fieldName.contains( QLatin1String( "/" ) ) )
if ( fieldName.contains( '/' ) )
{
if ( fieldName.section( QStringLiteral( "/" ), 0, 0 ) != typeName )
if ( fieldName.section( '/', 0, 0 ) != typeName )
{
throw QgsRequestNotWellFormedException( QStringLiteral( "PropertyName text '%1' has to contain TypeName '%2'" ).arg( fieldName ).arg( typeName ) );
}
fieldName = fieldName.section( QStringLiteral( "/" ), 1, 1 );
fieldName = fieldName.section( '/', 1, 1 );
}
propertyList.append( fieldName );
}
@ -878,7 +878,7 @@ namespace QgsWfs
query.removeAllQueryItems( QStringLiteral( "_DC" ) );
query.addQueryItem( QStringLiteral( "REQUEST" ), QStringLiteral( "DescribeFeatureType" ) );
query.addQueryItem( QStringLiteral( "TYPENAME" ), typeNames.join( QStringLiteral( "," ) ) );
query.addQueryItem( QStringLiteral( "TYPENAME" ), typeNames.join( ',' ) );
query.addQueryItem( QStringLiteral( "OUTPUTFORMAT" ), QStringLiteral( "XMLSCHEMA" ) );
mapUrl.setQuery( query );

View File

@ -243,7 +243,7 @@ namespace QgsWfs
QString name = layer->name();
if ( !layer->shortName().isEmpty() )
name = layer->shortName();
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
name = name.replace( ' ', '_' );
if ( !typeNameList.contains( name ) )
{
@ -779,7 +779,7 @@ namespace QgsWfs
// parse FEATUREID
if ( parameters.contains( QStringLiteral( "FEATUREID" ) ) )
{
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( QStringLiteral( "," ) );
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( ',' );
QMap<QString, QgsFeatureIds> fidsMap;
@ -790,13 +790,13 @@ namespace QgsWfs
QString fid = *fidIt;
fid = fid.trimmed();
// testing typename in the WFS featureID
if ( !fid.contains( QLatin1String( "." ) ) )
if ( !fid.contains( '.' ) )
{
throw QgsRequestNotWellFormedException( QStringLiteral( "FEATUREID has to have TYPENAME in the values" ) );
}
QString typeName = fid.section( QStringLiteral( "." ), 0, 0 );
fid = fid.section( QStringLiteral( "." ), 1, 1 );
QString typeName = fid.section( '.', 0, 0 );
fid = fid.section( '.', 1, 1 );
if ( !typeNameList.contains( typeName ) )
{
typeNameList << typeName;
@ -830,7 +830,7 @@ namespace QgsWfs
throw QgsRequestNotWellFormedException( QStringLiteral( "TYPENAME is mandatory except if FEATUREID is used" ) );
}
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( QStringLiteral( "," ) );
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( ',' );
// Create actions based on TypeName
QStringList::const_iterator typeNameIt = typeNameList.constBegin();
@ -925,7 +925,7 @@ namespace QgsWfs
bool ok;
for ( int i = 0; i < 4; i++ )
{
corners[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
corners[i].replace( ' ', '+' );
d[i] = corners[i].toDouble( &ok );
if ( !ok )
{
@ -1038,8 +1038,8 @@ namespace QgsWfs
transactionDelete parseDeleteActionElement( QDomElement &actionElem )
{
QString typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
if ( typeName.contains( QLatin1String( ":" ) ) )
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
if ( typeName.contains( ':' ) )
typeName = typeName.section( ':', 1, 1 );
QDomElement filterElem = actionElem.firstChild().toElement();
if ( filterElem.tagName() != QLatin1String( "Filter" ) )
@ -1065,8 +1065,8 @@ namespace QgsWfs
transactionUpdate parseUpdateActionElement( QDomElement &actionElem )
{
QString typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
if ( typeName.contains( QLatin1String( ":" ) ) )
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
if ( typeName.contains( ':' ) )
typeName = typeName.section( ':', 1, 1 );
QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral( "Property" ) );
if ( propertyNodeList.size() != 1 )
@ -1130,8 +1130,8 @@ namespace QgsWfs
for ( int i = 0; i < featureNodeList.count(); ++i )
{
QString tempTypeName = featureNodeList.at( i ).toElement().localName();
if ( tempTypeName.contains( QLatin1String( ":" ) ) )
tempTypeName = tempTypeName.section( QStringLiteral( ":" ), 1, 1 );
if ( tempTypeName.contains( ':' ) )
tempTypeName = tempTypeName.section( ':', 1, 1 );
if ( typeName.isEmpty() )
{

View File

@ -85,7 +85,7 @@ namespace QgsWfs
fids.insert( fid.toInt() );
}
if ( fids.size() > 0 )
if ( !fids.isEmpty() )
{
request.setFilterFids( fids );
}

View File

@ -31,10 +31,10 @@ namespace QgsWms
{
QMap<QString, QString> options;
QStringList optionsList = optionString.split( QStringLiteral( ";" ) );
QStringList optionsList = optionString.split( ';' );
for ( auto optionsIt = optionsList.constBegin(); optionsIt != optionsList.constEnd(); ++optionsIt )
{
int equalIdx = optionsIt->indexOf( QLatin1String( ":" ) );
int equalIdx = optionsIt->indexOf( ':' );
if ( equalIdx > 0 && equalIdx < ( optionsIt->length() - 1 ) )
{
options.insert( optionsIt->left( equalIdx ).toUpper(),
@ -54,7 +54,7 @@ namespace QgsWms
QMap<QString, QString>::const_iterator layerAttributesIt = options.find( QStringLiteral( "LAYERATTRIBUTES" ) );
if ( layerAttributesIt != options.constEnd() )
{
layerAttributes = options.value( QStringLiteral( "LAYERATTRIBUTES" ) ).split( QStringLiteral( "," ) );
layerAttributes = options.value( QStringLiteral( "LAYERATTRIBUTES" ) ).split( ',' );
}
//LAYERS and STYLES

View File

@ -58,8 +58,8 @@ namespace QgsWms
QStringLiteral( "LAYERS is mandatory for DescribeLayer operation" ), 400 );
}
QStringList layersList = parameters[ QStringLiteral( "LAYERS" )].split( QStringLiteral( "," ), QString::SkipEmptyParts );
if ( layersList.size() < 1 )
QStringList layersList = parameters[ QStringLiteral( "LAYERS" )].split( ',', QString::SkipEmptyParts );
if ( layersList.isEmpty() )
{
throw QgsServiceException( QStringLiteral( "InvalidParameterValue" ), QStringLiteral( "Layers is empty" ), 400 );
}

View File

@ -947,7 +947,7 @@ namespace QgsWms
//keyword list
if ( !l->keywordList().isEmpty() )
{
QStringList keywordStringList = l->keywordList().split( QStringLiteral( "," ) );
QStringList keywordStringList = l->keywordList().split( ',' );
QDomElement keywordListElem = doc.createElement( QStringLiteral( "KeywordList" ) );
for ( int i = 0; i < keywordStringList.size(); ++i )
@ -1619,7 +1619,7 @@ namespace QgsWms
reversedList << layerList[ i ];
QDomElement layerDrawingOrderElem = doc.createElement( QStringLiteral( "LayerDrawingOrder" ) );
QDomText drawingOrderText = doc.createTextNode( reversedList.join( QStringLiteral( "," ) ) );
QDomText drawingOrderText = doc.createTextNode( reversedList.join( ',' ) );
layerDrawingOrderElem.appendChild( drawingOrderText );
parentElem.appendChild( layerDrawingOrderElem );
}

View File

@ -356,7 +356,7 @@ namespace QgsWms
//keyword list
if ( !l->keywordList().isEmpty() )
{
QStringList keywordStringList = l->keywordList().split( QStringLiteral( "," ) );
QStringList keywordStringList = l->keywordList().split( ',' );
bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );
QDomElement keywordsElem = doc.createElement( QStringLiteral( "ows:Keywords" ) );

View File

@ -74,7 +74,7 @@ namespace QgsWms
QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral( "Feature" ) );
QDomElement currentFeatureElement;
if ( featureNodeList.size() < 1 ) //raster layer?
if ( featureNodeList.isEmpty() ) //raster layer?
{
QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral( "Attribute" ) );
for ( int j = 0; j < attributeNodeList.size(); ++j )

View File

@ -173,7 +173,7 @@ namespace QgsWms
readLayersAndStyles( mParameters, layersList, stylesList );
if ( layersList.size() < 1 )
if ( layersList.isEmpty() )
{
return nullptr;
}
@ -193,7 +193,7 @@ namespace QgsWms
QgsCoordinateReferenceSystem dummyCRS;
QStringList layerIds = layerSet( layersList, stylesList, dummyCRS, scaleDenominator );
if ( layerIds.size() < 1 )
if ( layerIds.isEmpty() )
{
return nullptr;
}
@ -965,8 +965,8 @@ namespace QgsWms
throw QgsBadRequestException( QStringLiteral( "ParameterMissing" ), QStringLiteral( "No QUERY_LAYERS" ) );
}
QStringList queryLayerList = mParameters[ QStringLiteral( "QUERY_LAYERS" )].split( QStringLiteral( "," ), QString::SkipEmptyParts );
if ( queryLayerList.size() < 1 )
QStringList queryLayerList = mParameters[ QStringLiteral( "QUERY_LAYERS" )].split( ',', QString::SkipEmptyParts );
if ( queryLayerList.isEmpty() )
{
throw QgsBadRequestException( QStringLiteral( "InvalidParameterValue" ), QStringLiteral( "Malformed QUERY_LAYERS" ) );
}
@ -1921,10 +1921,10 @@ namespace QgsWms
QString filterParameter = mParameters.value( QStringLiteral( "FILTER" ) );
if ( !filterParameter.isEmpty() )
{
QStringList layerSplit = filterParameter.split( QStringLiteral( ";" ) );
QStringList layerSplit = filterParameter.split( ';' );
for ( auto layerIt = layerSplit.constBegin(); layerIt != layerSplit.constEnd(); ++layerIt )
{
QStringList eqSplit = layerIt->split( QStringLiteral( ":" ) );
QStringList eqSplit = layerIt->split( ':' );
if ( eqSplit.size() < 2 )
{
continue;
@ -2027,7 +2027,7 @@ namespace QgsWms
return false;
}
QStringList tokens = filter.split( QStringLiteral( " " ), QString::SkipEmptyParts );
QStringList tokens = filter.split( ' ', QString::SkipEmptyParts );
groupStringList( tokens, QStringLiteral( "'" ) );
groupStringList( tokens, QStringLiteral( "\"" ) );
@ -2161,7 +2161,7 @@ namespace QgsWms
Q_FOREACH ( const QString &selectionLayer, selectionString.split( ";" ) )
{
//separate layer name from id list
QStringList layerIdSplit = selectionLayer.split( QStringLiteral( ":" ) );
QStringList layerIdSplit = selectionLayer.split( ':' );
if ( layerIdSplit.size() < 2 )
{
continue;
@ -2194,7 +2194,7 @@ namespace QgsWms
continue;
}
QStringList idList = layerIdSplit.at( 1 ).split( QStringLiteral( "," ) );
QStringList idList = layerIdSplit.at( 1 ).split( ',' );
QgsFeatureIds selectedIds;
Q_FOREACH ( const QString &id, idList )
@ -2236,7 +2236,7 @@ namespace QgsWms
{
return;
}
QStringList opacityList = opIt.value().split( QStringLiteral( "," ) );
QStringList opacityList = opIt.value().split( ',' );
//collect leaf layers and their opacity
QVector< QPair< QgsMapLayer *, int > > layerOpacityList;
@ -2386,7 +2386,7 @@ namespace QgsWms
QDomElement currentFeatureElem;
QDomNodeList featureList = currentLayerElem.elementsByTagName( QStringLiteral( "Feature" ) );
if ( featureList.size() < 1 )
if ( featureList.isEmpty() )
{
//raster?
QDomNodeList attributeList = currentLayerElem.elementsByTagName( QStringLiteral( "Attribute" ) );
@ -2989,6 +2989,11 @@ namespace QgsWms
mNicknameLayers[lname]->setCustomProperty( "readSLD", true );
layers.append( mNicknameLayers[lname] );
}
else
{
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ),
QStringLiteral( "Layer \"%1\" does not exist" ).arg( lname ) );
}
}
}
}
@ -3005,7 +3010,7 @@ namespace QgsWms
{
QString nickname = param.mNickname;
QString style = param.mStyle;
if ( mNicknameLayers.contains( nickname ) )
if ( mNicknameLayers.contains( nickname ) && !mRestrictedLayers.contains( nickname ) )
{
if ( !style.isEmpty() )
{
@ -3018,6 +3023,11 @@ namespace QgsWms
layers.append( mNicknameLayers[nickname] );
}
else
{
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ),
QStringLiteral( "Layer \"%1\" does not exist" ).arg( nickname ) );
}
}
return layers;

View File

@ -109,10 +109,10 @@ namespace QgsWms
void readLayersAndStyles( const QgsServerRequest::Parameters &parameters, QStringList &layersList, QStringList &stylesList )
{
//get layer and style lists from the parameters trying LAYERS and LAYER as well as STYLE and STYLES for GetLegendGraphic compatibility
layersList = parameters.value( QStringLiteral( "LAYER" ) ).split( QStringLiteral( "," ), QString::SkipEmptyParts );
layersList = layersList + parameters.value( QStringLiteral( "LAYERS" ) ).split( QStringLiteral( "," ), QString::SkipEmptyParts );
stylesList = parameters.value( QStringLiteral( "STYLE" ) ).split( QStringLiteral( "," ), QString::SkipEmptyParts );
stylesList = stylesList + parameters.value( QStringLiteral( "STYLES" ) ).split( QStringLiteral( "," ), QString::SkipEmptyParts );
layersList = parameters.value( QStringLiteral( "LAYER" ) ).split( ',', QString::SkipEmptyParts );
layersList = layersList + parameters.value( QStringLiteral( "LAYERS" ) ).split( ',', QString::SkipEmptyParts );
stylesList = parameters.value( QStringLiteral( "STYLE" ) ).split( ',', QString::SkipEmptyParts );
stylesList = stylesList + parameters.value( QStringLiteral( "STYLES" ) ).split( ',', QString::SkipEmptyParts );
}
@ -179,7 +179,7 @@ namespace QgsWms
QgsRectangle parseBbox( const QString &bboxStr )
{
QStringList lst = bboxStr.split( QStringLiteral( "," ) );
QStringList lst = bboxStr.split( ',' );
if ( lst.count() != 4 )
return QgsRectangle();
@ -187,7 +187,7 @@ namespace QgsWms
bool ok;
for ( int i = 0; i < 4; i++ )
{
lst[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
lst[i].replace( ' ', '+' );
d[i] = lst[i].toDouble( &ok );
if ( !ok )
return QgsRectangle();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB