24 QString QgsVectorTileProviderConnection::encodedUri(
const QgsVectorTileProviderConnection::Data &conn )
27 uri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"xyz" ) );
28 uri.
setParam( QStringLiteral(
"url" ), conn.url );
29 if ( conn.zMin != -1 )
30 uri.
setParam( QStringLiteral(
"zmin" ), QString::number( conn.zMin ) );
31 if ( conn.zMax != -1 )
32 uri.
setParam( QStringLiteral(
"zmax" ), QString::number( conn.zMax ) );
36 QgsVectorTileProviderConnection::Data QgsVectorTileProviderConnection::decodedUri(
const QString &uri )
41 QgsVectorTileProviderConnection::Data conn;
42 conn.url = dsUri.
param( QStringLiteral(
"url" ) );
43 conn.zMin = dsUri.
hasParam( QStringLiteral(
"zmin" ) ) ? dsUri.
param( QStringLiteral(
"zmin" ) ).toInt() : -1;
44 conn.zMax = dsUri.
hasParam( QStringLiteral(
"zmax" ) ) ? dsUri.
param( QStringLiteral(
"zmax" ) ).toInt() : -1;
48 QString QgsVectorTileProviderConnection::encodedLayerUri(
const QgsVectorTileProviderConnection::Data &conn )
52 uri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"xyz" ) );
53 uri.
setParam( QStringLiteral(
"url" ), conn.url );
54 if ( conn.zMin != -1 )
55 uri.
setParam( QStringLiteral(
"zmin" ), QString::number( conn.zMin ) );
56 if ( conn.zMax != -1 )
57 uri.
setParam( QStringLiteral(
"zmax" ), QString::number( conn.zMax ) );
61 QStringList QgsVectorTileProviderConnection::connectionList()
64 settings.
beginGroup( QStringLiteral(
"qgis/connections-vector-tile" ) );
70 QgsVectorTileProviderConnection::Data QgsVectorTileProviderConnection::connection(
const QString &name )
73 settings.
beginGroup(
"qgis/connections-vector-tile/" + name );
75 if ( settings.
value(
"url" ).toString().isEmpty() )
76 return QgsVectorTileProviderConnection::Data();
78 QgsVectorTileProviderConnection::Data conn;
79 conn.url = settings.
value( QStringLiteral(
"url" ) ).toString();
80 conn.zMin = settings.
value( QStringLiteral(
"zmin" ), -1 ).toInt();
81 conn.zMax = settings.
value( QStringLiteral(
"zmax" ), -1 ).toInt();
85 void QgsVectorTileProviderConnection::deleteConnection(
const QString &name )
88 settings.
remove(
"qgis/connections-vector-tile/" + name );
91 void QgsVectorTileProviderConnection::addConnection(
const QString &name, QgsVectorTileProviderConnection::Data conn )
95 settings.
beginGroup(
"qgis/connections-vector-tile/" + name );
96 settings.
setValue( QStringLiteral(
"url" ), conn.url );
97 settings.
setValue( QStringLiteral(
"zmin" ), conn.zMin );
98 settings.
setValue( QStringLiteral(
"zmax" ), conn.zMax );
101 QString QgsVectorTileProviderConnection::selectedConnection()
104 return settings.
value( QStringLiteral(
"qgis/connections-vector-tile/selected" ) ).toString();
107 void QgsVectorTileProviderConnection::setSelectedConnection(
const QString &name )
110 return settings.
setValue( QStringLiteral(
"qgis/connections-vector-tile/selected" ), name );
115 QgsVectorTileProviderConnection::QgsVectorTileProviderConnection(
const QString &name )
118 setUri( encodedUri( connection( name ) ) );
121 QgsVectorTileProviderConnection::QgsVectorTileProviderConnection(
const QString &uri,
const QVariantMap &configuration )
126 void QgsVectorTileProviderConnection::store(
const QString &name )
const
128 addConnection( name, decodedUri( uri() ) );
131 void QgsVectorTileProviderConnection::remove(
const QString &name )
const
133 deleteConnection( name );