Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Server][WFS] check const and indetation
  • Loading branch information
rldhont committed Oct 12, 2017
1 parent 1558b03 commit 2f29e16
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 59 deletions.
6 changes: 3 additions & 3 deletions src/server/qgsrequesthandler.cpp
Expand Up @@ -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;

Expand Down
34 changes: 17 additions & 17 deletions src/server/services/wfs/qgswfsgetcapabilities.cpp
Expand Up @@ -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() )
{
Expand All @@ -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 );
Expand All @@ -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() )
{
Expand All @@ -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" ) );
Expand All @@ -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() )
{
Expand All @@ -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() )
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down
24 changes: 12 additions & 12 deletions src/server/services/wfs/qgswfsgetcapabilities_1_0_0.cpp
Expand Up @@ -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" ) );
Expand All @@ -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" ) );
Expand All @@ -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" ) );
Expand All @@ -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" ) );
Expand All @@ -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" ) );
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/server/services/wfs/qgswfsgetfeature.h
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wfs/qgswfsparameters.cpp
Expand Up @@ -475,4 +475,4 @@ namespace QgsWfs
{
throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ), msg );
}
}
}
51 changes: 34 additions & 17 deletions src/server/services/wfs/qgswfsparameters.h
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/server/services/wfs/qgswfsserviceexception.h
Expand Up @@ -72,7 +72,8 @@ namespace QgsWfs
{}
};

/** \ingroup server
/**
* \ingroup server
* \class QgsBadRequestException
* \brief Exception thrown in case of malformed request
*/
Expand Down
18 changes: 12 additions & 6 deletions src/server/services/wfs/qgswfstransaction_1_0_0.h
Expand Up @@ -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 );

Expand Down

0 comments on commit 2f29e16

Please sign in to comment.