From 9d6f370528b5689c37d6b5d5241941341deb48d9 Mon Sep 17 00:00:00 2001 From: Pradeeban Kathiravelu Date: Wed, 4 Feb 2026 06:40:17 -0900 Subject: [PATCH 1/5] fix repeat definition of the to_degrees function. Refactor to_degrees function for GPS conversion and add error handling. --- dreamsApp/app/utils/location_extractor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dreamsApp/app/utils/location_extractor.py b/dreamsApp/app/utils/location_extractor.py index fccbee4..e1437c4 100644 --- a/dreamsApp/app/utils/location_extractor.py +++ b/dreamsApp/app/utils/location_extractor.py @@ -29,9 +29,10 @@ def extract_gps_from_image(image_file): return None def to_degrees(val): - if not (isinstance(val, (tuple, list)) and len(val) == 3): - def to_degrees(val): - return sum((c[0]/c[1] if isinstance(c, tuple) else float(c)) / 60**i for i, c in enumerate(val)) + """Converts GPS coordinates from DMS to decimal degrees.""" + if not isinstance(val, (tuple, list)) or len(val) != 3: + raise ValueError(f"Invalid GPS coordinate format: {val}") + return sum(float(c) / 60**i for i, c in enumerate(val)) lat = to_degrees(gps_info["GPSLatitude"]) if gps_info.get("GPSLatitudeRef") == "S": From ba86f63b85725a8c3ae77feb991daef7b1bb6ede Mon Sep 17 00:00:00 2001 From: Pradeeban Kathiravelu Date: Wed, 4 Feb 2026 06:49:57 -0900 Subject: [PATCH 2/5] remove redundant file path retrieval in app.py Removed redundant code for finding transcript and description paths. --- dream-integration/app/app.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/dream-integration/app/app.py b/dream-integration/app/app.py index 72fba06..204a0ae 100644 --- a/dream-integration/app/app.py +++ b/dream-integration/app/app.py @@ -119,16 +119,6 @@ def _find_first_file(directory, patterns): transcript_path = _find_first_file(sample_dir, ["transcript*.txt", "clip-*.txt"]) description_path = _find_first_file(sample_dir, ["description*.txt"]) - transcript_path = None - for pattern in ("transcript*.txt", "clip-*.txt"): - matches = glob.glob(os.path.join(sample_dir, pattern)) - if matches: - transcript_path = matches[0] - break - - description_matches = glob.glob(os.path.join(sample_dir, "description*.txt")) - description_path = description_matches[0] if description_matches else None - out_dir = os.path.join(sample_dir, "analysis") os.makedirs(out_dir, exist_ok=True) From 265d5d2134754c43cb7fbe0a276a73c710295722 Mon Sep 17 00:00:00 2001 From: Pradeeban Kathiravelu Date: Wed, 4 Feb 2026 06:59:43 -0900 Subject: [PATCH 3/5] Update dreamsApp/app/utils/location_extractor.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- dreamsApp/app/utils/location_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dreamsApp/app/utils/location_extractor.py b/dreamsApp/app/utils/location_extractor.py index e1437c4..ee7a2bf 100644 --- a/dreamsApp/app/utils/location_extractor.py +++ b/dreamsApp/app/utils/location_extractor.py @@ -32,7 +32,7 @@ def to_degrees(val): """Converts GPS coordinates from DMS to decimal degrees.""" if not isinstance(val, (tuple, list)) or len(val) != 3: raise ValueError(f"Invalid GPS coordinate format: {val}") - return sum(float(c) / 60**i for i, c in enumerate(val)) + return sum((c[0] / c[1] if isinstance(c, tuple) else float(c)) / 60**i for i, c in enumerate(val)) lat = to_degrees(gps_info["GPSLatitude"]) if gps_info.get("GPSLatitudeRef") == "S": From 02b733e2936d8609ffdf8c8959bc93dfc524f6a5 Mon Sep 17 00:00:00 2001 From: Pradeeban Kathiravelu Date: Wed, 4 Feb 2026 07:02:00 -0900 Subject: [PATCH 4/5] Update dreamsApp/app/utils/location_extractor.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- dreamsApp/app/utils/location_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dreamsApp/app/utils/location_extractor.py b/dreamsApp/app/utils/location_extractor.py index ee7a2bf..b0d23a3 100644 --- a/dreamsApp/app/utils/location_extractor.py +++ b/dreamsApp/app/utils/location_extractor.py @@ -32,7 +32,7 @@ def to_degrees(val): """Converts GPS coordinates from DMS to decimal degrees.""" if not isinstance(val, (tuple, list)) or len(val) != 3: raise ValueError(f"Invalid GPS coordinate format: {val}") - return sum((c[0] / c[1] if isinstance(c, tuple) else float(c)) / 60**i for i, c in enumerate(val)) + return sum(((c[0] / c[1] if c[1] != 0 else 0) if isinstance(c, tuple) else float(c)) / 60**i for i, c in enumerate(val)) lat = to_degrees(gps_info["GPSLatitude"]) if gps_info.get("GPSLatitudeRef") == "S": From 9752e0ccc1169605c758dc8cc3e164619c4af1b9 Mon Sep 17 00:00:00 2001 From: Pradeeban Kathiravelu Date: Wed, 4 Feb 2026 07:04:40 -0900 Subject: [PATCH 5/5] Update dreamsApp/app/utils/location_extractor.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- dreamsApp/app/utils/location_extractor.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dreamsApp/app/utils/location_extractor.py b/dreamsApp/app/utils/location_extractor.py index b0d23a3..168a8e1 100644 --- a/dreamsApp/app/utils/location_extractor.py +++ b/dreamsApp/app/utils/location_extractor.py @@ -32,7 +32,15 @@ def to_degrees(val): """Converts GPS coordinates from DMS to decimal degrees.""" if not isinstance(val, (tuple, list)) or len(val) != 3: raise ValueError(f"Invalid GPS coordinate format: {val}") - return sum(((c[0] / c[1] if c[1] != 0 else 0) if isinstance(c, tuple) else float(c)) / 60**i for i, c in enumerate(val)) + total_degrees = 0.0 + for i, c in enumerate(val): + if isinstance(c, tuple): + if c[1] == 0: + raise ValueError(f"Invalid GPS coordinate component with zero denominator: {c}") + total_degrees += (c[0] / c[1]) / (60**i) + else: + total_degrees += float(c) / (60**i) + return total_degrees lat = to_degrees(gps_info["GPSLatitude"]) if gps_info.get("GPSLatitudeRef") == "S":