本文整理汇总了Python中qgis.PyQt.QtWidgets.QApplication.processEvents方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.processEvents方法的具体用法?Python QApplication.processEvents怎么用?Python QApplication.processEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.processEvents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: end_process
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def end_process(self):
"""
Make some stuff after the process
"""
self.pushButton_runQuery.setDisabled(False)
self.pushButton_runQuery.setText(self.pushButton_runQuery.initialText)
self.progressBar_execution.setMinimum(0)
self.progressBar_execution.setMaximum(100)
self.progressBar_execution.setValue(100)
QApplication.processEvents()
示例2: execute
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def execute(func, message = None, useThread = False):
global _dialog
cursor = QApplication.overrideCursor()
waitCursor = (cursor is not None and cursor.shape() == Qt.WaitCursor)
dialogCreated = False
try:
QCoreApplication.processEvents()
if not waitCursor:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if message is not None and useThread:
t = Thread(func)
loop = QEventLoop()
t.finished.connect(loop.exit, Qt.QueuedConnection)
if _dialog is None:
dialogCreated = True
_dialog = QProgressDialog(message, "Mapstory", 0, 0, config.iface.mainWindow())
_dialog.setWindowTitle("Mapstory")
_dialog.setWindowModality(Qt.WindowModal);
_dialog.setMinimumDuration(1000)
_dialog.setMaximum(100)
_dialog.setValue(0)
_dialog.setMaximum(0)
_dialog.setCancelButton(None)
else:
oldText = _dialog.labelText()
_dialog.setLabelText(message)
QApplication.processEvents()
t.start()
loop.exec_(flags = QEventLoop.ExcludeUserInputEvents)
if t.exception is not None:
raise t.exception
return t.returnValue
else:
return func()
finally:
if message is not None and useThread:
if dialogCreated:
_dialog.reset()
_dialog = None
else:
_dialog.setLabelText(oldText)
if not waitCursor:
QApplication.restoreOverrideCursor()
QCoreApplication.processEvents()
示例3: process_query
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def process_query(
dialog=None,
query=None,
nominatim=None,
bbox=None,
output_dir=None,
prefix_file=None,
output_geometry_types=None,
layer_name="OsmQuery",
white_list_values=None,
config_outputs=None):
"""execute a query and send the result file to open_file."""
# Prepare outputs
dialog.set_progress_text(tr('Prepare outputs'))
# Getting the default overpass api and running the query
server = get_setting('defaultOAPI', OVERPASS_SERVERS[0]) + 'interpreter'
dialog.set_progress_text(
tr('Downloading data from Overpass {}').format(server))
# Replace Nominatim or BBOX
query = QueryPreparation(query, bbox, nominatim, server)
QApplication.processEvents()
final_query = query.prepare_query()
url = query.prepare_url()
connexion_overpass_api = ConnexionOAPI(url)
LOGGER.debug('Encoded URL: {}'.format(url))
osm_file = connexion_overpass_api.run()
return open_file(
dialog=dialog,
osm_file=osm_file,
output_geom_types=output_geometry_types,
white_list_column=white_list_values,
layer_name=layer_name,
output_dir=output_dir,
prefix_file=prefix_file,
final_query=final_query,
config_outputs=config_outputs)
示例4: set_progress_text
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def set_progress_text(self, text):
"""
Slot to update text during process
"""
self.label_progress.setText(text)
QApplication.processEvents()
示例5: set_progress_percentage
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def set_progress_percentage(self, percent):
"""
Slot to update percentage during process
"""
self.progressBar_execution.setValue(percent)
QApplication.processEvents()
示例6: open_file
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def open_file(
dialog=None,
osm_file=None,
output_geom_types=None,
white_list_column=None,
layer_name="OsmFile",
config_outputs=None,
output_dir=None,
final_query=None,
prefix_file=None):
"""
Open an osm file.
Memory layer if no output directory is set, or Geojson in the output directory.
:param final_query: The query where the file comes from. Might be empty if
it's a local OSM file.
:type final_query: basestring
"""
outputs = {}
if output_dir:
for layer in ['points', 'lines', 'multilinestrings', 'multipolygons']:
if not prefix_file:
prefix_file = layer_name
outputs[layer] = join(
output_dir, prefix_file + "_" + layer + ".geojson")
if isfile(outputs[layer]):
raise FileOutPutException(suffix='(' + outputs[layer] + ')')
# Legacy, waiting to remove the OsmParser for QGIS >= 3.6
# Change in osm_file_dialog.py L131 too
output_geom_legacy = [l.value.lower() for l in output_geom_types]
if not white_list_column:
white_list_column = {}
white_list_legacy = (
{l.value.lower(): csv for l, csv in white_list_column.items()}
)
LOGGER.info('The OSM file is: {}'.format(osm_file))
# Parsing the file
osm_parser = OsmParser(
osm_file=osm_file,
layers=output_geom_legacy,
white_list_column=white_list_legacy)
osm_parser.signalText.connect(dialog.set_progress_text)
osm_parser.signalPercentage.connect(dialog.set_progress_percentage)
start_time = time.time()
layers = osm_parser.parse()
elapsed_time = time.time() - start_time
parser_time = time.strftime("%Hh %Mm %Ss", time.gmtime(elapsed_time))
LOGGER.info('The OSM parser took: {}'.format(parser_time))
# Finishing the process with geojson or memory layer
num_layers = 0
for i, (layer, item) in enumerate(layers.items()):
dialog.set_progress_percentage(i / len(layers) * 100)
QApplication.processEvents()
if item['featureCount'] and LayerType(layer.capitalize()) in output_geom_types:
final_layer_name = layer_name
# If configOutputs is not None (from My Queries)
if config_outputs:
if config_outputs[layer]['namelayer']:
final_layer_name = config_outputs[layer]['namelayer']
if output_dir:
dialog.set_progress_text(tr('From memory to GeoJSON: ' + layer))
# Transforming the vector file
osm_geometries = {
'points': QgsWkbTypes.Point,
'lines': QgsWkbTypes.LineString,
'multilinestrings': QgsWkbTypes.MultiLineString,
'multipolygons': QgsWkbTypes.MultiPolygon}
memory_layer = item['vector_layer']
encoding = get_default_encoding()
writer = QgsVectorFileWriter(
outputs[layer],
encoding,
memory_layer.fields(),
osm_geometries[layer],
memory_layer.crs(),
"GeoJSON")
for f in memory_layer.getFeatures():
writer.addFeature(f)
del writer
# Loading the final vector file
new_layer = QgsVectorLayer(outputs[layer], final_layer_name, "ogr")
else:
new_layer = item['vector_layer']
new_layer.setName(final_layer_name)
#.........这里部分代码省略.........
示例7: wkblify_raster_level
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def wkblify_raster_level(self, options, ds, level, band_range, infile, i):
band_from = band_range[0]
band_to = band_range[1]
# Collect raster and block dimensions
raster_size = ( ds.RasterXSize, ds.RasterYSize )
if options['block_size'] is not None:
block_size = self.parse_block_size(options, ds)
read_block_size = ( block_size[0] * level, block_size[1] * level)
grid_size = self.calculate_grid_size(raster_size, read_block_size)
else:
block_size = raster_size # Whole raster as a single block
read_block_size = block_size
grid_size = (1, 1)
gen_table = options['schema_table']
# Write (original) raster to hex binary output
tile_count = 0
hexwkb = ''
self.progress_label.setText(self.tr("Uploading tiles..."))
importString = ""
sum_tiles = grid_size[0]*grid_size[1]
copy_size = 500
for ycell in range(0, grid_size[1]):
for xcell in range(0, grid_size[0]):
xoff = xcell * read_block_size[0]
yoff = ycell * read_block_size[1]
if options['block_size'] is not None:
hexwkb = '' # Reset buffer as single INSERT per tile is generated
hexwkb += self.wkblify_raster_header(options, ds, level, (xoff, yoff),
block_size[0], block_size[1])
else:
hexwkb += self.wkblify_raster_header(options, ds, level, (xoff, yoff))
for b in range(band_from, band_to):
band = ds.GetRasterBand(b)
hexwkb += self.wkblify_band_header(options, band)
hexwkb += self.wkblify_band(options, band, level, xoff, yoff, read_block_size, block_size, infile, b)
# Creating COPY String
importString += str(tile_count)+"\t"+hexwkb+"\n"
tile_count = tile_count + 1
# Periodically update ui
if (tile_count % copy_size) == 0:
self.cursor.copy_from(StringIO(importString), '%s' % gen_table)
importString = ""
self.progress_label.setText(self.tr("{table}: {count} of {sum_tiles} tiles uploaded").format(
table=gen_table,
count=tile_count,
sum_tiles= sum_tiles))
QApplication.processEvents()
self.cursor.copy_from(StringIO(importString), '%s' % gen_table)
self.conn.commit()
self.progress_label.setText(self.tr("Calculating raster params for {sum_tiles} tiles ...").format(
sum_tiles= sum_tiles))
QApplication.processEvents()
self.cursor.execute(self.make_sql_addrastercolumn(options))
self.conn.commit()
return (gen_table, tile_count)
示例8: profiles_progress
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def profiles_progress(self, msg):
self.iface.mainWindow().statusBar().showMessage(msg)
self.ui.IDC_lblCreateStatus.setText(msg)
QApplication.processEvents()
示例9: run_query
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def run_query(self):
"""
Process for running the query
"""
# Block the button and save the initial text
QApplication.setOverrideCursor(Qt.WaitCursor)
self.output_directory.setDisabled(True)
self.pushButton_showQuery.setDisabled(True)
self.start_process()
QApplication.processEvents()
# Get all values
key = self.comboBox_key.currentText()
value = self.comboBox_value.currentText()
nominatim = self.nominatim_value()
timeout = self.spinBox_timeout.value()
output_directory = self.output_directory.filePath()
prefix_file = self.lineEdit_filePrefix.text()
query_type = self.cb_query_type.currentData()
is_around = query_type == 'around'
distance = self.spinBox_distance_point.value()
# Which geometry at the end ?
output_geometry_types = self.get_output_geometry_types()
# Which osm objects ?
osm_objects = self._get_osm_objects()
try:
# Test values
if not osm_objects:
raise OsmObjectsException
if not output_geometry_types:
raise OutPutGeomTypesException
# If bbox, we must set None to nominatim, we can't have both
bbox = None
if query_type in ['layer', 'canvas']:
nominatim = None
bbox = self.get_bounding_box()
if nominatim == '':
nominatim = None
if output_directory and not isdir(output_directory):
raise DirectoryOutPutException
num_layers = process_quick_query(
dialog=self,
key=key,
value=value,
nominatim=nominatim,
is_around=is_around,
distance=distance,
bbox=bbox,
osm_objects=osm_objects,
timeout=timeout,
output_directory=output_directory,
prefix_file=prefix_file,
output_geometry_types=output_geometry_types)
# We can test numLayers to see if there are some results
if num_layers:
self.label_progress.setText(
tr('Successful query'))
display_message_bar(
tr('Successful query'),
level=Qgis.Success,
duration=5)
else:
self.label_progress.setText(tr('No result'))
display_message_bar(
tr('Successful query, but no result.'),
level=Qgis.Warning,
duration=7)
except QuickOsmException as e:
self.display_geo_algorithm_exception(e)
except Exception as e: # pylint: disable=broad-except
self.display_exception(e)
finally:
# Resetting the button
self.output_directory.setDisabled(False)
self.pushButton_showQuery.setDisabled(False)
QApplication.restoreOverrideCursor()
self.end_process()
QApplication.processEvents()
示例10: upload
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def upload(self, db, data_sources_items, maxSize):
import_ok = True
layers_to_replace = {}
raster_to_upload = {}
self.status_bar.showMessage(self.tr("Uploading to database '{db}'...").format(db=db.database))
QApplication.processEvents()
messages = ""
# Connect to database
try:
conn = db.psycopg_connection()
cursor = conn.cursor()
except Exception as e:
raise RuntimeError("Connection to database failed %s" % str(e))
for data_source, item in list(data_sources_items.items()):
# Check available space, block if exceded
size = DbConnections().db_size()
if size > float(maxSize):
QMessageBox.warning(None, self.tr("Database full"), self.tr("You have exceeded the maximum database size for your current QGIS Cloud plan. Please free up some space or upgrade your QGIS Cloud plan."))
break
# Layers contains all layers with shared data source
layer = item['layers'][0]
if layer.type() == QgsMapLayer.VectorLayer:
fields = QgsFields(layer.fields())
srid = layer.crs().postgisSrid()
geom_column = "wkb_geometry"
wkbType = layer.wkbType()
# Check if database schema exists
cursor.execute("SELECT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = '%s')" % item['schema'])
schema_exists = cursor.fetchone()[0]
if not schema_exists:
cursor.execute("create schema %s" % item['schema'])
if wkbType == QgsWkbTypes.NoGeometry:
cloudUri = "dbname='%s' host=%s port=%d user='%s' password='%s' key='' table=\"%s\".\"%s\"" % (
db.database, db.host, db.port, db.username, db.password, item['schema'], item['table'])
geom_column = ""
else:
if not QgsWkbTypes.isMultiType(wkbType):
wkbType = QgsWkbTypes.multiType(wkbType)
# Create table (pk='' => always generate a new primary key)
cloudUri = "dbname='%s' host=%s port=%d user='%s' password='%s' key='' table=\"%s\".\"%s\" (%s)" % (
db.database, db.host, db.port, db.username, db.password, item['schema'], item['table'], geom_column
)
self.progress_label.setText(self.tr("Creating table '{table}'...").format(table=item['table']))
QApplication.processEvents()
if wkbType != QgsWkbTypes.NoGeometry:
# Check if SRID is known on database, otherwise create record
cursor.execute("SELECT srid FROM public.spatial_ref_sys WHERE srid = %s" % layer.crs().postgisSrid())
if not cursor.fetchone():
try:
cursor.execute("INSERT INTO public.spatial_ref_sys VALUES ({srid},'EPSG',{srid},'{wktstr}','{projstr}')".format(
srid = layer.crs().postgisSrid(),
wktstr = layer.crs().toWkt(),
projstr = layer.crs().toProj4()))
conn.commit()
except Exception as e:
conn.rollback()
import_ok &= False
messages += "Failed to create SRS record on database: " + str(e) + "\n"
continue
# cursor.close()
# TODO: Ask user for overwriting existing table
# The postgres provider is terribly slow at creating tables with
# many attribute columns in QGIS < 2.9.0
vectorLayerImport = PGVectorLayerImport(db, conn, cursor, cloudUri, fields, wkbType, layer.crs(), True)
if vectorLayerImport.hasError():
import_ok &= False
messages += "VectorLayerImport-Error: "+vectorLayerImport.errorMessage() + "\n"
continue
vectorLayerImport = None
# Build import string
attribs = list(range(0, fields.count()))
count = 0
importstr = bytearray()
ok = True
self.progress_label.setText(self.tr("Uploading features..."))
QApplication.processEvents()
for feature in layer.getFeatures():
f_geometry = feature.geometry()
f_geometry.convertToMultiType()
# First field is primary key
importstr.extend(str(count).encode('utf-8'))
#.........这里部分代码省略.........
示例11: run_query
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def run_query(self):
"""
Process for running the query
"""
# Block the button and save the initial text
self.output_directory.setDisabled(True)
self.pushButton_generateQuery.setDisabled(True)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.start_process()
QApplication.processEvents()
# Get all values
query = self.textEdit_query.toPlainText()
output_directory = self.output_directory.filePath()
prefix_file = self.lineEdit_filePrefix.text()
nominatim = self.nominatim_value()
# Set bbox
bbox = None
if self.cb_query_type.isEnabled():
query_type = self.cb_query_type.currentData()
if query_type in ['layer', 'canvas']:
nominatim = None
bbox = self.get_bounding_box()
# Check nominatim
if nominatim == '':
nominatim = None
# Which geometry at the end ?
output_geometry_types = self.get_output_geometry_types()
white_list_values = self.get_white_list_values()
try:
# Test values
if not output_geometry_types:
raise OutPutGeomTypesException
if output_directory and not isdir(output_directory):
raise DirectoryOutPutException
if not nominatim and \
re.search(r'\{\{nominatim\}\}', query) or \
re.search(r'\{\{nominatimArea:\}\}', query) or \
re.search(r'\{\{geocodeArea:\}\}', query):
raise MissingParameterException(suffix="nominatim field")
num_layers = process_query(
dialog=self,
query=query,
output_dir=output_directory,
prefix_file=prefix_file,
output_geometry_types=output_geometry_types,
white_list_values=white_list_values,
nominatim=nominatim,
bbox=bbox)
if num_layers:
display_message_bar(
tr('Successful query'),
level=Qgis.Success,
duration=5)
self.label_progress.setText(
tr('Successful query'))
else:
display_message_bar(
tr('Successful query, but no result.'),
level=Qgis.Warning,
duration=7)
except QuickOsmException as e:
self.display_geo_algorithm_exception(e)
pass
except Exception as e: # pylint: disable=broad-except
self.display_exception(e)
pass
finally:
# Resetting the button
self.output_directory.setDisabled(False)
self.pushButton_generateQuery.setDisabled(False)
QApplication.restoreOverrideCursor()
self.end_process()
QApplication.processEvents()
示例12: open_file
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def open_file(self):
"""
Open the osm file with the osmconf
"""
QApplication.setOverrideCursor(Qt.WaitCursor)
self.start_process()
QApplication.processEvents()
# Get fields
osm_file = self.osm_file.filePath()
osm_conf = self.osm_conf.filePath()
output_directory = self.output_directory.filePath()
prefix_file = self.lineEdit_filePrefix.text()
load_only = self.radioButton_osmConf.isChecked()
# Which geometry at the end ?
output_geometry_types = self.get_output_geometry_types()
try:
if not output_geometry_types:
raise OutPutGeomTypesException
if not isfile(osm_file):
raise FileDoesntExistException(suffix="*.osm or *.pbf")
if load_only:
if not isfile(osm_conf):
raise FileDoesntExistException(suffix="*.ini")
if output_directory and not isdir(output_directory):
raise DirectoryOutPutException
if load_only:
# Legacy, waiting to remove the OsmParser for QGIS >= 3.6
# Change in osm_file_dialog.py L131 too
output_geom_legacy = [
l.value.lower() for l in output_geometry_types]
osm_parser = OsmParser(
osm_file,
load_only=True,
osm_conf=osm_conf,
layers=output_geom_legacy)
layers = osm_parser.parse()
for item in list(layers.values()):
QgsProject.instance().addMapLayer(item)
else:
open_file(
dialog=self,
osm_file=osm_file,
output_geom_types=output_geometry_types,
output_dir=output_directory,
prefix_file=prefix_file)
display_message_bar(
tr('Successful query'),
level=Qgis.Success,
duration=5)
except QuickOsmException as e:
self.display_geo_algorithm_exception(e)
except Exception as e: # pylint: disable=broad-except
self.display_exception(e)
finally:
QApplication.restoreOverrideCursor()
self.end_process()
QApplication.processEvents()
示例13: processEvents
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def processEvents():
try:
qApp.processEvents()
except:
QApplication.processEvents()
示例14: __init__
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def __init__(self, conn, cursor, raster, max_size, progress_label):
QObject.__init__(self)
self.cursor = cursor
self.conn = conn
self.progress_label = progress_label
self.messages = ""
opts = {}
opts['version'] = g_rt_version
opts['endian'] = NDR
opts['column'] = 'rast'
opts['create_table'] = 1
opts['drop_table'] = 1
opts['overview_level'] = 1
opts['block_size'] = 'auto'
opts['band'] = None
opts['register'] = None
# Create PostGIS Raster Tool Functions
raster_tools_file = "%s/raster_tools.sql" % os.path.dirname(__file__)
sql = open(raster_tools_file).read().encode('ascii',errors='ignore')
self.cursor.execute(sql)
self.conn.commit()
i = 0
# Burn all specified input raster files into single WKTRaster table
gt = None
layer_info = raster
opts['srid'] = layer_info['layer'].dataProvider().crs().postgisSrid()
infile = layer_info['data_source']
file_info = QFileInfo(infile)
file_size = file_info.size()
size = DbConnections().db_size()
file_size /= 1024 * 1024
size = size + file_size
if size > float(max_size):
QMessageBox.warning(None, self.tr("Database full"), self.tr("Upload would exceeded the maximum database size for your current QGIS Cloud plan. Please free up some space or upgrade your QGIS Cloud plan."))
return False
opts['schema_table'] = "\"%s\".\"%s\"" % (layer_info['schema_name'], layer_info['table_name'])
opts['table'] = layer_info['table_name']
opts['schema'] = layer_info['schema_name']
self.progress_label.setText(self.tr("Creating table '{table}'...").format(table=opts['schema_table'].replace('"', '')))
QApplication.processEvents()
self.cursor.execute(self.make_sql_drop_raster_table(opts['schema_table']))
self.conn.commit()
self.cursor.execute(self.make_sql_create_table(opts, opts['schema_table']))
self.conn.commit()
gt = self.wkblify_raster(opts, infile.replace( '\\', '/') , i, gt)
i += 1
self.cursor.execute(self.make_sql_create_gist(opts['schema_table'], opts['column']))
self.conn.commit()
# create raster overviews
for level in [4, 8, 16, 32]:
sql = 'drop table if exists "%s"."o_%d_%s"' %(opts['schema'], level, opts['table'])
self.cursor.execute(sql)
self.conn.commit()
sql = "select st_createoverview_qgiscloud('%s'::text, '%s'::name, %d)" % (opts['schema_table'].replace('"', ''), opts['column'], level)
self.progress_label.setText(self.tr("Creating overview-level {level} for table '{table}'...").format(level=level, table=opts['schema_table'].replace('"', '')))
QApplication.processEvents()
self.cursor.execute(sql)
self.conn.commit()
index_table = opts['schema']+'.o_'+str(level)+'_'+opts['table']
self.cursor.execute(self.make_sql_create_gist(index_table, opts['column']))
self.conn.commit()
self.progress_label.setText(self.tr("Registering raster columns of table '%s'..." % (opts['schema_table'].replace('"', ''))))
QApplication.processEvents()
self.cursor.execute(self.make_sql_addrastercolumn(opts))
self.conn.commit()
示例15: test
# 需要导入模块: from qgis.PyQt.QtWidgets import QApplication [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QApplication import processEvents [as 别名]
def test(self):
# This test is quite fragile as it depends on windows manager behaviour
# regarding focus, so not surprising it doesn't pass
# on other platforms than Linux.
#if 'TRAVIS_OS_NAME' in os.environ and os.environ['TRAVIS_OS_NAME'] == 'osx':
# return
main_dialog = QgsProviderRegistry.instance().selectWidget("WFS")
main_dialog.setProperty("hideDialogs", True)
self.assertIsNotNone(main_dialog)
# Create new connection
btnNew = main_dialog.findChild(QWidget, "btnNew")
self.assertIsNotNone(btnNew)
QTest.mouseClick(btnNew, Qt.LeftButton)
new_conn = find_window('QgsNewHttpConnectionBase')
self.assertIsNotNone(new_conn)
txtName = new_conn.findChild(QLineEdit, "txtName")
self.assertIsNotNone(txtName)
txtName.setText("test_connection")
txtUrl = new_conn.findChild(QLineEdit, "txtUrl")
self.assertIsNotNone(txtUrl)
txtUrl.setText("test_url")
new_conn.accept()
# Wait for object to be destroyed
new_conn = self.wait_object_destruction(new_conn)
# Try to connect
btnConnect = main_dialog.findChild(QWidget, "btnConnect")
self.assertIsNotNone(btnConnect)
QTest.mouseClick(btnConnect, Qt.LeftButton)
# Depends on asynchronous signal
QApplication.processEvents()
error_box = find_window('WFSCapabilitiesErrorBox')
self.assertIsNotNone(error_box)
# Close error box
error_box.accept()
# Wait for object to be destroyed
error_box = self.wait_object_destruction(error_box)
# Edit connection
btnEdit = main_dialog.findChild(QWidget, "btnEdit")
self.assertIsNotNone(btnEdit)
QTest.mouseClick(btnEdit, Qt.LeftButton)
new_conn = find_window('QgsNewHttpConnectionBase',)
self.assertIsNotNone(new_conn)
txtName = new_conn.findChild(QLineEdit, "txtName")
self.assertIsNotNone(txtName)
txtName.setText("test_connection")
txtUrl = new_conn.findChild(QLineEdit, "txtUrl")
self.assertIsNotNone(txtUrl)
endpoint = self.basetestpath + '/fake_qgis_http_endpoint'
expected_endpoint = endpoint
if sys.platform == 'win32' and expected_endpoint[1] == ':':
expected_endpoint = expected_endpoint[0] + expected_endpoint[2:]
with open(sanitize(endpoint, '?SERVICE=WFS?REQUEST=GetCapabilities?ACCEPTVERSIONS=2.0.0,1.1.0,1.0.0'), 'wb') as f:
f.write("""
<wfs:WFS_Capabilities version="2.0.0" xmlns="http://www.opengis.net/wfs/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://schemas.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0">
<FeatureTypeList>
<FeatureType>
<Name>my:typename</Name>
<Title>Title</Title>
<Abstract>Abstract</Abstract>
<DefaultCRS>urn:ogc:def:crs:EPSG::4326</DefaultCRS>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-71.123 66.33</ows:LowerCorner>
<ows:UpperCorner>-65.32 78.3</ows:UpperCorner>
</ows:WGS84BoundingBox>
</FeatureType>
</FeatureTypeList>
<fes:Filter_Capabilities>
<fes:Spatial_Capabilities>
<fes:GeometryOperands>
<fes:GeometryOperand name="gml:Envelope"/>
<fes:GeometryOperand name="gml:Point"/>
<fes:GeometryOperand name="gml:MultiPoint"/>
<fes:GeometryOperand name="gml:LineString"/>
<fes:GeometryOperand name="gml:MultiLineString"/>
<fes:GeometryOperand name="gml:Polygon"/>
<fes:GeometryOperand name="gml:MultiPolygon"/>
<fes:GeometryOperand name="gml:MultiGeometry"/>
</fes:GeometryOperands>
<fes:SpatialOperators>
<fes:SpatialOperator name="Disjoint"/>
<fes:SpatialOperator name="Equals"/>
<fes:SpatialOperator name="DWithin"/>
<fes:SpatialOperator name="Beyond"/>
<fes:SpatialOperator name="Intersects"/>
<fes:SpatialOperator name="Touches"/>
<fes:SpatialOperator name="Crosses"/>
<fes:SpatialOperator name="Within"/>
<fes:SpatialOperator name="Contains"/>
<fes:SpatialOperator name="Overlaps"/>
<fes:SpatialOperator name="BBOX"/>
</fes:SpatialOperators>
#.........这里部分代码省略.........