Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] WMS-C support, new spatial authorities, wms selection impro…
…vements

- QgsDataProvider&QgsMapLayer: add dataChanged() signal, so that a provider can signal that the datasource changed
- use QNetworkAccessManager instead of QgsHttpTransaction (including caching and
  dynamic authentification to website and proxies)
- resolve EPSG dependency in spatial reference systems and
  included french IGNF definitions in srs.db
- wms provider:
  - do request asynchronously through QNetworkAccessManager
  - add support for WMS-C
  - dataChanged() is to cause a redraw asynchronously, when new tiles arrive
- wms selection:
  - add support for WMS-C tilesets
  - allow inserting of all layers of a branch
  - add support for more mime types
  - move load/save to button box
  - and more cleanups
- raster provider: reduce debugging noise
- allow adding parts to multi points and lines



git-svn-id: http://svn.osgeo.org/qgis/trunk@13093 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 20, 2010
1 parent 2394e50 commit 7fb0e90
Show file tree
Hide file tree
Showing 33 changed files with 2,330 additions and 1,480 deletions.
Binary file modified resources/srs.db
Binary file not shown.
14 changes: 7 additions & 7 deletions scripts/postprocess_srs.sql
Expand Up @@ -4,17 +4,17 @@

-- Swedish RT-90 projections with increased accuracy
INSERT INTO tbl_srs VALUES(NULL,'RT90 7.5 gon V from WGS84','tmerc','GRS80',
'+proj=tmerc +lat_0=0 +lon_0=11.306250000000 +k=1.000006000000 +x_0=1500025.141 +y_0=-667.282 +ellps=GRS80 +units=m +no_defs',93019,93019,0);
'+proj=tmerc +lat_0=0 +lon_0=11.306250000000 +k=1.000006000000 +x_0=1500025.141 +y_0=-667.282 +ellps=GRS80 +units=m +no_defs',93019,'EPSG',93019,0);
INSERT INTO tbl_srs VALUES(NULL,'RT90 5 gon V from WGS84','tmerc','GRS80',
'+proj=tmerc +lat_0=0 +lon_0=13.55626666666 +k=1.000005800000 +x_0=1500044.695 +y_0=-667.130 +ellps=GRS80 +units=m +no_defs',93020,93020,0);
'+proj=tmerc +lat_0=0 +lon_0=13.55626666666 +k=1.000005800000 +x_0=1500044.695 +y_0=-667.130 +ellps=GRS80 +units=m +no_defs',93020,'EPSG',93020,0);
INSERT INTO tbl_srs VALUES(NULL,'RT90 2.5 gon V from WGS84','tmerc','GRS80',
'+proj=tmerc +lat_0=0 +lon_0=15.806284529444 +k=1.000005610240 +x_0=1500064.274 +y_0=-667.711 +ellps=GRS80 +units=m +no_defs',93021,93021,0);
'+proj=tmerc +lat_0=0 +lon_0=15.806284529444 +k=1.000005610240 +x_0=1500064.274 +y_0=-667.711 +ellps=GRS80 +units=m +no_defs',93021,'EPSG',93021,0);
INSERT INTO tbl_srs VALUES(NULL,'RT90 0 gon from WGS84','tmerc','GRS80',
'+proj=tmerc +lat_0=0 +lon_0=18.056300000000 +k=1.000005400000 +x_0=1500083.521 +y_0=-668.844 +ellps=GRS80 +units=m +no_defs',93022,93022,0);
'+proj=tmerc +lat_0=0 +lon_0=18.056300000000 +k=1.000005400000 +x_0=1500083.521 +y_0=-668.844 +ellps=GRS80 +units=m +no_defs',93022,'EPSG',93022,0);
INSERT INTO tbl_srs VALUES(NULL,'RT90 2.5 gon O from WGS84','tmerc','GRS80',
'+proj=tmerc +lat_0=0 +lon_0=20.306316666666 +k=1.000005200000 +x_0=1500102.765 +y_0=-670.706 +ellps=GRS80 +units=m +no_defs',93023,93023,0);
'+proj=tmerc +lat_0=0 +lon_0=20.306316666666 +k=1.000005200000 +x_0=1500102.765 +y_0=-670.706 +ellps=GRS80 +units=m +no_defs',93023,'EPSG',93023,0);
INSERT INTO tbl_srs VALUES(NULL,'RT90 5 gon O from WGS84','tmerc','GRS80',
'+proj=tmerc +lat_0=0 +lon_0=22.556333333333 +k=1.000004900000 +x_0=1500121.846 +y_0=-672.557 +ellps=GRS80 +units=m +no_defs',93024,93024,0);
'+proj=tmerc +lat_0=0 +lon_0=22.556333333333 +k=1.000004900000 +x_0=1500121.846 +y_0=-672.557 +ellps=GRS80 +units=m +no_defs',93024,'EPSG',93024,0);

