Skip to content

Commit 7fb0e90

Browse files
author
jef
committed
[FEATURE] WMS-C support, new spatial authorities, wms selection improvements
- 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
1 parent 2394e50 commit 7fb0e90

33 files changed

+2330
-1480
lines changed

resources/srs.db

161 KB
Binary file not shown.

scripts/postprocess_srs.sql

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
-- Swedish RT-90 projections with increased accuracy
66
INSERT INTO tbl_srs VALUES(NULL,'RT90 7.5 gon V from WGS84','tmerc','GRS80',
7-
'+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);
7+
'+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);
88
INSERT INTO tbl_srs VALUES(NULL,'RT90 5 gon V from WGS84','tmerc','GRS80',
9-
'+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);
9+
'+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);
1010
INSERT INTO tbl_srs VALUES(NULL,'RT90 2.5 gon V from WGS84','tmerc','GRS80',
11-
'+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);
11+
'+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);
1212
INSERT INTO tbl_srs VALUES(NULL,'RT90 0 gon from WGS84','tmerc','GRS80',
13-
'+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);
13+
'+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);
1414
INSERT INTO tbl_srs VALUES(NULL,'RT90 2.5 gon O from WGS84','tmerc','GRS80',
15-
'+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);
15+
'+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);
1616
INSERT INTO tbl_srs VALUES(NULL,'RT90 5 gon O from WGS84','tmerc','GRS80',
17-
'+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);
17+
'+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);
1818

1919
-- S-JTSK/Krovak (Greenwich) (ticket #728)
20-
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');
20+
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');

scripts/qgis_srs.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ echo "CREATE TABLE tbl_srs (
164164
ellipsoid_acronym NOT NULL,
165165
parameters text NOT NULL,
166166
srid integer NULL,
167-
epsg integer NULL,
167+
auth_name varchar NULL,
168+
auth_id varchar NULL,
168169
is_geo integer NOT NULL
169170
);"
170171
}
@@ -233,7 +234,8 @@ echo "CREATE VIEW vw_srs as
233234
a.is_geo as is_geo,
234235
b.name as name,
235236
a.parameters as parameters,
236-
a.epsg as epsg
237+
a.auth_name as auth_name,
238+
a.auth_id as auth_id
237239
from tbl_srs a
238240
inner join tbl_projection b
239241
on a.projection_acronym=b.acronym
@@ -268,7 +270,7 @@ elif [ "$1" = "--srs" ]; then
268270
mk_tbl_projs; pop_tbl_projs
269271
mk_tbl_srss_srs; pop_tbl_srss
270272
mk_view
271-
echo "CREATE UNIQUE INDEX idx_srsepsg on tbl_srs(epsg);
273+
echo "CREATE UNIQUE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);
272274
CREATE UNIQUE INDEX idx_srssrid on tbl_srs(srid);
273275
COMMIT;"
274276

src/app/qgisapp.cpp

+163-18
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include <QMenuBar>
4646
#include <QMenuItem>
4747
#include <QMessageBox>
48-
#include <QNetworkProxy>
4948
#include <QPainter>
5049
#include <QPictureIO>
5150
#include <QPixmap>
@@ -67,6 +66,13 @@
6766
#include <QToolButton>
6867
#include <QVBoxLayout>
6968
#include <QWhatsThis>
69+
70+
#include <QNetworkAccessManager>
71+
#include <QNetworkDiskCache>
72+
#include <QNetworkReply>
73+
#include <QNetworkProxy>
74+
#include <QAuthenticator>
75+
7076
//
7177
// Mac OS X Includes
7278
// Must include before GEOS 3 due to unqualified use of 'Point'
@@ -328,12 +334,12 @@ QgisApp *QgisApp::smInstance = 0;
328334

329335
// constructor starts here
330336
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WFlags fl )
331-
: QMainWindow( parent, fl ),
332-
mSplash( splash ),
333-
mPythonUtils( NULL )
337+
: QMainWindow( parent, fl )
338+
, mSplash( splash )
339+
, mPythonUtils( NULL )
340+
, mNAM( NULL )
334341
#ifdef HAVE_QWT
335-
,
336-
mpGpsWidget( NULL )
342+
, mpGpsWidget( NULL )
337343
#endif
338344
{
339345
if ( smInstance )
@@ -347,6 +353,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
347353

348354
smInstance = this;
349355

356+
namSetup();
357+
350358
// setupUi(this);
351359
resize( 640, 480 );
352360

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

1852+
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ),
1853+
this, SLOT( layerWasAdded( QgsMapLayer * ) ) );
1854+
18441855
connect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), mMapCanvas, SLOT( setRenderFlag( bool ) ) );
18451856
//
18461857
// Do we really need this ??? - its already connected to the esc key...TS
@@ -4468,11 +4479,7 @@ void QgisApp::loadPythonSupport()
44684479
#endif
44694480
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 );
44704481
QgsDebugMsg( QString( "load library %1 (%2)" ).arg( pythonlibName ).arg( version ) );
4471-
#if QT_VERSION >= 0x040400
44724482
QLibrary pythonlib( pythonlibName, version );
4473-
#else
4474-
QLibrary pythonlib( pythonlibName );
4475-
#endif
44764483
// It's necessary to set these two load hints, otherwise Python library won't work correctly
44774484
// see http://lists.kde.org/?l=pykde&m=117190116820758&w=2
44784485
pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );
@@ -5074,6 +5081,25 @@ void QgisApp::markDirty()
50745081
QgsProject::instance()->dirty( true );
50755082
}
50765083

