Attender / update_utm_coordinates.py
chualinwei3's picture
Upload 30 files
f742815 verified
Raw
History Blame Contribute Delete
2.58 kB
"""
Update all UTM Faculty of Computing venues to correct GPS coordinates
Based on Plus Code: HJ7Q+F5 Johor Bahru (UTM Skudai Campus)
Coordinates: 1.5638°N, 103.6388°E
"""
from app import app, db
from models import Classroom
def update_utm_coordinates():
"""Update all UTM venues to correct coordinates, except PUTERI-COURT"""
with app.app_context():
print("Updating UTM Faculty of Computing venue coordinates...")
print("Base location: HJ7Q+F5 Johor Bahru (UTM Skudai)")
print("=" * 70)
# Base coordinates for UTM FC (from Plus Code HJ7Q+F5)
BASE_LAT = 1.5638
BASE_LON = 103.6388
# Get all venues except PUTERI-COURT
utm_venues = Classroom.query.filter(Classroom.name != 'PUTERI-COURT').all()
if not utm_venues:
print("No UTM venues found to update!")
return
updated_count = 0
# Update each venue with slight offset from base coordinates
for idx, venue in enumerate(utm_venues):
# Create slight variations for each venue (small offsets)
# This simulates different rooms being in slightly different locations
lat_offset = (idx % 10) * 0.0001 # Small latitude variation
lon_offset = (idx // 10) * 0.0001 # Small longitude variation
venue.latitude = BASE_LAT + lat_offset
venue.longitude = BASE_LON + lon_offset
venue.radius_meters = 50 # Keep 50m radius for classrooms
updated_count += 1
print(f"Updated: {venue.name} -> ({venue.latitude:.6f}, {venue.longitude:.6f})")
# Commit all changes
db.session.commit()
print("=" * 70)
print(f"[OK] Successfully updated {updated_count} UTM venues")
print(f"Base coordinates: {BASE_LAT}N, {BASE_LON}E")
print(f"PUTERI-COURT was NOT updated (kept separate)")
print("=" * 70)
# Verify PUTERI-COURT wasn't changed
puteri = Classroom.query.filter_by(name='PUTERI-COURT').first()
if puteri:
print(f"\n[OK] PUTERI-COURT location verified:")
print(f" Latitude: {puteri.latitude}")
print(f" Longitude: {puteri.longitude}")
print(f" (Jalan Raja Chulan, KL - unchanged)")
print(f"\nTotal venues in database: {Classroom.query.count()}")
if __name__ == '__main__':
update_utm_coordinates()