mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
Merge pull request #4486 from rldhont/server-wfs-refactoring
[Server] little WFS refactoring
This commit is contained in:
commit
1f3ff11b35
@ -154,7 +154,7 @@ QStringList QgsServerProjectUtils::wfsLayerIds( const QgsProject &project )
|
||||
return project.readListEntry( QStringLiteral( "WFSLayers" ), QStringLiteral( "/" ) );
|
||||
}
|
||||
|
||||
int QgsServerProjectUtils::wfsLayerPrecision( const QString &layerId, const QgsProject &project )
|
||||
int QgsServerProjectUtils::wfsLayerPrecision( const QgsProject &project, const QString &layerId )
|
||||
{
|
||||
return project.readNumEntry( QStringLiteral( "WFSLayersPrecision" ), "/" + layerId, 6 );
|
||||
}
|
||||
|
@ -185,7 +185,13 @@ namespace QgsServerProjectUtils
|
||||
*/
|
||||
SERVER_EXPORT QStringList wfsLayerIds( const QgsProject &project );
|
||||
|
||||
SERVER_EXPORT int wfsLayerPrecision( const QString &layerId, const QgsProject &project );
|
||||
/** Returns the Layer precision defined in a QGIS project for the WFS GetFeature.
|
||||
* @param project the QGIS project
|
||||
* @param layerId the layer id in the project
|
||||
* @return the layer precision for WFS GetFeature.
|
||||
*/
|
||||
|
||||
SERVER_EXPORT int wfsLayerPrecision( const QgsProject &project, const QString &layerId );
|
||||
|
||||
/** Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
|
||||
* @param project the QGIS project
|
||||
|
@ -68,79 +68,17 @@ namespace QgsWfs
|
||||
wfsCapabilitiesElement.setAttribute( QStringLiteral( "updateSequence" ), QStringLiteral( "0" ) );
|
||||
doc.appendChild( wfsCapabilitiesElement );
|
||||
|
||||
//configParser->serviceCapabilities( wfsCapabilitiesElement, doc );
|
||||
//INSERT Service
|
||||
//wfs:Service
|
||||
wfsCapabilitiesElement.appendChild( getServiceElement( doc, project ) );
|
||||
|
||||
//wfs:Capability element
|
||||
QDomElement capabilityElement = doc.createElement( QStringLiteral( "Capability" )/*wfs:Capability*/ );
|
||||
wfsCapabilitiesElement.appendChild( capabilityElement );
|
||||
|
||||
//wfs:Request element
|
||||
QDomElement requestElement = doc.createElement( QStringLiteral( "Request" )/*wfs:Request*/ );
|
||||
capabilityElement.appendChild( requestElement );
|
||||
//wfs:GetCapabilities
|
||||
QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral( "GetCapabilities" )/*wfs:GetCapabilities*/ );
|
||||
requestElement.appendChild( getCapabilitiesElement );
|
||||
|
||||
QDomElement dcpTypeElement = doc.createElement( QStringLiteral( "DCPType" )/*wfs:DCPType*/ );
|
||||
getCapabilitiesElement.appendChild( dcpTypeElement );
|
||||
QDomElement httpElement = doc.createElement( QStringLiteral( "HTTP" )/*wfs:HTTP*/ );
|
||||
dcpTypeElement.appendChild( httpElement );
|
||||
|
||||
//Prepare url
|
||||
QString hrefString = serviceUrl( request, project );
|
||||
|
||||
//only Get supported for the moment
|
||||
QDomElement getElement = doc.createElement( QStringLiteral( "Get" )/*wfs:Get*/ );
|
||||
httpElement.appendChild( getElement );
|
||||
getElement.setAttribute( QStringLiteral( "onlineResource" ), hrefString );
|
||||
QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
|
||||
|
||||
//wfs:DescribeFeatureType
|
||||
QDomElement describeFeatureTypeElement = doc.createElement( QStringLiteral( "DescribeFeatureType" )/*wfs:DescribeFeatureType*/ );
|
||||
requestElement.appendChild( describeFeatureTypeElement );
|
||||
QDomElement schemaDescriptionLanguageElement = doc.createElement( QStringLiteral( "SchemaDescriptionLanguage" )/*wfs:SchemaDescriptionLanguage*/ );
|
||||
describeFeatureTypeElement.appendChild( schemaDescriptionLanguageElement );
|
||||
QDomElement xmlSchemaElement = doc.createElement( QStringLiteral( "XMLSCHEMA" )/*wfs:XMLSCHEMA*/ );
|
||||
schemaDescriptionLanguageElement.appendChild( xmlSchemaElement );
|
||||
QDomElement describeFeatureTypeDhcTypeElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypeElement );
|
||||
QDomElement describeFeatureTypeDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
describeFeatureTypeDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypePostElement );
|
||||
|
||||
//wfs:GetFeature
|
||||
QDomElement getFeatureElement = doc.createElement( QStringLiteral( "GetFeature" )/*wfs:GetFeature*/ );
|
||||
requestElement.appendChild( getFeatureElement );
|
||||
QDomElement getFeatureFormatElement = doc.createElement( QStringLiteral( "ResultFormat" ) );/*wfs:ResultFormat*/
|
||||
getFeatureElement.appendChild( getFeatureFormatElement );
|
||||
QDomElement gmlFormatElement = doc.createElement( QStringLiteral( "GML2" ) );/*wfs:GML2*/
|
||||
getFeatureFormatElement.appendChild( gmlFormatElement );
|
||||
QDomElement gml3FormatElement = doc.createElement( QStringLiteral( "GML3" ) );/*wfs:GML3*/
|
||||
getFeatureFormatElement.appendChild( gml3FormatElement );
|
||||
QDomElement geojsonFormatElement = doc.createElement( QStringLiteral( "GeoJSON" ) );/*wfs:GeoJSON*/
|
||||
getFeatureFormatElement.appendChild( geojsonFormatElement );
|
||||
QDomElement getFeatureDhcTypeGetElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
getFeatureElement.appendChild( getFeatureDhcTypeGetElement );
|
||||
QDomElement getFeatureDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
getFeatureDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
getFeatureElement.appendChild( getFeatureDhcTypePostElement );
|
||||
|
||||
//wfs:Transaction
|
||||
QDomElement transactionElement = doc.createElement( QStringLiteral( "Transaction" )/*wfs:Transaction*/ );
|
||||
requestElement.appendChild( transactionElement );
|
||||
QDomElement transactionDhcTypeElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
transactionDhcTypeElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
transactionElement.appendChild( transactionDhcTypeElement );
|
||||
//wfs:Capability
|
||||
wfsCapabilitiesElement.appendChild( getCapabilityElement( doc, project, request ) );
|
||||
|
||||
//wfs:FeatureTypeList
|
||||
wfsCapabilitiesElement.appendChild( getFeatureTypeListElement( doc, serverIface, project ) );
|
||||
|
||||
/*
|
||||
* Adding ogc:Filter_Capabilities in capabilityElement
|
||||
* Adding ogc:Filter_Capabilities in wfsCapabilitiesElement
|
||||
*/
|
||||
//ogc:Filter_Capabilities element
|
||||
QDomElement filterCapabilitiesElement = doc.createElement( QStringLiteral( "ogc:Filter_Capabilities" )/*ogc:Filter_Capabilities*/ );
|
||||
@ -238,6 +176,74 @@ namespace QgsWfs
|
||||
|
||||
}
|
||||
|
||||
QDomElement getCapabilityElement( QDomDocument &doc, const QgsProject *project, const QgsServerRequest &request )
|
||||
{
|
||||
//wfs:Capability element
|
||||
QDomElement capabilityElement = doc.createElement( QStringLiteral( "Capability" )/*wfs:Capability*/ );
|
||||
|
||||
//wfs:Request element
|
||||
QDomElement requestElement = doc.createElement( QStringLiteral( "Request" )/*wfs:Request*/ );
|
||||
capabilityElement.appendChild( requestElement );
|
||||
//wfs:GetCapabilities
|
||||
QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral( "GetCapabilities" )/*wfs:GetCapabilities*/ );
|
||||
requestElement.appendChild( getCapabilitiesElement );
|
||||
|
||||
QDomElement dcpTypeElement = doc.createElement( QStringLiteral( "DCPType" )/*wfs:DCPType*/ );
|
||||
getCapabilitiesElement.appendChild( dcpTypeElement );
|
||||
QDomElement httpElement = doc.createElement( QStringLiteral( "HTTP" )/*wfs:HTTP*/ );
|
||||
dcpTypeElement.appendChild( httpElement );
|
||||
|
||||
//Prepare url
|
||||
QString hrefString = serviceUrl( request, project );
|
||||
|
||||
//only Get supported for the moment
|
||||
QDomElement getElement = doc.createElement( QStringLiteral( "Get" )/*wfs:Get*/ );
|
||||
httpElement.appendChild( getElement );
|
||||
getElement.setAttribute( QStringLiteral( "onlineResource" ), hrefString );
|
||||
QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
|
||||
|
||||
//wfs:DescribeFeatureType
|
||||
QDomElement describeFeatureTypeElement = doc.createElement( QStringLiteral( "DescribeFeatureType" )/*wfs:DescribeFeatureType*/ );
|
||||
requestElement.appendChild( describeFeatureTypeElement );
|
||||
QDomElement schemaDescriptionLanguageElement = doc.createElement( QStringLiteral( "SchemaDescriptionLanguage" )/*wfs:SchemaDescriptionLanguage*/ );
|
||||
describeFeatureTypeElement.appendChild( schemaDescriptionLanguageElement );
|
||||
QDomElement xmlSchemaElement = doc.createElement( QStringLiteral( "XMLSCHEMA" )/*wfs:XMLSCHEMA*/ );
|
||||
schemaDescriptionLanguageElement.appendChild( xmlSchemaElement );
|
||||
QDomElement describeFeatureTypeDhcTypeElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypeElement );
|
||||
QDomElement describeFeatureTypeDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
describeFeatureTypeDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypePostElement );
|
||||
|
||||
//wfs:GetFeature
|
||||
QDomElement getFeatureElement = doc.createElement( QStringLiteral( "GetFeature" )/*wfs:GetFeature*/ );
|
||||
requestElement.appendChild( getFeatureElement );
|
||||
QDomElement getFeatureFormatElement = doc.createElement( QStringLiteral( "ResultFormat" ) );/*wfs:ResultFormat*/
|
||||
getFeatureElement.appendChild( getFeatureFormatElement );
|
||||
QDomElement gmlFormatElement = doc.createElement( QStringLiteral( "GML2" ) );/*wfs:GML2*/
|
||||
getFeatureFormatElement.appendChild( gmlFormatElement );
|
||||
QDomElement gml3FormatElement = doc.createElement( QStringLiteral( "GML3" ) );/*wfs:GML3*/
|
||||
getFeatureFormatElement.appendChild( gml3FormatElement );
|
||||
QDomElement geojsonFormatElement = doc.createElement( QStringLiteral( "GeoJSON" ) );/*wfs:GeoJSON*/
|
||||
getFeatureFormatElement.appendChild( geojsonFormatElement );
|
||||
QDomElement getFeatureDhcTypeGetElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
getFeatureElement.appendChild( getFeatureDhcTypeGetElement );
|
||||
QDomElement getFeatureDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
getFeatureDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
getFeatureElement.appendChild( getFeatureDhcTypePostElement );
|
||||
|
||||
//wfs:Transaction
|
||||
QDomElement transactionElement = doc.createElement( QStringLiteral( "Transaction" )/*wfs:Transaction*/ );
|
||||
requestElement.appendChild( transactionElement );
|
||||
QDomElement transactionDhcTypeElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
|
||||
transactionDhcTypeElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
|
||||
transactionElement.appendChild( transactionDhcTypeElement );
|
||||
|
||||
return capabilityElement;
|
||||
}
|
||||
|
||||
QDomElement getFeatureTypeListElement( QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project )
|
||||
{
|
||||
QgsAccessControl *accessControl = serverIface->accessControls();
|
||||
|
@ -32,6 +32,11 @@ namespace QgsWfs
|
||||
*/
|
||||
QDomElement getFeatureTypeListElement( QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project );
|
||||
|
||||
/**
|
||||
* Create Capability element for get capabilities document
|
||||
*/
|
||||
QDomElement getCapabilityElement( QDomDocument &doc, const QgsProject *project, const QgsServerRequest &request );
|
||||
|
||||
/**
|
||||
* Create Service element for get capabilities document
|
||||
*/
|
||||
|
@ -282,7 +282,7 @@ namespace QgsWfs
|
||||
|
||||
if ( onlyOneLayer )
|
||||
{
|
||||
requestPrecision = QgsServerProjectUtils::wfsLayerPrecision( vlayer->id(), *project );
|
||||
requestPrecision = QgsServerProjectUtils::wfsLayerPrecision( *project, vlayer->id() );
|
||||
}
|
||||
|
||||
if ( onlyOneLayer && !featureRequest.filterRect().isEmpty() )
|
||||
@ -295,7 +295,7 @@ namespace QgsWfs
|
||||
featureRequest.setLimit( aRequest.maxFeatures + aRequest.startIndex - sentFeatures );
|
||||
}
|
||||
// specific layer precision
|
||||
int layerPrecision = QgsServerProjectUtils::wfsLayerPrecision( vlayer->id(), *project );
|
||||
int layerPrecision = QgsServerProjectUtils::wfsLayerPrecision( *project, vlayer->id() );
|
||||
// specific layer crs
|
||||
QgsCoordinateReferenceSystem layerCrs = vlayer->crs();
|
||||
//excluded attributes for this layer
|
||||
|
Loading…
x
Reference in New Issue
Block a user