示例#1
0
    def crs_selector(self):

        # Request CRS for layers
        proj_selector = QgsProjectionSelectionDialog()
        proj_selector.exec_()
        # crs = QgsCoordinateReferenceSystem(proj_id)
        self.params.crs = proj_selector.crs()
示例#2
0
 def layer_crs(self):
     self.projection_selector = QgsProjectionSelectionDialog()
     self.projection_selector.exec()
     crs = (self.projection_selector.crs())
     layer = self.view.currentLayer()
     layer.setCrs(crs)
     self.zoom_to_layer()
示例#3
0
 def openCrsSelectionDialogForSection(self, section):
     projSelector = QgsProjectionSelectionDialog()
     if (projSelector.exec()):
         if section == CoordinatorDockWidget.SectionInput:
             self.setInputCrs(projSelector.crs())
         elif section == CoordinatorDockWidget.SectionOutput:
             self.setOutputCrs(projSelector.crs())
示例#4
0
 def selectcrs(self):
     # Select a new CRS
     s = QSettings()
     previousselectedcrs=s.value("quickcrs/crs", 0)
     #if previousselectedcrs=="" or previousselectedcrs==0 or previousselectedcrs is None:
         #self.nocrsselected()
     global selectedcrs
     try:
         projSelector = QgsGenericProjectionSelector()
         projSelector.exec_()
         projSelector.selectedCrsId()
         selectedcrs=projSelector.selectedCrsId()
     except:
         projSelector = QgsProjectionSelectionDialog()
         projSelector.exec_()
         selectedcrsdef = projSelector.crs()
         selectedcrs=selectedcrsdef.srsid()
     if (selectedcrs=="" or selectedcrs==0 or self.CrsId2AuthID(selectedcrs)=="" or selectedcrs is None):
         #selectedcrs=previousselectedcrs
         pass
     if (selectedcrs=="" or selectedcrs==0 or self.CrsId2AuthID(selectedcrs)=="" or selectedcrs is None) and (previousselectedcrs=="" or previousselectedcrs==0 or previousselectedcrs is None):
         #self.nocrsselected()
         pass
     else:
         #self.dlg.labelselectedcrs.setText(self.CrsId2AuthID(selectedcrs))
         src=self.CrsId2AuthID(selectedcrs).replace('\n','')
         if(not self.buscarEnArchivo(src, "src.txt")):
             this_folder = os.path.dirname(os.path.abspath(__file__))
             file = open(this_folder+"/src.txt", mode='a')
             file.write('\n'+src)
             file.close()
             self.file2Combo("src.txt", self.dlg.combo_src,'')
         self.dlg.combo_src.setCurrentText(src)
     self.dlg.show()
示例#5
0
 def edit():
     selector = QgsProjectionSelectionDialog()
     selector.setCrs(value);
     if selector.exec_():
         crs = selector.crs()
         if crs.upper().startswith("EPSG:"):
             self.lineEdit.setText(crs)
 def set_crs(self, s):
     """Figure out the CRS for layer creation, from the selected options and/or string"""
     if self.dlg.CRSFromProject.isChecked():
         self.crs_source = 'from project'
         self.crs = QgsProject.instance().crs()
     elif self.dlg.CRSFromFile.isChecked() and s:
         self.crs_source = 'from .3d file'
         self.crs = QgsCoordinateReferenceSystem()
         match = search('epsg:([0-9]*)', s)  # check for epsg in proj string
         if match:  # if found, use the EPSG number explicitly
             self.crs.createFromString('EPSG:{}'.format(int(
                 match.group(1))))
         else:  # fall back to proj4
             self.crs.createFromProj4(s)
     else:  # fall back to raising a CRS selection dialog
         self.crs_source = 'from dialog'
         dialog = QgsProjectionSelectionDialog()
         dialog.setMessage('define the CRS for the imported layers')
         dialog.exec()  # run the dialog ..
         self.crs = dialog.crs()  # .. and recover the user input
     if self.crs.isValid():
         msg = 'CRS {} : {}'.format(self.crs_source, self.crs.authid())
         QgsMessageLog.logMessage(msg, tag='Import .3d', level=Qgis.Info)
         QgsMessageLog.logMessage(self.crs.description(),
                                  tag='Import .3d',
                                  level=Qgis.Info)
     else:  # hopefully never happens
         msg = "CRS invalid!"
         QgsMessageLog.logMessage(msg, tag='Import .3d', level=Qgis.Info)
         self.crs = None
示例#7
0
    def selectProjection(self):
        dialog = QgsProjectionSelectionDialog(self.widget)
        current_crs = QgsCoordinateReferenceSystem(self.combo.currentText())
        if current_crs.isValid():
            dialog.setCrs(current_crs)

        if dialog.exec_():
            self.setValue(dialog.crs().authid())
