Skip to content
Permalink
Browse files

[Server][WFS] check const and indetation

  • Loading branch information
rldhont committed Oct 12, 2017
1 parent 1558b03 commit 2f29e162d155c080cdfd5d045f2f3cf820c989e3
@@ -251,12 +251,12 @@ void QgsRequestHandler::parseInput()
if ( map.item( i ).isNull() )
continue;

QDomNode attrNode = map.item( i );
QDomAttr attr = attrNode.toAttr();
const QDomNode attrNode = map.item( i );
const QDomAttr attr = attrNode.toAttr();
if ( attr.isNull() )
continue;

QString attrName = attr.name();
const QString attrName = attr.name();
if ( attrName.startsWith( "xmlns" ) || attrName.startsWith( "xsi:" ) )
continue;

@@ -166,7 +166,7 @@ namespace QgsWfs
if ( !keywords.isEmpty() && !keywords.join( QStringLiteral( ", " ) ).isEmpty() )
{
QDomElement keywordsElem = doc.createElement( QStringLiteral( "ows:Keywords" ) );
for ( QString keyword : keywords )
for ( const QString &keyword : keywords )
{
if ( !keyword.isEmpty() )
{
@@ -193,7 +193,7 @@ namespace QgsWfs

QDomElement feesElem = doc.createElement( QStringLiteral( "ows:Fees" ) );
QDomText feesText = doc.createTextNode( "None" );
QString fees = QgsServerProjectUtils::owsServiceFees( *project );
const QString fees = QgsServerProjectUtils::owsServiceFees( *project );
if ( !fees.isEmpty() )
{
feesText = doc.createTextNode( fees );
@@ -202,7 +202,7 @@ namespace QgsWfs
serviceElem.appendChild( feesElem );

QDomElement accessConstraintsElem = doc.createElement( QStringLiteral( "ows:AccessConstraints" ) );
QString accessConstraints = QgsServerProjectUtils::owsServiceAccessConstraints( *project );
const QString accessConstraints = QgsServerProjectUtils::owsServiceAccessConstraints( *project );
QDomText accessConstraintsText = doc.createTextNode( "None" );
if ( !accessConstraints.isEmpty() )
{
@@ -221,7 +221,7 @@ namespace QgsWfs
QDomElement serviceElem = doc.createElement( QStringLiteral( "ows:ServiceProvider" ) );

//ProviderName
QString contactOrganization = QgsServerProjectUtils::owsServiceContactOrganization( *project );
const QString contactOrganization = QgsServerProjectUtils::owsServiceContactOrganization( *project );
if ( !contactOrganization.isEmpty() )
{
QDomElement providerNameElem = doc.createElement( QStringLiteral( "ows:ProviderName" ) );
@@ -230,8 +230,8 @@ namespace QgsWfs
serviceElem.appendChild( providerNameElem );
}

QString contactPerson = QgsServerProjectUtils::owsServiceContactPerson( *project );
QString contactPosition = QgsServerProjectUtils::owsServiceContactPosition( *project );
const QString contactPerson = QgsServerProjectUtils::owsServiceContactPerson( *project );
const QString contactPosition = QgsServerProjectUtils::owsServiceContactPosition( *project );
if ( !contactPerson.isEmpty() ||
!contactPosition.isEmpty() )
{
@@ -254,9 +254,9 @@ namespace QgsWfs
serviceContactElem.appendChild( positionNameElem );
}

QString contactMail = QgsServerProjectUtils::owsServiceContactMail( *project );
QString contactPhone = QgsServerProjectUtils::owsServiceContactPhone( *project );
QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
const QString contactMail = QgsServerProjectUtils::owsServiceContactMail( *project );
const QString contactPhone = QgsServerProjectUtils::owsServiceContactPhone( *project );
const QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
if ( !contactMail.isEmpty() ||
!contactPhone.isEmpty() ||
!onlineResource.isEmpty() )
@@ -414,13 +414,13 @@ namespace QgsWfs
QDomElement queryElement = doc.createElement( QStringLiteral( "Query" )/*wfs:Query*/ );
operationsElement.appendChild( queryElement );

QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project );
QStringList wfstUpdateLayersId = QgsServerProjectUtils::wfstUpdateLayerIds( *project );
QStringList wfstInsertLayersId = QgsServerProjectUtils::wfstInsertLayerIds( *project );
QStringList wfstDeleteLayersId = QgsServerProjectUtils::wfstDeleteLayerIds( *project );
for ( int i = 0; i < wfsLayerIds.size(); ++i )
const QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project );
const QStringList wfstUpdateLayersId = QgsServerProjectUtils::wfstUpdateLayerIds( *project );
const QStringList wfstInsertLayersId = QgsServerProjectUtils::wfstInsertLayerIds( *project );
const QStringList wfstDeleteLayersId = QgsServerProjectUtils::wfstDeleteLayerIds( *project );
for ( const QString &wfsLayerId : wfsLayerIds )
{
QgsMapLayer *layer = project->mapLayer( wfsLayerIds.at( i ) );
QgsMapLayer *layer = project->mapLayer( wfsLayerId );
if ( layer->type() != QgsMapLayer::LayerType::VectorLayer )
{
continue;
@@ -482,14 +482,14 @@ namespace QgsWfs
}

//create DefaultSRS element
QString defaultSrs = layer->crs().authid();
const QString defaultSrs = layer->crs().authid();
QDomElement srsElem = doc.createElement( QStringLiteral( "DefaultSRS" ) );
QDomText srsText = doc.createTextNode( defaultSrs );
srsElem.appendChild( srsText );
layerElem.appendChild( srsElem );

//create OtherSRS elements
QStringList outputCrsList = QgsServerProjectUtils::wmsOutputCrsList( *project );
const QStringList outputCrsList = QgsServerProjectUtils::wmsOutputCrsList( *project );
for ( const QString &crs : outputCrsList )
{
if ( crs == defaultSrs )
@@ -120,7 +120,7 @@ namespace QgsWfs
nameElem.appendChild( nameText );
serviceElem.appendChild( nameElem );

QString title = QgsServerProjectUtils::owsServiceTitle( *project );
const QString title = QgsServerProjectUtils::owsServiceTitle( *project );
if ( !title.isEmpty() )
{
QDomElement titleElem = doc.createElement( QStringLiteral( "Title" ) );
@@ -129,7 +129,7 @@ namespace QgsWfs
serviceElem.appendChild( titleElem );
}

QString abstract = QgsServerProjectUtils::owsServiceAbstract( *project );
const QString abstract = QgsServerProjectUtils::owsServiceAbstract( *project );
if ( !abstract.isEmpty() )
{
QDomElement abstractElem = doc.createElement( QStringLiteral( "Abstract" ) );
@@ -138,7 +138,7 @@ namespace QgsWfs
serviceElem.appendChild( abstractElem );
}

QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
const QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
if ( !keywords.isEmpty() && !keywords.join( QStringLiteral( ", " ) ).isEmpty() )
{
QDomElement keywordsElem = doc.createElement( QStringLiteral( "Keywords" ) );
@@ -148,15 +148,15 @@ namespace QgsWfs
}

QDomElement onlineResourceElem = doc.createElement( QStringLiteral( "OnlineResource" ) );
QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
const QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
if ( !onlineResource.isEmpty() )
{
QDomText onlineResourceText = doc.createTextNode( onlineResource );
onlineResourceElem.appendChild( onlineResourceText );
}
serviceElem.appendChild( onlineResourceElem );

QString fees = QgsServerProjectUtils::owsServiceFees( *project );
const QString fees = QgsServerProjectUtils::owsServiceFees( *project );
if ( !fees.isEmpty() )
{
QDomElement feesElem = doc.createElement( QStringLiteral( "Fees" ) );
@@ -165,7 +165,7 @@ namespace QgsWfs
serviceElem.appendChild( feesElem );
}

QString accessConstraints = QgsServerProjectUtils::owsServiceAccessConstraints( *project );
const QString accessConstraints = QgsServerProjectUtils::owsServiceAccessConstraints( *project );
if ( !accessConstraints.isEmpty() )
{
QDomElement accessConstraintsElem = doc.createElement( QStringLiteral( "AccessConstraints" ) );
@@ -259,13 +259,13 @@ namespace QgsWfs
QDomElement queryElement = doc.createElement( QStringLiteral( "Query" )/*wfs:Query*/ );
operationsElement.appendChild( queryElement );

QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project );
QStringList wfstUpdateLayersId = QgsServerProjectUtils::wfstUpdateLayerIds( *project );
QStringList wfstInsertLayersId = QgsServerProjectUtils::wfstInsertLayerIds( *project );
QStringList wfstDeleteLayersId = QgsServerProjectUtils::wfstDeleteLayerIds( *project );
for ( int i = 0; i < wfsLayerIds.size(); ++i )
const QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project );
const QStringList wfstUpdateLayersId = QgsServerProjectUtils::wfstUpdateLayerIds( *project );
const QStringList wfstInsertLayersId = QgsServerProjectUtils::wfstInsertLayerIds( *project );
const QStringList wfstDeleteLayersId = QgsServerProjectUtils::wfstDeleteLayerIds( *project );
for ( const QString &wfsLayerId : wfsLayerIds )
{
QgsMapLayer *layer = project->mapLayer( wfsLayerIds.at( i ) );
QgsMapLayer *layer = project->mapLayer( wfsLayerId );
if ( layer->type() != QgsMapLayer::LayerType::VectorLayer )
{
continue;
@@ -50,11 +50,13 @@ namespace QgsWfs
QString geometryName;
};

/** Add SortBy element to featureRequest
/**
* Add SortBy element to featureRequest
*/
void parseSortByElement( QDomElement &sortByElem, QgsFeatureRequest &featureRequest, const QString &typeName );

/** Transform Query element to getFeatureQuery
/**
* Transform Query element to getFeatureQuery
*/
getFeatureQuery parseQueryElement( QDomElement &queryElem );

@@ -475,4 +475,4 @@ namespace QgsWfs
{
throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ), msg );
}
}
}
@@ -123,7 +123,8 @@ namespace QgsWfs
*/
QgsProjectVersion versionAsNumber() const;

/** Returns OUTPUTFORMAT parameter as a string.
/**
* Returns OUTPUTFORMAT parameter as a string.
* \returns outputFormat parameter as string
*/
QString outputFormatAsString() const;
@@ -135,91 +136,107 @@ namespace QgsWfs
*/
Format outputFormat() const;

/** Returns RESULTTYPE parameter as a string.
/**
* Returns RESULTTYPE parameter as a string.
* \returns resultType parameter as string
*/
QString resultTypeAsString() const;

/** Returns resultType. If the RESULTTYPE parameter is not used, then the
/**
* Returns resultType. If the RESULTTYPE parameter is not used, then the
* default value is RESULTS.
* \returns resultType
*/
ResultType resultType() const;

/** Returns PROPERTYNAME parameter as list.
/**
* Returns PROPERTYNAME parameter as list.
* \returns propertyName parameter as list
*/
QStringList propertyNames() const;

/** Returns MAXFEATURES parameter as a string.
/**
* Returns MAXFEATURES parameter as a string.
* \returns maxFeatures parameter as string
*/
QString maxFeatures() const;

/** Returns MAXFEATURES parameter as an int or its default value if not
/**
* Returns MAXFEATURES parameter as an int or its default value if not
* defined. An exception is raised if I is defined and cannot be
* converted.
* \returns maxFeatures parameter
* \throws QgsBadRequestException
*/
int maxFeaturesAsInt() const;

/** Returns STARTINDEX parameter as a string.
/**
* Returns STARTINDEX parameter as a string.
* \returns startIndex parameter as string
*/
QString startIndex() const;

/** Returns STARTINDEX parameter as an int or its default value if not
/**
* Returns STARTINDEX parameter as an int or its default value if not
* defined. An exception is raised if I is defined and cannot be
* converted.
* \returns startIndex parameter
* \throws QgsBadRequestException
*/
int startIndexAsInt() const;

/** Returns SRSNAME parameter as a string.
/**
* Returns SRSNAME parameter as a string.
* \returns srsName parameter as string
*/
QString srsName() const;

/** Returns TYPENAME parameter as list.
/**
* Returns TYPENAME parameter as list.
* \returns typeName parameter as list
*/
QStringList typeNames() const;

/** Returns FEATUREID parameter as list.
/**
* Returns FEATUREID parameter as list.
* \returns featureId parameter as list
*/
QStringList featureIds() const;

/** Returns FILTER parameter as list.
/**
* Returns FILTER parameter as list.
* \returns filter parameter as list
*/
QStringList filters() const;

/** Returns BBOX if defined or an empty string.
/**
* Returns BBOX if defined or an empty string.
* \returns bbox parameter
*/
QString bbox() const;

/** Returns BBOX as a rectangle if defined and valid. An exception is
/**
* Returns BBOX as a rectangle if defined and valid. An exception is
* raised if the BBOX string cannot be converted into a rectangle.
* \returns bbox as rectangle
* \throws QgsBadRequestException
*/
QgsRectangle bboxAsRectangle() const;

/** Returns SORTBY parameter as list.
/**
* Returns SORTBY parameter as list.
* \returns sortBy parameter as list
*/
QStringList sortBy() const;

/** Returns EXP_FILTER parameter as list.
/**
* Returns EXP_FILTER parameter as list.
* \returns expFilters parameter as list
*/
QStringList expFilters() const;

/** Returns GEOMETRYNAME parameter as a string.
/**
* Returns GEOMETRYNAME parameter as a string.
* \returns geometryName parameter as string
*/
QString geometryNameAsString() const;
@@ -72,7 +72,8 @@ namespace QgsWfs
{}
};

