I'm having a Spatialite layer to store photo locations from objects (stored in another Spatialite layer) taken in the field. Therefor I'm using a custom photo form like explained here.
Since now I type the corresponding object id in the "Objekt" field as an attribute of the photo layer. As an improvement I want to have a combo box (see picture of the photo form) were I can choose the object ids from a selection of the 5 nearest objects.
What I need is the coordinates from the point that will be created after I close the form. Or in other the words: the coordinates from the canvas click before the custom form appears. To search the 5 nearest objects (which is simple to achieve) I need the coordinates before the custom form opens, then a function can search for the neighbors and the results can be added to the combo box.
By now I'm using the following map tool (for the use in the Python console) to get click coordinates from the canvas:
from qgis.gui import QgsMapTool from PyQt4.QtCore import pyqtSignal class PointTool(QgsMapTool): def __init__(self, canvas): QgsMapTool.__init__(self, canvas) self.canvas = canvas canvasClicked = pyqtSignal(['QgsPoint']) def canvasReleaseEvent(self, event): point = self.toMapCoordinates(event.pos()) self.canvasClicked.emit(point) def getCanvasCoordinates(point): QgsMessageLog.logMessage(str(point)) mapTool = PointTool(iface.mapCanvas()) iface.mapCanvas().setMapTool(mapTool) mapTool.canvasClicked.connect(getCanvasCoordinates)
How can I implement this in the custom form to get the coordinates, that I need to make the next steps explained above?
Is there a way to connect the
getCanvasCoordinates function to the