示例#8
0
文件: settings.py 项目: co-city/qgyf
 def defineCRS(self):
     projSelector = QgsProjectionSelectionDialog()
     projSelector.exec()
     crs_id = projSelector.crs().authid()
     if crs_id:
         crs_id = ''.join(c for c in crs_id if c.isdigit())
         self.proj.writeEntry("QGYF", "CRS", crs_id)
         print(self.proj.readEntry("QGYF", "CRS")[0])
     self.crs.setText(projSelector.crs().description())
示例#9
0
    def projection_selector(self):
        """
        Opens the QGIS projection selector
        """
        projection_selector = QgsProjectionSelectionDialog(self)

        if projection_selector.exec_() == QDialog.Accepted:
            # Remove 'EPSG:' part
            self._srid = projection_selector.crs().authid()[5:]
            self.btnCoord.setText(projection_selector.crs().authid())
 def setCrs(self):
     selector = QgsProjectionSelectionDialog(self.iface.mainWindow())
     selector.setCrs(self.crs)
     if selector.exec():
         self.crs = selector.crs()
         self.transform.setDestinationCrs(self.crs)
         if self.crs.mapUnits() == QgsUnitTypes.DistanceDegrees:
             self.userCrsDisplayPrecision = 5
         else:
             self.userCrsDisplayPrecision = 3
 def set_dst_crs(self):
     try:
         frmCRS = QgsProjectionSelectionDialog(self._main_form)
         if frmCRS.exec_():
             if frmCRS.crs() is not None and frmCRS.crs().authid():
                 self.destination_crs_name = frmCRS.crs().authid()
                 self._main_form.map_widget.update_project_map_crs_info(self.destination_crs_name)
                 self._main_form.txtCrs.setText(self.destination_crs_name)
     except:
         pass
示例#12
0
 def crsTriggered(self, action):
     self.crsButton.setDefaultAction(action)
     self.inputProjection = action.data()
     if self.inputProjection == 3:
         selector = QgsProjectionSelectionDialog()
         selector.setCrs(QgsCoordinateReferenceSystem(self.inputCustomCRS))
         if selector.exec():
             self.inputCustomCRS = selector.crs().authid()
         else:
             self.inputCustomCRS = 'EPSG:4326'
     self.saveSettings()
    def selectOtherCrs(self, checked):
        self.l_OtherCrsName.setEnabled(checked)
        self.pb_OtherCrs.setEnabled(checked)

        if checked:
            if self.otherCrsId is None:
                crsSelector = QgsProjectionSelectionDialog()
                crsSelector.setCrs(QgsCoordinateReferenceSystem("EPSG:4326"))
                if crsSelector.exec():
                    self.otherCrsId = crsSelector.crs().srsid()
                    self.featureCrsId = self.otherCrsId
                self.__displayAuthid()
示例#14
0
    def testDialogNotSetOption(self):
        """ test allowing no projection option for QgsProjectionSelectionTreeWidget """
        w = QgsProjectionSelectionDialog()
        w.show()
        w.setShowNoProjection(True)
        self.assertTrue(w.showNoProjection())
        w.setShowNoProjection(False)
        self.assertFalse(w.showNoProjection())

        w.setShowNoProjection(True)
        w.setCrs(QgsCoordinateReferenceSystem())
        self.assertFalse(w.crs().isValid())
    def reprojectCoords(self):
        self.refreshCoordsMatrix(self.prev_row)

        if self.valueChecker.checkCoordsMatrix(self.coords_matrix):
            srcProj = QgsCoordinateReferenceSystem()
            srcProj.createFromSrsId(self.featureCrsId)

            crsSelectorFrom = QgsProjectionSelectionDialog()
            crsSelectorFrom.setCrs(srcProj)
            crsSelectorFrom.setMessage(
                self.translate_str("Select source coordinates system"))

            if crsSelectorFrom.exec():
                crsSelectorTo = QgsProjectionSelectionDialog()
                crsSelectorTo.setMessage(
                    self.translate_str(
                        "Select destination coordinates system"))

                if crsSelectorTo.exec():
                    rc = ReprojectCoordinates(crsSelectorFrom.crs().srsid(),
                                              crsSelectorTo.crs().srsid(),
                                              self.has_Z, self.has_M)
                    self.coords_matrix = list(
                        rc.reproject(self.coords_matrix, False))

                    self.__part_changing = True
                    self.refreshTable(self.prev_row)
                    self.__part_changing = False

                    self.featureCrsId = crsSelectorTo.crs().srsid()
                    if self.featureCrsId == self.mapCanvas.currentLayer().crs(
                    ).srsid():
                        self.rb_LayerCrs.setChecked(True)
                    elif self.featureCrsId == self.projectCrsId:
                        self.rb_ProjectCrs.setChecked(True)
                    else:
                        self.rb_OtherCrs.blockSignals(True)
                        self.rb_OtherCrs.setChecked(True)
                        self.rb_OtherCrs.blockSignals(False)
                        self.__displayAuthid()
    def select_ellipsoid(self):
        """raise a dialog to choose the desired ellipsoid"""

        projSelector = QgsProjectionSelectionDialog()
        projSelector.exec_()

        crs = projSelector.crs()

        if crs.isValid():
            if crs.ellipsoidAcronym() != '':
                self.ellipsoidSelector.setText(crs.ellipsoidAcronym())
            else:
                self.ellipsoidSelector.setText('WGS84')
 def SelectOtherCrsClicked(self):
     crsSelector = QgsProjectionSelectionDialog()
     if self.otherCrsId is None:
         crsSelector.setCrs(QgsCoordinateReferenceSystem("EPSG:4326"))
     else:
         currentQCRS = QgsCoordinateReferenceSystem()
         if currentQCRS.createFromSrsId(self.otherCrsId):
             crsSelector.setCrs(currentQCRS)
         else:
             crsSelector.setCrs(QgsCoordinateReferenceSystem("EPSG:4326"))
     if crsSelector.exec():
         self.otherCrsId = crsSelector.crs().srsid()
         self.featureCrsId = self.otherCrsId
     self.__displayAuthid()