/** \ingroup server
/**
* \ingroup server
* \class QgsBadRequestException
* \brief Exception thrown in case of malformed request
*/
@@ -81,29 +81,35 @@ namespace QgsWfs
QList< transactionDelete > deletes;
};

/** Transform Insert element to transactionInsert
/**
* Transform Insert element to transactionInsert
*/
transactionInsert parseInsertActionElement( QDomElement &actionElem );

/** Transform Update element to transactionUpdate
/**
* Transform Update element to transactionUpdate
*/
transactionUpdate parseUpdateActionElement( QDomElement &actionElem );

/** Transform Delete element to transactionDelete
/**
* Transform Delete element to transactionDelete
*/
transactionDelete parseDeleteActionElement( QDomElement &actionElem );

/** Transform RequestBody root element to getFeatureRequest
/**
* Transform RequestBody root element to getFeatureRequest
*/
transactionRequest parseTransactionRequestBody( QDomElement &docElem );

transactionRequest parseTransactionParameters( QgsServerRequest::Parameters parameters );

/** Transform GML feature nodes to features
/**
* Transform GML feature nodes to features
*/
QgsFeatureList featuresFromGML( QDomNodeList featureNodeList, QgsVectorDataProvider *provider );

/** Perform the transaction
/**
* Perform the transaction
*/
void performTransaction( transactionRequest &aRequest, QgsServerInterface *serverIface, const QgsProject *project );

0 comments on commit 2f29e16

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