예제 #1
0
파일: search_bar.py 프로젝트: tlh22/TOMs
    def disableSearchBar(self):
        TOMsMessageLog.logMessage("In disableSearchBar", level=Qgis.Info)

        self.initialPass = True
        self.actionGoToItem.setEnabled(False)
        self.toolButton.setEnabled(False)
        self.searchTextbox.textChanged.disconnect(self.doLookupItem)
예제 #2
0
파일: search_bar.py 프로젝트: tlh22/TOMs
    def setupCompleter(self):
        # set up string list for completer

        TOMsMessageLog.logMessage("In setupCompleter:", level=Qgis.Info)
        lookupStringSet = set()
        # https://gis.stackexchange.com/questions/155805/qstringlist-error-in-plugin-of-qgis-2-10

        self.GazetteerLayer = QgsProject.instance().mapLayersByName("StreetGazetteerRecords")[0]

        for row in self.GazetteerLayer.getFeatures():
            streetName = row.attribute("Descriptor_")
            locality = row.attribute("Locality")
            nameString = streetName
            if locality:
                nameString = nameString + ", " + locality

            if nameString:
                TOMsMessageLog.logMessage("In setupCompleter: nameString: " + nameString, level=Qgis.Info)
                lookupStringSet.add(nameString)
                # self.gazetteerStringList.append((nameString))

        completer = QCompleter()
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setFilterMode(Qt.MatchContains)
        self.searchTextbox.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        model.setStringList(self.gazetteerStringList)
        model.setStringList(sorted(lookupStringSet))
    def changeLayerForFeature(self, currLayer, currFeature):

        status = False

        sameGeomTypeLayerList = self.getSameGeomTypeLayerList(
            currLayer, currFeature)

        TOMsMessageLog.logMessage(
            "In setNewLayerForFeature: sameGeomTypeLayerList: {}".format(
                sameGeomTypeLayerList),
            level=Qgis.Info)

        surveyDialog = QInputDialog()
        surveyDialog.setLabelText("Please confirm new layer for this feature ")
        surveyDialog.setComboBoxItems(sameGeomTypeLayerList)
        surveyDialog.setTextValue(currLayer.name())

        if surveyDialog.exec_() == QDialog.Accepted:
            newLayerName = surveyDialog.textValue()
            TOMsMessageLog.logMessage(
                "In setNewLayerForFeature: {}".format(newLayerName),
                level=Qgis.Info)

            if currLayer.name() != newLayerName:
                newLayer = QgsProject.instance().mapLayersByName(
                    newLayerName)[0]
                reply = QMessageBox.information(
                    None, "Information", "Setting {} to layer {}".format(
                        currFeature.attribute("GeometryID"), newLayer.name()),
                    QMessageBox.Ok)

                status = self.moveFeatureToNewLayer(currLayer, currFeature,
                                                    newLayer)

        return status
    def copyRestriction(self, currFeature, newFeature):

        TOMsMessageLog.logMessage("In TOMsNodeTool:copyRestriction",
                                  level=Qgis.Info)

        newFeatureFieldMap = newFeature.fields()
        currFeatureFieldMap = currFeature.fields()

        for field in newFeature.fields():

            fieldName = field.name()
            idx_newFeature = newFeatureFieldMap.indexFromName(field.name())
            # see if can find same field name ... adn set
            idx_currFeature = currFeatureFieldMap.indexFromName(fieldName)
            if idx_currFeature >= 0:
                if not newFeature.setAttribute(
                        idx_newFeature,
                        currFeature.attribute(idx_currFeature)):
                    reply = QMessageBox.information(
                        None, "Information",
                        "Problem adding: {}".format(field.name()),
                        QMessageBox.Ok)
                    return None
        # set new restriction id and geometry id
        newRestrictionID = str(uuid.uuid4())
        idxRestrictionID = newFeature.fields().indexFromName("RestrictionID")
        newFeature[idxRestrictionID] = newRestrictionID

        idxGeometryID = newFeature.fields().indexFromName("GeometryID")
        newFeature[idxGeometryID] = None

        # copy geometry ...
        newFeature.setGeometry(QgsGeometry(currFeature.geometry()))

        return newFeature
