File size: 2,580 Bytes
f742815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""

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()