| """
|
| 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_LAT = 1.5638
|
| BASE_LON = 103.6388
|
|
|
|
|
| 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
|
|
|
|
|
| for idx, venue in enumerate(utm_venues):
|
|
|
|
|
| lat_offset = (idx % 10) * 0.0001
|
| lon_offset = (idx // 10) * 0.0001
|
|
|
| venue.latitude = BASE_LAT + lat_offset
|
| venue.longitude = BASE_LON + lon_offset
|
| venue.radius_meters = 50
|
|
|
| updated_count += 1
|
| print(f"Updated: {venue.name} -> ({venue.latitude:.6f}, {venue.longitude:.6f})")
|
|
|
|
|
| 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)
|
|
|
|
|
| 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()
|
|
|