|
| 1 | +/*************************************************************************** |
| 2 | + qgsrasteridentifyresult.h |
| 3 | + -------------------------------------- |
| 4 | + Date : Apr 8, 2013 |
| 5 | + Copyright : (C) 2013 by Radim Blazek |
| 6 | + email : radim dot blazek at gmail dot com |
| 7 | + ***************************************************************************/ |
| 8 | + |
| 9 | +/*************************************************************************** |
| 10 | + * * |
| 11 | + * This program is free software; you can redistribute it and/or modify * |
| 12 | + * it under the terms of the GNU General Public License as published by * |
| 13 | + * the Free Software Foundation; either version 2 of the License, or * |
| 14 | + * (at your option) any later version. * |
| 15 | + * * |
| 16 | + ***************************************************************************/ |
| 17 | + |
| 18 | +#ifndef QGSRASTERIDENTIFYRESULT_H |
| 19 | +#define QGSRASTERIDENTIFYRESULT_H |
| 20 | + |
| 21 | +#include "qgis.h" |
| 22 | +#include "qgslogger.h" |
| 23 | +#include "qgsrasterdataprovider.h" |
| 24 | + |
| 25 | +/** \ingroup core |
| 26 | + * Raster identify results container. |
| 27 | + */ |
| 28 | +class CORE_EXPORT QgsRasterIdentifyResult |
| 29 | +{ |
| 30 | + public: |
| 31 | + QgsRasterIdentifyResult(); |
| 32 | + |
| 33 | + /** \brief Constructor. Creates valid result. |
| 34 | + * @param theResults results |
| 35 | + */ |
| 36 | + QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormat theFormat, QMap<int, QVariant> theResults ); |
| 37 | + |
| 38 | + /** \brief Constructor. Creates invalid result with error. |
| 39 | + * @param theResults results |
| 40 | + */ |
| 41 | + QgsRasterIdentifyResult( QgsError theError ); |
| 42 | + |
| 43 | + virtual ~QgsRasterIdentifyResult(); |
| 44 | + |
| 45 | + /** \brief Returns true if valid */ |
| 46 | + bool isValid() const { return mValid; } |
| 47 | + |
| 48 | + /** \brief Get results format */ |
| 49 | + QgsRasterDataProvider::IdentifyFormat format() const { return mFormat; } |
| 50 | + |
| 51 | + /** \brief Get results. Results are different for each format: |
| 52 | + * IdentifyFormatValue: map of values for each band, keys are band numbers (from 1). |
| 53 | + * IdentifyFormatFeature: map of QgsRasterFeatureList for each sublayer (WMS) |
| 54 | + * IdentifyFormatHtml: map of HTML strings for each sublayer (WMS). |
| 55 | + */ |
| 56 | + QMap<int, QVariant> results() const { return mResults; } |
| 57 | + |
| 58 | + /** Set map of optional parameters */ |
| 59 | + void setParams( const QMap<QString, QVariant> & theParams ) { mParams = theParams; } |
| 60 | + |
| 61 | + /** Get map of optional parameters */ |
| 62 | + QMap<QString, QVariant> params() const { return mParams; } |
| 63 | + |
| 64 | + /** \brief Get error */ |
| 65 | + QgsError error() const { return mError; } |
| 66 | + |
| 67 | + /** \brief Set error */ |
| 68 | + void setError( const QgsError & theError ) { mError = theError;} |
| 69 | + |
| 70 | + /** \brief Add error message */ |
| 71 | + void appendError( const QgsErrorMessage & theMessage ) { mError.append( theMessage );} |
| 72 | + |
| 73 | + private: |
| 74 | + /** \brief Is valid */ |
| 75 | + bool mValid; |
| 76 | + |
| 77 | + /** \brief Results format */ |
| 78 | + QgsRasterDataProvider::IdentifyFormat mFormat; |
| 79 | + |
| 80 | + /** \brief Results */ |
| 81 | + // TODO: better hierarchy (sublayer multiple feature sets)? |
| 82 | + // TODO?: results are not consistent for different formats (per band x per sublayer) |
| 83 | + QMap<int, QVariant> mResults; |
| 84 | + |
| 85 | + /** \brief Additional params (e.g. request url used by WMS) */ |
| 86 | + QMap<QString, QVariant> mParams; |
| 87 | + |
| 88 | + /** \brief Error */ |
| 89 | + QgsError mError; |
| 90 | +}; |
| 91 | + |
| 92 | +#endif |
| 93 | + |
| 94 | + |
0 commit comments