-- S-JTSK/Krovak (Greenwich) (ticket #728)
INSERT INTO tbl_srs VALUES (NULL,'S-JTSK (Greenwich) / Krovak','krovak','bessel','+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs','102067','102067','0');
INSERT INTO tbl_srs VALUES (NULL,'S-JTSK (Greenwich) / Krovak','krovak','bessel','+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs','102067','EPSG','102067','0');
8 changes: 5 additions & 3 deletions scripts/qgis_srs.sh
Expand Up @@ -164,7 +164,8 @@ echo "CREATE TABLE tbl_srs (
ellipsoid_acronym NOT NULL,
parameters text NOT NULL,
srid integer NULL,
epsg integer NULL,
auth_name varchar NULL,
auth_id varchar NULL,
is_geo integer NOT NULL
);"
}
Expand Down Expand Up @@ -233,7 +234,8 @@ echo "CREATE VIEW vw_srs as
a.is_geo as is_geo,
b.name as name,
a.parameters as parameters,
a.epsg as epsg
a.auth_name as auth_name,
a.auth_id as auth_id
from tbl_srs a
inner join tbl_projection b
on a.projection_acronym=b.acronym
Expand Down Expand Up @@ -268,7 +270,7 @@ elif [ "$1" = "--srs" ]; then
mk_tbl_projs; pop_tbl_projs
mk_tbl_srss_srs; pop_tbl_srss
mk_view
echo "CREATE UNIQUE INDEX idx_srsepsg on tbl_srs(epsg);
echo "CREATE UNIQUE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);
CREATE UNIQUE INDEX idx_srssrid on tbl_srs(srid);
COMMIT;"

Expand Down
181 changes: 163 additions & 18 deletions src/app/qgisapp.cpp
Expand Up @@ -45,7 +45,6 @@
#include <QMenuBar>
#include <QMenuItem>
#include <QMessageBox>
#include <QNetworkProxy>
#include <QPainter>
#include <QPictureIO>
#include <QPixmap>
Expand All @@ -67,6 +66,13 @@
#include <QToolButton>
#include <QVBoxLayout>
#include <QWhatsThis>

#include <QNetworkAccessManager>
#include <QNetworkDiskCache>
#include <QNetworkReply>
#include <QNetworkProxy>
#include <QAuthenticator>

//
// Mac OS X Includes
// Must include before GEOS 3 due to unqualified use of 'Point'
Expand Down Expand Up @@ -328,12 +334,12 @@ QgisApp *QgisApp::smInstance = 0;

// constructor starts here
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WFlags fl )
: QMainWindow( parent, fl ),
mSplash( splash ),
mPythonUtils( NULL )
: QMainWindow( parent, fl )
, mSplash( splash )
, mPythonUtils( NULL )
, mNAM( NULL )
#ifdef HAVE_QWT
,
mpGpsWidget( NULL )
, mpGpsWidget( NULL )
#endif
{
if ( smInstance )
Expand All @@ -347,6 +353,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,

smInstance = this;

namSetup();

// setupUi(this);
resize( 640, 480 );

Expand Down Expand Up @@ -1841,6 +1849,9 @@ void QgisApp::setupConnections()
connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( markDirty() ) );
connect( mMapLegend, SIGNAL( zOrderChanged() ), this, SLOT( markDirty() ) );

connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ),
this, SLOT( layerWasAdded( QgsMapLayer * ) ) );

connect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), mMapCanvas, SLOT( setRenderFlag( bool ) ) );
//
// Do we really need this ??? - its already connected to the esc key...TS
Expand Down Expand Up @@ -4468,11 +4479,7 @@ void QgisApp::loadPythonSupport()
#endif
QString version = QString( "%1.%2.%3" ).arg( QGis::QGIS_VERSION_INT / 10000 ).arg( QGis::QGIS_VERSION_INT / 100 % 100 ).arg( QGis::QGIS_VERSION_INT % 100 );
QgsDebugMsg( QString( "load library %1 (%2)" ).arg( pythonlibName ).arg( version ) );
#if QT_VERSION >= 0x040400
QLibrary pythonlib( pythonlibName, version );
#else
QLibrary pythonlib( pythonlibName );
#endif
// It's necessary to set these two load hints, otherwise Python library won't work correctly
// see http://lists.kde.org/?l=pykde&m=117190116820758&w=2
pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );
Expand Down Expand Up @@ -5074,6 +5081,25 @@ void QgisApp::markDirty()
QgsProject::instance()->dirty( true );
}

void QgisApp::layerWasAdded( QgsMapLayer *layer )
{
QgsDataProvider *provider = 0;

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( vlayer )
provider = vlayer->dataProvider();

QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
if ( rlayer )
provider = rlayer->dataProvider();

if ( provider )
{
connect( provider, SIGNAL( dataChanged() ), layer, SLOT( clearCacheImage() ) );
connect( provider, SIGNAL( dataChanged() ), mMapCanvas, SLOT( refresh() ) );
}
}

void QgisApp::showExtents()
{
if ( !mToggleExtentsViewButton->isChecked() )
Expand Down Expand Up @@ -5194,7 +5220,7 @@ void QgisApp::projectProperties()
SLOT( updateMouseCoordinatePrecision() ) );
QApplication::restoreOverrideCursor();

//pass any refresg signals off to canvases
//pass any refresh signals off to canvases
// Line below was commented out by wonder three years ago (r4949).
// It is needed to refresh scale bar after changing display units.
connect( pp, SIGNAL( refresh() ), mMapCanvas, SLOT( refresh() ) );
Expand Down Expand Up @@ -5345,12 +5371,14 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionCapturePoint->setEnabled( true );
mActionCapturePoint->setVisible( true );
mActionDeletePart->setEnabled( true );
mActionAddIsland->setEnabled( true );
}
else
{
mActionCapturePoint->setEnabled( false );
mActionCapturePoint->setVisible( false );
mActionDeletePart->setEnabled( false );
mActionAddIsland->setEnabled( false );
}
mActionCaptureLine->setEnabled( false );
mActionCapturePolygon->setEnabled( false );
Expand All @@ -5362,6 +5390,9 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionMoveVertex->setEnabled( false );
#endif
mActionAddRing->setEnabled( false );
#if 0
mActionAddIsland->setEnabled( false );
#endif
mActionAddIsland->setEnabled( false );
mActionReshapeFeatures->setEnabled( false );
mActionSplitFeatures->setEnabled( false );
Expand Down Expand Up @@ -5608,6 +5639,7 @@ bool QgisApp::addRasterLayer( QgsRasterLayer * theRasterLayer )
SIGNAL( drawingProgress( int, int ) ),
this,
SLOT( showProgress( int, int ) ) );

