def setPoint( self, coords ):
     ''' guarantee srs and pass to the API '''
     self._enabled = False
     self.setMarker(coords)
     coords = UiUtility.transform(self._iface, coords)    
     
     # init new address object and open form
     addInstance = self._controller.initialiseAddressObj()
     NewAddressDialog.newAddress(addInstance, self._layers, self._controller, self._iface.mainWindow(), coords)
     self._canvas.scene().removeItem(self._marker)
     self._enabled = True
Exemplo n.º 2
0
    def canvasReleaseEvent(self, mouseEvent):
        """
        Identify the AIMS Feature(s) the user clicked

        @param mouseEvent: QtGui.QMouseEvent
        @type mouseEvent: QtGui.QMouseEvent
        """

        self._iface.setActiveLayer(self._layers.addressLayer())

        results = self.identify(mouseEvent.x(), mouseEvent.y(),
                                self.ActiveLayer, self.VectorLayer)
        if self._currentRevItem:

            if self._currentRevItem._changeType in ('Retire', 'AddLineage'):
                self._iface.messageBar().pushMessage(
                    "{} review items cannot be relocated".format(
                        self._currentRevItem._changeType),
                    level=QgsMessageBar.WARNING,
                    duration=5)
                return

            if len(results) == 0:
                coords = self.toMapCoordinates(
                    QPoint(mouseEvent.x(), mouseEvent.y()))
            else:
                # Snapping. i.e Move to stack
                coords = results[0].mFeature.geometry().asPoint()
            coords = list(UiUtility.transform(self._iface, coords))

            respId = int(time.time())

            if self._currentRevItem._changeType in ('Add', 'Update'):
                feedType = FEEDS['AR']
                self._currentRevItem._addressedObject_addressPositions[
                    0].setCoordinates(coords)
                self._controller.uidm.repairAddress(self._currentRevItem,
                                                    respId)
            else:
                feedType = FEEDS['GR']
                changeId = self._currentRevItem._changeId
                self._currentRevItem = self._currentRevItem.meta.entities[0]
                self._currentRevItem._addressedObject_addressPositions[
                    0].setCoordinates(coords)
                self._currentRevItem.setChangeId(changeId)
                self._controller.uidm.repairAddress(self._currentRevItem,
                                                    respId)

            self.RespHandler.handleResp(respId, feedType)
            self._controller.setPreviousMapTool()
    def NewAimsFeature( self, coords ):
        """
        Get New Address Instance. Make Address Editing Form
        visible to user

        @param coords: QgsPoint
        @type coords: QgsPoint
        """   
        # init new address object and open form
        UiUtility.clearForm(self._controller._queues.tabWidget)
        coords = UiUtility.transform(self._iface, coords)
        self.setMarker(coords)        
        addInstance = self.af.get()
        self._controller._queues.uEditFeatureTab.setFeature('add', addInstance, coords)
        self._controller._queues.tabWidget.setCurrentIndex(0)
        UiUtility.setEditability(self._controller._queues.uEditFeatureTab)
    def NewAimsFeature(self, coords):
        """
        Get New Address Instance. Make Address Editing Form
        visible to user

        @param coords: QgsPoint
        @type coords: QgsPoint
        """
        # init new address object and open form
        UiUtility.clearForm(self._controller._queues.tabWidget)
        coords = UiUtility.transform(self._iface, coords)
        self.setMarker(coords)
        addInstance = self.af.get()
        self._controller._queues.uEditFeatureTab.setFeature(
            'add', addInstance, coords)
        self._controller._queues.tabWidget.setCurrentIndex(0)
        UiUtility.setEditability(self._controller._queues.uEditFeatureTab)
    def canvasReleaseEvent(self, mouseEvent):
        """
        Identify the AIMS Feature(s) the user clicked

        @param mouseEvent: QtGui.QMouseEvent
        @type mouseEvent: QtGui.QMouseEvent
        """

        self._iface.setActiveLayer(self._layers.addressLayer())
        
        results = self.identify(mouseEvent.x(), mouseEvent.y(), self.ActiveLayer, self.VectorLayer)
        if self._currentRevItem:
            
            if self._currentRevItem._changeType in ('Retire', 'AddLineage' ):
                self._iface.messageBar().pushMessage("{} review items cannot be relocated".format(self._currentRevItem._changeType), 
                                                     level=QgsMessageBar.WARNING, duration = 5)
                return
            
            if len(results) == 0:                     
                coords = self.toMapCoordinates(QPoint(mouseEvent.x(), mouseEvent.y()))
            else:
                # Snapping. i.e Move to stack
                coords = results[0].mFeature.geometry().asPoint()    
            coords = list(UiUtility.transform(self._iface, coords))
            
            respId = int(time.time())
            
            if self._currentRevItem._changeType in ('Add', 'Update'):
                feedType = FEEDS['AR']
                self._currentRevItem._addressedObject_addressPositions[0].setCoordinates(coords)
                self._controller.uidm.repairAddress(self._currentRevItem, respId)
            else:
                feedType = FEEDS['GR'] 
                changeId = self._currentRevItem._changeId
                self._currentRevItem = self._currentRevItem.meta.entities[0]
                self._currentRevItem._addressedObject_addressPositions[0].setCoordinates(coords)
                self._currentRevItem.setChangeId(changeId)
                self._controller.uidm.repairAddress(self._currentRevItem, respId)
            
            self.RespHandler.handleResp(respId, feedType)
            self._controller.setPreviousMapTool() 
 def canvasReleaseEvent(self, mouseEvent):
     self._iface.setActiveLayer(self._layers.addressLayer())
     
     if mouseEvent.button() == Qt.LeftButton:
         results = self.identify(mouseEvent.x(), mouseEvent.y(), self.ActiveLayer, self.VectorLayer)
         # Ensure feature list and highlighting is reset
         self._features = []
         self._canvas.scene().removeItem(self._marker)
         
         if len(results) == 0: 
             return
         elif len(results) == 1:
             # Highlight feature
             coords = results[0].mFeature.geometry().asPoint()
             self.setMarker(coords)
             # create address object for feature. It is this obj properties that will be passed to API
             self._features.append(UiUtility.mapResultsToAddObj(results[0], self._controller))
             self._sb.showMessage("Right click for features new location")
             
         else: # Stacked points
             identifiedFeatures=[] 
             coords = results[0].mFeature.geometry().asPoint()
             self.setMarker(coords)
             for i in range (0,len(results)):
                 identifiedFeatures.append(dict(
                 fullAddress=results[i].mFeature.attribute('fullAddress'),
                 addressId= results[i].mFeature.attribute('addressId')
                 ))
                 
             dlg = MoveAddressDialog(self._iface.mainWindow())
             moveFeatures = dlg.selectFeatures(identifiedFeatures)
             
             if moveFeatures: 
                 # Form a list of Ids as selected by the user
                 moveFeaturesIds = [d['addressId'] for d in moveFeatures]
                 
                 for result in results:
                     if result.mFeature.attribute('addressId') in moveFeaturesIds:
                         self._features.append(UiUtility.mapResultsToAddObj(result, self._controller))
                                        
                 self._sb.showMessage("Right click for features new location")
                 
             else: 
                 self._features = None
                 self._canvas.scene().removeItem(self._marker)
     
     # Right click for new position         
     if mouseEvent.button() == Qt.RightButton:
         results = self.identify(mouseEvent.x(), mouseEvent.y(), self.ActiveLayer, self.VectorLayer)
         if self._features:
             if len(results) == 0:                     
                 coords = self.toMapCoordinates(QPoint(mouseEvent.x(), mouseEvent.y()))
             else:
                 # Snapping. i.e Move to stack
                 coords = results[0].mFeature.geometry().asPoint()    
             
             # set new coords for all selected features
             coords = UiUtility.transform(self._iface, coords)
             for feature in self._features:          
                     feature.set_x(coords[0])
                     feature.set_y(coords[1])  
                 
             payload = feature.aimsObject()
             valErrors = self._controller.updateFeature(payload)
         
             if len(valErrors) == 0:
                 pass #no errors
             else:
                 QMessageBox.warning(self._iface.mainWindow(),"Move Feature", valErrors +'\n'*2 + feature._fullAddress )
             
             self._features = []
             self._canvas.scene().removeItem(self._marker)
             self._sb.clearMessage()
             
         else: QMessageBox.warning(self._iface.mainWindow(),"Move Feature", "You must first select a feature to move")
