[QGIS Commit] r14003 - in trunk/qgis: python/core src/app src/core
src/providers/wms
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Aug 3 17:24:22 EDT 2010
Author: jef
Date: 2010-08-03 21:24:22 +0000 (Tue, 03 Aug 2010)
New Revision: 14003
Modified:
trunk/qgis/python/core/qgsrasterdataprovider.sip
trunk/qgis/src/app/qgswmssourceselect.cpp
trunk/qgis/src/core/qgsrasterdataprovider.cpp
trunk/qgis/src/core/qgsrasterdataprovider.h
trunk/qgis/src/providers/wms/qgswmsprovider.cpp
trunk/qgis/src/providers/wms/qgswmsprovider.h
Log:
show wms get capabilities error
Modified: trunk/qgis/python/core/qgsrasterdataprovider.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterdataprovider.sip 2010-08-03 07:39:17 UTC (rev 14002)
+++ trunk/qgis/python/core/qgsrasterdataprovider.sip 2010-08-03 21:24:22 UTC (rev 14003)
@@ -5,14 +5,14 @@
* QgsVectorDataProvider, and does not yet make
* sense for Raster layers.
*/
-
+
class QgsRasterDataProvider : QgsDataProvider
{
-%TypeHeaderCode
+ % TypeHeaderCode
#include <qgsrasterdataprovider.h>
-%End
+ % End
-public:
+ public:
//! If you add to this, please also add to capabilitiesString()
enum Capability
@@ -32,8 +32,8 @@
/**
* Add the list of WMS layer names to be rendered by this server
*/
- virtual void addLayers(const QStringList & layers,
- const QStringList & styles = QStringList()) = 0;
+ virtual void addLayers( const QStringList & layers,
+ const QStringList & styles = QStringList() ) = 0;
//! get raster image encodings supported by (e.g.) the WMS Server, expressed as MIME types
virtual QStringList supportedImageEncodings() = 0;
@@ -46,18 +46,18 @@
/**
* Set the image encoding (as a MIME type) used in the transfer from (e.g.) the WMS server
*/
- virtual void setImageEncoding(const QString & mimeType) = 0;
-
+ virtual void setImageEncoding( const QString & mimeType ) = 0;
+
/**
* Set the image projection (in WMS CRS format) used in the transfer from (e.g.) the WMS server
*/
- virtual void setImageCrs(const QString & crs) = 0;
+ virtual void setImageCrs( const QString & crs ) = 0;
// TODO: Document this better.
/** \brief Renders the layer as an image
*/
- virtual QImage* draw(const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight) = 0;
+ virtual QImage* draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) = 0;
/** Returns a bitmask containing the supported capabilities
Note, some capabilities may change depending on whether
@@ -73,10 +73,10 @@
// TODO: Get the supported formats by this provider
-
+
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box
-
+
/**
* Get metadata in a format suitable for feeding directly
* into a subset of the GUI raster properties "Metadata" tab.
@@ -96,7 +96,7 @@
* \note The arbitraryness of the returned document is enforced by WMS standards
* up to at least v1.3.0
*/
- virtual QString identifyAsText(const QgsPoint& point) = 0;
+ virtual QString identifyAsText( const QgsPoint& point ) = 0;
/**
* \brief Identify details from a server (e.g. WMS) from the last screen update
@@ -113,7 +113,7 @@
*
* \note added in 1.5
*/
- virtual QString identifyAsHtml(const QgsPoint& point) = 0;
+ virtual QString identifyAsHtml( const QgsPoint& point ) = 0;
/**
* \brief Returns the caption error text for the last error in this provider
@@ -137,16 +137,19 @@
*/
virtual QString lastError() = 0;
- /**Returns the dpi of the output device.
+ /**
+ * \brief Returns the format of the error text for the last error in this provider
+ *
+ * \note added in 1.6
+ */
+ virtual QString lastErrorFormat();
+
+ /**Returns the dpi of the output device.
@note: this method was added in version 1.2*/
int dpi();
/**Sets the output device resolution.
@note: this method was added in version 1.2*/
- void setDpi(int dpi);
-
-
-protected:
-
+ void setDpi( int dpi );
};
Modified: trunk/qgis/src/app/qgswmssourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgswmssourceselect.cpp 2010-08-03 07:39:17 UTC (rev 14002)
+++ trunk/qgis/src/app/qgswmssourceselect.cpp 2010-08-03 21:24:22 UTC (rev 14003)
@@ -1021,20 +1021,17 @@
void QgsWMSSourceSelect::showError( QgsWmsProvider * wms )
{
-#if 0
- QMessageBox::warning(
- this,
- wms->lastErrorTitle(),
- tr( "Could not understand the response. The %1 provider said:\n%2", "COMMENTED OUT" )
- .arg( wms->name() ).arg( wms->lastError() )
- );
-#endif
-
QgsMessageViewer * mv = new QgsMessageViewer( this );
mv->setWindowTitle( wms->lastErrorTitle() );
- mv->setMessageAsPlainText( tr( "Could not understand the response. The %1 provider said:\n%2" )
- .arg( wms->name() ).arg( wms->lastError() )
- );
+
+ if ( wms->lastErrorFormat() == "text/html" )
+ {
+ mv->setMessageAsHtml( wms->lastError() );
+ }
+ else
+ {
+ mv->setMessageAsPlainText( tr( "Could not understand the response. The %1 provider said:\n%2" ).arg( wms->name() ).arg( wms->lastError() ) );
+ }
mv->showMessage( true ); // Is deleted when closed
}
@@ -1042,8 +1039,7 @@
{
// Remember which server was selected.
QSettings settings;
- settings.setValue( "/Qgis/connections-wms/selected",
- cmbConnections->currentText() );
+ settings.setValue( "/Qgis/connections-wms/selected", cmbConnections->currentText() );
}
void QgsWMSSourceSelect::on_btnAddDefault_clicked()
Modified: trunk/qgis/src/core/qgsrasterdataprovider.cpp
===================================================================
--- trunk/qgis/src/core/qgsrasterdataprovider.cpp 2010-08-03 07:39:17 UTC (rev 14002)
+++ trunk/qgis/src/core/qgsrasterdataprovider.cpp 2010-08-03 21:24:22 UTC (rev 14003)
@@ -25,13 +25,12 @@
{
}
-
QgsRasterDataProvider::QgsRasterDataProvider( QString const & uri )
- : QgsDataProvider( uri ), mDpi( -1 )
+ : QgsDataProvider( uri )
+ , mDpi( -1 )
{
}
-
QString QgsRasterDataProvider::capabilitiesString() const
{
QStringList abilitiesList;
@@ -53,4 +52,9 @@
return false;
}
+QString QgsRasterDataProvider::lastErrorFormat()
+{
+ return "text/plain";
+}
+
// ENDS
Modified: trunk/qgis/src/core/qgsrasterdataprovider.h
===================================================================
--- trunk/qgis/src/core/qgsrasterdataprovider.h 2010-08-03 07:39:17 UTC (rev 14002)
+++ trunk/qgis/src/core/qgsrasterdataprovider.h 2010-08-03 21:24:22 UTC (rev 14003)
@@ -172,6 +172,14 @@
*/
virtual QString lastError() = 0;
+ /**
+ * \brief Returns the format of the error text for the last error in this provider
+ *
+ * \note added in 1.6
+ */
+ virtual QString lastErrorFormat();
+
+
/**Returns the dpi of the output device.
@note: this method was added in version 1.2*/
int dpi() const {return mDpi;}
Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp 2010-08-03 07:39:17 UTC (rev 14002)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp 2010-08-03 21:24:22 UTC (rev 14003)
@@ -727,6 +727,7 @@
if ( !status.isNull() && status.toInt() >= 400 )
{
QVariant phrase = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
+ mErrorFormat = "text/plain";
mError = tr( "tile request err %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
emit statusChanged( mError );
@@ -808,6 +809,7 @@
if ( !status.isNull() && status.toInt() >= 400 )
{
QVariant phrase = cacheReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
+ mErrorFormat = "text/plain";
mError = tr( "map request error %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
emit statusChanged( mError );
@@ -865,10 +867,19 @@
if ( httpcapabilitiesresponse.isEmpty() )
{
- QgsDebugMsg( "empty capabilities: " + mError );
+ mErrorFormat = "text/plain";
+ mError = tr( "empty capabilities document" );
return false;
}
+ if ( httpcapabilitiesresponse.startsWith( "<html>" ) ||
+ httpcapabilitiesresponse.startsWith( "<HTML>" ) )
+ {
+ mErrorFormat = "text/html";
+ mError = httpcapabilitiesresponse;
+ return false;
+ }
+
QgsDebugMsg( "Converting to Dom." );
bool domOK;
@@ -919,11 +930,13 @@
if ( httpcapabilitiesresponse.isEmpty() )
{
+ mErrorFormat = "text/plain";
mError = tr( "empty of capabilities: %1" ).arg( mCapabilitiesReply->errorString() );
}
}
else
{
+ mErrorFormat = "text/plain";
mError = tr( "Download of capabilities failed: %1" ).arg( mCapabilitiesReply->errorString() );
QgsDebugMsg( "error: " + mError );
httpcapabilitiesresponse.clear();
@@ -966,9 +979,12 @@
if ( !contentSuccess )
{
mErrorCaption = tr( "Dom Exception" );
- mError = tr( "Could not get WMS capabilities: %1 at line %2 column %3\n" )
- .arg( errorMsg ).arg( errorLine ).arg( errorColumn )
- + tr( "This is probably due to an incorrect WMS Server URL." );
+ mErrorFormat = "text/plain";
+ mError = tr( "Could not get WMS capabilities: %1 at line %2 column %3\nThis is probably due to an incorrect WMS Server URL.\nResponse was:\n\n%4" )
+ .arg( errorMsg )
+ .arg( errorLine )
+ .arg( errorColumn )
+ .arg( QString( xml ) );
QgsLogger::debug( "Dom Exception: " + mError );
@@ -986,10 +1002,12 @@
)
{
mErrorCaption = tr( "Dom Exception" );
- mError = tr( "Could not get WMS capabilities in the "
- "expected format (DTD): no %1 or %2 found\n" )
- .arg( "WMS_Capabilities" ).arg( "WMT_MS_Capabilities" )
- + tr( "This is probably due to an incorrect WMS Server URL." );
+ mErrorFormat = "text/plain";
+ mError = tr( "Could not get WMS capabilities in the expected format (DTD): no %1 or %2 found.\nThis might be due to an incorrect WMS Server URL.\nTag:%3\nResponse was:\n%4" )
+ .arg( "WMS_Capabilities" )
+ .arg( "WMT_MS_Capabilities" )
+ .arg( docElem.tagName() )
+ .arg( QString( xml ) );
QgsLogger::debug( "Dom Exception: " + mError );
@@ -1825,11 +1843,13 @@
if ( !contentSuccess )
{
mErrorCaption = tr( "Dom Exception" );
- mError = tr( "Could not get WMS Service Exception at %1: %2 at line %3 column %4" )
+ mErrorFormat = "text/plain";
+ mError = tr( "Could not get WMS Service Exception at %1: %2 at line %3 column %4\n\nResponse was:\n\n%4" )
.arg( mBaseUrl )
.arg( errorMsg )
.arg( errorLine )
- .arg( errorColumn );
+ .arg( errorColumn )
+ .arg( QString( xml ) );
QgsLogger::debug( "Dom Exception: " + mError );
@@ -1875,10 +1895,12 @@
QString seCode = e.attribute( "code" );
QString seText = e.text();
+ mErrorFormat = "text/plain";
+
// set up friendly descriptions for the service exception
if ( seCode == "InvalidFormat" )
{
- mError = tr( "Request contains a Format not offered by the server." );
+ mError = tr( "Request contains a format not offered by the server." );
}
else if ( seCode == "InvalidCRS" )
{
@@ -2744,6 +2766,7 @@
if ( !status.isNull() && status.toInt() >= 400 )
{
QVariant phrase = mIdentifyReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
+ mErrorFormat = "text/plain";
mError = tr( "map request error %1: %2" ).arg( status.toInt() ).arg( phrase.toString() );
emit statusChanged( mError );
@@ -2781,6 +2804,10 @@
return mError;
}
+QString QgsWmsProvider::lastErrorFormat()
+{
+ return mErrorFormat;
+}
QString QgsWmsProvider::name() const
{
Modified: trunk/qgis/src/providers/wms/qgswmsprovider.h
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.h 2010-08-03 07:39:17 UTC (rev 14002)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.h 2010-08-03 21:24:22 UTC (rev 14003)
@@ -579,9 +579,13 @@
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
-
QString lastError();
+ /**
+ * \brief Returns the format of the error message (text or html)
+ */
+ QString lastErrorFormat();
+
/** return a provider name
Essentially just returns the provider key. Should be used to build file
@@ -884,6 +888,11 @@
*/
QString mError;
+
+ /** The mime type of the message
+ */
+ QString mErrorFormat;
+
//! A QgsCoordinateTransform is used for transformation of WMS layer extents
QgsCoordinateTransform *mCoordinateTransform;
More information about the QGIS-commit
mailing list