Skip to content
Permalink
Browse files

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

[Server] bulk enhancements: string, list and exceptions
  • Loading branch information
rldhont committed Jun 6, 2017
2 parents 38d905f + ad14373 commit dbedd7e190ebd4f4d022854f7dc4cf2eab9c6090
@@ -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;
@@ -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();
}
@@ -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 ) )
{
@@ -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,15 +260,15 @@ namespace QgsWcs

QgsRectangle parseBbox( const QString &bboxStr )
{
QStringList lst = bboxStr.split( QStringLiteral( "," ) );
QStringList lst = bboxStr.split( ',' );
if ( lst.count() != 4 )
return QgsRectangle();

double d[4];
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();
@@ -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*/ );
@@ -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 );
@@ -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() )
{
@@ -85,7 +85,7 @@ namespace QgsWfs
fids.insert( fid.toInt() );
}

if ( fids.size() > 0 )
if ( !fids.isEmpty() )
{
request.setFilterFids( fids );
}
@@ -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

0 comments on commit dbedd7e

Please sign in to comment.
You can’t perform that action at this time.