|
28 | 28 | #include <QDomDocument>
|
29 | 29 | #include <QFileInfo>
|
30 | 30 | #include <QStringList>
|
| 31 | +#include <QTextStream> |
31 | 32 | #include <QUrl>
|
32 | 33 |
|
33 | 34 | QgsServerProjectParser::QgsServerProjectParser( QDomDocument* xmlDoc, const QString& filePath )
|
@@ -151,6 +152,7 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&
|
151 | 152 |
|
152 | 153 | addJoinLayersForElement( elem, useCache );
|
153 | 154 | addValueRelationLayersForElement( elem, useCache );
|
| 155 | + addGetFeatureLayers( elem, useCache ); |
154 | 156 |
|
155 | 157 | QDomElement dataSourceElem = elem.firstChildElement( "datasource" );
|
156 | 158 | QString uri = dataSourceElem.text();
|
@@ -1422,3 +1424,39 @@ void QgsServerProjectParser::addValueRelationLayersForElement( const QDomElement
|
1422 | 1424 | }
|
1423 | 1425 | }
|
1424 | 1426 | }
|
| 1427 | + |
| 1428 | +void QgsServerProjectParser::addGetFeatureLayers( const QDomElement& layerElem, bool useCache ) const |
| 1429 | +{ |
| 1430 | + QString str; |
| 1431 | + QTextStream stream( &str ); |
| 1432 | + layerElem.save( stream, 2 ); |
| 1433 | + |
| 1434 | + QRegExp rx( "getFeature\\('([^']*)'" ); |
| 1435 | + int idx = 0; |
| 1436 | + while (( idx = rx.indexIn( str, idx ) ) != -1 ) |
| 1437 | + { |
| 1438 | + QString name = rx.cap( 1 ); |
| 1439 | + QgsMapLayer* ml = 0; |
| 1440 | + QHash< QString, QDomElement >::const_iterator layerElemIt = mProjectLayerElementsById.find( name ); |
| 1441 | + if ( layerElemIt != mProjectLayerElementsById.constEnd() ) |
| 1442 | + { |
| 1443 | + ml = createLayerFromElement( layerElemIt.value() ); |
| 1444 | + } |
| 1445 | + else |
| 1446 | + { |
| 1447 | + layerElemIt = mProjectLayerElementsByName.find( name ); |
| 1448 | + if ( layerElemIt != mProjectLayerElementsByName.constEnd() ) |
| 1449 | + { |
| 1450 | + ml = createLayerFromElement( layerElemIt.value() ); |
| 1451 | + } |
| 1452 | + } |
| 1453 | + |
| 1454 | + if ( ml ) |
| 1455 | + { |
| 1456 | + QgsMapLayerRegistry::instance()->addMapLayer( ml, false, false ); |
| 1457 | + } |
| 1458 | + idx += rx.matchedLength(); |
| 1459 | + } |
| 1460 | +} |
| 1461 | + |
| 1462 | + |
0 commit comments