Skip to content

Commit

Permalink
[BUGFIX][Server] Enhance cleaning propertyname and searching by prope…
Browse files Browse the repository at this point in the history
…rtyname
  • Loading branch information
rldhont committed Apr 3, 2018
1 parent e7d587f commit 24737be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/server/services/wfs/qgswfsdescribefeaturetype.cpp
Expand Up @@ -263,7 +263,7 @@ namespace QgsWfs

//xsd:element
QDomElement attElem = doc.createElement( QStringLiteral( "element" )/*xsd:element*/ );
attElem.setAttribute( QStringLiteral( "name" ), attributeName.replace( ' ', '_' ) );
attElem.setAttribute( QStringLiteral( "name" ), attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
QVariant::Type attributeType = fields.at( idx ).type();
if ( attributeType == QVariant::Int )
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "integer" ) );
Expand Down
12 changes: 9 additions & 3 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -250,15 +250,21 @@ namespace QgsWfs
QList<int> idxList;
// build corresponding propertyname
QList<QString> propertynames;
QList<QString> fieldnames;
for ( int idx = 0; idx < fields.count(); ++idx )
{
propertynames.append( fields.field( idx ).name().replace( ' ', '_' ) );
fieldnames.append( fields[idx].name() );
propertynames.append( fields.field( idx ).name().replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
}
QString fieldName;
for ( plstIt = propertyList.begin(); plstIt != propertyList.end(); ++plstIt )
{
fieldName = *plstIt;
int fieldNameIdx = propertynames.indexOf( fieldName );
if ( fieldNameIdx == -1 )
{
fieldNameIdx = fieldnames.indexOf( fieldName );
}
if ( fieldNameIdx > -1 )
{
idxList.append( fieldNameIdx );
Expand Down Expand Up @@ -1319,7 +1325,7 @@ namespace QgsWfs
}
QString attributeName = fields.at( idx ).name();

QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ) );
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
Expand Down Expand Up @@ -1416,7 +1422,7 @@ namespace QgsWfs
}
QString attributeName = fields.at( idx ).name();

QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ) );
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
Expand Down
3 changes: 3 additions & 0 deletions src/server/services/wfs/qgswfsutils.h
Expand Up @@ -58,6 +58,9 @@ namespace QgsWfs
const QString OGC_NAMESPACE = QStringLiteral( "http://www.opengis.net/ogc" );
const QString QGS_NAMESPACE = QStringLiteral( "http://www.qgis.org/gml" );

// Define clean tagName regExp
const QRegExp cleanTagNameRegExp( "(?![\\w\\d\\.-])." );

This comment has been minimized.

Copy link
@elpaso

elpaso Apr 3, 2018

Contributor

I think this should be uppercase (and probably static).


} // namespace QgsWfs

#endif
Expand Down

9 comments on commit 24737be

@haubourg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rldhont Hi, good practices are to use PR's to have a review process. Any objection to follow that ?
Cheers
Régis

@rldhont
Copy link
Contributor Author

@rldhont rldhont commented on 24737be Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haubourg no objection, but it's hard to maintain 2 and 3, the code is not the same!

@haubourg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to see the relation between PR process and code complexity ..

@rldhont
Copy link
Contributor Author

@rldhont rldhont commented on 24737be Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I have to open a PR for each branch ?
An if it's necessary to open a PR for bugfix ?
The code is not the same in the 4 branches:

@DelazJ
Copy link
Contributor

@DelazJ DelazJ commented on 24737be Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-2_14 b7c566b

I think you can leave 2.14. It is no more released since 3.0 release, as far as I know...

@rldhont
Copy link
Contributor Author

@rldhont rldhont commented on 24737be Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DelazJ the transition to QGIS Server 2.18 is not so easy because of some issues...

@Gustry
Copy link
Contributor

@Gustry Gustry commented on 24737be Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you still releasing 2.14 on your side @rldhont? No more release of 2.14 since January according to the roadmap: https://www.qgis.org/ca/site/getinvolved/development/roadmap.html#release-schedule

@rldhont
Copy link
Contributor Author

@rldhont rldhont commented on 24737be Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gustry yes, some customers continue to use it with their own package for QGIS Server.

@haubourg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I must have missed something, that PR points to master. I was expecting a PR for master. Backports of unmaintained branch can probably be pushed directly.

Please sign in to comment.