5084+
void QgisApp::layerWasAdded( QgsMapLayer *layer )
5085+
{
5086+
QgsDataProvider *provider = 0;
5087+
5088+
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
5089+
if ( vlayer )
5090+
provider = vlayer->dataProvider();
5091+
5092+
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
5093+
if ( rlayer )
5094+
provider = rlayer->dataProvider();
5095+
5096+
if ( provider )
5097+
{
5098+
connect( provider, SIGNAL( dataChanged() ), layer, SLOT( clearCacheImage() ) );
5099+
connect( provider, SIGNAL( dataChanged() ), mMapCanvas, SLOT( refresh() ) );
5100+
}
5101+
}
5102+
50775103
void QgisApp::showExtents()
50785104
{
50795105
if ( !mToggleExtentsViewButton->isChecked() )
@@ -5194,7 +5220,7 @@ void QgisApp::projectProperties()
51945220
SLOT( updateMouseCoordinatePrecision() ) );
51955221
QApplication::restoreOverrideCursor();
51965222

5197-
//pass any refresg signals off to canvases
5223+
//pass any refresh signals off to canvases
51985224
// Line below was commented out by wonder three years ago (r4949).
51995225
// It is needed to refresh scale bar after changing display units.
52005226
connect( pp, SIGNAL( refresh() ), mMapCanvas, SLOT( refresh() ) );
@@ -5345,12 +5371,14 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
53455371
mActionCapturePoint->setEnabled( true );
53465372
mActionCapturePoint->setVisible( true );
53475373
mActionDeletePart->setEnabled( true );
5374+
mActionAddIsland->setEnabled( true );
53485375
}
53495376
else
53505377
{
53515378
mActionCapturePoint->setEnabled( false );
53525379
mActionCapturePoint->setVisible( false );
53535380
mActionDeletePart->setEnabled( false );
5381+
mActionAddIsland->setEnabled( false );
53545382
}
53555383
mActionCaptureLine->setEnabled( false );
53565384
mActionCapturePolygon->setEnabled( false );
@@ -5362,6 +5390,9 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
53625390
mActionMoveVertex->setEnabled( false );
53635391
#endif
53645392
mActionAddRing->setEnabled( false );
5393+
#if 0
5394+
mActionAddIsland->setEnabled( false );
5395+
#endif
53655396
mActionAddIsland->setEnabled( false );
53665397
mActionReshapeFeatures->setEnabled( false );
53675398
mActionSplitFeatures->setEnabled( false );
@@ -5608,6 +5639,7 @@ bool QgisApp::addRasterLayer( QgsRasterLayer * theRasterLayer )
56085639
SIGNAL( drawingProgress( int, int ) ),
56095640
this,
56105641
SLOT( showProgress( int, int ) ) );
5642+
56115643
// connect up any request the raster may make to update the statusbar message
56125644
QObject::connect( theRasterLayer,
56135645
SIGNAL( statusChanged( QString ) ),
@@ -5681,13 +5713,14 @@ QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterFile, QString con
56815713
\note Copied from the equivalent addVectorLayer function in this file
56825714
TODO Make it work for rasters specifically.
56835715
*/
5684-
QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterLayerPath,
5685-
QString const & baseName,
5686-
QString const & providerKey,
5687-
QStringList const & layers,
5688-
QStringList const & styles,
5689-
QString const & format,
5690-
QString const & crs )
5716+
QgsRasterLayer* QgisApp::addRasterLayer(
5717+
QString const &rasterLayerPath,
5718+
QString const &baseName,
5719+
QString const &providerKey,
5720+
QStringList const & layers,
5721+
QStringList const & styles,
5722+
QString const &format,
5723+
QString const &crs )
56915724
{
56925725
QgsDebugMsg( "about to get library for " + providerKey );
56935726

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

61286161
}
61296162
}
6163+
6164+
void QgisApp::namSetup()
6165+
{
6166+
if ( mNAM )
6167+
return;
6168+
6169+
mNAM = new QNetworkAccessManager( this );
6170+
6171+
namUpdate();
6172+
6173+
connect( mNAM, SIGNAL( authenticationRequired( QNetworkReply *, QAuthenticator * ) ),
6174+
this, SLOT( namAuthenticationRequired( QNetworkReply *, QAuthenticator * ) ) );
6175+
6176+
connect( mNAM, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ),
6177+
this, SLOT( namProxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ) );
6178+
6179+
QCoreApplication::instance()->setProperty( "qgisNetworkAccessManager", qVariantFromValue<QObject*>( mNAM ) );
6180+
}
6181+
6182+
QNetworkAccessManager *QgisApp::nam()
6183+
{
6184+
namSetup();
6185+
return mNAM;
6186+
}
6187+
6188+
void QgisApp::namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth )
6189+
{
6190+
QString username = auth->user();
6191+
QString password = auth->password();
6192+
6193+
bool ok = QgsCredentials::instance()->get(
6194+
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
6195+
username, password,
6196+
tr( "Authentication required" ) );
6197+
if ( !ok )
6198+
return;
6199+
6200+
auth->setUser( username );
6201+
auth->setPassword( password );
6202+
}
6203+
6204+
void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth )
6205+
{
6206+
QString username = auth->user();
6207+
QString password = auth->password();
6208+
6209+
bool ok = QgsCredentials::instance()->get(
6210+
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
6211+
username, password,
6212+
tr( "Proxy authentication required" ) );
6213+
if ( !ok )
6214+
return;
6215+
6216+
auth->setUser( username );
6217+
auth->setPassword( password );
6218+
}
6219+
6220+
void QgisApp::namUpdate()
6221+
{
6222+
QSettings settings;
6223+
6224+
//read type, host, port, user, passw from settings
6225+
QString proxyHost = settings.value( "proxy/proxyHost", "" ).toString();
6226+
int proxyPort = settings.value( "proxy/proxyPort", "" ).toString().toInt();
6227+
QString proxyUser = settings.value( "proxy/proxyUser", "" ).toString();
6228+
QString proxyPassword = settings.value( "proxy/proxyPassword", "" ).toString();
6229+
6230+
QString proxyTypeString = settings.value( "proxy/proxyType", "" ).toString();
6231+
QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
6232+
if ( proxyTypeString == "DefaultProxy" )
6233+
{
6234+
proxyType = QNetworkProxy::DefaultProxy;
6235+
}
6236+
else if ( proxyTypeString == "Socks5Proxy" )
6237+
{
6238+
proxyType = QNetworkProxy::Socks5Proxy;
6239+
}
6240+
else if ( proxyTypeString == "HttpProxy" )
6241+
{
6242+
proxyType = QNetworkProxy::HttpProxy;
6243+
}
6244+
else if ( proxyTypeString == "HttpCachingProxy" )
6245+
{
6246+
proxyType = QNetworkProxy::HttpCachingProxy;
6247+
}
6248+
else if ( proxyTypeString == "FtpCachingProxy" )
6249+
{
6250+
proxyType = QNetworkProxy::FtpCachingProxy;
6251+
}
6252+
QgsDebugMsg( QString( "setting proxy %1 %2:%3 %4/%5" )
6253+
.arg( proxyType )
6254+
.arg( proxyHost ).arg( proxyPort )
6255+
.arg( proxyUser ).arg( proxyPassword )
6256+
);
6257+
nam()->setProxy( QNetworkProxy( proxyType, proxyHost, proxyPort, proxyUser, proxyPassword ) );
6258+
6259+
QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>( nam()->cache() );
6260+
if ( !cache )
6261+
cache = new QNetworkDiskCache( this );
6262+
6263+
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
6264+
qint64 cacheSize = settings.value( "cache/size", 50 * 1024 * 1024 ).toULongLong();
6265+
QgsDebugMsg( QString( "setCacheDirectory: %1" ).arg( cacheDirectory ) );
6266+
QgsDebugMsg( QString( "setMaximumCacheSize: %1" ).arg( cacheSize ) );
6267+
cache->setCacheDirectory( cacheDirectory );
6268+
cache->setMaximumCacheSize( cacheSize );
6269+
QgsDebugMsg( QString( "cacheDirectory: %1" ).arg( cache->cacheDirectory() ) );
6270+
QgsDebugMsg( QString( "maximumCacheSize: %1" ).arg( cache->maximumCacheSize() ) );
6271+
6272+
if ( mNAM->cache() != cache )
6273+
mNAM->setCache( cache );
6274+
}

0 commit comments

Comments
 (0)