Exemplo n.º 7
0
    def canvasReleaseEvent(self, mouseEvent):
        """
        Identify the AIMS Feature(s) the user clicked

        @param mouseEvent: QtGui.QMouseEvent
        @type mouseEvent: QtGui.QMouseEvent
        """

        self._iface.setActiveLayer(self._layers.addressLayer())

        if mouseEvent.button() == Qt.LeftButton:
            results = self.identify(mouseEvent.x(), mouseEvent.y(), self.ActiveLayer, self.VectorLayer)
            # Ensure feature list and highlighting is reset
            self._features = []
            self.hideMarker()

            if len(results) == 0:
                return
            elif len(results) == 1:
                # Highlight feature
                coords = results[0].mFeature.geometry().asPoint()
                self.setMarker(coords)
                # create address object for feature. It is this obj properties that will be passed to API
                self._features.append(
                    self._controller.uidm.singleFeatureObj(results[0].mFeature.attribute("addressId"))
                )
                self._sb.showMessage("Right click for features new location")

            else:  # Stacked points

                identifiedFeatures = []
                coords = results[0].mFeature.geometry().asPoint()
                self.setMarker(coords)
                for i in range(0, len(results)):
                    identifiedFeatures.append(
                        dict(
                            fullAddress=results[i].mFeature.attribute("fullAddress"),
                            addressId=results[i].mFeature.attribute("addressId"),
                        )
                    )

                dlg = MoveAddressDialog(self._iface.mainWindow())
                moveFeatures = dlg.selectFeatures(identifiedFeatures)

                if moveFeatures:
                    # Form a list of Ids as selected by the user
                    moveFeaturesIds = [d["addressId"] for d in moveFeatures]

                    for featureId in moveFeaturesIds:
                        self._features.append(self._controller.uidm.singleFeatureObj(featureId))

                    self._sb.showMessage("Right click for features new location")

                else:
                    self._features = None

        # Right click for new position
        if mouseEvent.button() == Qt.RightButton:
            results = self.identify(mouseEvent.x(), mouseEvent.y(), self.ActiveLayer, self.VectorLayer)
            if self._features:
                if len(results) == 0:
                    coords = self.toMapCoordinates(QPoint(mouseEvent.x(), mouseEvent.y()))
                else:
                    # Snapping. i.e Move to stack
                    coords = results[0].mFeature.geometry().asPoint()

                # set new coords for all selected features
                coords = list(UiUtility.transform(self._iface, coords))

                for feature in self._features:
                    # Hack to retrieve the properties missing on the
                    # feature feed from the resolution feed <
                    respId = int(time.time())
                    self._controller.uidm.supplementAddress(feature, respId)
                    feature = self._controller.RespHandler.handleResp(respId, FEEDS["AR"], "supplement")
                    # />
                    feature._addressedObject_addressPositions[0].setCoordinates(coords)
                    if feature._codes_isMeshblockOverride != True:
                        feature.setMeshblock(None)
                    feature = self.af[FeedType.CHANGEFEED].cast(feature)
                    respId = int(time.time())
                    self._controller.uidm.updateAddress(feature, respId)
                    self.RespHandler.handleResp(respId, FEEDS["AC"])

                self._features = []
                self.hideMarker()
                self._sb.clearMessage()
