-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE][needs-docs] Add XYZ connection to provide default OpenStreetMap tiles #5000
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
273243b
Add XYZ connection to provide default OpenStreetMap tiles
jgrocha 8486767
Support removal of global defined XYZ connections
jgrocha 59aa5d3
Fix TRAVIS qgis_global_settings path
jgrocha ce01bc0
Include settings.globalChildGroups in test
jgrocha 7af72f7
Improve test: assert → assertTrue
jgrocha 390a34f
settings.globalChildGroups() test moved to test_qgssettings.py
jgrocha dc50a3e
settings.globalChildGroups() test moved to test_qgssettings.py
jgrocha a82dd5b
Merge remote-tracking branch 'origin/add-default-layers' into add-def…
jgrocha aa4213f
remove unwanted files
jgrocha e681547
remove unnecessary test
jgrocha 858413e
Improve test: assert → assertTrue
jgrocha File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
INSTALL(FILES srs.db qgis.db symbology-style.xml spatialite.db customization.xml | ||
DESTINATION ${QGIS_DATA_DIR}/resources) | ||
INSTALL(FILES qgis_global_settings.ini | ||
DESTINATION ${QGIS_DATA_DIR}) | ||
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources) | ||
INSTALL(DIRECTORY themes DESTINATION ${QGIS_DATA_DIR}/resources) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[qgis] | ||
connections-xyz\OpenStreetMap\authcfg= | ||
connections-xyz\OpenStreetMap\password= | ||
connections-xyz\OpenStreetMap\referer= | ||
connections-xyz\OpenStreetMap\url=http://a.tile.openstreetmap.org/{z}/{x}/{y}.png | ||
connections-xyz\OpenStreetMap\username= | ||
connections-xyz\OpenStreetMap\zmax=19 | ||
connections-xyz\OpenStreetMap\zmin=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
*************************************************************************** | ||
test_qgis_global_settings.py | ||
--------------------- | ||
Date : January 2017 | ||
Copyright : (C) 2017, Jorge Gustavo Rocha | ||
Email : jgr at geomaster dot pt | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
*************************************************************************** | ||
""" | ||
|
||
__author__ = 'Jorge Gustavo Rocha' | ||
__date__ = 'August 2017' | ||
__copyright__ = '(C) 2017, Jorge Gustavo Rocha' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
from qgis.testing import start_app, unittest | ||
from qgis.PyQt.QtCore import qDebug | ||
from qgis.core import QgsApplication, QgsRasterLayer, QgsSettings | ||
|
||
start_app() | ||
|
||
|
||
def createXYZLayerFromURL(url): | ||
typeandurl = "type=xyz&url=" + url | ||
osm = QgsRasterLayer(typeandurl, "OpenStreetMap", "wms") | ||
return osm | ||
|
||
|
||
class TestQgsGlobalSettings(unittest.TestCase): | ||
|
||
def setUp(self): | ||
qDebug('QgsApplication.pkgDataPath(): {0}'.format(QgsApplication.pkgDataPath())) | ||
# Path after deployment | ||
# QgsSettings.setGlobalSettingsPath(QgsApplication.pkgDataPath() + '/qgis_global_settings.ini') | ||
# Path before deployment | ||
assert QgsSettings.setGlobalSettingsPath(QgsApplication.pkgDataPath() + '/resources/qgis_global_settings.ini') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @m-kuhn thanks! Fixed! |
||
self.settings = QgsSettings('testqgissettings', 'testqgissettings') | ||
|
||
def test_global_settings_exist(self): | ||
qDebug('settings.allKeys(): {0}'.format(self.settings.allKeys())) | ||
defaulturl = self.settings.value('qgis/connections-xyz/OpenStreetMap/url') | ||
self.assertEqual(defaulturl, 'http://a.tile.openstreetmap.org/{z}/{x}/{y}.png') | ||
layer = createXYZLayerFromURL(defaulturl) | ||
self.assertEqual(layer.name(), 'OpenStreetMap') | ||
|
||
def test_global_settings_group(self): | ||
self.assertEqual(['qgis'], self.settings.childGroups()) | ||
self.assertEqual(['qgis'], self.settings.globalChildGroups()) | ||
|
||
self.settings.beginGroup('qgis') | ||
self.assertEqual(['connections-xyz'], self.settings.childGroups()) | ||
self.assertEqual(['connections-xyz'], self.settings.globalChildGroups()) | ||
# qDebug('settings.allKeys(): {0}'.format(self.settings.allKeys())) | ||
self.settings.endGroup() | ||
|
||
self.settings.beginGroup('qgis/connections-xyz') | ||
self.assertEqual(['OpenStreetMap'], self.settings.childGroups()) | ||
self.assertEqual(['OpenStreetMap'], self.settings.globalChildGroups()) | ||
# qDebug('settings.allKeys(): {0}'.format(self.settings.allKeys())) | ||
self.settings.endGroup() | ||
|
||
# add group to user's settings | ||
self.settings.beginGroup('qgis/connections-xyz') | ||
self.settings.setValue('OSM/url', 'http://c.tile.openstreetmap.org/{z}/{x}/{y}.png') | ||
self.settings.setValue('OSM/zmax', '19') | ||
self.settings.setValue('OSM/zmin', '0') | ||
self.settings.endGroup() | ||
|
||
# groups should be different | ||
self.settings.beginGroup('qgis/connections-xyz') | ||
self.assertEqual(['OSM', 'OpenStreetMap'], self.settings.childGroups()) | ||
self.assertEqual(['OpenStreetMap'], self.settings.globalChildGroups()) | ||
# qDebug('settings.allKeys(): {0}'.format(self.settings.allKeys())) | ||
self.settings.endGroup() | ||
|
||
self.settings.beginGroup('qgis/connections-xyz') | ||
self.settings.remove('OSM') | ||
self.assertEqual(['OpenStreetMap'], self.settings.childGroups()) | ||
self.assertEqual(['OpenStreetMap'], self.settings.globalChildGroups()) | ||
self.settings.endGroup() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a test case for
globalChildGroups()
to https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgssettings.py ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @elpaso. I discovered another minor issue writing the test. The test now covers the
settings.globalChildGroups()
.