示例#18
0
 def select_crs(self):
     """Shows a dialog to select a new CRS for the model"""
     crs_dialog = QgsProjectionSelectionDialog()
     crs_dialog.setShowNoProjection(True)
     if self.dlg.crsLineEdit.text() != "None":
         old_crs = QgsCoordinateReferenceSystem("EPSG:{}".format(
             self.dlg.crsLineEdit.text()))
         crs_dialog.setCrs(old_crs)
     crs_dialog.exec()
     if crs_dialog.crs().postgisSrid() == 0:
         self.dlg.crsLineEdit.setText("None")
     else:
         self.dlg.crsLineEdit.setText("{}".format(
             crs_dialog.crs().postgisSrid()))
示例#19
0
    def openCrsSelectionDialogForSection(self, section):
        projSelector = QgsProjectionSelectionDialog()
        if (projSelector.exec()):
            selectedCrs = projSelector.crs()

            # workaround for checking if there was no CRS selected
            # but user clicked 'OK': check if authid-string is empty:
            if not selectedCrs.authid():
                return

            if section == CoordinatorDockWidget.SectionInput:
                self.setInputCrs(selectedCrs)
            elif section == CoordinatorDockWidget.SectionOutput:
                self.setOutputCrs(selectedCrs)
    def __init__(self, title, parent=None):
        QDialog.__init__(self)
        self.setWindowTitle(title)

        layout = QVBoxLayout()
        self.selector = QgsProjectionSelectionDialog(self)
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Close)

        layout.addWidget(self.selector)
        layout.addWidget(buttonBox)
        self.setLayout(layout)

        self.connect(buttonBox, SIGNAL("accepted()"), self.accept)
        self.connect(buttonBox, SIGNAL("rejected()"), self.reject)
示例#21
0
 def crsTileButton(self):
     self.crs_select = QgsProjectionSelectionDialog()
     self.crs_select.exec_()
     self.selectedcrsdef = self.crs_select.crs()
     print(self.selectedcrsdef)
     self.tileselectedcrs = self.selectedcrsdef.authid()
     print(self.tileselectedcrs)
     if self.tileselectedcrs != '':
         self.tile_epsg_code = self.tileselectedcrs.split(":")
         print(self.tile_epsg_code)
         self.tile_code = self.tile_epsg_code[1]
         print(self.tile_code)
     else:
         self.tile_epsg_code = ''
         print(self.tile_epsg_code)
         self.tile_code = ''
         print(self.tile_code)
示例#22
0
from qgis.gui import QgsProjectionSelectionDialog

lyr = iface.activeLayer()
crs_select = QgsProjectionSelectionDialog()
crs_select.exec_()
selectedcrsdef = crs_select.crs()
selectedcrs = selectedcrsdef.authid()
epsg_code = selectedcrs.split(":")
code = epsg_code[1]
for f in lyr.getFeatures():
    if code != f["SR_EPSG"]:
        print('diverso')
    else:
        print('uguale')
示例#23
0
 def testDialogGettersSetters(self):
     """ basic tests for QgsProjectionSelectionTreeWidget """
     w = QgsProjectionSelectionDialog()
     w.show()
     w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
     self.assertEqual(w.crs().authid(), 'EPSG:3111')
示例#24
0
 def loadAvailableSystems(self):
     coordSys = ""
     crsDlg = QgsProjectionSelectionDialog(self.parent)
     if crsDlg.exec_() == QDialog.Accepted:
         coordSys = str(crsDlg.crs().authid())
     return coordSys
示例#25
0
 def changeCRS(self):
     projSelector = QgsProjectionSelectionDialog()
     projSelector.exec_()
     self.crs = projSelector.crs()
     self.crsLabel.setText(self.crs.authid())