mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
show wms get capabilities error
git-svn-id: http://svn.osgeo.org/qgis/trunk@14003 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
665157bd5a
commit
a97db4595e
@ -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 @@ public:
|
||||
/**
|
||||
* 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 @@ public:
|
||||
/**
|
||||
* 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,9 +73,9 @@ public:
|
||||
|
||||
|
||||
// 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
|
||||
@ -96,7 +96,7 @@ public:
|
||||
* \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 @@ public:
|
||||
*
|
||||
* \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 @@ public:
|
||||
*/
|
||||
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 );
|
||||
};
|
||||
|
||||
|
@ -1021,20 +1021,17 @@ void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
|
||||
|
||||
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 @@ void QgsWMSSourceSelect::on_cmbConnections_activated( int )
|
||||
{
|
||||
// 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()
|
||||
|
@ -25,13 +25,12 @@ QgsRasterDataProvider::QgsRasterDataProvider(): mDpi( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QgsRasterDataProvider::QgsRasterDataProvider( QString const & uri )
|
||||
: QgsDataProvider( uri ), mDpi( -1 )
|
||||
: QgsDataProvider( uri )
|
||||
, mDpi( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString QgsRasterDataProvider::capabilitiesString() const
|
||||
{
|
||||
QStringList abilitiesList;
|
||||
@ -53,4 +52,9 @@ bool QgsRasterDataProvider::identify( const QgsPoint& thePoint, QMap<QString, QS
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QgsRasterDataProvider::lastErrorFormat()
|
||||
{
|
||||
return "text/plain";
|
||||
}
|
||||
|
||||
// ENDS
|
||||
|
@ -172,6 +172,14 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
|
||||
*/
|
||||
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;}
|
||||
|
@ -727,6 +727,7 @@ void QgsWmsProvider::tileReplyFinished()
|
||||
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 @@ void QgsWmsProvider::cacheReplyFinished()
|
||||
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,7 +867,16 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -919,11 +930,13 @@ void QgsWmsProvider::capabilitiesReplyFinished()
|
||||
|
||||
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 @@ bool QgsWmsProvider::parseCapabilitiesDom( QByteArray const &xml, QgsWmsCapabili
|
||||
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 @@ bool QgsWmsProvider::parseCapabilitiesDom( QByteArray const &xml, QgsWmsCapabili
|
||||
)
|
||||
{
|
||||
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 @@ bool QgsWmsProvider::parseServiceExceptionReportDom( QByteArray const & xml )
|
||||
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 @@ void QgsWmsProvider::parseServiceException( QDomElement const & e )
|
||||
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 @@ void QgsWmsProvider::identifyReplyFinished()
|
||||
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 @@ QString QgsWmsProvider::lastError()
|
||||
return mError;
|
||||
}
|
||||
|
||||
QString QgsWmsProvider::lastErrorFormat()
|
||||
{
|
||||
return mErrorFormat;
|
||||
}
|
||||
|
||||
QString QgsWmsProvider::name() const
|
||||
{
|
||||
|
@ -579,9 +579,13 @@ class QgsWmsProvider : public QgsRasterDataProvider
|
||||
* 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 @@ class QgsWmsProvider : public QgsRasterDataProvider
|
||||
*/
|
||||
QString mError;
|
||||
|
||||
|
||||
/** The mime type of the message
|
||||
*/
|
||||
QString mErrorFormat;
|
||||
|
||||
//! A QgsCoordinateTransform is used for transformation of WMS layer extents
|
||||
QgsCoordinateTransform *mCoordinateTransform;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user