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) diff --git a/dreamsApp/app/utils/location_extractor.py b/dreamsApp/app/utils/location_extractor.py index fccbee4..168a8e1 100644 --- a/dreamsApp/app/utils/location_extractor.py +++ b/dreamsApp/app/utils/location_extractor.py @@ -29,9 +29,18 @@ 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}") + 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":