예제 #5
0
    def __init__(self, iface):

        QgsMessageLog.logMessage("Starting featuresWithGPS ... ",
                                 tag="TOMs panel")
        """Constructor.
        
        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)

        self.actions = []  # ?? check - assume it initialises array of actions

        self.closeGPSToolsFlag = False

        # Set up local logging
        loggingUtils = TOMsMessageLog()
        loggingUtils.setLogFile()

        QgsMessageLog.logMessage("In featuresWithGPS. Finished init",
                                 tag="TOMs panel")
예제 #6
0
파일: expressions.py 프로젝트: tlh22/TOMs
def getLoadingRestrictionLabelText(feature, parent):
    # Returns the text to label the feature

    #TOMsMessageLog.logMessage("In getLoadingRestrictionLabelText:", level=Qgis.Info)

    try:
        waitingText, loadingText = generateGeometryUtils.getWaitingLoadingRestrictionLabelText(
            feature)

    except:
        TOMsMessageLog.logMessage('getLoadingRestrictionLabelText',
                                  level=Qgis.Info)
        exc_type, exc_value, exc_traceback = sys.exc_info()
        TOMsMessageLog.logMessage(
            'getLoadingRestrictionLabelText: error in expression function: ' +
            str(repr(traceback.extract_tb(exc_traceback))),
            level=Qgis.Info)
        """TOMsMessageLog.logMessage(
        "In getLoadingRestrictionLabelText ****:" + " Waiting: " + str(waitingText) + " Loading: " + str(loadingText),
        level=Qgis.Info)"""

    if loadingText:
        #labelText = "No Loading: " + loadingText
        labelText = loadingText

        #TOMsMessageLog.logMessage("In getLoadingRestrictionLabelText: passing " + str(labelText), level=Qgis.Info)
        return labelText

    return None
    def pointInPoly(layerName, refColumn, defaultValue, geom, feature, parent):
        # attempt to make a generic point in poly function ...

        TOMsMessageLog.logMessage("In pointInPoly", level=Qgis.Warning)

        # Get the reference layer
        try:
            refLayer = QgsProject.instance().mapLayersByName(layerName)[0]
        except Exception as e:
            refLayer = None

        if refLayer:

            TOMsMessageLog.logMessage("In pointInPoly. ref layer found ... ",
                                      level=Qgis.Warning)
            # TODO: ensure refLayer is polygon
            # TODO: deal with different geom types for the incoming geom. For the moment assume a point

            for poly in refLayer.getFeatures():
                if poly.geometry().intersects(
                        geom):  # take the first intersecting poly
                    #TOMsMessageLog.logMessage("In getPolygonForRestriction. feature found", level=Qgis.Info)
                    return poly.attribute(refColumn)

        return defaultValue
예제 #8
0
파일: search_bar.py 프로젝트: tlh22/TOMs
    def initSearchBar(self):
        TOMsMessageLog.logMessage("In initSearchBox:", level=Qgis.Info)

        self.initialPass = True
        self.gazetteerStringList = []

        # Create & add a textbox
        self.searchTextbox = QLineEdit(self.iface.mainWindow())
        # Set width
        self.searchTextbox.setFixedWidth(250)
        # Add textbox to toolbar
        self.txtEntry = self.TOMsSearchBar.addWidget(self.searchTextbox)
        #self.txtEntry.setToolTip(self.tr(u'Enter Street Name'))

        self.searchTextbox.textChanged.connect(self.doLookupItem)

        self.actionGoToItem = QAction(QIcon(":/plugins/TOMs/resources/magnifyingGlass.png"),
                                            QCoreApplication.translate("MyPlugin", "Start TOMs"), self.iface.mainWindow())
        self.TOMsSearchBar.addAction(self.actionGoToItem)
        self.actionGoToItem.triggered.connect(self.doGoToItem)
        self.actionGoToItem.setCheckable(True)

        # Add in details of the Instant Print plugin
        self.toolButton = QToolButton(self.iface.mainWindow())
        self.toolButton.setIcon(QIcon(":/plugins/TOMs/InstantPrint/icons/icon.png"))
        #self.toolButton.setToolTip(self.tr("Instant Print"))
        self.toolButton.setCheckable(True)
        self.printButtonAction = self.TOMsSearchBar.addWidget(self.toolButton)

        """self.actionInstantPrint = QAction(QIcon(":/plugins/TOMs/InstantPrint/icons/icon.png"),
                                          QCoreApplication.translate("Print", "Print"), self.iface.mainWindow())"""

        self.toolButton.toggled.connect(self.__enablePrintTool)
        self.iface.mapCanvas().mapToolSet.connect(self.__onPrintToolSet)
    def doAddGPSLocation(self):

        # need to have a addPointFromGPS function within each tool

        TOMsMessageLog.logMessage("In doAddGPSLocation", level=Qgis.Info)

        if self.gpsConnection:

            if self.curr_gps_location:
                try:
                    status = self.createRestrictionMapTool.addPointFromGPS(
                        self.curr_gps_location, self.curr_gps_info)
                except Exception as e:
                    TOMsMessageLog.logMessage(
                        "In doAddGPSLocation: Problem adding gnss location: {}"
                        .format(e),
                        level=Qgis.Warning)
                    reply = QMessageBox.information(
                        self.iface.mainWindow(), "Error",
                        "Problem adding gnss location ... ", QMessageBox.Ok)
            else:
                reply = QMessageBox.information(self.iface.mainWindow(),
                                                "Information",
                                                "No position found ...",
                                                QMessageBox.Ok)
        else:

            reply = QMessageBox.information(
                self.iface.mainWindow(), "Information",
                "You need to activate the tool first ...", QMessageBox.Ok)
예제 #10
0
 def displayPixmapUpdated(self, FIELD, pixmap):
     TOMsMessageLog.logMessage("In utils::displayPixmapUpdated ... ",
                               level=Qgis.Info)
     FIELD.setPixmap(pixmap)
     FIELD.setScaledContents(True)
     QApplication.processEvents(
     )  # processes the event queue - https://stackoverflow.com/questions/43094589/opencv-imshow-prevents-qt-python-crashing
예제 #11
0
    def enableTOMsToolbarItems(self, restrictionTransaction):

        TOMsMessageLog.logMessage("In enableTOMsToolbarItems", level=Qgis.Info)

        self.actionSelectRestriction.setEnabled(True)
        self.actionRestrictionDetails.setEnabled(True)
        self.actionCreateBayRestriction.setEnabled(True)
        self.actionCreateLineRestriction.setEnabled(True)
        self.actionCreatePolygonRestriction.setEnabled(True)
        self.actionCreateSignRestriction.setEnabled(True)
        self.actionRemoveRestriction.setEnabled(True)
        self.actionEditRestriction.setEnabled(True)
        self.actionSplitRestriction.setEnabled(True)
        self.actionCreateConstructionLine.setEnabled(True)

        # set up a Transaction object
        # self.tableNames = TOMSLayers(self.iface)
        # self.tableNames.getLayers()
        self.restrictionTransaction = restrictionTransaction
        """self.proposalsManager.TOMsToolChanged.connect(
            functools.partial(self.restrictionTransaction.commitTransactionGroup, self.tableNames.PROPOSALS))"""

        #self.iface.mapCanvas().mapToolSet.connect(self.unCheckNodeTool)

        pass
예제 #12
0
    def __getRestrictionsInProposalForLayerForAction(self,
                                                     layerID,
                                                     actionOnAcceptance=None):
        # Will return a list of restrictions within a Proposal subject to actionOnAcceptance

        self.RestrictionsInProposalsLayer = self.tableNames.setLayer(
            "RestrictionsInProposals")

        query = (
            "\"ProposalID\" = {proposalID} AND \"RestrictionTableID\" = {layerID}"
        ).format(proposalID=str(self.thisProposalNr), layerID=str(layerID))

        if actionOnAcceptance is not None:
            query = (
                "{query} AND \"ActionOnProposalAcceptance\" = {actionOnAcceptance}"
            ).format(query=query, actionOnAcceptance=str(actionOnAcceptance))

        TOMsMessageLog.logMessage(
            "In __getRestrictionsInProposalForLayerForAction. query: " +
            str(query),
            level=Qgis.Info)
        request = QgsFeatureRequest().setFilterExpression(query)

        restrictionList = []
        for restrictionInProposalDetails in self.RestrictionsInProposalsLayer.getFeatures(
                request):
            restrictionList.append([
                restrictionInProposalDetails["RestrictionID"],
                restrictionInProposalDetails
            ])

        return restrictionList
예제 #13
0
    def getCurrentRestrictionsForLayerAtDate(self, layerID, dateString=None):

        if not dateString:
            dateString = self.date()

        dateString = self.__date.toString('yyyy-MM-dd')
        dateChoosenFormatted = "'{dateString}'".format(dateString=dateString)

        filterString = u'"OpenDate" \u003C\u003D to_date({dateChoosenFormatted}) AND (("CloseDate" \u003E to_date({dateChoosenFormatted})  OR "CloseDate" IS NULL))'.format(
            dateChoosenFormatted=dateChoosenFormatted)

        thisLayer = self.getRestrictionLayerFromID(layerID)

        request = QgsFeatureRequest().setFilterExpression(filterString)

        TOMsMessageLog.logMessage(
            "In ProposalsManager:getCurrentRestrictionsForLayerAtDate. Layer: "
            + thisLayer.name() + " Filter: " + filterString,
            level=Qgis.Info)
        restrictionList = []
        for currentRestrictionDetails in thisLayer.getFeatures(request):
            TOMsMessageLog.logMessage(
                "In ProposalsManager:getCurrentRestrictionsForLayerAtDate. Layer: "
                + thisLayer.name() + " restrictionID: " +
                str(currentRestrictionDetails["RestrictionID"]),
                level=Qgis.Info)
            currRestriction = ProposalElementFactory.getProposalElement(
                self, layerID, currentRestrictionDetails,
                currentRestrictionDetails["RestrictionID"])
            restrictionList.append(
                [currentRestrictionDetails["RestrictionID"], currRestriction])

        return restrictionList
예제 #14
0
    def __init__(self, iface, TOMsToolBar):
        #def __init__(self, iface, TOMsMenu, proposalsManager):

        # Save reference to the QGIS interface
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.TOMsToolBar = TOMsToolBar

        self.actionProposalsPanel = QAction(
            QIcon(":/plugins/TOMs/resources/TOMsStart.png"),
            QCoreApplication.translate("MyPlugin", "Start TOMs"),
            self.iface.mainWindow())
        self.actionProposalsPanel.setCheckable(True)

        self.TOMsToolBar.addAction(self.actionProposalsPanel)

        self.actionProposalsPanel.triggered.connect(self.onInitProposalsPanel)

        self.newProposalRequired = False

        self.proposalsManager = TOMsProposalsManager(self.iface)
        self.tableNames = self.proposalsManager.tableNames

        # Now set up the toolbar

        self.RestrictionTools = manageRestrictionDetails(
            self.iface, self.TOMsToolBar, self.proposalsManager)
        self.RestrictionTools.disableTOMsToolbarItems()
        self.searchBar = searchBar(self.iface, self.TOMsToolBar,
                                   self.proposalsManager)
        self.searchBar.disableSearchBar()

        TOMsMessageLog.logMessage("Finished proposalsPanel init ...",
                                  level=Qgis.Warning)
예제 #15
0
    def closeTOMsTools(self):
        # actions when the Proposals Panel is closed or the toolbar "start" is toggled

        TOMsMessageLog.logMessage("In closeTOMsTools. Deactivating ...",
                                  level=Qgis.Info)

        # TODO: Delete any objects that are no longer needed

        self.proposalTransaction.rollBackTransactionGroup()
        del self.proposalTransaction  # There is another call to this function from the dock.close()

        # Now disable the items from the Toolbar

        self.RestrictionTools.disableTOMsToolbarItems()
        self.searchBar.disableSearchBar()

        self.actionProposalsPanel.setChecked(False)

        # Now close the proposals panel

        self.dock.close()

        # Now clear the filters

        self.proposalsManager.clearRestrictionFilters()

        pass
예제 #16
0
    def __init__(self, proposalsManager, layerID, restriction, restrictionID):
        #def __init__(self, proposalsManager, layerID=None, restriction=None, restrictionID=None):
        super().__init__()
        TOMsMessageLog.logMessage(
            "In TOMsProposalElement.init. Creating Proposal Element ... " +
            str(layerID) + ";" + str(restriction),
            level=Qgis.Info)
        self.proposalsManager = proposalsManager
        self.currProposal = self.proposalsManager.currentProposalObject()
        self.tableNames = self.proposalsManager.tableNames
        self.layerID = layerID

        self.setThisLayer()

        if restriction is not None:
            self.thisElement = restriction
            self.thisRestrictionID = restrictionID

        elif restrictionID is not None:
            self.setElement(restrictionID)

        TOMsMessageLog.logMessage(
            "In factory. Creating Proposal Element ... " +
            str(self.thisElement),
            level=Qgis.Info)
예제 #17
0
    def initialiseProposal(self):

        self.thisProposal = QgsFeature(self.proposalsLayer.fields())
        self.thisProposal.setGeometry(QgsGeometry())
        #self.proposalsLayer.addFeature(self.thisProposal)  # TH (added for v3)
        """self.setProposalTitle('')   #str(uuid.uuid4())
        self.setProposalOpenDate = self.proposalsManager.date()
        self.setProposalCreateDate = self.proposalsManager.date()
        self.setProposalStatusID = ProposalStatus.IN_PREPARATION"""

        self.thisProposal[self.idxProposalTitle] = ''  #str(uuid.uuid4())
        self.thisProposal[self.idxCreateDate] = self.proposalsManager.date()
        self.thisProposal[self.idxOpenDate] = self.proposalsManager.date()
        self.thisProposal[
            self.idxProposalStatusID] = ProposalStatus.IN_PREPARATION

        self.proposalsLayer.addFeature(self.thisProposal)  # TH (added for v3)

        TOMsMessageLog.logMessage(
            "In TOMsProposal:createProposal - attributes: (fid=" +
            str(self.thisProposal.id()) + ") " +
            str(self.thisProposal.attributes()),
            level=Qgis.Info)

        return self
예제 #18
0
    def showRestrictionDetails(self, closestLayer, closestFeature):

        TOMsMessageLog.logMessage("In showRestrictionDetails ... Layer: " +
                                  str(closestLayer.name()),
                                  level=Qgis.Info)

        #self.showRestrictionMapTool.notifyFeatureFound.disconnect(self.showRestrictionDetails)

        # TODO: could improve ... basically check to see if transaction in progress ...
        if closestLayer.isEditable() == True:
            if closestLayer.commitChanges() == False:
                reply = QMessageBox.information(
                    None, "Information", "Problem committing changes" +
                    str(closestLayer.commitErrors()), QMessageBox.Ok)
            else:
                TOMsMessageLog.logMessage(
                    "In showRestrictionDetails: changes committed",
                    level=Qgis.Info)

        status = self.iface.activeLayer().startEditing()

        dialog = self.iface.getFeatureForm(closestLayer, closestFeature)
        #self.TOMsUtils.setupRestrictionDialog(self.dialog, closestLayer, closestFeature)
        self.setupFieldRestrictionDialog(dialog, closestLayer, closestFeature)

        dialog.show()
예제 #19
0
    def onAttributeChangedClass2_local(self, currFeature, layer, fieldName,
                                       value):

        #self.TOMsUtils.onAttributeChangedClass2(currFeature, layer, fieldName, value)

        TOMsMessageLog.logMessage(
            "In field:FormOpen:onAttributeChangedClass 2 - layer: " +
            str(layer.name()) + " (" + fieldName + "): " + str(value),
            level=Qgis.Info)

        # self.currRestriction.setAttribute(fieldName, value)
        try:

            currFeature[layer.fields().indexFromName(fieldName)] = value
            #currFeature.setAttribute(layer.fields().indexFromName(fieldName), value)

        except Exception as e:

            reply = QMessageBox.information(
                None, "Error",
                "onAttributeChangedClass2. Update failed for: " +
                str(layer.name()) + " (" + fieldName + "): " + str(value),
                QMessageBox.Ok)  # rollback all changes

        self.storeLastUsedDetails(layer.name(), fieldName, value)

        return
예제 #20
0
 def errorInTransaction(self, errorMsg):
     reply = QMessageBox.information(
         None, "Error",
         "TOMsTransaction:Proposal changes failed: " + errorMsg,
         QMessageBox.Ok)
     TOMsMessageLog.logMessage("In errorInTransaction: " + errorMsg,
                               level=Qgis.Warning)
예제 #21
0
 def getProposalElement(proposalsManager, proposalElementType, restriction,
                        RestrictionID):
     TOMsMessageLog.logMessage("In factory. getProposalElement ... " +
                               str(proposalElementType) + ";" +
                               str(restriction),
                               level=Qgis.Info)
     try:
         if proposalElementType == RestrictionLayers.BAYS:
             return Bay(proposalsManager, proposalElementType, restriction,
                        RestrictionID)
         elif proposalElementType == RestrictionLayers.LINES:
             return Line(proposalsManager, proposalElementType, restriction,
                         RestrictionID)
         elif proposalElementType == RestrictionLayers.SIGNS:
             return Sign(proposalsManager, proposalElementType, restriction,
                         RestrictionID)
         elif proposalElementType == RestrictionLayers.RESTRICTION_POLYGONS:
             return Sign(proposalsManager, proposalElementType, restriction,
                         RestrictionID)
             # return RestrictionPolygonFactory.getProposalElement(proposalElementType, restrictionLayer, RestrictionID)
         elif proposalElementType == RestrictionLayers.CPZS:
             return CPZ(proposalsManager, proposalElementType, restriction,
                        RestrictionID)
         elif proposalElementType == RestrictionLayers.PTAS:
             return PTA(proposalsManager, proposalElementType, restriction,
                        RestrictionID)
         raise AssertionError("Restriction Type NOT found")
     except AssertionError as _e:
         TOMsMessageLog.logMessage(
             "In ProposalElementFactory. TYPE not found or something else ... ",
             level=Qgis.Info)
예제 #22
0
    def __init__(self, iface, layer):

        TOMsMessageLog.logMessage(("In CreatePointTool - init."), level=Qgis.Info)

        if layer.geometryType() == 0: # PointGeometry:
            captureMode = (CreateRestrictionTool.CapturePoint)
        else:
            TOMsMessageLog.logMessage(("In CreateRestrictionTool - No geometry type found. EXITING ...."), level=Qgis.Warning)
            return

        QgsMapToolCapture.__init__(self, iface.mapCanvas(), iface.cadDockWidget(), captureMode)
        FieldRestrictionTypeUtilsMixin.__init__(self, iface)

        # TODO: change pointer type so that know in this tool

        self.iface = iface
        self.canvas = iface.mapCanvas()
        self.currLayer = layer

        self.lastPoint = None

        self.setAutoSnapEnabled(True)

        self.tableNames = TOMsLayers(self.iface)
        self.TOMsConfigFileObject = TOMsConfigFile()
        self.TOMsConfigFileObject.initialiseTOMsConfigFile()

        self.tableNames.getLayers(self.TOMsConfigFileObject)
 def gpsErrorEncountered(self, e):
     TOMsMessageLog.logMessage(
         "In enableTools - GPS connection has error {}".format(e),
         level=Qgis.Warning)
     """self.actionCreateRestriction.setEnabled(False)
     self.actionAddGPSLocation.setEnabled(False)"""
     self.disableGnssToolbarItem()
예제 #24
0
    def getProposalsListWithStatus(self, proposalStatus=None):

        self.ProposalsLayer = self.tableNames.setLayer("Proposals")

        query = ''

        if proposalStatus is not None:
            query = ("\"ProposalStatusID\" = {proposalStatus}").format(
                proposalStatus=str(proposalStatus))

        TOMsMessageLog.logMessage("In __getProposalsListWithStatus. query: " +
                                  str(query),
                                  level=Qgis.Info)
        request = QgsFeatureRequest().setFilterExpression(query)

        proposalsList = []
        for proposalDetails in self.ProposalsLayer.getFeatures(request):
            proposalsList.append([
                proposalDetails["ProposalID"],
                proposalDetails["ProposalTitle"],
                proposalDetails["ProposalStatusID"],
                proposalDetails["ProposalOpenDate"], proposalDetails
            ])

        return proposalsList
예제 #25
0
    def onDateChanged(self):
        TOMsMessageLog.logMessage("In onDateChanged.", level=Qgis.Info)
        date = self.proposalsManager.date()
        self.dock.filterDate.setDate(date)
        """ onChangeProposalStatus(self):
        TOMsMessageLog.logMessage("In onChangeProposalStatus. Proposed status: " + str(self.Proposals.fields().indexFromName("ProposalStatusID")), level=Qgis.Info)

        # check to see if the proposal is "Accepted"
        acceptProposal = False

        newProposalStatus = int(self.Proposals.fields().indexFromName("ProposalStatusID"))

        if newProposalStatus == 1:    # should be 2 but with list ...

            # if so, check to see if this was intended

            reply = QMessageBox.question(self.iface.mainWindow(), 'Confirm changes to Proposal',
                                         'Are you you want to accept this proposal?. Accepting will make all the proposed changes permanent.', QMessageBox.Yes, QMessageBox.No)
            if reply == QMessageBox.Yes:
                # make the changes permanent
                acceptProposal = True

        # bring the Proposals dislog back to the front

        self.dlg.activateWindow()

        return acceptProposal"""
        """def getRestrictionLayerTableID(self, currRestLayer):
