本文整理汇总了Python中qgis.core.QgsApplication.qgisUserDatabaseFilePath方法的典型用法代码示例。如果您正苦于以下问题:Python QgsApplication.qgisUserDatabaseFilePath方法的具体用法?Python QgsApplication.qgisUserDatabaseFilePath怎么用?Python QgsApplication.qgisUserDatabaseFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsApplication
的用法示例。
在下文中一共展示了QgsApplication.qgisUserDatabaseFilePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDatabaseFilePath [as 别名]
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() + "/python/plugins/" + __package__
# initialize locale. Default to Danish
self.config = QSettings()
localePath = ""
try:
locale = self.config.value("locale/userLocale")[0:2]
except:
locale = 'da'
if QFileInfo(self.plugin_dir).exists():
localePath = self.plugin_dir + "/i18n/" + locale + ".qt.qm"
if QFileInfo(localePath).exists():
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QgsApplication.installTranslator(self.translator)
# new config method
self.settings = Settings()
self.options_factory = OptionsFactory(self.settings)
self.options_factory.setTitle('Geosearch DK')
iface.registerOptionsWidgetFactory(self.options_factory)
示例2: getTranslate
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDatabaseFilePath [as 别名]
def getTranslate(namePlugin, nameDir=None):
if nameDir is None:
nameDir = namePlugin
pluginPath = os.path.join('python', 'plugins', nameDir)
userPath = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path()
userPluginPath = os.path.join(userPath, pluginPath)
systemPath = QgsApplication.prefixPath()
systemPluginPath = os.path.join(systemPath, pluginPath)
overrideLocale = QSettings().value('locale/overrideFlag', False, type=bool)
localeFullName = QLocale.system().name() if not overrideLocale else QSettings().value('locale/userLocale', '')
qmPathFile = os.path.join('i18n', '{0}_{1}.qm'.format(namePlugin, localeFullName))
pp = userPluginPath if QFileInfo(userPluginPath).exists() else systemPluginPath
translationFile = os.path.join(pp, qmPathFile)
if QFileInfo(translationFile).exists():
translator = QTranslator()
translator.load(translationFile)
QCoreApplication.installTranslator(translator)
QgsApplication.messageLog().logMessage(('Installed translation file {}'.format(translationFile)), 'Midvatten',
level=Qgis.Info)
return translator
else:
QgsApplication.messageLog().logMessage(
("translationFile {} didn't exist, no translation file installed!".format(translationFile)), 'Midvatten',
level=Qgis.Info)
示例3: _populate_bookmarks_list
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDatabaseFilePath [as 别名]
def _populate_bookmarks_list(self):
"""Read the sqlite database and populate the bookmarks list.
If no bookmarks are found, the bookmarks radio button will be disabled
and the label will be shown indicating that the user should add
bookmarks in QGIS first.
Every bookmark are reprojected to mapcanvas crs.
"""
# Connect to the QGIS sqlite database and check if the table exists.
# noinspection PyArgumentList
db_file_path = QgsApplication.qgisUserDatabaseFilePath()
db = sqlite3.connect(db_file_path)
cursor = db.cursor()
cursor.execute(
'SELECT COUNT(*) '
'FROM sqlite_master '
'WHERE type=\'table\' '
'AND name=\'tbl_bookmarks\';')
number_of_rows = cursor.fetchone()[0]
if number_of_rows > 0:
cursor.execute(
'SELECT * '
'FROM tbl_bookmarks;')
bookmarks = cursor.fetchall()
canvas_crs = self.canvas.mapSettings().destinationCrs()
for bookmark in bookmarks:
name = bookmark[1]
srid = bookmark[7]
rectangle = QgsRectangle(
bookmark[3], bookmark[4], bookmark[5], bookmark[6])
if srid != canvas_crs.srsid():
transform = QgsCoordinateTransform(
QgsCoordinateReferenceSystem(srid),
canvas_crs,
QgsProject.instance()
)
try:
rectangle = transform.transform(rectangle)
except QgsCsException:
rectangle = QgsRectangle()
if rectangle.isEmpty():
pass
self.bookmarks_list.addItem(name, rectangle)
if self.bookmarks_list.currentIndex() >= 0:
self.create_bookmarks_label.hide()
else:
self.create_bookmarks_label.show()
self.hazard_exposure_bookmark.setDisabled(True)
self.bookmarks_list.hide()
示例4: __init__
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisUserDatabaseFilePath [as 别名]
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# docked or dialog, defaults to dialog
# 2018 may: RD: deprecating Docked window, as the content is getting to big anyway
# if isinstance(QSettings().value("/pdokservicesplugin/docked"), QVariant):
# self.docked = QSettings().value("/pdokservicesplugin/docked", QVariant(False))
# else:
# self.docked = QSettings().value("/pdokservicesplugin/docked", False)
#
# # Create the dialog and keep reference
# if "True" == self.docked or "true" == self.docked or True is self.docked:
# self.dlg = PdokServicesPluginDockWidget()
# self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dlg)
# else:
# self.dlg = PdokServicesPluginDialog(parent=self.iface.mainWindow())
self.dlg = PdokServicesPluginDialog(parent=self.iface.mainWindow())
# initialize plugin directory
self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() + "/python/plugins/pdokservicesplugin"
# initialize locale
localePath = ""
if isinstance(QSettings().value("locale/userLocale"), QVariant):
locale = QSettings().value("locale/userLocale").value()[0:2]
else:
locale = QSettings().value("locale/userLocale")[0:2]
if QFileInfo(self.plugin_dir).exists():
localePath = self.plugin_dir + "/i18n/pdokservicesplugin_" + locale + ".qm"
if QFileInfo(localePath).exists():
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.currentLayer = None
self.SETTINGS_SECTION = '/pdokservicesplugin/'
self.pointer = None
self.pdokgeocoder = PDOKGeoLocator(self.iface)
self.geocoderSourceModel = None