def testTreeWidgetUnknownCrs(self):
     w = QgsProjectionSelectionTreeWidget()
     w.show()
     self.assertFalse(w.hasValidSelection())
     w.setCrs(
         QgsCoordinateReferenceSystem.fromWkt(
             'GEOGCS["WGS 84",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'
         ))
     self.assertTrue(w.crs().isValid())
     self.assertFalse(w.crs().authid())
     self.assertTrue(w.hasValidSelection())
     self.assertEqual(
         w.crs().toWkt(QgsCoordinateReferenceSystem.WKT2_2018),
         'GEOGCRS["WGS 84",DATUM["unknown",ELLIPSOID["WGS84",6378137,298.257223563,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["longitude",east,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["latitude",north,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]]]'
     )
Exemplo n.º 2
0
 def testTreeWidgetGettersSetters(self):
     """ basic tests for QgsProjectionSelectionTreeWidget """
     w = QgsProjectionSelectionTreeWidget()
     w.show()
     self.assertFalse(w.hasValidSelection())
     w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
     self.assertEqual(w.crs().authid(), 'EPSG:3111')
     self.assertTrue(w.hasValidSelection())
 def testTreeWidgetGettersSetters(self):
     """ basic tests for QgsProjectionSelectionTreeWidget """
     w = QgsProjectionSelectionTreeWidget()
     w.show()
     self.assertFalse(w.hasValidSelection())
     w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
     self.assertEqual(w.crs().authid(), 'EPSG:3111')
     self.assertTrue(w.hasValidSelection())
Exemplo n.º 4
0
    def testTreeWidgetNotSetOption(self):
        """ test allowing no projection option for QgsProjectionSelectionTreeWidget """
        w = QgsProjectionSelectionTreeWidget()
        w.show()
        w.setShowNoProjection(True)
        self.assertTrue(w.showNoProjection())
        w.setShowNoProjection(False)
        self.assertFalse(w.showNoProjection())

        w.setShowNoProjection(True)
        # no projection should be a valid selection
        w.setCrs(QgsCoordinateReferenceSystem())
        self.assertTrue(w.hasValidSelection())
        self.assertFalse(w.crs().isValid())
    def testTreeWidgetNotSetOption(self):
        """ test allowing no projection option for QgsProjectionSelectionTreeWidget """
        w = QgsProjectionSelectionTreeWidget()
        w.show()
        w.setShowNoProjection(True)
        self.assertTrue(w.showNoProjection())
        w.setShowNoProjection(False)
        self.assertFalse(w.showNoProjection())

        w.setShowNoProjection(True)
        # no projection should be a valid selection
        w.setCrs(QgsCoordinateReferenceSystem())
        self.assertTrue(w.hasValidSelection())
        self.assertFalse(w.crs().isValid())
Exemplo n.º 6
0
class crs_page(QWizardPage):
    def __init__(self, parent=None):
        super().__init__(parent)
        global import_export
        if import_export == 'Import':
            self.setTitle('Project Coordinate System')
            self.setSubTitle('Choosing an appropriate projection for EPANET layers.')
        elif import_export == 'Export':
            self.setTitle('Project Coordinate System')
            self.setSubTitle('Choosing projection for EPANET coordinates.')

        self.selector = QgsProjectionSelectionTreeWidget()
        layout = QVBoxLayout()
        layout.addWidget(self.selector)
        self.setLayout(layout)
        self.selector.crsSelected.connect(self.crs_selected)

    def crs_selected(self):
        self.completeChanged.emit()

    def isComplete(self):
        global result_crs
        result_crs = self.selector.crs()
        return self.selector.crs().isValid()
    def testTreeWidgetDeferredLoad(self):
        """
        Test that crs setting made before widget is initialized is respected
        """
        w = QgsProjectionSelectionTreeWidget()
        spy = QSignalSpy(w.crsSelected)
        self.assertFalse(w.hasValidSelection())
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        self.assertEqual(len(spy), 1)
        self.assertTrue(w.hasValidSelection())
        self.assertEqual(w.crs().authid(), 'EPSG:3111')
        self.assertEqual(len(spy), 1)

        w = QgsProjectionSelectionTreeWidget()
        spy = QSignalSpy(w.crsSelected)
        self.assertFalse(w.hasValidSelection())
        w.setCrs(QgsCoordinateReferenceSystem())
        self.assertEqual(len(spy), 1)
        self.assertTrue(w.hasValidSelection())
        self.assertFalse(w.crs().isValid())
        self.assertEqual(len(spy), 1)
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
        self.assertEqual(len(spy), 2)

        # expect same behavior if we show
        w = QgsProjectionSelectionTreeWidget()
        spy = QSignalSpy(w.crsSelected)
        self.assertFalse(w.hasValidSelection())
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        self.assertEqual(len(spy), 1)
        w.show()
        self.assertTrue(w.hasValidSelection())
        self.assertEqual(w.crs().authid(), 'EPSG:3111')
        self.assertEqual(len(spy), 1)

        w = QgsProjectionSelectionTreeWidget()
        spy = QSignalSpy(w.crsSelected)
        self.assertFalse(w.hasValidSelection())
        w.setCrs(QgsCoordinateReferenceSystem())
        self.assertEqual(len(spy), 1)
        w.show()
        self.assertTrue(w.hasValidSelection())
        self.assertFalse(w.crs().isValid())
        self.assertEqual(len(spy), 1)

        # no double signals if same crs set
        w = QgsProjectionSelectionTreeWidget()
        spy = QSignalSpy(w.crsSelected)
        self.assertFalse(w.hasValidSelection())
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        self.assertEqual(len(spy), 1)

        # no double signals if same crs set
        w = QgsProjectionSelectionTreeWidget()
        spy = QSignalSpy(w.crsSelected)
        self.assertFalse(w.hasValidSelection())
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        w.show()
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
        self.assertEqual(len(spy), 1)
        w.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
        self.assertEqual(len(spy), 2)