Repository: CS-SI/eodag
Pull request #667 (2023-03-07 14:41:38)

fix: shapely transform inverted xy and warning
Fixes inverted x/y when using `shapely.ops.transform()` in `convert_from_ewkt()` and `convert_from_georss()`, and supresses deprecation warning following https://shapely.readthedocs.io/en/latest/manual.html#other-transformations guidelines

github-actions[bot]: ## Unit Test Results
    2 files  ±0      2 suites  ±0   5m 6s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") - 1m 39s
373 tests ±0  370 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0  2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")  - 1  1 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") +1 
746 runs  ±0  740 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0  5 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")  - 1  1 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") +1 

For more details on these failures, see [this check](https://github.com/CS-SI/eodag/runs/11825051361).

Results for commit 267e85e2. ± Comparison against base commit d0712120.

[test-results]:data:application/gzip;base64,H4sIAPlOB2QC/02NSw6DIBBAr2JYd4F8pZdpCEJCqtLwWZnevYMKdTV5bzJvduT8YhN6DuQxoFR87jCXqLMPGyDFAgSscl1SSRu9UjHmUPiv3v5zJU7htF9AjF3YGEMEU29i2WpTMnFBS0qGuzmLvPEtePC9Z8K6+gyAiJB24pZIGEQxpxTXYhIzs/CMEqqwMXjUBH1/++uhRgUBAAA=

github-actions[bot]: <strong> </strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `88%` | :white_check_mark: |
| eodag/api/product/metadata\_mapping.py | `89%` | :white_check_mark: |
| tests/units/test\_download\_plugins.py | `98%` | :white_check_mark: |

<strong> </strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `88%` | :white_check_mark: |
| eodag/api/product/metadata\_mapping.py | `89%` | :white_check_mark: |
| tests/units/test\_download\_plugins.py | `98%` | :white_check_mark: |
| eodag/api/product/metadata\_mapping.py | `89%` | :white_check_mark: |
| tests/units/test\_download\_plugins.py | `98%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

<p align="right">Generated by :monkey: cobertura-action against b1223abe9e8d45c484ab5d18bc52a16aa11198e5 </p>

Patch:
diff --git a/eodag/api/product/metadata_mapping.py b/eodag/api/product/metadata_mapping.py
index 14c3ece4..67dea0b7 100644
--- a/eodag/api/product/metadata_mapping.py
+++ b/eodag/api/product/metadata_mapping.py
@@ -19,7 +19,6 @@ import ast
 import logging
 import re
 from datetime import datetime, timedelta
-from functools import partial
 from string import Formatter
 
 import geojson
@@ -322,12 +321,14 @@ def format_metadata(search_param, *args, **kwargs):
                 from_proj = g["proj"].replace("SRID", "EPSG").replace("=", ":")
                 input_geom = wkt.loads(g["wkt"])
 
-                from_proj = pyproj.Proj(from_proj)
-                to_proj = pyproj.Proj(DEFAULT_PROJ)
+                from_proj = pyproj.CRS(from_proj)
+                to_proj = pyproj.CRS(DEFAULT_PROJ)
 
                 if from_proj != to_proj:
                     # reproject
-                    project = partial(pyproj.transform, from_proj, to_proj)
+                    project = pyproj.Transformer.from_crs(
+                        from_proj, to_proj, always_xy=True
+                    ).transform
                     return transform(project, input_geom)
                 else:
                     return input_geom
@@ -360,9 +361,11 @@ def format_metadata(search_param, *args, **kwargs):
                 # Multipolygon
                 from_proj = getattr(georss[0], "attrib", {}).get("srsName", None)
                 if from_proj:
-                    from_proj = pyproj.Proj(from_proj)
-                    to_proj = pyproj.Proj(DEFAULT_PROJ)
-                    project = partial(pyproj.transform, from_proj, to_proj)
+                    from_proj = pyproj.CRS(from_proj)
+                    to_proj = pyproj.CRS(DEFAULT_PROJ)
+                    project = pyproj.Transformer.from_crs(
+                        from_proj, to_proj, always_xy=True
+                    ).transform
 
                 # function to get deepest elements
                 def flatten_elements(nested):
diff --git a/setup.cfg b/setup.cfg
index be3df248..a9051e25 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -47,7 +47,7 @@ install_requires =
     owslib < 0.26;python_version>='3.10'
     owslib;python_version<'3.10'
     geojson
-    pyproj
+    pyproj >= 2.1.0
     usgs >= 0.3.1
     boto3
     flasgger


Test patch:
diff --git a/tests/units/test_download_plugins.py b/tests/units/test_download_plugins.py
index 4c832406..88c72499 100644
--- a/tests/units/test_download_plugins.py
+++ b/tests/units/test_download_plugins.py
@@ -568,7 +568,7 @@ class TestDownloadPluginHttpRetry(BaseDownloadPluginTest):
                 self.plugin.download(
                     self.product,
                     outputs_prefix=self.output_dir,
-                    wait=0.01 / 60,
+                    wait=0.02 / 60,
                     timeout=0.2 / 60,
                 )
 
diff --git a/tests/units/test_metadata_mapping.py b/tests/units/test_metadata_mapping.py
index 06248a5b..7aa9e29a 100644
--- a/tests/units/test_metadata_mapping.py
+++ b/tests/units/test_metadata_mapping.py
@@ -131,8 +131,8 @@ class TestMetadataFormatter(unittest.TestCase):
             to_format, fieldname="SRID=3857;POINT (321976 5390999)"
         )
         geom = wkt.loads(wkt_str)
-        self.assertEqual(round(geom.x, 1), 43.5)
-        self.assertEqual(round(geom.y, 1), 2.9)
+        self.assertEqual(round(geom.x, 1), 2.9)
+        self.assertEqual(round(geom.y, 1), 43.5)
 
     def test_convert_to_ewkt(self):
         to_format = "{fieldname#to_ewkt}"
@@ -175,11 +175,11 @@ class TestMetadataFormatter(unittest.TestCase):
         sub_multipolygon.attrib["srsName"] = "EPSG:3857"
         sub_polygon1 = etree.SubElement(sub_multipolygon, "foo")
         sub_polygon1.text = (
-            "4833492 136933 4871341 136933 4871341 187044 4833492 187044 4833492 136933"
+            "136923 5376120 136923 5428376 187017 5428376 187017 5376120 136923 5376120"
         )
         sub_polygon2 = etree.SubElement(sub_multipolygon, "bar")
         sub_polygon2.text = (
-            "4833492 248305 4871341 248305 4871341 409938 4833492 409938 4833492 248305"
+            "248242 5376120 248242 5428376 409655 5428376 409655 5376120 248242 5376120"
         )
         wkt_str = format_metadata(to_format, fieldname=georss)
         geom = wkt.loads(wkt_str)