Python qgis.core.Qgis.Warning() Examples
The following are 26
code examples of qgis.core.Qgis.Warning().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qgis.core.Qgis
, or try the search function
.
Example #1
Source File: azDigitizer.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 14 votes |
def canvasPressEvent(self, event): """Capture the coordinate when the mouse button has been released.""" pt = self.snappoint(event.originalPixelPoint()) self.removeVertexMarker() if self.azDigitizerDialog is None: from .azDigitizer import AzDigitizerWidget self.azDigitizerDialog = AzDigitizerWidget(self.iface, self.iface.mainWindow()) layer = self.iface.activeLayer() if layer is None or layer.wkbType() != QgsWkbTypes.Point: self.azDigitizerDialog.includeStartLabel.setEnabled(False) self.azDigitizerDialog.checkBox.setEnabled(False) else: self.azDigitizerDialog.includeStartLabel.setEnabled(True) self.azDigitizerDialog.checkBox.setEnabled(True) try: canvasCRS = self.canvas.mapSettings().destinationCrs() transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance()) pt4326 = transform.transform(pt.x(), pt.y()) self.azDigitizerDialog.setPoint(pt4326) self.azDigitizerDialog.show() except Exception: self.iface.messageBar().pushMessage("", tr("Clicked location is invalid"), level=Qgis.Warning, duration=4)
Example #2
Source File: copyLatLonTool.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 7 votes |
def canvasReleaseEvent(self, event): '''Capture the coordinate when the mouse button has been released, format it, and copy it to the clipboard. pt is QgsPointXY''' pt = self.snappoint(event.originalPixelPoint()) self.removeVertexMarker() if settings.captureShowLocation: if self.marker is None: self.marker = QgsVertexMarker(self.canvas) self.marker.setIconSize(18) self.marker.setPenWidth(2) self.marker.setIconType(QgsVertexMarker.ICON_CROSS) self.marker.setCenter(pt) else: self.removeMarker() try: msg = self.formatCoord(pt, self.settings.delimiter) formatString = self.coordFormatString() if msg is not None: clipboard = QApplication.clipboard() clipboard.setText(msg) self.iface.messageBar().pushMessage("", "{} coordinate {} copied to the clipboard".format(formatString, msg), level=Qgis.Info, duration=4) except Exception as e: self.iface.messageBar().pushMessage("", "Invalid coordinate: {}".format(e), level=Qgis.Warning, duration=4)
Example #3
Source File: logger.py From orstools-qgis-plugin with MIT License | 6 votes |
def log(message, level_in=0): """ Writes to QGIS inbuilt logger accessible through panel. :param message: logging message to write, error or URL. :type message: str :param level_in: integer representation of logging level. :type level_in: int """ if level_in == 0: level = Qgis.Info elif level_in == 1: level = Qgis.Warning elif level_in == 2: level = Qgis.Critical else: level = Qgis.Info QgsMessageLog.logMessage(message, PLUGIN_NAME.strip(), level)
Example #4
Source File: QgsFmvOpenStream.py From QGISFMV with GNU General Public License v3.0 | 6 votes |
def OpenStream(self, _): protocol = self.cmb_protocol.currentText().lower() host = self.ln_host.text() port = self.ln_port.text() v = protocol + "://" + host + ":" + port if host != "" and port != "": qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvOpenStream", "Checking connection!")) QApplication.setOverrideCursor(Qt.WaitCursor) QApplication.processEvents() # Check if connection exist cap = cv2.VideoCapture(v) ret, _ = cap.read() cap.release() if ret: self.parent.AddFileRowToManager(v, v) self.close() else: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvOpenStream", "There is no such connection!"), level=QGis.Warning) QApplication.restoreOverrideCursor()
Example #5
Source File: zoomToLatLon.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 6 votes |
def zoomToPressed(self): try: text = self.coordTxt.text().strip() (lat, lon, srcCrs) = self.convertCoordinate(text) pt = self.lltools.zoomTo(srcCrs, lat, lon) if self.settings.persistentMarker: if self.marker is None: self.marker = QgsVertexMarker(self.canvas) self.marker.setCenter(pt) self.marker.setIconSize(18) self.marker.setPenWidth(2) self.marker.setIconType(QgsVertexMarker.ICON_CROSS) elif self.marker is not None: self.removeMarker() except Exception: # traceback.print_exc() self.iface.messageBar().pushMessage("", "Invalid Coordinate", level=Qgis.Warning, duration=2) return
Example #6
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 6 votes |
def packetStreamParser(self, stdout_data): '''Common packet process @type stdout_data: String @param stdout_data: Binary data ''' for packet in StreamParser(stdout_data): try: if isinstance(packet, UnknownElement): qgsu.showUserAndLogMessage( "Error interpreting klv data, metadata cannot be read.", "the parser did not recognize KLV data", level=QGis.Warning, onlyLog=True) continue data = packet.MetadataList() self.data = data if self.metadataDlg.isVisible(): # Only add metadata to table if this QDockWidget is visible (speed plugin) self.addMetadata(data) try: UpdateLayers(packet, parent=self, mosaic=self.createingMosaic, group=self.fileName) except Exception: None QApplication.processEvents() return except Exception as e: qgsu.showUserAndLogMessage("", "QgsFmvPlayer packetStreamParser failed! : " + str(e), onlyLog=True)
Example #7
Source File: minimumAreaTool.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def on_drawShape_clicked(self): """ Draws the select template shape on the map canvas """ scaleText = self.mScaleWidget.scaleString() scale = int(scaleText.split(':')[-1].replace('.','').replace(',',''))/1000 size = self.sizesComboBox.currentText() shape = self.shapesComboBox.currentText() validated = self.validateCombos(self.sizesComboBox.currentIndex(), self.shapesComboBox.currentIndex()) if validated: crs = self.iface.mapCanvas().mapSettings().destinationCrs() if crs.mapUnits() == 2: self.iface.messageBar().pushMessage(self.tr('Critical!'), self.tr('This tool does not work with angular unit reference system!'), level=Qgis.Warning, duration=3) else: self.run(scale, size, shape) else: QMessageBox.warning(self.iface.mainWindow(), self.tr(u"Error!"), self.tr(u"<font color=red>Shape value not defined :</font><br><font color=blue>Define all values to activate tool!</font>"), QMessageBox.Close)
Example #8
Source File: datasourceConversion.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def validate(self): """ Verifies contents displayed on mapping table in order to infer its validity as datasource conversion map. :return: (bool) map validity status. """ # validate map msg = self.invalidatedReason() if msg: # if an invalidation reason was given, warn user and nothing else. msgBar = QgsMessageBar(self) # if window is resized, msgBar stays, not ideal, but works for now # maybe we should connect to some parent resizing signal or something... msgBar.resize(QSize(self.geometry().size().width(), msgBar.geometry().height())) msgBar.pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) QgsMessageLog.logMessage(msg, 'DSGTools Plugin', Qgis.Critical) return msg == ''
Example #9
Source File: lineDigitizer.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 6 votes |
def canvasPressEvent(self, event): '''Capture the coordinate when the mouse button has been released.''' pt = self.snappoint(event.originalPixelPoint()) self.removeVertexMarker() layer = self.iface.activeLayer() if layer is None: return if self.lineDigitizerDialog is None: from .lineDigitizer import LineDigitizerWidget self.lineDigitizerDialog = LineDigitizerWidget(self.iface, self.iface.mainWindow()) if layer.geometryType() == QgsWkbTypes.LineGeometry: self.lineDigitizerDialog.closeLineCheckBox.setEnabled(True) else: self.lineDigitizerDialog.closeLineCheckBox.setEnabled(False) try: canvasCRS = self.canvas.mapSettings().destinationCrs() transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance()) pt4326 = transform.transform(pt.x(), pt.y()) self.lineDigitizerDialog.setPoint(pt4326) self.lineDigitizerDialog.valuesTextEdit.clear() self.lineDigitizerDialog.show() except Exception: self.iface.messageBar().pushMessage("", tr("Clicked location is invalid"), level=Qgis.Warning, duration=4)
Example #10
Source File: workflowSetupDialog.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def ok(self): """ Closes dialog and checks if current workflow is valid. """ msg = self.validate() if msg == "" and self.currentWorkflow(): self.done(1) else: self.messageBar.pushMessage( self.tr('Invalid workflow'), self.validate(), level=Qgis.Warning, duration=5 )
Example #11
Source File: workflowSetupDialog.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def export(self): """ Exports current input data as a workflow JSON, IF input is valid. :return: (bool) operation success. """ msg = self.validate() if msg != "": self.messageBar.pushMessage( self.tr('Invalid workflow'), msg, level=Qgis.Warning, duration=5 ) return False fd = QFileDialog() filename = fd.getSaveFileName( caption=self.tr("Export DSGTools Workflow"), filter=self.tr("DSGTools Workflow (*.workflow)") ) filename = filename[0] if isinstance(filename, tuple) else "" if filename == "": return False filename = filename if filename.lower().endswith(".workflow") \ else "{0}.workflow".format(filename) try: self.exportWorkflow(filename) except Exception as e: self.messageBar.pushMessage( self.tr('Invalid workflow'), self.tr("Unable to export workflow to '{fp}' ({error}).").format( fp=filename, error=str(e) ), level=Qgis.Warning, duration=5 ) return False result = os.path.exists(filename) msg = (self.tr("Workflow exported to {fp}") if result else \ self.tr("Unable to export workflow to '{fp}'")).format(fp=filename) lvl = Qgis.Success if result else Qgis.Warning self.messageBar.pushMessage( self.tr('Workflow exportation'), msg, level=lvl, duration=5 ) return result
Example #12
Source File: inspectFeatures.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def on_refreshPushButton_clicked(self): activeLayer = self.iface.activeLayer() if isinstance(activeLayer, QgsVectorLayer): self.mMapLayerComboBox.setLayer(activeLayer) else: self.iface.messageBar().pushMessage(self.tr('Warning!'), self.tr('Active layer is not valid to be used in this tool.'), level=Qgis.Warning, duration=2)
Example #13
Source File: inspectFeatures.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getFeatIdList(self, currentLayer): #getting all features ids if self.mFieldExpressionWidget.currentText() == '': featIdList = currentLayer.allFeatureIds() elif not self.mFieldExpressionWidget.isValidExpression(): self.iface.messageBar().pushMessage(self.tr('Warning!'), self.tr('Invalid attribute filter!'), level=Qgis.Warning, duration=2) return [] else: request = QgsFeatureRequest().setFilterExpression(self.mFieldExpressionWidget.asExpression()) request.setFlags(QgsFeatureRequest.NoGeometry) featIdList = [i.id() for i in currentLayer.getFeatures(request)] #sort is faster than sorted (but sort is just available for lists) featIdList.sort() return featIdList
Example #14
Source File: datasourceConversion.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def run(self, conversionMap): """ Executes conversion itself based on a conversion map. :param conversionMap: (dict) the conversion map. (SPECIFY FORMAT!) """ # task = DbConverter(iface, conversionMap, description=self.tr('DSGTools Dataset Conversion')) # summaryDlg = TextBrowserDialog(parent=iface.mainWindow()) # summaryDlg.savePushButton.setEnabled(False) # task.progressChanged.connect(summaryDlg.progressBar.setValue) # task.taskCompleted.connect(lambda : summaryDlg.setHtml(task.output['log'])) # task.taskCompleted.connect(lambda : summaryDlg.cancelPushButton.setEnabled(False)) # task.taskCompleted.connect(lambda : summaryDlg.savePushButton.setEnabled(True)) # task.conversionUpdated.connect(summaryDlg.addToHtml) # summaryDlg.cancelPushButton.clicked.connect(partial(self.cancelConversion, task, summaryDlg)) # # to clear log message before repopulating with conversion summary # task.conversionFinished.connect(summaryDlg.clearHtml) # QgsApplication.taskManager().addTask(task) # summaryDlg.show() # conversion off the thread conv = DbConverter(iface, conversionMap, description=self.tr('DSGTools Dataset Conversion')) summaryDlg = TextBrowserDialog(parent=iface.mainWindow()) summaryDlg.cancelPushButton.hide() summaryDlg.progressBar.hide() try: QtWidgets.QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) if not conv.run(): # advise conversion has failed msg = self.tr("Dataset conversion has finished with some errors. Check conversion log for details.") iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) else: self.resetInterface() QtWidgets.QApplication.restoreOverrideCursor() summaryDlg.setHtml(conv.output['log']) except Exception as e: QtWidgets.QApplication.restoreOverrideCursor() msg = self.tr("Dataset conversion has failed: '{0}'").format(', '.join(map(str, e.args))) iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical) summaryDlg.exec_()
Example #15
Source File: newDatabaseLineEdit.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def isValid(self): """ Validates selection. :return: (bool) validation status. """ # return self.validate() == '' msg = self.validate() # if msg: # # if an invalidation reason was given, warn user and nothing else. # iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) return msg == ''
Example #16
Source File: newConnectionLineEdit.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def isValid(self): """ Validates selection. :return: (bool) validation status. """ # return self.validate() == '' msg = self.validate() # if msg: # # if an invalidation reason was given, warn user and nothing else. # iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) return msg == ''
Example #17
Source File: connectionComboBox.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def isValid(self): """ Validates selection. :return: (bool) validation status. """ return self.validate() == '' # msg = self.validate() # if msg: # # if an invalidation reason was given, warn user and nothing else. # iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) # return msg == ''
Example #18
Source File: log.py From raster-vision-qgis with GNU General Public License v3.0 | 5 votes |
def log_warning(cls, msg): QgsMessageLog.logMessage(msg, tag="Raster Vision", level=Qgis.Warning)
Example #19
Source File: __init__.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setError(msg, trace=None): iface.messageBar().pushMessage("Geoserver", msg, level=Qgis.Warning, duration=10) if trace is not None: QgsMessageLog.logMessage("{}:{}".format(msg, trace), level=Qgis.Critical)
Example #20
Source File: __init__.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setWarning(msg): iface.messageBar().pushMessage("Warning", msg, level = Qgis.Warning, duration = 10)
Example #21
Source File: searchDialog.py From qgis-searchlayers-plugin with GNU General Public License v2.0 | 5 votes |
def showErrorMessage(self, message): '''Display an error message.''' self.iface.messageBar().pushMessage("", message, level=Qgis.Warning, duration=2)
Example #22
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
def statusChanged(self, status): '''Signal Status video change @type status: QMediaPlayer::MediaStatus @param status: Video status ''' self.handleCursor(status) if status is QMediaPlayer.LoadingMedia or status is QMediaPlayer.StalledMedia or status is QMediaPlayer.InvalidMedia: self.videoAvailableChanged(False) elif status == QMediaPlayer.InvalidMedia: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvPlayer", self.player.errorString()), level=QGis.Warning) self.videoAvailableChanged(False) else: self.videoAvailableChanged(True)
Example #23
Source File: QgsFmvMetadata.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
def finishedTask(self, e, result=None): """ Common finish task function """ if e is None: if result is None: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvMetadata", 'Completed with no exception and no result ' '(probably manually canceled by the user)'), level=QGis.Warning) else: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvMetadata", "Succesfully " + result['task'] + "!")) else: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvMetadata", "Failed " + result['task'] + "!"), level=QGis.Warning) raise e
Example #24
Source File: azDigitizer.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 4 votes |
def accept(self): try: distance = float(self.distLineEdit.text()) azimuth = float(self.azimuthLineEdit.text()) units = self.unitsComboBox.currentIndex() # 0 km, 1 m, 2 nm, 3 miles, 4 yards, 5 ft, 6 inches, 7 cm start = self.checkBox.isChecked() except Exception: self.iface.messageBar().pushMessage("", tr("Either distance or azimuth were invalid"), level=Qgis.Warning, duration=4) return layer = self.iface.activeLayer() if layer is None: self.iface.messageBar().pushMessage("", tr("No point or line layer selected"), level=Qgis.Warning, duration=4) return measureFactor = conversionToMeters(units) distance = distance * measureFactor pt = self.pt destCRS = layer.crs() transform = QgsCoordinateTransform(epsg4326, destCRS, QgsProject.instance()) if layer.wkbType() == QgsWkbTypes.Point: g = geod.Direct(pt.y(), pt.x(), azimuth, distance, Geodesic.LATITUDE | Geodesic.LONGITUDE) if start: ptStart = transform.transform(self.pt.x(), self.pt.y()) feat = QgsFeature(layer.fields()) feat.setGeometry(QgsGeometry.fromPointXY(ptStart)) layer.addFeature(feat) pt = transform.transform(g['lon2'], g['lat2']) feat = QgsFeature(layer.fields()) feat.setGeometry(QgsGeometry.fromPointXY(pt)) layer.addFeature(feat) else: # It will either be a LineString or MultiLineString maxseglen = settings.maxSegLength * 1000.0 # Needs to be in meters maxSegments = settings.maxSegments gline = geod.Line(pt.y(), pt.x(), azimuth) n = int(math.ceil(distance / maxseglen)) if n > maxSegments: n = maxSegments seglen = distance / n pts = [] for i in range(0, n + 1): s = seglen * i g = gline.Position(s, Geodesic.LATITUDE | Geodesic.LONGITUDE | Geodesic.LONG_UNROLL) ptc = transform.transform(g['lon2'], g['lat2']) pts.append(ptc) feat = QgsFeature(layer.fields()) if layer.wkbType() == QgsWkbTypes.LineString: feat.setGeometry(QgsGeometry.fromPolylineXY(pts)) else: feat.setGeometry(QgsGeometry.fromMultiPolylineXY([pts])) layer.addFeatures([feat]) layer.updateExtents() self.iface.mapCanvas().refresh() self.close()
Example #25
Source File: htmlExpansionDialog.py From qgis-kmltools-plugin with GNU General Public License v2.0 | 4 votes |
def accept(self): """Called when the OK button has been pressed.""" layer = self.inputLayerComboBox.currentLayer() if not layer: return newlayername = self.outputLayerLineEdit.text().strip() type = self.typeComboBox.currentIndex() # Find all the possible fields in the description area field = self.descriptionComboBox.currentField() index = layer.fields().indexFromName(field) if index == -1: self.iface.messageBar().pushMessage("", "Invalid field name", level=Qgis.Warning, duration=3) return # Set up the HTML expansion processor self.htmlProcessor = HTMLExpansionProcess(layer, field, type) self.htmlProcessor.addFeature.connect(self.addFeature) # Have it generate a list of all possible expansion field names self.htmlProcessor.autoGenerateFileds() # From the expansion processor get the list of possible expansion fields # and show a popup of them so the user can select which he wants in the output. fieldsDialog = HTMLFieldSelectionDialog(self.iface, self.htmlProcessor.fields()) fieldsDialog.exec_() # From the users selections of expansion fields, set them in the processor. # This is just a list of names. self.htmlProcessor.setDesiredFields(fieldsDialog.selected) wkbtype = layer.wkbType() layercrs = layer.crs() # Create the new list of attribute names from the original data with the unique # expansion names. fieldsout = QgsFields(layer.fields()) for item in self.htmlProcessor.uniqueDesiredNames(layer.fields().names()): fieldsout.append(QgsField(item, QVariant.String)) newLayer = QgsVectorLayer("{}?crs={}".format(QgsWkbTypes.displayString(wkbtype), layercrs.authid()), newlayername, "memory") self.dp = newLayer.dataProvider() self.dp.addAttributes(fieldsout) newLayer.updateFields() # Process each record in the input layer with the expanded entries. # The actual record is added with the 'addFeature' callback self.htmlProcessor.processSource() self.htmlProcessor.addFeature.disconnect(self.addFeature) newLayer.updateExtents() QgsProject.instance().addMapLayer(newLayer) self.close()
Example #26
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 4 votes |
def playFile(self, videoPath, islocal=False, klv_folder=None): ''' Play file from path @param videoPath: Video file path @param islocal: Check if video is local,created using multiplexor or is MISB @param klv_folder: klv folder if video is created using multiplexor ''' self.islocal = islocal self.klv_folder = klv_folder try: # Remove All Data self.RemoveAllData() self.clearMetadata() QApplication.processEvents() # Create Group root = QgsProject.instance().layerTreeRoot() node_group = QgsLayerTreeGroup(videoPath) #If you have a loaded project, insert the group #on top of it. root.insertChildNode(0, node_group) self.fileName = videoPath self.playlist = QMediaPlaylist() self.isStreaming = False if "://" in self.fileName: self.isStreaming = True if self.isStreaming: # show video from splitter (port +1) oldPort = videoPath.split(":")[2] newPort = str(int(oldPort) + 10) proto = videoPath.split(":")[0] url = QUrl(proto + "://127.0.0.1:" + newPort) else: url = QUrl.fromLocalFile(videoPath) qgsu.showUserAndLogMessage("", "Added: " + str(url), onlyLog=True) self.playlist.addMedia(QMediaContent(url)) self.player.setPlaylist(self.playlist) self.setWindowTitle(QCoreApplication.translate( "QgsFmvPlayer", 'Playing : ') + os.path.basename(videoPath)) CreateVideoLayers(hasElevationModel(), videoPath) self.HasFileAudio = True if not self.HasAudio(videoPath): self.actionAudio.setEnabled(False) self.actionSave_Audio.setEnabled(False) self.HasFileAudio = False self.playClicked(True) except Exception as e: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvPlayer", 'Open Video File : '), str(e), level=QGis.Warning)