Salome HOME
Issue with CRS not available with actual version of pyproj V2_3
authorYoann Audouin <yoann.audouin@edf.fr>
Thu, 6 Jan 2022 14:22:10 +0000 (15:22 +0100)
committerYoann Audouin <yoann.audouin@edf.fr>
Thu, 6 Jan 2022 14:22:10 +0000 (15:22 +0100)
src/salome_hydro/changeCoordsDialog.py

index fbf360fda6dc4ab0ae6ca0bd423e4004b984cd73..1ac32c05be020ea8a023c67773b7ce403130d048 100644 (file)
@@ -24,7 +24,6 @@ from PyQt5.QtWidgets import *
 from PyQt5 import uic
 
 import pyproj
-from pyproj import CRS
 
 from salome.hydrotools.changeCoords import changeCoords
 
@@ -49,14 +48,38 @@ class changeCoordsDialog(QDialog):
         self.medFileIn = None
         self.medFileOut = None
         EPSG_list = (2154, 27561, 27562, 27563, 27564, 27571, 27572, 27573, 27574 )
+        has_CRS = pyproj.__version__ >= "2.0.0"
+        try:
+            import pyproj.CRS
+            has_CRS = True
+        except ImportError:
+            has_CRS = False
+
+        if has_CRS:
+            for epsg in EPSG_list:
+                crs_code = CRS.from_epsg(epsg)
+                EPSG_name[epsg] = crs_code.name
+            EPSG_name = {}
+        else:
+            EPSG_name = {\
+                2154 :"RGF93 / Lambert-93",
+                27561:"NTF (Paris) / Lambert Nord France",
+                27562:"NTF (Paris) / Lambert Centre France",
+                27563:"NTF (Paris) / Lambert Sud France",
+                27564:"NTF (Paris) / Lambert Corse",
+                27571:"NTF (Paris) / Lambert zone I",
+                27572:"NTF (Paris) / Lambert zone II",
+                27573:"NTF (Paris) / Lambert zone III",
+                27574:"NTF (Paris) / Lambert zone IV",
+                        }
+
         for epsg in EPSG_list:
-            crs_code = CRS.from_epsg(epsg)
-            codeName = str(epsg) + ' ' + crs_code.name
+            codeName = str(epsg) + ' ' + EPSG_name[epsg]
             self.cmb_systemIn.addItem(codeName)
             self.cmb_systemOut.addItem(codeName)
         self.cb_changeCoordSystem.setChecked(True)
         self.cb_changeCoordSystem.setChecked(False)
-        
+
     def on_med_file_in_browse(self):
         """
         Select input MED file
@@ -70,7 +93,7 @@ class changeCoordsDialog(QDialog):
         a = os.path.splitext(self.medFileIn)
         self.medFileOut = a[0] + '_coo' + a[1]
         self.le_medFileOut.setText(self.medFileOut)
-        
+
     def on_med_file_out_browse(self):
         """
         Select output MED file
@@ -81,7 +104,7 @@ class changeCoordsDialog(QDialog):
         if not self.medFileOut:
             return
         self.le_medFileOut.setText(self.medFileOut)
-        
+
     def on_help(self):
         """
         display a help message
@@ -91,14 +114,14 @@ class changeCoordsDialog(QDialog):
 
         This dialog is used to change the nodes coordinates in a mesh. It is used either for a simple translation, a change of coordinates system
         (for instance from Lambert II to Lambert-93), or a combination.
-        <br><br>        
+        <br><br>
         The modified mesh is saved in a new file.
-        <br> 
+        <br>
         If there is a change of coordinates system, the input mesh is first translated, when it uses a local origin.
         After the change of coordinates system, the output mesh can be translated (new local origin).
-        <br>     
+        <br>
         When there is only a simple translation, the operation is: Xout = Xin + offsetXin -offsetXout, Yout = Yin + offsetYin -offsetYout.
-        <br><br>         
+        <br><br>
         Below is the description of the dialog controls.
 
         <h3>Change coordinates system</h3>
@@ -107,26 +130,26 @@ class changeCoordsDialog(QDialog):
         <h3>Input MED file</h3>
         This field allows the selection of a med file (via the standard file open dialog).
         The filling of this field is mandatory.
-        
+
         <h3>Input offsetX, offsetY</h3>
-        These fields are used to set the Origin of the local coordinates system of the input mesh, if any. 
+        These fields are used to set the Origin of the local coordinates system of the input mesh, if any.
 
         <h3>Input Coord System</h3>
-        This combo box is use to select the coordinate system of the input mesh. 
+        This combo box is use to select the coordinate system of the input mesh.
 
         <h3>Output MED file</h3>
         This field allows the definition of a med file (via the standard file save dialog).
         The filling of this field is mandatory.
-        
+
         <h3>Output offsetX, offsetY</h3>
-        These fields are used to set the Origin of the local coordinates system of the output mesh, if any. 
+        These fields are used to set the Origin of the local coordinates system of the output mesh, if any.
 
         <h3>Output Coord System</h3>
-        This combo box is use to select the coordinate system of the output mesh. 
+        This combo box is use to select the coordinate system of the output mesh.
         """
         QMessageBox.about(self, self.tr("About change coordinates dialog"), msg);
-       
-   
+
+
     def on_accept(self):
         print("accept")
         #TODO check medfile in and out not empty
@@ -168,7 +191,7 @@ class changeCoordsDialog(QDialog):
     def on_reject(self):
         print("reject")
         self.reject()
-        
+
 
 def execDialog(context):
     print("execDialog")
@@ -176,4 +199,4 @@ def execDialog(context):
     study = context.study
     sg = context.sg
     dlg = changeCoordsDialog()
-    dlg.exec_()        
+    dlg.exec_()