예제 #26
0
 def setRevisionNr(self, value):
     TOMsMessageLog.logMessage("In TOMsTile:setRevisionNr newRevisionNr: " +
                               str(value),
                               level=Qgis.Info)
     #self.thisTile[self.idxRevisionNr] = value
     self.tilesLayer.changeAttributeValue(self.thisTile.id(),
                                          self.idxRevisionNr, value)
예제 #27
0
    def findNearestFeatureAtC(self, pos):
        #  def findFeatureAt(self, pos, excludeFeature=None):
        # http://www.lutraconsulting.co.uk/blog/2014/10/17/getting-started-writing-qgis-python-plugins/ - generates "closest feature" function
        """ Find the feature close to the given position.

            'pos' is the position to check, in canvas coordinates.

            if 'excludeFeature' is specified, we ignore this feature when
            finding the clicked-on feature.

            If no feature is close to the given coordinate, we return None.
        """
        mapPt = self.transformCoordinates(pos)
        tolerance = 1.0
        searchRect = QgsRectangle(mapPt.x() - tolerance,
                                  mapPt.y() - tolerance,
                                  mapPt.x() + tolerance,
                                  mapPt.y() + tolerance)

        request = QgsFeatureRequest()
        request.setFilterRect(searchRect)
        request.setFlags(QgsFeatureRequest.ExactIntersect)

        #self.RestrictionLayers = QgsMapLayerRegistry.instance().mapLayersByName("RestrictionLayers")[0]
        #self.currLayer = QgsMapLayerRegistry.instance().mapLayersByName("MovingTrafficSigns")[0]
        self.currLayer = self.iface.activeLayer()
        featureList = []
        layerList = []

        # Loop through all features in the layer to find the closest feature
        for f in self.currLayer.getFeatures(request):
            # Add any features that are found should be added to a list
            featureList.append(f)
            layerList.append(self.currLayer)

        TOMsMessageLog.logMessage(
            "In findNearestFeatureAt: Considering layer: {}; nrFeatures: {}".
            format(self.currLayer.name(), len(featureList)),
            level=Qgis.Info)

        if len(featureList) == 0:
            return None, None
        elif len(featureList) == 1:
            return featureList[0], layerList[0]
        else:
            # set up a context menu
            TOMsMessageLog.logMessage(
                "In findNearestFeatureAt: multiple features: " +
                str(len(featureList)),
                level=Qgis.Info)

            feature, layer = self.getFeatureDetails(featureList, layerList)
            # TODO: Need to pick up primary key(s)
            """TOMsMessageLog.logMessage("In findNearestFeatureAt: feature: " + str(feature.attribute('id')),
                                     level=Qgis.Info)"""

            return feature, layer

        pass
