mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -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
@ -137,6 +137,13 @@ public:
|
||||
*/
|
||||
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();
|
||||
@ -144,9 +151,5 @@ public:
|
||||
/**Sets the output device resolution.
|
||||
@note: this method was added in version 1.2*/
|
||||
void setDpi( int dpi );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
@ -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