Python qgis.core.Qgis.Info() Examples
The following are 23
code examples of qgis.core.Qgis.Info().
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: 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 #2
Source File: acquisition.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def run(self, func, action): layer = self.canvas.currentLayer() if layer in self.iface.editableLayers(): if layer.geometryType() in [QgsWkbTypes.LineGeometry , QgsWkbTypes.PolygonGeometry]: if self.tool: self.tool.deactivate() self.tool = func(self.canvas, self.iface, action) self.tool.setAction(action) self.canvas.setMapTool(self.tool) else: self.iface.messageBar().pushMessage(self.tr('Warning'), self.tr('Tool not defined for points'), level=Qgis.Info, duration=3) self.tool.deactivate() if self.tool else "" else: self.iface.messageBar().pushMessage(self.tr('Warning'), self.tr('Start editing in current layer!'), level=Qgis.Info, duration=3) self.tool.deactivate() if self.tool else ""
Example #3
Source File: flipLineTool.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def flipSelectedLines(self): """ Method for flipping all selected lines. Used for button callback. """ # get all selected features and remove all features that are not lines selectedFeatures = self.getAllSelectedLines() pop = 0 for idx, item in enumerate(selectedFeatures): if item[2] != 1: selectedFeatures.pop(idx-pop) pop += 1 if not selectedFeatures: logMsg = self.getLogMessage(None, None) self.iface.messageBar().pushMessage(self.tr('Error'), logMsg, level=Qgis.Critical, duration=3) # QMessageBox.critical(self, self.tr('Critical!'), logMsg) QgsMessageLog.logMessage(logMsg, "DSGTools Plugin", Qgis.Critical) return # call the method for flipping features from geometry module flippedLines, failedLines = self.DsgGeometryHandler.flipFeatureList(featureList=selectedFeatures, debugging=True) logMsg = self.getLogMessage(flippedLines, failedLines) self.iface.messageBar().pushMessage(self.tr('Success'), logMsg, level=Qgis.Info, duration=3) QgsMessageLog.logMessage(logMsg, "DSGTools Plugin", Qgis.Info)
Example #4
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 #5
Source File: field_toolbox.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def reclassify(self): """ Performs the actual reclassification, moving the geometry to the correct layer along with the specified attributes """ if not self.checkConditions(): return #button that sent the signal self.buttonName = self.sender().text().split(' [')[0].replace('&', '') (reclassificationLayer, self.category, self.edgvClass) = self.getLayerFromButton(self.buttonName) if reclassificationLayer is not None: reclassificationDict = self.reclassificationDict[self.category][self.edgvClass][self.buttonName] reclassifiedFeatures = self.layerHandler.reclassifySelectedFeatures( reclassificationLayer, reclassificationDict ) self.iface.mapCanvas().refreshAllLayers() if reclassifiedFeatures > 0: self.iface.messageBar().pushMessage( self.tr('Information!'), self.tr('{} features reclassified with success!').format(reclassifiedFeatures), level=Qgis.Info, duration=3 )
Example #6
Source File: progressWidget.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def __init__(self, min, max, message, parent=None, timeout = 1.5): """ Constructs a progress widget """ super(self.__class__, self).__init__(parent) self.min = min self.max = max sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) if parent: self.setMinimumSize(parent.width(),40) else: self.setMinimumSize(766,40) self.setSizePolicy(sizePolicy) self.progressBar = QProgressBar() self.progressBar.setMinimum(min) self.progressBar.setMaximum(max) self.parent = parent self.msgBarItem = QgsMessageBarItem(self.tr("INFO: "), message, self.progressBar, level=Qgis.Info, duration=timeout, parent = self.parent) self.pushItem(self.msgBarItem) self.parent.repaint()
Example #7
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 6 votes |
def saveInfoToJson(self): """ Save video Info to json """ out_json, _ = askForFiles(self, QCoreApplication.translate( "QgsFmvPlayer", "Save Json"), isSave=True, exts="json") if not out_json: return taskSaveInfoToJson = QgsTask.fromFunction('Save Video Info to Json Task', self.converter.probeToJson, fname=self.fileName, output=out_json, on_finished=self.finishedTask, flags=QgsTask.CanCancel) QgsApplication.taskManager().addTask(taskSaveInfoToJson) return
Example #8
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
def showVideoInfo(self): ''' Show default probe info ''' taskSaveInfoToJson = QgsTask.fromFunction('Show Video Info Task', self.converter.probeShow, fname=self.fileName, on_finished=self.finishedTask, flags=QgsTask.CanCancel) QgsApplication.taskManager().addTask(taskSaveInfoToJson) return
Example #9
Source File: workflowSetupDialog.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def import_(self): """ Request a file for Workflow importation and sets it to GUI. :return: (bool) operation status. """ fd = QFileDialog() filename = fd.getOpenFileName( caption=self.tr('Select a Workflow file'), filter=self.tr('DSGTools Workflow (*.workflow *.json)') ) filename = filename[0] if isinstance(filename, tuple) else "" if not filename: return False try: self.importWorkflow(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.Critical, duration=5 ) return False self.messageBar.pushMessage( self.tr('Success'), self.tr("Workflow '{fp}' imported!").format( fp=filename ), level=Qgis.Info, duration=5 ) return True
Example #10
Source File: calc_contour.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def updateLayer(self, geom): """ Updates the layer """ if self.layerCombo.currentIndex() == 0: self.iface.messageBar().pushMessage(self.tr('Information'), self.tr('A layer must be selected!'), level=Qgis.Info, duration=3) return if self.attributeCombo.currentIndex() == 0: self.iface.messageBar().pushMessage(self.tr('Information'), self.tr('A field must be selected!'), level=Qgis.Info, duration=3) return #canvas crs to be used in case a reprojection is needed canvasCrs = self.iface.mapCanvas().mapSettings().destinationCrs() if self.ascendingRadioButton.isChecked(): signal = 1 else: signal = -1 ret = self.contourTool.assignValues(self.attributeCombo.currentText(), signal*self.spinBox.value(), geom, canvasCrs) self.iface.mapCanvas().refresh() if ret == 1: self.iface.messageBar().pushMessage(self.tr('Information!'), self.tr('Layer successfully updated!'), level=Qgis.Info, duration=3) elif ret == 0: self.iface.messageBar().pushMessage(self.tr('Critical!'), self.tr('Could not update features!'), level=Qgis.Critical, duration=3) elif ret == -1: self.iface.messageBar().pushMessage(self.tr('Critical!'), self.tr('Problem ordering the features!'), level=Qgis.Critical, duration=3) elif ret == -2: self.iface.messageBar().pushMessage(self.tr('Critical!'), self.tr('The line created does not cross any features in the selected layer!'), level=Qgis.Critical, duration=3) elif ret == -3: self.iface.messageBar().pushMessage(self.tr('Critical!'), self.tr('Assign a value for the selected attribute of the first crossed feature!'), level=Qgis.Critical, duration=3)
Example #11
Source File: export_raster_collar.py From albion with GNU General Public License v3.0 | 5 votes |
def accept(self): self.__project.create_raster_from_collar(self.useDepth.isChecked(), self.outDir.filePath() ) iface.messageBar().pushMessage("Export raster completed", """<a href="file:///{dir}">{dir}</a>""".format(dir=self.outDir.filePath()), level=Qgis.Info, duration=5) self.close()
Example #12
Source File: export_raster_formation.py From albion with GNU General Public License v3.0 | 5 votes |
def accept(self): self.__project.create_raster_from_formation(self.formation.currentData(), self.level.currentText(), self.outDir.filePath() ) iface.messageBar().pushMessage("Export raster completed", """<a href="file:///{dir}">{dir}</a>""".format(dir=self.outDir.filePath()), level=Qgis.Info, duration=5) self.close()
Example #13
Source File: __init__.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setInfo(msg): iface.messageBar().pushMessage("Info", msg, level = Qgis.Info, duration = 10)
Example #14
Source File: QgsFmvPlayer.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( "QgsFmvPlayer", 'Completed with no exception and no result ' '(probably manually canceled by the user)'), level=QGis.Warning) else: if "Georeferencing" in result['task']: return qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvPlayer", "Succesfully " + result['task'] + "!")) if "Bitrate" in result['task']: self.matplot = ShowPlot(self.BitratePlot.bitrate_data, self.BitratePlot.frame_count, self.fileName, self.BitratePlot.output) if result['task'] == 'Show Video Info Task': self.showVideoInfoDialog(self.converter.bytes_value) if result['task'] == 'Save Current Georeferenced Frame Task': buttonReply = qgsu.CustomMessage( QCoreApplication.translate("QgsFmvPlayer", "Information"), QCoreApplication.translate("QgsFmvPlayer", "Do you want to load the layer?"), icon="Information") if buttonReply == QMessageBox.Yes: file = result['file'] root, _ = os.path.splitext(file) layer = QgsRasterLayer(file, root) QgsProject.instance().addMapLayer(layer) return else: qgsu.showUserAndLogMessage(QCoreApplication.translate( "QgsFmvPlayer", "Failed " + result['task'] + "!"), level=QGis.Warning) raise e
Example #15
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
def updateDurationInfo(self, currentInfo): '''Update labels duration Info and CallBack Metadata @type currentInfo: String @param currentInfo: Current time value ''' duration = self.duration self.currentInfo = currentInfo if currentInfo or duration: totalTime = _seconds_to_time(duration) currentTime = _seconds_to_time(currentInfo) tStr = currentTime + " / " + totalTime currentTimeInfo = _seconds_to_time_frac(currentInfo) if self.isStreaming: # get last metadata available self.get_metadata_from_buffer() # qgsu.showUserAndLogMessage("", "Streaming on ", onlyLog=True) # nextTime = currentInfo + self.pass_time / 1000 # nextTimeInfo = _seconds_to_time_frac(nextTime) # self.callBackMetadata(currentTimeInfo, nextTimeInfo) elif self.islocal: self.readLocal(currentInfo) else: # Get Metadata from buffer self.get_metadata_from_buffer(currentTimeInfo) else: tStr = "" self.labelDuration.setText(tStr)
Example #16
Source File: log.py From raster-vision-qgis with GNU General Public License v3.0 | 5 votes |
def log_info(cls, msg): QgsMessageLog.logMessage(msg, tag="Raster Vision", level=Qgis.Info)
Example #17
Source File: mapillary_coverage.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def __init__(self,module): self.module = module self.iface = module.iface self.cache_dir = os.path.join(tempfile.gettempdir(),'go2mapillary') QgsMessageLog.logMessage("CACHE_DIR"+self.cache_dir, tag="go2mapillary",level=Qgis.Info) if not os.path.exists(self.cache_dir): os.makedirs(self.cache_dir) self.setDefaultLayers() self.actual_ranges = None
Example #18
Source File: mapillary_coverage.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def stop(self, msg = ''): ''' the progressbar is stopped with a succes message :param msg: string :return: ''' self.iface.messageBar().clearWidgets() message = self.iface.messageBar().createMessage(self.title,msg) self.iface.messageBar().pushWidget(message, Qgis.Info, 2)
Example #19
Source File: mapillary_coverage.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def start(self,max=0, msg = ''): self.widget = self.iface.messageBar().createMessage(self.title,msg) self.progressBar = QProgressBar() self.progressBar.setRange(0,max) self.progressBar.setValue(0) self.progressBar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) self.widget.layout().addWidget(self.progressBar) QApplication.processEvents() self.iface.messageBar().pushWidget(self.widget, Qgis.Info, 50) QApplication.processEvents()
Example #20
Source File: mapillary_api.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def proto_method(self, endpoint, **kwargs): kwargs['client_id'] = CLIENT_ID res = requests.get(ROOT+endpoint, params=kwargs, proxies=getProxiesConf()) if res.status_code == 200: return res.json() else: QgsMessageLog.logMessage("mapillary connection error: %d" % res.status_code, tag="go2mapillary",level=Qgis.Info)
Example #21
Source File: latLonTools.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
def copyCanvas(self): extent = self.iface.mapCanvas().extent() canvasCrs = self.canvas.mapSettings().destinationCrs() if settings.bBoxCrs == 0 and canvasCrs != epsg4326: transform = QgsCoordinateTransform(canvasCrs, epsg4326, QgsProject.instance()) p1x, p1y = transform.transform(float(extent.xMinimum()), float(extent.yMinimum())) p2x, p2y = transform.transform(float(extent.xMaximum()), float(extent.yMaximum())) extent.set(p1x, p1y, p2x, p2y) delim = settings.bBoxDelimiter prefix = settings.bBoxPrefix suffix = settings.bBoxSuffix precision = settings.bBoxDigits outStr = '' minX = extent.xMinimum() minY = extent.yMinimum() maxX = extent.xMaximum() maxY = extent.yMaximum() if settings.bBoxFormat == 0: # minX,minY,maxX,maxY - using the delimiter outStr = '{:.{prec}f}{}{:.{prec}f}{}{:.{prec}f}{}{:.{prec}f}'.format( minX, delim, minY, delim, maxX, delim, maxY, prec=precision) elif settings.bBoxFormat == 1: # minX,maxX,minY,maxY - Using the selected delimiter' outStr = '{:.{prec}f}{}{:.{prec}f}{}{:.{prec}f}{}{:.{prec}f}'.format( minX, delim, maxX, delim, minY, delim, maxY, prec=precision) elif settings.bBoxFormat == 2: # x1 y1,x2 y2,x3 y3,x4 y4,x1 y1 - Polygon format outStr = '{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f}'.format( minX, minY, minX, maxY, maxX, maxY, maxX, minY, minX, minY, prec=precision) elif settings.bBoxFormat == 3: # x1,y1 x2,y2 x3,y3 x4,y4 x1,y1 - Polygon format outStr = '{:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f} {:.{prec}f},{:.{prec}f}'.format( minX, minY, minX, maxY, maxX, maxY, maxX, minY, minX, minY, prec=precision) elif settings.bBoxFormat == 4: # WKT Polygon outStr = extent.asWktPolygon() elif settings.bBoxFormat == 5: # bbox: [minX, minY, maxX, maxY] - MapProxy outStr = 'bbox: [{}, {}, {}, {}]'.format( minX, minY, maxX, maxY) elif settings.bBoxFormat == 6: # bbox: [minX, minY, maxX, maxY] - MapProxy outStr = 'bbox={},{},{},{}'.format( minX, minY, maxX, maxY) outStr = '{}{}{}'.format(prefix, outStr, suffix) clipboard = QApplication.clipboard() clipboard.setText(outStr) self.iface.messageBar().pushMessage("", "'{}' copied to the clipboard".format(outStr), level=Qgis.Info, duration=4)
Example #22
Source File: QgsFmvPlayer.py From QGISFMV with GNU General Public License v3.0 | 4 votes |
def get_metadata_from_buffer(self, currentTime=None): """Metadata CallBack @type currentTime: String @param currentTime: Current video timestamp """ try: # There is no way to spawn a thread and call after join() without blocking the video UI thread. # callBackMetadata can be as fast as possible, it will always create a small video lag every time meta are read. # To get rid of this, we fill a buffer (BufferedMetaReader) in the QManager with some Metadata in advance, # and hope they'll be ready to read here in a totaly non-blocking # way (increase the buffer size if needed in QManager). if not self.islocal: stdout_data = self.meta_reader.get(currentTime) # debug qgsu.showUserAndLogMessage("", "Buffer size:" + str(self.meta_reader.getSize()), onlyLog=True) else: stdout_data = b'\x15' # qgsu.showUserAndLogMessage( # "", "stdout_data: " + str(stdout_data) + " currentTime: " + str(currentTime), onlyLog=True) if stdout_data == 'NOT_READY': qgsu.showUserAndLogMessage("", "Buffer value read but is not ready, increase buffer size:" + str(self.meta_reader.getSize()), onlyLog=True) return # Values need to be read, pause the video a short while elif stdout_data == 'BUFFERING': qgsu.showUserAndLogMessage(QCoreApplication.translate("QgsFmvPlayer", "Buffering metadata..."), duration=4, level=QGis.Info) self.player.pause() QTimer.singleShot(2500, lambda: self.player.play()) return elif stdout_data is None: qgsu.showUserAndLogMessage(QCoreApplication.translate("QgsFmvPlayer", "No metadata to show, buffer size:" + str(self.meta_reader.getSize())), level=QGis.Info) # qgsu.showUserAndLogMessage("No metadata to show.", "Buffer returned None Type, check pass_time. : ", onlyLog=True) return elif stdout_data == b'' or len(stdout_data) == 0: qgsu.showUserAndLogMessage(QCoreApplication.translate("QgsFmvPlayer", "No metadata to show, buffer size:" + str(self.meta_reader.getSize())), level=QGis.Info) # qgsu.showUserAndLogMessage("No metadata to show.", "Buffer returned empty metadata, check pass_time. : ", onlyLog=True) return self.packetStreamParser(stdout_data) except Exception as inst: qgsu.showUserAndLogMessage("", "Metadata Buffer Failed! : " + str(inst), onlyLog=True) # qgsu.showUserAndLogMessage(QCoreApplication.translate("QgsFmvPlayer", "Metadata Buffer Failed! : "), str(inst))
Example #23
Source File: showOnMapTool.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 4 votes |
def canvasPressEvent(self, event): '''Capture the coordinate when the mouse button has been released, format it, and copy it to the clipboard.''' pt = self.snappoint(event.originalPixelPoint()) self.removeVertexMarker() if settings.externalMapShowLocation: 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() button = event.button() canvasCRS = self.canvas.mapSettings().destinationCrs() transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance()) pt4326 = transform.transform(pt.x(), pt.y()) lat = pt4326.y() lon = pt4326.x() if settings.googleEarthMapProvider(button): f = tempfile.NamedTemporaryFile(mode='w', suffix=".kml", delete=False) f.write('<?xml version="1.0" encoding="UTF-8"?>') f.write('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">') f.write('<Document>') f.write(' <name>QGIS Location</name>') f.write(' <description>{:.8f}, {:.8f}</description>'.format(lon, lat)) f.write(' <Placemark>') f.write(' <name>QGIS Location</name>') f.write(' <Point>') f.write(' <coordinates>{:.8f},{:.8f},0</coordinates>'.format(lon, lat)) f.write(' </Point>') f.write(' </Placemark>') f.write('</Document>') f.write('</kml>') f.close() if platform.system() == 'Windows': os.startfile(f.name) else: webbrowser.open(f.name) self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in Google Earth" % (lat, lon), level=Qgis.Info, duration=3) else: mapprovider = settings.getMapProviderString(lat, lon, button) url = QUrl(mapprovider).toString() webbrowser.open(url, new=2) self.iface.messageBar().pushMessage("", "Viewing Coordinate %f,%f in external map" % (lat, lon), level=Qgis.Info, duration=3)