Files
giglez/scripts/test_gps_extraction.py
T
Trilltechnician 04bd80b25b GPS Auto-Extraction + First Successful Upload Complete
Major milestone: GPS coordinates now auto-extract from filenames and
uploads appear on map with full end-to-end workflow functional!

 GPS Auto-Extraction Features:
- JavaScript GPS extractor class matching Python patterns
- Supports 3 filename formats:
  * N/S/E/W: 34.0478N_118.2349W_filename.sub
  * lat/lon prefix: lat34.0478lon-118.2348_filename.sub
  * Signed decimal: -34.0478_118.2348_filename.sub
- Auto-populates latitude/longitude form fields on file drop
- Green notification toast shows detected coordinates
- File list shows GPS badge for files with coordinates

🗺️ Web Interface Improvements:
- Upload endpoint now stores captures in-memory
- Query endpoint returns uploaded captures for map display
- Stats endpoint shows real-time upload counts
- Map displays uploaded captures as markers
- Color-coded by frequency band

📁 Updated Files:
- static/js/upload.js: GPS extraction + auto-population
- src/api/main_simple.py: In-memory storage + endpoints
- src/parser/gps_extractor.py: Backend GPS extraction (Python)
- scripts/test_gps_extraction.py: Python test suite
- test_gps_extraction.html: Browser test suite

📊 T-Embed Files Updated:
- 34.0478N_118.2348W_1637_raw_8.sub: 315 MHz Princeton
- 34.0478N_118.2349W_1351_raw_10.sub: 433.92 MHz Princeton
- 34.0478N_118.2349W_1650_test_raw.sub: 433.92 MHz RAW
- All now have proper Flipper SubGhz headers

 Tested Features:
- GPS extraction from filename: 34.0478N_118.2349W → 34.0478, -118.2349
- Auto-population of GPS fields in upload form
- File upload with GPS validation
- Capture appears on map after upload
- Statistics update in real-time
- Frequency distribution calculated correctly

🎯 End-to-End Flow Working:
1. User drops .sub file with GPS in filename
2. GPS auto-detected and form fields populate
3. User clicks Upload
4. Server parses RF data + GPS coordinates
5. Capture stored in memory
6. Map refreshes and displays new marker
7. Stats update with new counts

🚀 Demo: http://localhost:8000
Upload 34.0478N_118.2349W_1351_raw_10.sub and watch it appear on map!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-13 18:37:13 -08:00

93 lines
2.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Test GPS extraction from T-Embed files
Demonstrates automatic GPS population from filenames
"""
import sys
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from src.parser.gps_extractor import GPSFilenameExtractor
def main():
"""Test GPS extraction on T-Embed files"""
print("=" * 80)
print("GPS EXTRACTION TEST - T-Embed Files")
print("=" * 80)
print()
# Find T-Embed files
tembed_dir = Path(__file__).parent.parent / 'signatures' / 't-embed-rf'
if not tembed_dir.exists():
print(f"❌ T-Embed directory not found: {tembed_dir}")
return 1
sub_files = list(tembed_dir.glob('*.sub'))
print(f"Found {len(sub_files)} .sub files")
print()
# Test extraction
extractor = GPSFilenameExtractor()
with_gps = []
without_gps = []
for sub_file in sorted(sub_files):
coords = extractor.extract(sub_file.name)
if coords:
with_gps.append((sub_file.name, coords))
print(f"✅ {sub_file.name}")
print(f" 📍 Latitude: {coords.latitude:.6f}")
print(f" 📍 Longitude: {coords.longitude:.6f}")
print(f" 📋 Source: {coords.source}")
else:
without_gps.append(sub_file.name)
print(f"⏭️ {sub_file.name} - No GPS in filename")
print()
# Summary
print("=" * 80)
print("SUMMARY")
print("=" * 80)
print(f"Total files: {len(sub_files)}")
print(f"With GPS coords: {len(with_gps)} ({len(with_gps)/len(sub_files)*100:.1f}%)")
print(f"Without GPS coords: {len(without_gps)} ({len(without_gps)/len(sub_files)*100:.1f}%)")
print()
if with_gps:
print("Files with GPS coordinates:")
for filename, coords in with_gps:
print(f" - {filename}")
print(f" {coords.latitude:.6f}, {coords.longitude:.6f}")
print()
if without_gps:
print("Files without GPS (would need manual entry or JSON companion):")
for filename in without_gps:
print(f" - {filename}")
print()
print("=" * 80)
print("NEXT STEPS")
print("=" * 80)
print("1. Files with GPS in filename → Auto-populate coordinates")
print("2. Files without GPS → Look for companion JSON files")
print("3. If no JSON found → Require manual GPS entry during upload")
print("=" * 80)
return 0
if __name__ == '__main__':
sys.exit(main())