Skip to content

Commit

Permalink
Merge pull request #5297 from dmarteau/wfs_1_1_0
Browse files Browse the repository at this point in the history
[Server][FEATURE][needs-docs] Support WFS 1.1.0
  • Loading branch information
rldhont committed Oct 17, 2017
2 parents db97e27 + 2f29e16 commit ab107d0
Show file tree
Hide file tree
Showing 39 changed files with 4,297 additions and 719 deletions.
26 changes: 19 additions & 7 deletions src/server/qgsrequesthandler.cpp
Expand Up @@ -241,15 +241,27 @@ void QgsRequestHandler::parseInput()
setupParameters();

QDomElement docElem = doc.documentElement();
if ( docElem.hasAttribute( QStringLiteral( "version" ) ) )
{
mRequest.setParameter( QStringLiteral( "VERSION" ), docElem.attribute( QStringLiteral( "version" ) ) );
}
if ( docElem.hasAttribute( QStringLiteral( "service" ) ) )
// the document element tag name is the request
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
// loop through the attributes which are the parameters
// excepting the attributes started by xmlns or xsi
QDomNamedNodeMap map = docElem.attributes();
for ( int i = 0 ; i < map.length() ; ++i )
{
mRequest.setParameter( QStringLiteral( "SERVICE" ), docElem.attribute( QStringLiteral( "service" ) ) );
if ( map.item( i ).isNull() )
continue;

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

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

mRequest.setParameter( attrName.toUpper(), attr.value() );
}
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
mRequest.setParameter( QStringLiteral( "REQUEST_BODY" ), inputString );
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/server/services/wfs/CMakeLists.txt
Expand Up @@ -6,15 +6,24 @@ SET (wfs_SRCS
qgswfs.cpp
qgswfsutils.cpp
qgswfsgetcapabilities.cpp
qgswfsgetcapabilities_1_0_0.cpp
qgswfsdescribefeaturetype.cpp
qgswfsgetfeature.cpp
qgswfstransaction.cpp
qgswfstransaction_1_0_0.cpp
qgswfsparameters.cpp
)

SET (wfs_MOC_HDRS
qgswfsparameters.h
)

########################################################
# Build

ADD_LIBRARY (wfs MODULE ${wfs_SRCS})
QT5_WRAP_CPP(wfs_MOC_SRCS ${wfs_MOC_HDRS})

ADD_LIBRARY (wfs MODULE ${wfs_SRCS} ${wfs_MOC_SRCS} ${wfs_MOC_HDRS})


INCLUDE_DIRECTORIES(SYSTEM
Expand All @@ -30,10 +39,10 @@ INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}/src/analysis
${CMAKE_BINARY_DIR}/src/server
${CMAKE_CURRENT_BINARY_DIR}
../../../core
../../../core
../../../core/dxf
../../../core/expression
../../../core/geometry
../../../core/geometry
../../../core/metadata
../../../core/raster
../../../core/symbology
Expand Down
22 changes: 20 additions & 2 deletions src/server/services/wfs/qgswfs.cpp
Expand Up @@ -23,9 +23,11 @@
#include "qgsmodule.h"
#include "qgswfsutils.h"
#include "qgswfsgetcapabilities.h"
#include "qgswfsgetcapabilities_1_0_0.h"
#include "qgswfsgetfeature.h"
#include "qgswfsdescribefeaturetype.h"
#include "qgswfstransaction.h"
#include "qgswfstransaction_1_0_0.h"

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

if ( QSTR_COMPARE( req, "GetCapabilities" ) )
{
writeGetCapabilities( mServerIface, project, versionString, request, response );
// Supports WFS 1.0.0
if ( QSTR_COMPARE( versionString, "1.0.0" ) )
{
v1_0_0::writeGetCapabilities( mServerIface, project, versionString, request, response );
}
else
{
writeGetCapabilities( mServerIface, project, versionString, request, response );
}
}
else if ( QSTR_COMPARE( req, "GetFeature" ) )
{
Expand All @@ -83,7 +93,15 @@ namespace QgsWfs
}
else if ( QSTR_COMPARE( req, "Transaction" ) )
{
writeTransaction( mServerIface, project, versionString, request, response );
// Supports WFS 1.0.0
if ( QSTR_COMPARE( versionString, "1.0.0" ) )
{
v1_0_0::writeTransaction( mServerIface, project, versionString, request, response );
}
else
{
writeTransaction( mServerIface, project, versionString, request, response );
}
}
else
{
Expand Down
13 changes: 12 additions & 1 deletion src/server/services/wfs/qgswfsdescribefeaturetype.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgswfsutils.h"
#include "qgsserverprojectutils.h"
#include "qgswfsdescribefeaturetype.h"
#include "qgswfsparameters.h"

#include "qgsproject.h"
#include "qgsexception.h"
Expand Down Expand Up @@ -53,6 +54,13 @@ namespace QgsWfs
QDomDocument doc;

QgsServerRequest::Parameters parameters = request.parameters();
QgsWfsParameters wfsParameters( parameters );
QgsWfsParameters::Format oFormat = wfsParameters.outputFormat();

// test oFormat
if ( oFormat == QgsWfsParameters::Format::NONE )
throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ),
"OUTPUTFORMAT " + wfsParameters.outputFormatAsString() + "is not supported" );

QgsAccessControl *accessControl = serverIface->accessControls();

Expand All @@ -71,7 +79,10 @@ namespace QgsWfs
//xsd:import
QDomElement importElement = doc.createElement( QStringLiteral( "import" )/*xsd:import*/ );
importElement.setAttribute( QStringLiteral( "namespace" ), GML_NAMESPACE );
importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/2.1.2/feature.xsd" ) );
if ( oFormat == QgsWfsParameters::Format::GML2 )
importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/2.1.2/feature.xsd" ) );
else if ( oFormat == QgsWfsParameters::Format::GML3 )
importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" ) );
schemaElement.appendChild( importElement );

QStringList typeNameList;
Expand Down

0 comments on commit ab107d0

Please sign in to comment.