#!/usr/bin/env python3 """ Test script for Google Earth-style flythrough animation """ import os import sys sys.path.append('/home/pi/Desktop/traccar_animation') from py_scripts.advanced_3d_generator import Advanced3DGenerator from datetime import datetime def test_google_earth_animation(): """Test the new Google Earth flythrough animation""" # Find a project with GPS data projects_folder = "/home/pi/Desktop/traccar_animation/resources/projects" if not os.path.exists(projects_folder): print("Projects folder not found!") return # Look for projects projects = [d for d in os.listdir(projects_folder) if os.path.isdir(os.path.join(projects_folder, d))] if not projects: print("No projects found!") return # Use the first project found project_name = projects[0] project_folder = os.path.join(projects_folder, project_name) positions_file = os.path.join(project_folder, "positions.json") if not os.path.exists(positions_file): print(f"No positions.json found in project {project_name}") return print(f"Testing Google Earth animation with project: {project_name}") # Create generator generator = Advanced3DGenerator(project_folder) # Check dependencies try: generator.check_dependencies() print("✅ All dependencies available") except Exception as e: print(f"❌ Dependency error: {e}") return # Generate Google Earth-style animation output_video = os.path.join(project_folder, f"{project_name}_google_earth_test_{datetime.now().strftime('%Y%m%d_%H%M%S')}.mp4") def progress_callback(progress, message): print(f"Progress: {progress:.1f}% - {message}") try: print("Starting Google Earth flythrough generation...") success = generator.generate_3d_animation( positions_file, output_video, style='google_earth', progress_callback=progress_callback ) if success and os.path.exists(output_video): print(f"✅ SUCCESS! Google Earth flythrough created: {output_video}") # Get file size file_size = os.path.getsize(output_video) / (1024 * 1024) # MB print(f"📹 Video size: {file_size:.1f} MB") else: print("❌ Failed to create video") except Exception as e: print(f"❌ Error during generation: {e}") import traceback traceback.print_exc() if __name__ == "__main__": test_google_earth_animation()