Skip to content

Commit ab107d0

Browse files
authored
Merge pull request #5297 from dmarteau/wfs_1_1_0
[Server][FEATURE][needs-docs] Support WFS 1.1.0
2 parents db97e27 + 2f29e16 commit ab107d0

39 files changed

+4297
-719
lines changed

src/server/qgsrequesthandler.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,27 @@ void QgsRequestHandler::parseInput()
241241
setupParameters();
242242

243243
QDomElement docElem = doc.documentElement();
244-
if ( docElem.hasAttribute( QStringLiteral( "version" ) ) )
245-
{
246-
mRequest.setParameter( QStringLiteral( "VERSION" ), docElem.attribute( QStringLiteral( "version" ) ) );
247-
}
248-
if ( docElem.hasAttribute( QStringLiteral( "service" ) ) )
244+
// the document element tag name is the request
245+
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
246+
// loop through the attributes which are the parameters
247+
// excepting the attributes started by xmlns or xsi
248+
QDomNamedNodeMap map = docElem.attributes();
249+
for ( int i = 0 ; i < map.length() ; ++i )
249250
{
250-
mRequest.setParameter( QStringLiteral( "SERVICE" ), docElem.attribute( QStringLiteral( "service" ) ) );
251+
if ( map.item( i ).isNull() )
252+
continue;
253+
254+
const QDomNode attrNode = map.item( i );
255+
const QDomAttr attr = attrNode.toAttr();
256+
if ( attr.isNull() )
257+
continue;
258+
259+
const QString attrName = attr.name();
260+
if ( attrName.startsWith( "xmlns" ) || attrName.startsWith( "xsi:" ) )
261+
continue;
262+
263+
mRequest.setParameter( attrName.toUpper(), attr.value() );
251264
}
252-
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
253265
mRequest.setParameter( QStringLiteral( "REQUEST_BODY" ), inputString );
254266
}
255267
}

src/server/services/wfs/CMakeLists.txt

+12-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@ SET (wfs_SRCS
66
qgswfs.cpp
77
qgswfsutils.cpp
88
qgswfsgetcapabilities.cpp
9+
qgswfsgetcapabilities_1_0_0.cpp
910
qgswfsdescribefeaturetype.cpp
1011
qgswfsgetfeature.cpp
1112
qgswfstransaction.cpp
13+
qgswfstransaction_1_0_0.cpp
14+
qgswfsparameters.cpp
15+
)
16+
17+
SET (wfs_MOC_HDRS
18+
qgswfsparameters.h
1219
)
1320

1421
########################################################
1522
# Build
1623

17-
ADD_LIBRARY (wfs MODULE ${wfs_SRCS})
24+
QT5_WRAP_CPP(wfs_MOC_SRCS ${wfs_MOC_HDRS})
25+
26+
ADD_LIBRARY (wfs MODULE ${wfs_SRCS} ${wfs_MOC_SRCS} ${wfs_MOC_HDRS})
1827

1928

2029
INCLUDE_DIRECTORIES(SYSTEM
@@ -30,10 +39,10 @@ INCLUDE_DIRECTORIES(
3039
${CMAKE_BINARY_DIR}/src/analysis
3140
${CMAKE_BINARY_DIR}/src/server
3241
${CMAKE_CURRENT_BINARY_DIR}
33-
../../../core
42+
../../../core
3443
../../../core/dxf
3544
../../../core/expression
36-
../../../core/geometry
45+
../../../core/geometry
3746
../../../core/metadata
3847
../../../core/raster
3948
../../../core/symbology

src/server/services/wfs/qgswfs.cpp

+20-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
#include "qgsmodule.h"
2424
#include "qgswfsutils.h"
2525
#include "qgswfsgetcapabilities.h"
26+
#include "qgswfsgetcapabilities_1_0_0.h"
2627
#include "qgswfsgetfeature.h"
2728
#include "qgswfsdescribefeaturetype.h"
2829
#include "qgswfstransaction.h"
30+
#include "qgswfstransaction_1_0_0.h"
2931

3032
#define QSTR_COMPARE( str, lit )\
3133
(str.compare( QStringLiteral( lit ), Qt::CaseInsensitive ) == 0)
@@ -71,7 +73,15 @@ namespace QgsWfs
7173

7274
if ( QSTR_COMPARE( req, "GetCapabilities" ) )
7375
{
74-
writeGetCapabilities( mServerIface, project, versionString, request, response );
76+
// Supports WFS 1.0.0
77+
if ( QSTR_COMPARE( versionString, "1.0.0" ) )
78+
{
79+
v1_0_0::writeGetCapabilities( mServerIface, project, versionString, request, response );
80+
}
81+
else
82+
{
83+
writeGetCapabilities( mServerIface, project, versionString, request, response );
84+
}
7585
}
7686
else if ( QSTR_COMPARE( req, "GetFeature" ) )
7787
{
@@ -83,7 +93,15 @@ namespace QgsWfs
8393
}
8494
else if ( QSTR_COMPARE( req, "Transaction" ) )
8595
{
86-
writeTransaction( mServerIface, project, versionString, request, response );
96+
// Supports WFS 1.0.0
97+
if ( QSTR_COMPARE( versionString, "1.0.0" ) )
98+
{
99+
v1_0_0::writeTransaction( mServerIface, project, versionString, request, response );
100+
}
101+
else
102+
{
103+
writeTransaction( mServerIface, project, versionString, request, response );
104+
}
87105
}
88106
else
89107
{

src/server/services/wfs/qgswfsdescribefeaturetype.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgswfsutils.h"
2323
#include "qgsserverprojectutils.h"
2424
#include "qgswfsdescribefeaturetype.h"
25+
#include "qgswfsparameters.h"
2526

2627
#include "qgsproject.h"
2728
#include "qgsexception.h"
@@ -53,6 +54,13 @@ namespace QgsWfs
5354
QDomDocument doc;
5455

5556
QgsServerRequest::Parameters parameters = request.parameters();
57+
QgsWfsParameters wfsParameters( parameters );
58+
QgsWfsParameters::Format oFormat = wfsParameters.outputFormat();
59+
60+
// test oFormat
61+
if ( oFormat == QgsWfsParameters::Format::NONE )
62+
throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ),
63+
"OUTPUTFORMAT " + wfsParameters.outputFormatAsString() + "is not supported" );
5664

5765
QgsAccessControl *accessControl = serverIface->accessControls();
5866

@@ -71,7 +79,10 @@ namespace QgsWfs
7179
//xsd:import
7280
QDomElement importElement = doc.createElement( QStringLiteral( "import" )/*xsd:import*/ );
7381
importElement.setAttribute( QStringLiteral( "namespace" ), GML_NAMESPACE );
74-
importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/2.1.2/feature.xsd" ) );
82+
if ( oFormat == QgsWfsParameters::Format::GML2 )
83+
importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/2.1.2/feature.xsd" ) );
84+
else if ( oFormat == QgsWfsParameters::Format::GML3 )
85+
importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" ) );
7586
schemaElement.appendChild( importElement );
7687

7788
QStringList typeNameList;

0 commit comments

Comments
 (0)