// connect up any request the raster may make to update the statusbar message
QObject::connect( theRasterLayer,
SIGNAL( statusChanged( QString ) ),
Expand Down Expand Up @@ -5681,13 +5713,14 @@ QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterFile, QString con
\note Copied from the equivalent addVectorLayer function in this file
TODO Make it work for rasters specifically.
*/
QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterLayerPath,
QString const & baseName,
QString const & providerKey,
QStringList const & layers,
QStringList const & styles,
QString const & format,
QString const & crs )
QgsRasterLayer* QgisApp::addRasterLayer(
QString const &rasterLayerPath,
QString const &baseName,
QString const &providerKey,
QStringList const & layers,
QStringList const & styles,
QString const &format,
QString const &crs )
{
QgsDebugMsg( "about to get library for " + providerKey );

Expand Down Expand Up @@ -6127,3 +6160,115 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )

}
}

void QgisApp::namSetup()
{
if ( mNAM )
return;

mNAM = new QNetworkAccessManager( this );

namUpdate();

connect( mNAM, SIGNAL( authenticationRequired( QNetworkReply *, QAuthenticator * ) ),
this, SLOT( namAuthenticationRequired( QNetworkReply *, QAuthenticator * ) ) );

connect( mNAM, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ),
this, SLOT( namProxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ) );

QCoreApplication::instance()->setProperty( "qgisNetworkAccessManager", qVariantFromValue<QObject*>( mNAM ) );
}

QNetworkAccessManager *QgisApp::nam()
{
namSetup();
return mNAM;
}

void QgisApp::namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth )
{
QString username = auth->user();
QString password = auth->password();

bool ok = QgsCredentials::instance()->get(
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
username, password,
tr( "Authentication required" ) );
if ( !ok )
return;

auth->setUser( username );
auth->setPassword( password );
}

void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth )
{
QString username = auth->user();
QString password = auth->password();

bool ok = QgsCredentials::instance()->get(
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
username, password,
tr( "Proxy authentication required" ) );
if ( !ok )
return;

auth->setUser( username );
auth->setPassword( password );
}

void QgisApp::namUpdate()
{
QSettings settings;

//read type, host, port, user, passw from settings
QString proxyHost = settings.value( "proxy/proxyHost", "" ).toString();
int proxyPort = settings.value( "proxy/proxyPort", "" ).toString().toInt();
QString proxyUser = settings.value( "proxy/proxyUser", "" ).toString();
QString proxyPassword = settings.value( "proxy/proxyPassword", "" ).toString();

QString proxyTypeString = settings.value( "proxy/proxyType", "" ).toString();
QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
if ( proxyTypeString == "DefaultProxy" )
{
proxyType = QNetworkProxy::DefaultProxy;
}
else if ( proxyTypeString == "Socks5Proxy" )
{
proxyType = QNetworkProxy::Socks5Proxy;
}
else if ( proxyTypeString == "HttpProxy" )
{
proxyType = QNetworkProxy::HttpProxy;
}
else if ( proxyTypeString == "HttpCachingProxy" )
{
proxyType = QNetworkProxy::HttpCachingProxy;
}
else if ( proxyTypeString == "FtpCachingProxy" )
{
proxyType = QNetworkProxy::FtpCachingProxy;
}
QgsDebugMsg( QString( "setting proxy %1 %2:%3 %4/%5" )
.arg( proxyType )
.arg( proxyHost ).arg( proxyPort )
.arg( proxyUser ).arg( proxyPassword )
);
nam()->setProxy( QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword ) );

QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>( nam()->cache() );
if ( !cache )
cache = new QNetworkDiskCache( this );

QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
qint64 cacheSize = settings.value( "cache/size", 50 * 1024 * 1024 ).toULongLong();
QgsDebugMsg( QString( "setCacheDirectory: %1" ).arg( cacheDirectory ) );
QgsDebugMsg( QString( "setMaximumCacheSize: %1" ).arg( cacheSize ) );
cache->setCacheDirectory( cacheDirectory );
cache->setMaximumCacheSize( cacheSize );
QgsDebugMsg( QString( "cacheDirectory: %1" ).arg( cache->cacheDirectory() ) );
QgsDebugMsg( QString( "maximumCacheSize: %1" ).arg( cache->maximumCacheSize() ) );

if ( mNAM->cache() != cache )
mNAM->setCache( cache );
}

0 comments on commit 7fb0e90

Please sign in to comment.