📄 qgswmsprovider.h
字号:
/** * Set the visibility of the given sublayer name */ void setSubLayerVisibility(QString const & name, bool vis); /** * Get the image encoding (as a MIME type) used in the transfer from the WMS server */ QString imageEncoding() const; /** * Set the image encoding (as a MIME type) used in the transfer from the WMS server */ void setImageEncoding(QString const & mimeType); /** * Set the image projection (in WMS CRS format) used in the transfer from the WMS server * * \note an empty crs value will result in the previous CRS being retained. */ void setImageCrs(QString const & crs); // TODO: Document this better. /** \brief Renders the layer as an image * * \return A QImage - if the attempt to retrieve data for the draw was unsuccessful, returns 0 * and more information can be found in errorString() and errorCaptionString() * * \todo Add pixel depth parameter (intended to match the display or printer device) * * \note Ownership of the returned QImage remains with this provider and its lifetime * is guaranteed only until the next call to draw() or destruction of this provider. * * \warning A pointer to an QImage is used, as a plain QImage seems to have difficulty being * shared across library boundaries */ QImage * draw(QgsRect const & viewExtent, int pixelWidth, int pixelHeight); // /** Experimental function only **/// void getServerCapabilities(); /* Example URI: http://ims.cr.usgs.gov:80/servlet/com.esri.wms.Esrimap/USGS_EDC_Trans_BTS_Roads?SERVICE=WMS&REQUEST=GetCapabilities */ /** Return the extent for this data layer */ virtual QgsRect extent(); /** Reset the layer - for a PostgreSQL layer, this means clearing the PQresult * pointer and setting it to 0 */ void reset(); /**Returns true if layer is valid */ bool isValid(); //! get WMS Server version string QString wmsVersion(); //! get raster image encodings supported by the WMS Server, expressed as MIME types QStringList supportedImageEncodings(); /** * Sub-layers handled by this provider, in order from bottom to top * * Sub-layers are used to abstract the way the WMS server can combine * layers in some way at the server, before it serves them to this * WMS client. */ QStringList subLayers() const; /** * Sub-layer styles for each sub-layer handled by this provider, * in order from bottom to top * * Sub-layer styles are used to abstract the way the WMS server can symbolise * layers in some way at the server, before it serves them to this * WMS client. */ QStringList subLayerStyles() const; // TODO: Get the WMS connection // TODO: Get the table name associated with this provider instance /** Returns a bitmask containing the supported capabilities Note, some capabilities may change depending on which sublayers are visible on this provider, so it may be prudent to check this value per intended operation. */ int capabilities() const; /** * Get metadata in a format suitable for feeding directly * into a subset of the GUI raster properties "Metadata" tab. */ QString getMetadata(); /** * \brief Identify details from a WMS Server from the last screen update * * \param point[in] The pixel coordinate (as it was displayed locally on screen) * * \return A text document containing the return from the WMS server * * \note WMS Servers prefer to receive coordinates in image space, therefore * this function expects coordinates in that format. * * \note The arbitraryness of the returned document is enforced by WMS standards * up to at least v1.3.0 */ QString identifyAsText(const QgsPoint& point); /** * \brief Returns the caption error text for the last error in this provider * * If an operation returns 0 (e.g. draw()), this function * returns the text of the error associated with the failure. * Interactive users of this provider can then, for example, * call a QMessageBox to display the contents. */ QString errorCaptionString(); /** * \brief Returns the verbose error text for the last error in this provider * * If an operation returns 0 (e.g. draw()), this function * returns the text of the error associated with the failure. * Interactive users of this provider can then, for example, * call a QMessageBox to display the contents. */ QString errorString(); /** return a provider name Essentially just returns the provider key. Should be used to build file dialogs so that providers can be shown with their supported types. Thus if more than one provider supports a given format, the user is able to select a specific provider to open that file. @note Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description? */ QString name() const; /** return description Return a terse string describing what the provider is. @note Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description? */ QString description() const;signals: /** \brief emit a signal to notify of a progress event */ void setProgress(int theProgress, int theTotalSteps); /** \brief emit a signal to be caught by qgisapp and display a msg on status bar */ void setStatus(QString const & theStatusQString);public slots: void showStatusMessage(QString const & theMessage);private: /** * \brief Retrieve and parse the (cached) Capabilities document from the server * * \param forceRefresh if true, ignores any previous response cached in memory * and always contact the server for a new copy. * \retval FALSE if the capabilities document could not be retreived or parsed - * see errorString() for more info * * When this returns, "layers" will make sense. * * TODO: Make network-timeout tolerant */ bool retrieveServerCapabilities(bool forceRefresh = FALSE); /** * \brief Common URL retreival code for the differing WMS request types * * \retval 0 if an error occured - use errorString() and errorCaptionString() for details * */ QByteArray retrieveUrl(QString url);/* //! Test function: see if we can download a WMS' capabilites //! \retval FALSE if the download failed in some way bool downloadCapabilitiesURI(QString const & uri);*/ //! \return FALSE if the capabilities document could not be parsed - see errorString() for more info bool parseCapabilitiesDOM(QByteArray const & xml, QgsWmsCapabilitiesProperty& capabilitiesProperty); //! parse the WMS Service XML element void parseService(QDomElement const & e, QgsWmsServiceProperty& serviceProperty); //! parse the WMS Capability XML element void parseCapability(QDomElement const & e, QgsWmsCapabilityProperty& capabilityProperty); //! parse the WMS ContactPersonPrimary XML element void parseContactPersonPrimary(QDomElement const & e, QgsWmsContactPersonPrimaryProperty& contactPersonPrimaryProperty); //! parse the WMS ContactAddress XML element void parseContactAddress(QDomElement const & e, QgsWmsContactAddressProperty& contactAddressProperty); //! parse the WMS ContactInformation XML element void parseContactInformation(QDomElement const & e, QgsWmsContactInformationProperty& contactInformationProperty); //! parse the WMS OnlineResource XML element void parseOnlineResource(QDomElement const & e, QgsWmsOnlineResourceAttribute& onlineResourceAttribute); //! parse the WMS KeywordList XML element void parseKeywordList(QDomElement const & e, QStringList& keywordListProperty); //! parse the WMS Get XML element void parseGet(QDomElement const & e, QgsWmsGetProperty& getProperty); //! parse the WMS Post XML element void parsePost(QDomElement const & e, QgsWmsPostProperty& postProperty); //! parse the WMS HTTP XML element void parseHttp(QDomElement const & e, QgsWmsHttpProperty& httpProperty); //! parse the WMS DCPType XML element void parseDcpType(QDomElement const & e, QgsWmsDcpTypeProperty& dcpType); //! parse the WMS GetCapabilities, GetMap, or GetFeatureInfo XML element, each of type "OperationType". void parseOperationType(QDomElement const & e, QgsWmsOperationType& operationType); //! parse the WMS Request XML element void parseRequest(QDomElement const & e, QgsWmsRequestProperty& requestProperty); //! parse the WMS Legend URL XML element void parseLegendUrl(QDomElement const & e, QgsWmsLegendUrlProperty& legendUrlProperty); //! parse the WMS Style XML element void parseStyle(QDomElement const & e, QgsWmsStyleProperty& styleProperty); //! parse the WMS Layer XML element // TODO: Make recursable void parseLayer(QDomElement const & e, QgsWmsLayerProperty& layerProperty, QgsWmsLayerProperty *parentProperty=0); /** * \brief parse the full WMS ServiceExceptionReport XML document * * \note mErrorCaption and mError are updated to suit the results of this function. */ bool parseServiceExceptionReportDOM(QByteArray const & xml); //! parse the WMS ServiceException XML element void parseServiceException(QDomElement const & e); /** * \brief Calculates the combined extent of the layers selected by layersDrawn * * \retval FALSE if the capabilities document could not be retreived or parsed - * see errorString() for more info */ bool calculateExtent(); //! Data source URI of the WMS for this layer QString httpuri; //! URL part of URI (httpuri) QString baseUrl; //! HTTP proxy host name for the WMS for this layer QString mHttpProxyHost; //! HTTP proxy port number for the WMS for this layer int mHttpProxyPort; //! HTTP proxy username for the WMS for this layer QString mHttpProxyUser; //! HTTP proxy password for the WMS for this layer QString mHttpProxyPass; /** * Flag indicating if the layer data source is a valid WMS layer */ bool valid; /** * Spatial reference id of the layer */ QString srid; /** * Rectangle that contains the extent (bounding box) of the layer */ QgsRect layerExtent; /** * Capabilities of the WMS Server (raw) */ QByteArray httpcapabilitiesresponse; /** * Capabilities of the WMS Server */ QDomDocument capabilitiesDOM; /** * Last Service Exception Report from the WMS Server */ QDomDocument serviceExceptionReportDOM; /** * Parsed capabilities of the WMS Server */ QgsWmsCapabilitiesProperty mCapabilities; /** * layers hosted by the WMS Server */ std::vector<QgsWmsLayerProperty> layersSupported; /** * extents per layer (in WMS CRS:84 datum) */ std::map<QString, QgsRect> extentForLayer; /** * available CRSs per layer */ std::map<QString, std::vector<QString> > crsForLayer; /** * WMS "queryable" per layer * Used in determining if the Identify map tool can be useful on the rendered WMS map layer. */ std::map<QString, bool> mQueryableForLayer; /** * Active sublayers managed by this provider in a draw function, in order from bottom to top * (some may not be visible in a draw function, cf. activeSubLayerVisibility) */ QStringList activeSubLayers; QStringList activeSubStyles; /** * Visibility status of the given active sublayer */ std::map<QString, bool> activeSubLayerVisibility; /** * MIME type of the image encoding used from the WMS server */ QString imageMimeType; /** * WMS CRS type of the image CRS used from the WMS server */ QString imageCrs; /** * The previously retrieved image from the WMS server. * This can be reused if draw() is called consecutively * with the same parameters. */ QImage* cachedImage; /** * The previous parameter to draw(). */ QgsRect cachedViewExtent; /** * The previous parameter to draw(). */ int cachedPixelWidth; /** * The previous parameter to draw(). */ int cachedPixelHeight; /** * The error caption associated with the last WMS error. */ QString mErrorCaption; /** * The error message associated with the last WMS error. */ QString mError; //! A QgsCoordinateTransform is used for transformation of WMS layer extents QgsCoordinateTransform * mCoordinateTransform; //! See if calculateExtents() needs to be called before extent() returns useful data bool extentDirty; //! Base URL for WMS GetFeatureInfo requests QString mGetFeatureInfoUrlBase;};#endif// ENDS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -