From: Yoann Audouin Date: Thu, 6 Jan 2022 14:22:10 +0000 (+0100) Subject: Issue with CRS not available with actual version of pyproj X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fhydrosolver.git;a=commitdiff_plain;h=5b705e401b024346c53b08710bd7d19ad4cd8920 Issue with CRS not available with actual version of pyproj --- diff --git a/src/salome_hydro/changeCoordsDialog.py b/src/salome_hydro/changeCoordsDialog.py index fbf360f..1ac32c0 100644 --- a/src/salome_hydro/changeCoordsDialog.py +++ b/src/salome_hydro/changeCoordsDialog.py @@ -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. -

+

The modified mesh is saved in a new file. -
+
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). -
+
When there is only a simple translation, the operation is: Xout = Xin + offsetXin -offsetXout, Yout = Yin + offsetYin -offsetYout. -

+

Below is the description of the dialog controls.

Change coordinates system

@@ -107,26 +130,26 @@ class changeCoordsDialog(QDialog):

Input MED file

This field allows the selection of a med file (via the standard file open dialog). The filling of this field is mandatory. - +

Input offsetX, offsetY

- 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.

Input Coord System

- 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.

Output MED file

This field allows the definition of a med file (via the standard file save dialog). The filling of this field is mandatory. - +

Output offsetX, offsetY

- 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.

Output Coord System

- 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_()