Exemplo n.º 8
0
    def canvasReleaseEvent(self, mouseEvent):
        """
        Identify the AIMS Feature(s) the user clicked

        @param mouseEvent: QtGui.QMouseEvent
        @type mouseEvent: QtGui.QMouseEvent
        """

        self._iface.setActiveLayer(self._layers.addressLayer())

        if mouseEvent.button() == Qt.LeftButton:
            results = self.identify(mouseEvent.x(), mouseEvent.y(),
                                    self.ActiveLayer, self.VectorLayer)
            # Ensure feature list and highlighting is reset
            self._features = []
            self.hideMarker()

            if len(results) == 0:
                return
            elif len(results) == 1:
                # Highlight feature
                coords = results[0].mFeature.geometry().asPoint()
                self.setMarker(coords)
                # create address object for feature. It is this obj properties that will be passed to API
                self._features.append(
                    self._controller.uidm.singleFeatureObj(
                        results[0].mFeature.attribute('addressId')))
                self._sb.showMessage("Right click for features new location")

            else:  # Stacked points

                identifiedFeatures = []
                coords = results[0].mFeature.geometry().asPoint()
                self.setMarker(coords)
                for i in range(0, len(results)):
                    identifiedFeatures.append(
                        dict(fullAddress=results[i].mFeature.attribute(
                            'fullAddress'),
                             addressId=results[i].mFeature.attribute(
                                 'addressId')))

                dlg = MoveAddressDialog(self._iface.mainWindow())
                moveFeatures = dlg.selectFeatures(identifiedFeatures)

                if moveFeatures:
                    # Form a list of Ids as selected by the user
                    moveFeaturesIds = [d['addressId'] for d in moveFeatures]

                    for featureId in moveFeaturesIds:
                        self._features.append(
                            self._controller.uidm.singleFeatureObj(featureId))

                    self._sb.showMessage(
                        "Right click for features new location")

                else:
                    self._features = None

        # Right click for new position
        if mouseEvent.button() == Qt.RightButton:
            results = self.identify(mouseEvent.x(), mouseEvent.y(),
                                    self.ActiveLayer, self.VectorLayer)
            if self._features:
                if len(results) == 0:
                    coords = self.toMapCoordinates(
                        QPoint(mouseEvent.x(), mouseEvent.y()))
                else:
                    # Snapping. i.e Move to stack
                    coords = results[0].mFeature.geometry().asPoint()

                # set new coords for all selected features
                coords = list(UiUtility.transform(self._iface, coords))

                for feature in self._features:
                    # Hack to retrieve the properties missing on the
                    # feature feed from the resolution feed <
                    respId = int(time.time())
                    self._controller.uidm.supplementAddress(feature, respId)
                    feature = self._controller.RespHandler.handleResp(
                        respId, FEEDS['AR'], 'supplement')
                    # />
                    #feature.type = FEEDS['AF']

                    # below clone is part of a fix still to be tested
                    clone = feature.clone(feature, self.aff.get())
                    clone._addressedObject_addressPositions[0].setCoordinates(
                        coords, )
                    if clone._codes_isMeshblockOverride != True:
                        clone.setMeshblock(None)
                    respId = int(time.time())
                    clone = self.afc[FeedType.CHANGEFEED].cast(clone)
                    self._controller.uidm.updateAddress(clone, respId)
                    self.RespHandler.handleResp(respId, FEEDS['AC'])

                self._features = []
                self.hideMarker()
                self._sb.clearMessage()