Пример #1
0
void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
{
  QList<QDomElement> layerElems = projectLayerElements();

  QStringList nonIdentifiableLayers = identifyDisabledLayers();

  if ( layerElems.size() < 1 )
  {
    return;
  }

  QMap<QString, QgsMapLayer *> layerMap;

  QList<QDomElement>::const_iterator layerIt = layerElems.constBegin();
  for ( ; layerIt != layerElems.constEnd(); ++layerIt )
  {
    QgsMapLayer *layer = createLayerFromElement( *layerIt );
    if ( layer )
    {
      QgsDebugMsg( QString( "add layer %1 to map" ).arg( layer->id() ) );
      layerMap.insert( layer->id(), layer );
    }
#if QGSMSDEBUG
    else
    {
      QString buf;
      QTextStream s( &buf );
      layerIt->save( s, 0 );
      QgsDebugMsg( QString( "layer %1 not found" ).arg( buf ) );
    }
#endif
  }

  //According to the WMS spec, there can be only one toplevel layer.
  //So we create an artificial one here to be in accordance with the schema
  QString projTitle = projectTitle();
  QDomElement layerParentElem = doc.createElement( "Layer" );
  layerParentElem.setAttribute( "queryable", "1" );
  QDomElement layerParentNameElem = doc.createElement( "Name" );
  QDomText layerParentNameText = doc.createTextNode( projTitle );
  layerParentNameElem.appendChild( layerParentNameText );
  layerParentElem.appendChild( layerParentNameElem );
  QDomElement layerParentTitleElem = doc.createElement( "Title" );
  QDomText layerParentTitleText = doc.createTextNode( projTitle );
  layerParentTitleElem.appendChild( layerParentTitleText );
  layerParentElem.appendChild( layerParentTitleElem );

  QDomElement legendElem = mXMLDoc->documentElement().firstChildElement( "legend" );

  addLayers( doc, layerParentElem, legendElem, layerMap, nonIdentifiableLayers );

  parentElement.appendChild( layerParentElem );
  combineExtentAndCrsOfGroupChildren( layerParentElem, doc );
}
Пример #2
0
void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
{
  QStringList nonIdentifiableLayers = identifyDisabledLayers();
  QMap<QString, QgsMapLayer *> layerMap;

  foreach ( const QDomElement &elem, mProjectLayerElements )
  {
    QgsMapLayer *layer = createLayerFromElement( elem );
    if ( layer )
    {
      QgsDebugMsg( QString( "add layer %1 to map" ).arg( layer->id() ) );
      layerMap.insert( layer->id(), layer );
    }
#if QGSMSDEBUG
    else
    {
      QString buf;
      QTextStream s( &buf );
      elem.save( s, 0 );
      QgsDebugMsg( QString( "layer %1 not found" ).arg( buf ) );
    }
#endif
  }