예제 #1
0
 def create_new_dataset_if_empty(self):
     """Create a new mapView if there is None
     """
     self.mv = self.get_mapview()
     if self.mv is None:
         Main.main.addLayer(
             OsmDataLayer(DataSet(), OsmDataLayer.createNewName(), None))
         self.mv = self.get_mapview()
         GuiHelper.executeByMainWorkerInEDT(ZoomToDownloadInPref())
예제 #2
0
 def create_new_dataset_if_empty(self):
     """Create a new mapView if there is None
     """
     self.mv = self.get_mapview()
     if self.mv is None:
         Main.main.addLayer(OsmDataLayer(DataSet(),
                                         OsmDataLayer.createNewName(),
                                         None))
         self.mv = self.get_mapview()
         GuiHelper.executeByMainWorkerInEDT(ZoomToDownloadInPref())
예제 #3
0
    def goToNext(self, clickedError=None):
        """Send JOSM to the next error
        """
        if hasattr(self, "errorInfoDlg") and self.errorInfoDlg.isVisible():
            self.errorInfoDlg.hide()

        print "\n- Errors to review: ", self.selectedChecks[0].toDo
        self.clickedError = clickedError  # marker clicked
        errors = self.selectedChecks[0].errors

        if clickedError is not None:
            #An error has been selected with mouse click from JOSM view,
            #just zoom to the clicked marker and show error info
            self.selectedError = clickedError
            self.dlg.activate_error_tab(True)
            self.dlg.tabbedPane.setSelectedIndex(1)
        else:
            #Prepare the next error from the errors list
            i = self.selectedChecks[0].currentErrorIndex + 1
            self.selectedError = errors[i]
            if self.selectedError.done:
                #this error has already been reviewed by clicking on
                #its marker
                self.selectedChecks[0].currentErrorIndex = i
                self.goToNext()
                return

        #Collect error info
        errorInfo = ""
        osmId = self.selectedError.osmId
        if osmId != "":
            osmIdExtended = osmId
            osmIdExtended = osmIdExtended.replace("n", "node")
            osmIdExtended = osmIdExtended.replace("w", "way")
            osmIdExtended = osmIdExtended.replace("r", "relation")
            osmIdExtended = osmIdExtended.replace("_", ",")
            errorInfo = "%s %s, " % (self.strings.getString("editing"),
                                     osmIdExtended)
        bbox = self.selectedError.bbox

        #JOSM remote control url
        josmUrl = "http://127.0.0.1:8111/"
        josmUrl += "load_and_zoom?"
        bboxString = "left=%f&bottom=%f&right=%f&top=%f&zoom_mode=download" % tuple(
            bbox)
        josmUrl += bboxString
        if osmId != "":
            #we also know the OSM id. Select the object after download
            josmUrl += "&select=%s" % osmIdExtended
        #send command to JOSM
        response = self.send_to_josm(josmUrl)
        if response is False:
            print "josm is not running"
            return

        #Update user name of selected error
        if osmId != "":
            singleOsmId = osmId.split("_")[0]
            mv = self.get_mapview()
            if mv is not None:
                GuiHelper.executeByMainWorkerInEDT(
                    GetUserOfSelectedPrimitive(self, mv, singleOsmId))

        #Update text fields and buttons
        self.dlg.update_checks_buttons()
        self.dlg.update_error_buttons("new error")
        self.dlg.update_text_fields("show stats", errorInfo)
예제 #4
0
    def goToNext(self, clickedError=None):
        """Send JOSM to the next error
        """
        if hasattr(self, "errorInfoDlg") and self.errorInfoDlg.isVisible():
            self.errorInfoDlg.hide()

        print "\n- Errors to review: ", self.selectedChecks[0].toDo
        self.clickedError = clickedError    # marker clicked
        errors = self.selectedChecks[0].errors

        if clickedError is not None:
            #An error has been selected with mouse click from JOSM view,
            #just zoom to the clicked marker and show error info
            self.selectedError = clickedError
            self.dlg.activate_error_tab(True)
            self.dlg.tabbedPane.setSelectedIndex(1)
        else:
            #Prepare the next error from the errors list
            i = self.selectedChecks[0].currentErrorIndex + 1
            self.selectedError = errors[i]
            if self.selectedError.done:
                #this error has already been reviewed by clicking on
                #its marker
                self.selectedChecks[0].currentErrorIndex = i
                self.goToNext()
                return

        #Collect error info
        errorInfo = ""
        osmId = self.selectedError.osmId
        if osmId != "":
            osmIdExtended = osmId
            osmIdExtended = osmIdExtended.replace("n", "node")
            osmIdExtended = osmIdExtended.replace("w", "way")
            osmIdExtended = osmIdExtended.replace("r", "relation")
            osmIdExtended = osmIdExtended.replace("_", ",")
            errorInfo = "%s %s, " % (self.strings.getString("editing"),
                                     osmIdExtended)
        bbox = self.selectedError.bbox

        #JOSM remote control url
        josmUrl = "http://127.0.0.1:8111/"
        josmUrl += "load_and_zoom?"
        bboxString = "left=%f&bottom=%f&right=%f&top=%f&zoom_mode=download" % tuple(bbox)
        josmUrl += bboxString
        if osmId != "":
            #we also know the OSM id. Select the object after download
            josmUrl += "&select=%s" % osmIdExtended
        #send command to JOSM
        response = self.send_to_josm(josmUrl)
        if response is False:
            print "josm is not running"
            return

        #Update user name of selected error
        if osmId != "":
            singleOsmId = osmId.split("_")[0]
            mv = self.get_mapview()
            if mv is not None:
                GuiHelper.executeByMainWorkerInEDT(GetUserOfSelectedPrimitive(self,
                                                                              mv,
                                                                              singleOsmId))

        #Update text fields and buttons
        self.dlg.update_checks_buttons()
        self.dlg.update_error_buttons("new error")
        self.dlg.update_text_fields("show stats", errorInfo)