diff --git a/__pycache__/views.cpython-310.pyc b/__pycache__/views.cpython-310.pyc index d546196..c95db5d 100644 Binary files a/__pycache__/views.cpython-310.pyc and b/__pycache__/views.cpython-310.pyc differ diff --git a/templates/pxy_city_digital_twins/city_digital_twin.html b/templates/pxy_city_digital_twins/city_digital_twin.html index 7ef66b1..78afc75 100644 --- a/templates/pxy_city_digital_twins/city_digital_twin.html +++ b/templates/pxy_city_digital_twins/city_digital_twin.html @@ -1,51 +1,126 @@ +{% load static %} - + LDS City - - - - - + + + + + + + + - - {% load static %} - + + + - - + + - - {% for building in city_data.buildings %} - - - - - {% endfor %} + + - - {% for lamp in city_data.lamps %} - - - - - - {% endfor %} + + - - {% for tree in city_data.trees %} - - - - - - {% endfor %} + + + {% for building in city_data.buildings %} + + + + + {% endfor %} + + + + {% for lamp in city_data.lamps %} + + + + + + {% endfor %} + - - - + + + {% for tree in city_data.trees %} + + + + + + {% endfor %} + + + + + {% for tower in city_data.towers %} + + + + + {% endfor %} + + + + + {% for fiber in city_data.fiber_paths %} + + + + + {% endfor %} + + + + + {% for wifi in city_data.wifi_hotspots %} + + + + + {% endfor %} + + + + + diff --git a/views.py b/views.py index 925fbc7..eb5915f 100644 --- a/views.py +++ b/views.py @@ -7,6 +7,8 @@ def city_digital_twin(request, city_id, innovation_pct=None, technology_pct=None try: if city_id == "random_city": city_data = generate_random_city_data() + elif city_id == "com_con": + city_data = generate_com_con_city_data() elif city_id == "dream": # Retrieve percentages from GET parameters if not in URL innovation_pct = innovation_pct or request.GET.get('innovation', 0) @@ -164,7 +166,6 @@ def triangular_layout(num_elements): return positions - def generate_random_city_data(innovation_pct=100, technology_pct=100, science_pct=100, max_position=100, radius=50): num_buildings = random.randint(5, 35) num_lamps = random.randint(5, 100) @@ -241,3 +242,57 @@ def generate_random_city_data(innovation_pct=100, technology_pct=100, science_pc 'lamps': lamps, 'trees': trees, } + + +def generate_com_con_city_data(): + """ + Generates a telecom-focused digital twin for the hackathon. + It includes cell towers, fiber paths, and optimized coverage zones. + """ + num_towers = random.randint(3, 10) + num_fiber_paths = random.randint(5, 15) + num_wifi_hotspots = random.randint(5, 20) + + towers = [ + { + 'id': i + 1, + 'status': 'Active' if random.random() > 0.2 else 'Inactive', + 'position_x': random.uniform(-50, 50), + 'position_z': random.uniform(-50, 50), + 'height': random.randint(20, 50), + 'range': random.randint(500, 1500), # Coverage range in meters + 'color': '#ff4500' # Orange for telecom towers + } + for i in range(num_towers) + ] + + fiber_paths = [ + { + 'id': i + 1, + 'start_x': random.uniform(-50, 50), + 'start_z': random.uniform(-50, 50), + 'end_x': random.uniform(-50, 50), + 'end_z': random.uniform(-50, 50), + 'status': 'Connected' if random.random() > 0.1 else 'Broken', + 'color': '#4682b4' # Steel blue for fiber cables + } + for i in range(num_fiber_paths) + ] + + wifi_hotspots = [ + { + 'id': i + 1, + 'position_x': random.uniform(-50, 50), + 'position_z': random.uniform(-50, 50), + 'status': 'Online' if random.random() > 0.2 else 'Offline', + 'range': random.randint(100, 300), + 'color': '#32cd32' # Lime green for Wi-Fi coverage + } + for i in range(num_wifi_hotspots) + ] + + return { + 'towers': towers, + 'fiber_paths': fiber_paths, + 'wifi_hotspots': wifi_hotspots + }