Skip to content
Permalink
Browse files

WFS-T Apply axis inversion logic

  • Loading branch information
elpaso committed Oct 16, 2020
1 parent fd43194 commit 785854c8db581546d356b90c46441f5d7826af72
@@ -1173,7 +1173,8 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
return geometryToGML( geometry, doc, ( format == QLatin1String( "GML2" ) ) ? GML_2_1_2 : GML_3_2_1, QString(), false, QString(), precision );
}

QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocument &doc,
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry,
QDomDocument &doc,
GMLVersion gmlVersion,
const QString &srsName,
bool invertAxisOrientation,
@@ -376,7 +376,8 @@ bool QgsWFSDataSourceURI::hideDownloadProgressDialog() const

bool QgsWFSDataSourceURI::preferCoordinatesForWfst11() const
{
return mURI.hasParam( QgsWFSConstants::URI_PARAM_WFST_1_1_PREFER_COORDINATES );
return mURI.hasParam( QgsWFSConstants::URI_PARAM_WFST_1_1_PREFER_COORDINATES ) &&
mURI.param( QgsWFSConstants::URI_PARAM_WFST_1_1_PREFER_COORDINATES ).toUpper() == QLatin1String( "TRUE" );
}

QString QgsWFSDataSourceURI::build( const QString &baseUri,
@@ -113,7 +113,7 @@ class QgsWFSDataSourceURI
//! Whether to hide download progress dialog in QGIS main app. Defaults to false
bool hideDownloadProgressDialog() const;

//! Whether to use "ccordinates" instead of "pos" and "posList" for WFS-T 1.1 transactions (ESRI mapserver)
//! Whether to use "coordinates" instead of "pos" and "posList" for WFS-T 1.1 transactions (ESRI mapserver)
bool preferCoordinatesForWfst11() const;

//! Returns authorization parameters
@@ -787,6 +787,46 @@ void QgsWFSProvider::reloadProviderData()
mShared->invalidateCache();
}

QDomElement QgsWFSProvider::geometryElement( const QgsGeometry &geometry, QDomDocument &transactionDoc )
{
QDomElement gmlElem;

// Determine axis orientation and gml version
bool applyAxisInversion;
QgsOgcUtils::GMLVersion gmlVersion;

if ( mShared->mWFSVersion.startsWith( QLatin1String( "1.1" ) ) )
{
// WFS 1.1.0 uses preferably GML 3, but ESRI mapserver in 2020 doesn't like it so we stick to GML2
if ( ! mShared->mServerPrefersCoordinatesForTransactions_1_1 )
{
gmlVersion = QgsOgcUtils::GML_3_1_0;
}
else
{
gmlVersion = QgsOgcUtils::GML_2_1_2;
}
applyAxisInversion = ( crs().hasAxisInverted() && ! mShared->mURI.ignoreAxisOrientation() )
|| mShared->mURI.invertAxisOrientation();
}
else // 1.0
{
gmlVersion = QgsOgcUtils::GML_2_1_2;
applyAxisInversion = mShared->mURI.invertAxisOrientation();
}

gmlElem = QgsOgcUtils::geometryToGML(
geometry,
transactionDoc,
gmlVersion,
crs().authid(),
applyAxisInversion,
QString()
);

return gmlElem;
}

QgsWkbTypes::Type QgsWFSProvider::wkbType() const
{
return mShared->mWKBType;
@@ -877,19 +917,10 @@ bool QgsWFSProvider::addFeatures( QgsFeatureList &flist, Flags flags )
{
the_geom.convertToMultiType();
}
QDomElement gmlElem;
// WFS 1.1.0 uses preferably GML 3, but ESRI mapserver in 2020 doesn't like it so we stick to GML2
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) && ! mShared->mServerPrefersCoordinatesForTransactions_1_1 )
{
gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc, QLatin1String( "GML3" ) );
}
else
{
gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc, QLatin1String( "GML2" ) );
}
if ( !gmlElem.isNull() )

const QDomElement gmlElem { geometryElement( the_geom, transactionDoc ) };
if ( ! gmlElem.isNull() )
{
gmlElem.setAttribute( QStringLiteral( "srsName" ), crs().authid() );
geomElem.appendChild( gmlElem );
featureElem.appendChild( geomElem );
}
@@ -1054,18 +1085,9 @@ bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
nameElem.appendChild( nameText );
propertyElem.appendChild( nameElem );
QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Value" ) );
QDomElement gmlElem;
// WFS 1.1.0 uses preferably GML 3, but ESRI mapserver in 2020 doesn't like it so we stick to GML2
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) && ! mShared->mServerPrefersCoordinatesForTransactions_1_1 )
{
gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc, QLatin1String( "GML3" ) );
}
else
{
gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc, QLatin1String( "GML2" ) );
}
gmlElem.setAttribute( QStringLiteral( "srsName" ), crs().authid() );
valueElem.appendChild( gmlElem );

valueElem.appendChild( geometryElement( geomIt.value(), transactionDoc ) );

propertyElem.appendChild( valueElem );
updateElem.appendChild( propertyElem );

@@ -140,6 +140,11 @@ class QgsWFSProvider final: public QgsVectorDataProvider

friend class QgsWFSFeatureSource;

/**
* Create the geometry element
*/
QDomElement geometryElement( const QgsGeometry &geometry, QDomDocument &transactionDoc );

protected:

//! String used to define a subset of the layer
Binary file not shown.

0 comments on commit 785854c

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