def __init__(self, canvas):
     self.canvas = canvas
     QgsMapToolEmitPoint.__init__(self, self.canvas)
     self.rubberband = QgsRubberBand(self.canvas, QGis.Polygon)
     self.point = None
     self.points = []
     attribs = ['id']
     types = [QtCore.QVariant.String]
     self.layer = uf.createTempLayer('Danger Zones', 'POLYGON', '28992',
                                     attribs, types, 50)
     self.symbols = self.layer.rendererV2().symbols()
     self.symbol = self.symbols[0]
     self.symbol.setColor(QColor.fromRgb(160, 160, 160))
Пример #2
0
 def __init__(self, iface):
     # Save reference to the QGIS interface
     self.iface = iface
     # refernce to map canvas
     self.canvas = self.iface.mapCanvas()
     # out click tool will emit a QgsPoint on every click
     self.clickTool = QgsMapToolEmitPoint(self.canvas)
Пример #3
0
 def exit_dialog(self):
     self.points.append(QgsPoint(self.points_end))
     self.iface.mapCanvas().setMapTool(
         QgsMapToolEmitPoint(self.iface.mapCanvas()))
     self.edit = False
     self.preview.exit_dialog(self.points, self.crs)
     self.new()
     self.view.show()
     self.view.exec_()
Пример #4
0
    def gera_tracado_vertices(self, p1, p2, crs):
        self.crs = crs
        self.points = [p1]
        self.edit = True
        self.points_end = p2
        self.pointerEmitter = QgsMapToolEmitPoint(self.iface.mapCanvas())

        QObject.connect(
            self.pointerEmitter,
            SIGNAL("canvasClicked(const QgsPoint,Qt::MouseButton)"),
            self.get_click)
        name_tracado = self.preview.gera_tracado_vertices(self.pointerEmitter)
        self.preview.dialog.btnClose.clicked.connect(self.exit_dialog)
        return name_tracado
Пример #5
0
text_format.setSize(12)
text_format.setBackground(background_color)

buffer_settings = QgsTextBufferSettings()
buffer_settings.setEnabled(True)
buffer_settings.setSize(0.10)
buffer_settings.setColor(QColor("black"))

text_format.setBuffer(buffer_settings)
layer_settings.setFormat(text_format)

layer_settings.fieldName = "name"
layer_settings.placement = 4

layer_settings.enabled = True

layer_settings = QgsVectorLayerSimpleLabeling(layer_settings)
point_layer.setLabelsEnabled(True)
point_layer.setLabeling(layer_settings)

#creating a window to display the map of Melbourne and the RMIT location
canvas = QgsMapCanvas()
canvas.setLayers([point_layer, base_layer])
canvas.setExtent(road_layer.extent())
canvas.show()

#setup click trigger to capture the clicked location and then call the shortest path calculator function
pointTool = QgsMapToolEmitPoint(canvas)
pointTool.canvasClicked.connect(my_shortest_path)
canvas.setMapTool(pointTool)
    def __init__(self, parent=None):
        """Constructor."""
        super(Evacu8DockWidget, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.setupUi(self)

        #define globals
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.plugin_dir = os.path.dirname(__file__)
        self.emitPoint = QgsMapToolEmitPoint(self.canvas)
        self.toolPoly = PolyMapTool(self.canvas)
        self.emitEvac = QgsMapToolEmitPoint(self.canvas)
        self.emitShel = QgsMapToolEmitPoint(self.canvas)
        self.emitDel = QgsMapToolEmitPoint(self.canvas)
        self.input_template = self.scen_info.toHtml()

        # set up GUI operation signals
        # data
        self.load_scen.clicked.connect(self.openScenario)
        self.tabs.setTabEnabled(1, False)
        self.set_pt.clicked.connect(self.enterPoi)
        self.emitPoint.canvasClicked.connect(self.getPoint)
        self.set_rad.clicked.connect(self.calculateBuffer)
        self.set_rad.setEnabled(False)
        self.send_notes.clicked.connect(self.sendNotes)
        self.set_danger.clicked.connect(self.setDangerZone)
        self.get_danger.clicked.connect(self.getDangerZone)
        self.del_danger.clicked.connect(self.delDangerZone)
        self.emitDel.canvasClicked.connect(self.get_del)

        # set images and icons
        self.logo.setPixmap(QtGui.QPixmap(':images/Logosmall.jpeg'))
        self.load_scen.setIcon(QtGui.QIcon(':images/Open.png'))
        self.load_scen.setIconSize(QSize(25, 25))
        self.set_danger.setIcon(QtGui.QIcon(':images/Draw1.svg'))
        self.set_danger.setIconSize(QSize(25, 25))
        self.get_danger.setIcon(QtGui.QIcon(':images/Check.png'))
        self.get_danger.setIconSize(QSize(25, 25))
        self.del_danger.setIcon(QtGui.QIcon(':images/Delete.png'))
        self.del_danger.setIconSize(QSize(30, 30))
        self.shortestRouteButton.setIcon(QtGui.QIcon(':images/Route.png'))
        self.shortestRouteButton.setIconSize(QSize(25, 25))
        self.to_wiki1.setIcon(QtGui.QIcon(':images/Info.png'))
        self.to_wiki1.setIconSize(QSize(20, 20))

        # analysis
        self.evac = QgsPoint()
        self.evacId = int()
        self.shel = QgsPoint()
        self.shelId = int()

        self.evac_layer = QgsVectorLayer()
        self.evac_feat = QgsFeature()
        self.shel_layer = QgsVectorLayer()
        self.shel_feat = QgsFeature()

        self.select_POI.clicked.connect(self.enterEvac)
        self.emitEvac.canvasClicked.connect(self.getEvac)
        self.desel_POI.clicked.connect(self.deleteEvac)
        self.select_shelter.setEnabled(False)
        self.select_shelter.clicked.connect(self.enterShel)
        self.emitShel.canvasClicked.connect(self.getShel)
        self.shortestRouteButton.setEnabled(False)
        self.shortestRouteButton.clicked.connect(self.buildNetwork)
        self.shortestRouteButton.clicked.connect(self.calculateRoute)
        self.network_layer = QgsVectorLayer()
        self.tied_points = []
        self.to_evac_info.setVerticalHeaderLabels(
            ["Type", "Name", "Address", "Population", "Dist from Attack(m)"])
        self.shelter_info.setVerticalHeaderLabels(
            ["Type", "Name", "Address", "Capacity", "Route distance (m)"])

        # Open wiki
        self.to_wiki1.clicked.connect(self.open_wiki)

        self.big_button.clicked.connect(self.evacuateThis)
        self.savelog.clicked.connect(self.saveLog)

        self.big_button.setEnabled(False)
        self.warning_msg.setVisible(False)

        self.show_selected.clicked.connect(self.showSelected)
        self.hide_selected.clicked.connect(self.hideSelected)
        self.save_map.pressed.connect(self.showSelected)
        self.save_map.released.connect(self.saveMap)

        self.savelog.clicked.connect(self.timerMessage)
        self.save_map.released.connect(self.timerMessage)
        self.saved_msg.setVisible(False)

        self.sent_msg.setVisible(False)