From ef1114316a7aa48044e599563ce7be7da50d188c Mon Sep 17 00:00:00 2001
From: Daniel Scheffler <danschef@gfz-potsdam.de>
Date: Wed, 7 Feb 2024 15:48:05 +0100
Subject: [PATCH] Do not transform if we already have lon/lat coordinates.

Signed-off-by: Daniel Scheffler <danschef@gfz-potsdam.de>
---
 .../orthorectification/orthorectification.py           | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/enpt/processors/orthorectification/orthorectification.py b/enpt/processors/orthorectification/orthorectification.py
index aaf4fb59..4d8bfea8 100644
--- a/enpt/processors/orthorectification/orthorectification.py
+++ b/enpt/processors/orthorectification/orthorectification.py
@@ -232,9 +232,13 @@ class Orthorectifier(object):
         V_UL_UR_LL_LR_ll = [(V_lons[y, x], V_lats[y, x]) for y, x in [(0, 0), (0, -1), (-1, 0), (-1, -1)]]
         S_UL_UR_LL_LR_ll = [(S_lons[y, x], S_lats[y, x]) for y, x in [(0, 0), (0, -1), (-1, 0), (-1, -1)]]
 
-        # transform them to UTM
-        V_UL_UR_LL_LR_prj = [transform_any_prj(4326, tgt_epsg, x, y) for x, y in V_UL_UR_LL_LR_ll]
-        S_UL_UR_LL_LR_prj = [transform_any_prj(4326, tgt_epsg, x, y) for x, y in S_UL_UR_LL_LR_ll]
+        # transform them to tgt_epsg
+        if tgt_epsg != 4326:
+            V_UL_UR_LL_LR_prj = [transform_any_prj(4326, tgt_epsg, x, y) for x, y in V_UL_UR_LL_LR_ll]
+            S_UL_UR_LL_LR_prj = [transform_any_prj(4326, tgt_epsg, x, y) for x, y in S_UL_UR_LL_LR_ll]
+        else:
+            V_UL_UR_LL_LR_prj = V_UL_UR_LL_LR_ll
+            S_UL_UR_LL_LR_prj = S_UL_UR_LL_LR_ll
 
         # separate X and Y
         V_X_prj, V_Y_prj = zip(*V_UL_UR_LL_LR_prj)
-- 
GitLab