Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Server: fix loading of dependent layers when using the getFeature() f…
…unction (ticket #12090)
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
#include <QDomDocument> | ||
#include <QFileInfo> | ||
#include <QStringList> | ||
#include <QTextStream> | ||
#include <QUrl> | ||
|
||
QgsServerProjectParser::QgsServerProjectParser( QDomDocument* xmlDoc, const QString& filePath ) | ||
|
@@ -151,6 +152,7 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement& | |
|
||
addJoinLayersForElement( elem, useCache ); | ||
addValueRelationLayersForElement( elem, useCache ); | ||
addGetFeatureLayers( elem, useCache ); | ||
|
||
QDomElement dataSourceElem = elem.firstChildElement( "datasource" ); | ||
QString uri = dataSourceElem.text(); | ||
|
@@ -1422,3 +1424,39 @@ void QgsServerProjectParser::addValueRelationLayersForElement( const QDomElement | |
} | ||
} | ||
} | ||
|
||
void QgsServerProjectParser::addGetFeatureLayers( const QDomElement& layerElem, bool useCache ) const | ||
{ | ||
QString str; | ||
QTextStream stream( &str ); | ||
layerElem.save( stream, 2 ); | ||
|
||
QRegExp rx( "getFeature\\('([^']*)'" ); | ||
int idx = 0; | ||
while (( idx = rx.indexIn( str, idx ) ) != -1 ) | ||
{ | ||
QString name = rx.cap( 1 ); | ||
QgsMapLayer* ml = 0; | ||
QHash< QString, QDomElement >::const_iterator layerElemIt = mProjectLayerElementsById.find( name ); | ||
if ( layerElemIt != mProjectLayerElementsById.constEnd() ) | ||
{ | ||
ml = createLayerFromElement( layerElemIt.value() ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mhugent
Author
Contributor
|
||
} | ||
else | ||
{ | ||
layerElemIt = mProjectLayerElementsByName.find( name ); | ||
if ( layerElemIt != mProjectLayerElementsByName.constEnd() ) | ||
{ | ||
ml = createLayerFromElement( layerElemIt.value() ); | ||
} | ||
} | ||
|
||
if ( ml ) | ||
{ | ||
QgsMapLayerRegistry::instance()->addMapLayer( ml, false, false ); | ||
} | ||
idx += rx.matchedLength(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mhugent should this (and 1450) be passed "useCache" too?