wms-layer-tree.diff
| src/app/qgsserversourceselect.h (working copy) | ||
|---|---|---|
| 21 | 21 |
#include "ui_qgsserversourceselectbase.h" |
| 22 | 22 |
#include "qgisgui.h" |
| 23 | 23 | |
| 24 |
#include <vector> |
|
| 25 |
#include <map> |
|
| 26 |
#include <set> |
|
| 24 |
#include <QStringList> |
|
| 27 | 25 | |
| 28 | 26 |
class QgisApp; |
| 29 | 27 |
class QgsWmsProvider; |
| 30 | 28 |
class QButtonGroup; |
| 29 |
class QgsNumericSortTreeWidgetItem; |
|
| 30 | ||
| 31 | 31 |
/*! |
| 32 | 32 |
* \brief Dialog to create connections and add layers from WMS, etc. |
| 33 | 33 |
* |
| ... | ... | |
| 140 | 140 |
//! Populate the image encoding button group - private for now. |
| 141 | 141 |
void populateImageEncodingGroup( QgsWmsProvider* wmsProvider ); |
| 142 | 142 | |
| 143 |
//! create an item including possible parents |
|
| 144 |
QgsNumericSortTreeWidgetItem *createItem(int id, const QStringList &names, QMap<int, QgsNumericSortTreeWidgetItem *> &items, int &layerAndStyleCount, const QMap<int,int> &layerParents, const QMap<int, QStringList> &layerParentNames ); |
|
| 145 | ||
| 143 | 146 |
//! Returns a textual description for the EpsgCrsId number |
| 144 | 147 |
QString descriptionForEpsg( long epsg ); |
| 145 | 148 | |
| ... | ... | |
| 165 | 168 |
QStringList m_selectedStylesForSelectedLayers; |
| 166 | 169 |
long m_Epsg; |
| 167 | 170 | |
| 168 |
std::map<QString, QString> m_selectedStyleIdForLayer; |
|
| 171 |
QMap<QString, QString> m_selectedStyleIdForLayer; |
|
| 169 | 172 | |
| 170 | 173 |
//! The mime type, the text to use in the button and a unique number |
| 171 | 174 |
QMap<QString, QPair<QString, int> > m_PotentialFormats; |
| src/app/qgsserversourceselect.cpp (working copy) | ||
|---|---|---|
| 186 | 186 | |
| 187 | 187 |
} |
| 188 | 188 | |
| 189 |
bool QgsServerSourceSelect::populateLayerList( QgsWmsProvider* wmsProvider ) |
|
| 189 |
QgsNumericSortTreeWidgetItem *QgsServerSourceSelect::createItem( |
|
| 190 |
int id, const QStringList &names, QMap<int, QgsNumericSortTreeWidgetItem *> &items, int &layerAndStyleCount, |
|
| 191 |
const QMap<int,int> &layerParents, const QMap<int, QStringList> &layerParentNames ) |
|
| 192 | ||
| 190 | 193 |
{
|
| 191 |
std::vector<QgsWmsLayerProperty> layers; |
|
| 194 |
if( items.contains(id) ) |
|
| 195 |
return items[id]; |
|
| 192 | 196 | |
| 197 |
QgsNumericSortTreeWidgetItem *item; |
|
| 198 |
if( layerParents.contains( id ) ) |
|
| 199 |
{
|
|
| 200 |
int parent = layerParents[ id ]; |
|
| 201 |
item = new QgsNumericSortTreeWidgetItem( createItem( parent, layerParentNames[ parent ], items, layerAndStyleCount, layerParents, layerParentNames ) ); |
|
| 202 |
} |
|
| 203 |
else |
|
| 204 |
item = new QgsNumericSortTreeWidgetItem( lstLayers ); |
|
| 205 | ||
| 206 |
item->setText( 0, QString::number( ++layerAndStyleCount ) ); |
|
| 207 |
item->setText( 1, names[0].simplified() ); |
|
| 208 |
item->setText( 2, names[1].simplified() ); |
|
| 209 |
item->setText( 3, names[2].simplified() ); |
|
| 210 | ||
| 211 |
items[ id ] = item; |
|
| 212 | ||
| 213 |
return item; |
|
| 214 |
} |
|
| 215 | ||
| 216 |
bool QgsServerSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider ) |
|
| 217 |
{
|
|
| 218 |
QVector<QgsWmsLayerProperty> layers; |
|
| 219 | ||
| 193 | 220 |
if ( !wmsProvider->supportedLayers( layers ) ) |
| 194 | 221 |
{
|
| 195 | 222 |
return FALSE; |
| 196 | 223 |
} |
| 197 | 224 | |
| 225 |
QMap<int, QgsNumericSortTreeWidgetItem *> items; |
|
| 226 |
QMap<int, int> layerParents; |
|
| 227 |
QMap<int, QStringList> layerParentNames; |
|
| 228 |
wmsProvider->layerParents( layerParents, layerParentNames ); |
|
| 229 | ||
| 198 | 230 |
lstLayers->clear(); |
| 231 |
lstLayers->setSortingEnabled( true ); |
|
| 199 | 232 | |
| 200 |
int layerAndStyleCount = 0; |
|
| 233 |
int layerAndStyleCount = -1; |
|
| 201 | 234 | |
| 202 |
for ( std::vector<QgsWmsLayerProperty>::iterator layer = layers.begin(); |
|
| 235 |
for ( QVector<QgsWmsLayerProperty>::iterator layer = layers.begin(); |
|
| 203 | 236 |
layer != layers.end(); |
| 204 | 237 |
layer++ ) |
| 205 | 238 |
{
|
| 206 |
// QgsDebugMsg(QString("got layer name %1 and title '%2'.").arg(layer->name).arg(layer->title));
|
|
| 239 |
QgsNumericSortTreeWidgetItem *lItem = createItem(layer->orderId, QStringList() << layer->name << layer->title << layer->abstract, items, layerAndStyleCount, layerParents, layerParentNames ); |
|
| 207 | 240 | |
| 208 |
layerAndStyleCount++; |
|
| 241 |
lItem->setData( 0, Qt::UserRole, layer->name ); |
|
| 242 |
lItem->setData( 0, Qt::UserRole+1, "" ); |
|
| 209 | 243 | |
| 210 |
QgsNumericSortTreeWidgetItem *lItem = new QgsNumericSortTreeWidgetItem( lstLayers ); |
|
| 211 |
lItem->setText( 0, QString::number( layerAndStyleCount ) ); |
|
| 212 |
lItem->setText( 1, layer->name.simplified() ); |
|
| 213 |
lItem->setText( 2, layer->title.simplified() ); |
|
| 214 |
lItem->setText( 3, layer->abstract.simplified() ); |
|
| 215 | ||
| 216 | 244 |
// Also insert the styles |
| 217 | 245 |
// Layer Styles |
| 218 |
for ( uint j = 0; j < layer->style.size(); j++ ) |
|
| 246 |
for ( int j = 0; j < layer->style.size(); j++ ) |
|
| 219 | 247 |
{
|
| 220 | 248 |
QgsDebugMsg( QString( "got style name %1 and title '%2'." ).arg( layer->style[j].name ).arg( layer->style[j].title ) ); |
| 221 | 249 | |
| 222 |
layerAndStyleCount++; |
|
| 223 | ||
| 224 | 250 |
QgsNumericSortTreeWidgetItem *lItem2 = new QgsNumericSortTreeWidgetItem( lItem ); |
| 225 |
lItem2->setText( 0, QString::number( layerAndStyleCount ) ); |
|
| 251 |
lItem2->setText( 0, QString::number( ++layerAndStyleCount ) ); |
|
| 226 | 252 |
lItem2->setText( 1, layer->style[j].name.simplified() ); |
| 227 | 253 |
lItem2->setText( 2, layer->style[j].title.simplified() ); |
| 228 | 254 |
lItem2->setText( 3, layer->style[j].abstract.simplified() ); |
| 229 | 255 | |
| 256 |
lItem2->setData( 0, Qt::UserRole, layer->name ); |
|
| 257 |
lItem2->setData( 0, Qt::UserRole+1, layer->style[j].name ); |
|
| 230 | 258 |
} |
| 231 | ||
| 232 | 259 |
} |
| 233 | 260 | |
| 234 | 261 |
// If we got some layers, let the user add them to the map |
| 235 | 262 |
if ( lstLayers->topLevelItemCount() > 0 ) |
| 236 | 263 |
{
|
| 237 | 264 |
btnAdd->setEnabled( TRUE ); |
| 265 | ||
| 266 |
if( lstLayers->topLevelItemCount()==1 ) |
|
| 267 |
{
|
|
| 268 |
lstLayers->expandItem( lstLayers->topLevelItem(0) ); |
|
| 269 |
} |
|
| 238 | 270 |
} |
| 239 | 271 |
else |
| 240 | 272 |
{
|
| ... | ... | |
| 360 | 392 |
{
|
| 361 | 393 |
if ( m_selectedLayers.empty() == TRUE ) |
| 362 | 394 |
{
|
| 363 |
QMessageBox::information( this, tr( "Select Layer" ), tr( "You must select at least one layer first." ) ); |
|
| 395 |
QMessageBox::information( this, tr( "Select Layer" ), tr( "You must select at least one leaf layer first." ) ); |
|
| 364 | 396 |
} |
| 365 | 397 |
else if ( mWmsProvider->supportedCrsForLayers( m_selectedLayers ).size() == 0 ) |
| 366 | 398 |
{
|
| ... | ... | |
| 425 | 457 |
QStringList newSelectedLayers; |
| 426 | 458 |
QStringList newSelectedStylesForSelectedLayers; |
| 427 | 459 | |
| 428 |
std::map<QString, QString> newSelectedStyleIdForLayer; |
|
| 460 |
QMap<QString, QString> newSelectedStyleIdForLayer; |
|
| 429 | 461 | |
| 430 | 462 |
// Iterate through the layers |
| 431 | 463 |
QList<QTreeWidgetItem *> selected( lstLayers->selectedItems() ); |
| ... | ... | |
| 433 | 465 |
for ( it = selected.begin(); it != selected.end(); ++it ) |
| 434 | 466 |
{
|
| 435 | 467 |
QTreeWidgetItem *item = *it; |
| 436 |
QString layerName; |
|
| 437 | 468 | |
| 438 |
if ( item->parent() != 0 ) |
|
| 439 |
{
|
|
| 440 |
layerName = item->parent()->text( 1 ); |
|
| 441 |
newSelectedStylesForSelectedLayers += item->text( 1 ); |
|
| 442 |
} |
|
| 443 |
else |
|
| 444 |
{
|
|
| 445 |
layerName = item->text( 1 ); |
|
| 446 |
newSelectedStylesForSelectedLayers += ""; |
|
| 447 |
} |
|
| 469 |
QString layerName = item->data(0, Qt::UserRole).toString(); |
|
| 470 |
if( layerName.isEmpty() ) |
|
| 471 |
continue; |
|
| 448 | 472 | |
| 449 |
newSelectedLayers += layerName; |
|
| 473 |
newSelectedLayers << layerName; |
|
| 474 |
newSelectedStylesForSelectedLayers << item->data( 0, Qt::UserRole+1 ).toString(); |
|
| 475 | ||
| 450 | 476 |
newSelectedStyleIdForLayer[layerName] = item->text( 0 ); |
| 451 | 477 | |
| 452 | 478 |
// Check if multiple styles have now been selected |
| src/providers/wms/qgswmsprovider.h (working copy) | ||
|---|---|---|
| 21 | 21 |
#ifndef QGSWMSPROVIDER_H |
| 22 | 22 |
#define QGSWMSPROVIDER_H |
| 23 | 23 | |
| 24 |
#include <map> |
|
| 25 |
#include <vector> |
|
| 26 | ||
| 27 | 24 |
#include "qgsrasterdataprovider.h" |
| 28 | 25 |
#include "qgsrectangle.h" |
| 29 | 26 | |
| 30 | 27 |
#include <QString> |
| 31 | 28 |
#include <QStringList> |
| 32 | 29 |
#include <QDomElement> |
| 30 |
#include <QMap> |
|
| 31 |
#include <QVector> |
|
| 33 | 32 | |
| 34 | 33 |
class QgsCoordinateTransform; |
| 35 | 34 | |
| ... | ... | |
| 78 | 77 |
// TODO: Fill to WMS specifications |
| 79 | 78 |
struct QgsWmsOperationType |
| 80 | 79 |
{
|
| 81 |
QStringList format; |
|
| 82 |
std::vector<QgsWmsDcpTypeProperty> dcpType; |
|
| 80 |
QStringList format; |
|
| 81 |
QVector<QgsWmsDcpTypeProperty> dcpType; |
|
| 83 | 82 |
}; |
| 84 | 83 | |
| 85 | 84 |
/** Request Property structure */ |
| ... | ... | |
| 220 | 219 |
// TODO: Fill to WMS specifications |
| 221 | 220 |
struct QgsWmsStyleProperty |
| 222 | 221 |
{
|
| 223 |
QString name; |
|
| 224 |
QString title; |
|
| 225 |
QString abstract; |
|
| 226 |
std::vector<QgsWmsLegendUrlProperty> legendUrl; |
|
| 227 |
QgsWmsStyleSheetUrlProperty styleSheetUrl; |
|
| 228 |
QgsWmsStyleUrlProperty styleUrl; |
|
| 222 |
QString name; |
|
| 223 |
QString title; |
|
| 224 |
QString abstract; |
|
| 225 |
QVector<QgsWmsLegendUrlProperty> legendUrl; |
|
| 226 |
QgsWmsStyleSheetUrlProperty styleSheetUrl; |
|
| 227 |
QgsWmsStyleUrlProperty styleUrl; |
|
| 229 | 228 |
}; |
| 230 | 229 | |
| 231 | 230 |
/** Authority URL Property structure */ |
| ... | ... | |
| 273 | 272 |
struct QgsWmsLayerProperty |
| 274 | 273 |
{
|
| 275 | 274 |
// WMS layer properties |
| 276 |
QString name; |
|
| 277 |
QString title; |
|
| 278 |
QString abstract; |
|
| 279 |
QStringList keywordList; |
|
| 280 |
std::vector<QString> crs; // coord ref sys |
|
| 281 |
QgsRectangle ex_GeographicBoundingBox; |
|
| 282 |
std::vector<QgsWmsBoundingBoxProperty> boundingBox; |
|
| 283 |
std::vector<QgsWmsDimensionProperty> dimension; |
|
| 284 |
QgsWmsAttributionProperty attribution; |
|
| 285 |
std::vector<QgsWmsAuthorityUrlProperty> authorityUrl; |
|
| 286 |
std::vector<QgsWmsIdentifierProperty> identifier; |
|
| 287 |
std::vector<QgsWmsMetadataUrlProperty> metadataUrl; |
|
| 288 |
std::vector<QgsWmsDataListUrlProperty> dataListUrl; |
|
| 289 |
std::vector<QgsWmsFeatureListUrlProperty> featureListUrl; |
|
| 290 |
std::vector<QgsWmsStyleProperty> style; |
|
| 291 |
double minimumScaleDenominator; |
|
| 292 |
double maximumScaleDenominator; |
|
| 293 |
std::vector<QgsWmsLayerProperty> layer; // nested layers |
|
| 275 |
int orderId; |
|
| 276 |
QString name; |
|
| 277 |
QString title; |
|
| 278 |
QString abstract; |
|
| 279 |
QStringList keywordList; |
|
| 280 |
QVector<QString> crs; // coord ref sys |
|
| 281 |
QgsRectangle ex_GeographicBoundingBox; |
|
| 282 |
QVector<QgsWmsBoundingBoxProperty> boundingBox; |
|
| 283 |
QVector<QgsWmsDimensionProperty> dimension; |
|
| 284 |
QgsWmsAttributionProperty attribution; |
|
| 285 |
QVector<QgsWmsAuthorityUrlProperty> authorityUrl; |
|
| 286 |
QVector<QgsWmsIdentifierProperty> identifier; |
|
| 287 |
QVector<QgsWmsMetadataUrlProperty> metadataUrl; |
|
| 288 |
QVector<QgsWmsDataListUrlProperty> dataListUrl; |
|
| 289 |
QVector<QgsWmsFeatureListUrlProperty> featureListUrl; |
|
| 290 |
QVector<QgsWmsStyleProperty> style; |
|
| 291 |
double minimumScaleDenominator; |
|
| 292 |
double maximumScaleDenominator; |
|
| 293 |
QVector<QgsWmsLayerProperty> layer; // nested layers |
|
| 294 | 294 | |
| 295 | 295 |
// WMS layer attributes |
| 296 | 296 |
bool queryable; |
| ... | ... | |
| 331 | 331 |
*/ |
| 332 | 332 |
class QgsWmsProvider : public QgsRasterDataProvider |
| 333 | 333 |
{
|
| 334 | ||
| 335 | 334 |
Q_OBJECT |
| 336 | 335 | |
| 337 | 336 |
public: |
| 338 | ||
| 339 | ||
| 340 | 337 |
/** |
| 341 | 338 |
* Constructor for the provider. |
| 342 | 339 |
* |
| ... | ... | |
| 359 | 356 |
* |
| 360 | 357 |
* \todo Document this better, make static |
| 361 | 358 |
*/ |
| 362 |
virtual bool supportedLayers( std::vector<QgsWmsLayerProperty> & layers ); |
|
| 359 |
virtual bool supportedLayers( QVector<QgsWmsLayerProperty> & layers ); |
|
| 363 | 360 | |
| 361 |
/** |
|
| 362 |
* \brief Returns a map for the hierachy of layers |
|
| 363 |
*/ |
|
| 364 |
virtual void layerParents( QMap<int, int> &parents, QMap<int, QStringList> &parentNames ) const; |
|
| 365 | ||
| 364 | 366 |
// TODO: Document this better |
| 365 | 367 |
/** \brief Returns a list of the supported CRSs of the given layers |
| 366 | 368 |
* \note Since WMS can specify CRSs per layer, this may change depending |
| ... | ... | |
| 735 | 737 |
/** |
| 736 | 738 |
* layers hosted by the WMS Server |
| 737 | 739 |
*/ |
| 738 |
std::vector<QgsWmsLayerProperty> layersSupported; |
|
| 740 |
QVector<QgsWmsLayerProperty> layersSupported; |
|
| 739 | 741 | |
| 740 | 742 |
/** |
| 741 | 743 |
* extents per layer (in WMS CRS:84 datum) |
| 742 | 744 |
*/ |
| 743 |
std::map<QString, QgsRectangle> extentForLayer; |
|
| 745 |
QMap<QString, QgsRectangle> extentForLayer; |
|
| 744 | 746 | |
| 745 | 747 |
/** |
| 746 | 748 |
* available CRSs per layer |
| 747 | 749 |
*/ |
| 748 |
std::map<QString, std::vector<QString> > crsForLayer; |
|
| 750 |
QMap<QString, QVector<QString> > crsForLayer; |
|
| 749 | 751 | |
| 750 | 752 |
/** |
| 751 | 753 |
* WMS "queryable" per layer |
| 752 | 754 |
* Used in determining if the Identify map tool can be useful on the rendered WMS map layer. |
| 753 | 755 |
*/ |
| 754 |
std::map<QString, bool> mQueryableForLayer; |
|
| 756 |
QMap<QString, bool> mQueryableForLayer; |
|
| 755 | 757 | |
| 756 | 758 |
/** |
| 757 | 759 |
* Active sublayers managed by this provider in a draw function, in order from bottom to top |
| ... | ... | |
| 764 | 766 |
/** |
| 765 | 767 |
* Visibility status of the given active sublayer |
| 766 | 768 |
*/ |
| 767 |
std::map<QString, bool> activeSubLayerVisibility; |
|
| 769 |
QMap<QString, bool> activeSubLayerVisibility; |
|
| 768 | 770 | |
| 769 | 771 |
/** |
| 770 | 772 |
* MIME type of the image encoding used from the WMS server |
| ... | ... | |
| 816 | 818 | |
| 817 | 819 |
//! Base URL for WMS GetFeatureInfo requests |
| 818 | 820 |
QString mGetFeatureInfoUrlBase; |
| 821 | ||
| 822 |
int mLayerCount; |
|
| 823 |
QMap<int, int> mLayerParents; |
|
| 824 |
QMap<int, QStringList> mLayerParentNames; |
|
| 825 | ||
| 819 | 826 |
}; |
| 820 | 827 | |
| 821 | 828 |
#endif |
| src/providers/wms/qgswmsprovider.cpp (working copy) | ||
|---|---|---|
| 59 | 59 |
cachedPixelHeight( 0 ), |
| 60 | 60 |
mCoordinateTransform( 0 ), |
| 61 | 61 |
extentDirty( TRUE ), |
| 62 |
mGetFeatureInfoUrlBase( 0 ) |
|
| 62 |
mGetFeatureInfoUrlBase( 0 ), |
|
| 63 |
mLayerCount( -1 ) |
|
| 63 | 64 |
{
|
| 64 | 65 |
QgsDebugMsg( "QgsWmsProvider: constructing with uri '" + uri + "'." ); |
| 65 | 66 | |
| ... | ... | |
| 134 | 135 | |
| 135 | 136 | |
| 136 | 137 | |
| 137 |
bool QgsWmsProvider::supportedLayers( std::vector<QgsWmsLayerProperty> & layers ) |
|
| 138 |
bool QgsWmsProvider::supportedLayers( QVector<QgsWmsLayerProperty> &layers ) |
|
| 138 | 139 |
{
|
| 139 | 140 |
QgsDebugMsg( "Entering." ); |
| 140 | 141 | |
| ... | ... | |
| 159 | 160 |
QStringList::const_iterator i; |
| 160 | 161 |
for ( i = layers.constBegin(); i != layers.constEnd(); ++i ) |
| 161 | 162 |
{
|
| 162 |
std::vector<QString> crsVector = crsForLayer[*i]; |
|
| 163 |
QVector<QString> crsVector = crsForLayer[*i]; |
|
| 163 | 164 |
QSet<QString> crsSet; |
| 164 | 165 | |
| 165 | 166 |
// convert std::vector to std::set for set comparisons |
| 166 |
for ( uint j = 0; j < crsVector.size(); j++ ) |
|
| 167 |
for ( int j = 0; j < crsVector.size(); j++ ) |
|
| 167 | 168 |
{
|
| 168 | 169 |
crsSet.insert( crsVector[j] ); |
| 169 | 170 |
} |
| ... | ... | |
| 192 | 193 |
} // QgsWmsProvider::layerCount() |
| 193 | 194 | |
| 194 | 195 | |
| 195 |
void QgsWmsProvider::addLayers( QStringList const & layers, |
|
| 196 |
QStringList const & styles ) |
|
| 196 |
void QgsWmsProvider::addLayers( QStringList const &layers, |
|
| 197 |
QStringList const &styles ) |
|
| 197 | 198 |
{
|
| 198 | 199 |
QgsDebugMsg( "Entering with layer list of " + layers.join( ", " ) |
| 199 | 200 |
+ " and style list of " + styles.join( ", " ) ); |
| ... | ... | |
| 220 | 221 |
} |
| 221 | 222 | |
| 222 | 223 | |
| 223 |
void QgsWmsProvider::setLayerOrder( QStringList const & layers ) |
|
| 224 |
void QgsWmsProvider::setLayerOrder( QStringList const &layers ) |
|
| 224 | 225 |
{
|
| 225 | 226 |
QgsDebugMsg( "Entering." ); |
| 226 | 227 | |
| ... | ... | |
| 356 | 357 |
it != activeSubLayers.end(); |
| 357 | 358 |
++it ) |
| 358 | 359 |
{
|
| 359 |
if ( TRUE == activeSubLayerVisibility.find( *it )->second ) |
|
| 360 |
if ( activeSubLayerVisibility.find( *it ).value() ) |
|
| 360 | 361 |
{
|
| 361 | 362 |
visibleLayers += *it; |
| 362 | 363 |
visibleStyles += *it2; |
| ... | ... | |
| 379 | 380 |
crsKey = "CRS"; |
| 380 | 381 |
} |
| 381 | 382 | |
| 382 |
std::vector<QgsWmsDcpTypeProperty> dcpType = mCapabilities.capability.request.getMap.dcpType; |
|
| 383 |
QVector<QgsWmsDcpTypeProperty> dcpType = mCapabilities.capability.request.getMap.dcpType; |
|
| 383 | 384 |
if(dcpType.size() < 1) |
| 384 | 385 |
{
|
| 385 | 386 |
mError = tr("Could not determine URL for GetMap from the WMS capabilities response");
|
| ... | ... | |
| 849 | 850 |
QDomElement e1 = n1.toElement(); // try to convert the node to an element. |
| 850 | 851 |
if ( !e1.isNull() ) |
| 851 | 852 |
{
|
| 852 |
//QgsDebugMsg(" " + e1.tagName() ); // the node really is an element.
|
|
| 853 |
QgsDebugMsg(" " + e1.tagName() ); // the node really is an element.
|
|
| 853 | 854 | |
| 854 | 855 |
if ( e1.tagName() == "Title" ) |
| 855 | 856 |
{
|
| ... | ... | |
| 1308 | 1309 |
// layerProperty.title = QString::null; |
| 1309 | 1310 |
// layerProperty.abstract = QString::null; |
| 1310 | 1311 |
// layerProperty.keywordList.clear(); |
| 1311 | ||
| 1312 |
// assume true until we find a child layer |
|
| 1313 |
bool atleaf = TRUE; |
|
| 1314 | ||
| 1312 |
layerProperty.orderId = ++mLayerCount; |
|
| 1315 | 1313 |
layerProperty.queryable = e.attribute( "queryable" ).toUInt(); |
| 1316 | 1314 |
layerProperty.cascaded = e.attribute( "cascaded" ).toUInt(); |
| 1317 | 1315 |
layerProperty.opaque = e.attribute( "opaque" ).toUInt(); |
| ... | ... | |
| 1325 | 1323 |
QDomElement e1 = n1.toElement(); // try to convert the node to an element. |
| 1326 | 1324 |
if ( !e1.isNull() ) |
| 1327 | 1325 |
{
|
| 1328 |
//QgsDebugMsg(" " + e1.tagName() ); // the node really is an element.
|
|
| 1326 |
QgsDebugMsg(" " + e1.tagName() ); // the node really is an element.
|
|
| 1329 | 1327 | |
| 1330 | 1328 |
if ( e1.tagName() == "Layer" ) |
| 1331 | 1329 |
{
|
| 1332 |
// QgsDebugMsg(" Nested layer.");
|
|
| 1330 |
QgsDebugMsg(" Nested layer.");
|
|
| 1333 | 1331 | |
| 1334 | 1332 |
QgsWmsLayerProperty subLayerProperty; |
| 1335 | 1333 | |
| ... | ... | |
| 1344 | 1342 |
parseLayer( e1, subLayerProperty, &layerProperty ); |
| 1345 | 1343 | |
| 1346 | 1344 |
layerProperty.layer.push_back( subLayerProperty ); |
| 1347 | ||
| 1348 |
atleaf = FALSE; |
|
| 1349 | 1345 |
} |
| 1350 | 1346 |
else if ( e1.tagName() == "Name" ) |
| 1351 | 1347 |
{
|
| ... | ... | |
| 1474 | 1470 |
n1 = n1.nextSibling(); |
| 1475 | 1471 |
} |
| 1476 | 1472 | |
| 1477 |
if ( atleaf ) |
|
| 1473 |
if(parentProperty) |
|
| 1478 | 1474 |
{
|
| 1475 |
mLayerParents[ layerProperty.orderId ] = parentProperty->orderId; |
|
| 1476 |
} |
|
| 1477 | ||
| 1478 |
if ( layerProperty.layer.empty() ) |
|
| 1479 |
{
|
|
| 1479 | 1480 |
// We have all the information we need to properly evaluate a layer definition |
| 1480 | 1481 |
// TODO: Save this somewhere |
| 1481 | 1482 | |
| ... | ... | |
| 1493 | 1494 |
extentForLayer[ layerProperty.name ] = layerProperty.ex_GeographicBoundingBox; |
| 1494 | 1495 | |
| 1495 | 1496 |
// see if we can refine the bounding box with the CRS-specific bounding boxes |
| 1496 |
for ( uint i = 0; i < layerProperty.boundingBox.size(); i++ ) |
|
| 1497 |
for ( int i = 0; i < layerProperty.boundingBox.size(); i++ ) |
|
| 1497 | 1498 |
{
|
| 1498 | 1499 |
QgsDebugMsg( "testing bounding box CRS which is " |
| 1499 | 1500 |
+ layerProperty.boundingBox[i].crs + "." ); |
| ... | ... | |
| 1513 | 1514 |
layersSupported.push_back( layerProperty ); |
| 1514 | 1515 | |
| 1515 | 1516 |
//if there are several <Layer> elements without a parent layer, the style list needs to be cleared |
| 1516 |
if ( atleaf ) |
|
| 1517 |
if ( layerProperty.layer.empty() ) |
|
| 1517 | 1518 |
{
|
| 1518 | 1519 |
layerProperty.style.clear(); |
| 1519 | 1520 |
} |
| 1520 | 1521 |
} |
| 1522 |
else |
|
| 1523 |
{
|
|
| 1524 |
mLayerParentNames[ layerProperty.orderId ] = QStringList() << layerProperty.name << layerProperty.title << layerProperty.abstract; |
|
| 1525 |
} |
|
| 1521 | 1526 | |
| 1522 | 1527 |
// QgsDebugMsg("exiting.");
|
| 1523 | 1528 |
} |
| 1524 | 1529 | |
| 1530 |
void QgsWmsProvider::layerParents( QMap<int, int> &parents, QMap<int, QStringList> &parentNames ) const |
|
| 1531 |
{
|
|
| 1532 |
parents = mLayerParents; |
|
| 1533 |
parentNames = mLayerParentNames; |
|
| 1534 |
} |
|
| 1525 | 1535 | |
| 1526 | 1536 |
bool QgsWmsProvider::parseServiceExceptionReportDom( QByteArray const & xml ) |
| 1527 | 1537 |
{
|
| ... | ... | |
| 1749 | 1759 |
{
|
| 1750 | 1760 |
QgsDebugMsg( "Sublayer Iterator: " + *it ); |
| 1751 | 1761 |
// This is the extent for the layer name in *it |
| 1752 |
QgsRectangle extent = extentForLayer.find( *it )->second; |
|
| 1762 |
QgsRectangle extent = extentForLayer.find( *it ).value(); |
|
| 1753 | 1763 | |
| 1754 | 1764 |
// Convert to the user's CRS as required |
| 1755 | 1765 |
try |
| ... | ... | |
| 1805 | 1815 |
++it ) |
| 1806 | 1816 |
{
|
| 1807 | 1817 |
// Is sublayer visible? |
| 1808 |
if ( TRUE == activeSubLayerVisibility.find( *it )->second ) |
|
| 1818 |
if ( activeSubLayerVisibility.find( *it ).value() ) |
|
| 1809 | 1819 |
{
|
| 1810 | 1820 |
// Is sublayer queryable? |
| 1811 |
if ( TRUE == mQueryableForLayer.find( *it )->second ) |
|
| 1821 |
if ( mQueryableForLayer.find( *it ).value() ) |
|
| 1812 | 1822 |
{
|
| 1813 | 1823 |
QgsDebugMsg( "'" + ( *it ) + "' is queryable." ); |
| 1814 | 1824 |
canIdentify = TRUE; |
| ... | ... | |
| 1948 | 1958 | |
| 1949 | 1959 |
// Iterate through layers |
| 1950 | 1960 | |
| 1951 |
for ( uint i = 0; i < layersSupported.size(); i++ ) |
|
| 1961 |
for ( int i = 0; i < layersSupported.size(); i++ ) |
|
| 1952 | 1962 |
{
|
| 1953 | 1963 | |
| 1954 | 1964 |
// TODO: Handle nested layers |
| ... | ... | |
| 1988 | 1998 |
myMetadataQString += "<td bgcolor=\"gray\">"; |
| 1989 | 1999 |
myMetadataQString += ( activeSubLayers.indexOf( layerName ) >= 0 ) ? |
| 1990 | 2000 |
( |
| 1991 |
( activeSubLayerVisibility.find( layerName )->second ) ? |
|
| 2001 |
( activeSubLayerVisibility.find( layerName ).value() ) ? |
|
| 1992 | 2002 |
tr( "Visible" ) : tr( "Hidden" ) |
| 1993 | 2003 |
) : |
| 1994 | 2004 |
tr( "n/a" ); |
| ... | ... | |
| 2067 | 2077 |
myMetadataQString += "</td></tr>"; |
| 2068 | 2078 | |
| 2069 | 2079 |
// Layer Coordinate Reference Systems |
| 2070 |
for ( uint j = 0; j < layersSupported[i].crs.size(); j++ ) |
|
| 2080 |
for ( int j = 0; j < layersSupported[i].crs.size(); j++ ) |
|
| 2071 | 2081 |
{
|
| 2072 | 2082 |
myMetadataQString += "<tr><td bgcolor=\"gray\">"; |
| 2073 | 2083 |
myMetadataQString += tr( "Available in CRS" ); |
| ... | ... | |
| 2078 | 2088 |
} |
| 2079 | 2089 | |
| 2080 | 2090 |
// Layer Styles |
| 2081 |
for ( uint j = 0; j < layersSupported[i].style.size(); j++ ) |
|
| 2091 |
for ( int j = 0; j < layersSupported[i].style.size(); j++ ) |
|
| 2082 | 2092 |
{
|
| 2083 | 2093 |
myMetadataQString += "<tr><td bgcolor=\"gray\">"; |
| 2084 | 2094 |
myMetadataQString += tr( "Available in style" ); |
| ... | ... | |
| 2145 | 2155 |
++it ) |
| 2146 | 2156 |
{
|
| 2147 | 2157 |
// Is sublayer visible? |
| 2148 |
if ( TRUE == activeSubLayerVisibility.find( *it )->second ) |
|
| 2158 |
if ( activeSubLayerVisibility.find( *it ).value() ) |
|
| 2149 | 2159 |
{
|
| 2150 | 2160 |
// Is sublayer queryable? |
| 2151 |
if ( TRUE == mQueryableForLayer.find( *it )->second ) |
|
| 2161 |
if ( mQueryableForLayer.find( *it ).value() ) |
|
| 2152 | 2162 |
{
|
| 2153 | 2163 |
QgsDebugMsg( "Layer '" + *it + "' is queryable." ); |
| 2154 | 2164 |
// Compose request to WMS server |