예제 #28
0
    def paintEvent(self, paint_event):
        TOMsMessageLog.logMessage("In imageLabel::paintEvent ... ",
                                  level=Qgis.Info)
        #super().paintEvent(paint_event)
        painter = QtGui.QPainter(self)

        painter.drawPixmap(self.top_left_corner.x(), self.top_left_corner.y(),
                           self._displayed_pixmap)
예제 #29
0
 def __init__(self,
              proposalsManager,
              layerID=None,
              restriction=None,
              restrictionID=None):
     super().__init__(proposalsManager, layerID, restriction, restrictionID)
     TOMsMessageLog.logMessage("In factory. Creating Label ... ",
                               level=Qgis.Info)
예제 #30
0
    def _zoomActivity(self):

        if abs(self._zoom) < ZOOM_LIMIT:

            image_size = self._displayed_pixmap.size()
            TOMsMessageLog.logMessage(
                "In imageLabel.wheelEvent ... dimensions {}:{}. Resized to {}:{} "
                .format(image_size.width(), image_size.height(),
                        image_size.width() * self.factor,
                        image_size.height() * self.factor),
                level=Qgis.Info)
            if (self._zoom) == 0:
                image_size.setWidth(image_size.width())
                image_size.setHeight(image_size.height())
            else:
                image_size.setWidth(image_size.width() * self.factor)
                image_size.setHeight(image_size.height() * self.factor)

            TOMsMessageLog.logMessage(
                "In imageLabel.wheelEvent ... zoom:factor {}:{}".format(
                    self._zoom, self.factor),
                level=Qgis.Info)
            TOMsMessageLog.logMessage(
                "In imageLabel.wheelEvent ... screenpoint {}:{}".format(
                    self.curr_x, self.curr_y),
                level=Qgis.Info)

            if self._zoom == 0:
                self.top_left_corner.setX(0)
                self.top_left_corner.setY(0)
            else:
                self.top_left_corner.setX(self.top_left_corner.x() *
                                          self.factor + self.curr_x -
                                          (self.curr_x * self.factor))
                self.top_left_corner.setY(self.top_left_corner.y() *
                                          self.factor + self.curr_y -
                                          (self.curr_y * self.factor))

            TOMsMessageLog.logMessage(
                "In imageLabel.zoom ... tl new 2 {}:{}".format(
                    self.top_left_corner.x(), self.top_left_corner.y()),
                level=Qgis.Info)

            self.update_image(
                self.origImage.scaled(
                    image_size,
                    QtCore.Qt.KeepAspectRatio,
                    transformMode=QtCore.Qt.SmoothTransformation))

            TOMsMessageLog.logMessage(
                "In imageLabel.setPixmap ... called update zoom...",
                level=Qgis.Info)

        else:
            if self._zoom > 0:
                self._zoom -= 1
            else:
                self._zoom += 1