From 70d501aa44cbf7929692bf9d094c06cdd28c2a8a Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Mon, 19 Oct 2020 15:15:49 +0200 Subject: [PATCH] bug EDF #22200: fields are lost when change coordinates --- src/HYDROTools/changeCoords.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/HYDROTools/changeCoords.py b/src/HYDROTools/changeCoords.py index 8573a13b..c88036ce 100644 --- a/src/HYDROTools/changeCoords.py +++ b/src/HYDROTools/changeCoords.py @@ -1,4 +1,5 @@ +import shutil import numpy as np import MEDLoader as ml import medcoupling as mc @@ -29,6 +30,9 @@ def changeCoords(fileIn, fileOut, epsgIn=2154, epsgOut=2154, offsetXin=0, offset O if OK """ # TODO: do we need to transform the exception in return codes ? + if fileOut != fileIn: + shutil.copyfile(fileIn, fileOut) + if epsgIn != epsgOut: crs_in = CRS.from_epsg(epsgIn) crs_out = CRS.from_epsg(epsgOut) @@ -65,5 +69,5 @@ def changeCoords(fileIn, fileOut, epsgIn=2154, epsgOut=2154, offsetXin=0, offset ncoords.setInfoOnComponents(["X [m]", "Y [m]"]) meshMEDFileRead.setCoords(ncoords) - meshMEDFileRead.write(fileOut, 2) + meshMEDFileRead.write(fileOut, 0) return 0 -- 2.39.2