diff --git a/app/config.py b/app/config.py index 069c572..ce98a71 100644 --- a/app/config.py +++ b/app/config.py @@ -69,6 +69,31 @@ DEFAULTS = { 'check_interval_hours': 24, 'renewal_days_before_expiry': 30, }, + 'maps': { + 'default_map': 'DeepDesert', + 'DeepDesert': { + 'image': 'maps/Deep_Desert_Map1.jpg', + 'bounds': { + 'min_x': 466906, + 'max_x': 466907, + 'min_y': -620339, + 'max_y': -620340 + }, + 'flip_y': False, + 'image_size': {'width': 1200, 'height': 800} + }, + 'HaggaBasin': { + 'image': None, + 'bounds': { + 'min_x': 21352, + 'max_x': 23166, + 'min_y': 233981, + 'max_y': 237943 + }, + 'flip_y': False, + 'image_size': {'width': 800, 'height': 600} + } + }, } diff --git a/app/routes/main.py b/app/routes/main.py index 268f35c..347435d 100644 --- a/app/routes/main.py +++ b/app/routes/main.py @@ -557,11 +557,51 @@ def register_routes(app, services, settings): all_maps.add(loc['map']) maps = sorted(all_maps) + # Get map configuration from settings + map_config = settings.get('maps', {}) + default_map = map_config.get('default_map', 'DeepDesert') + + # Calculate pixel positions for markers + def to_pixel_coords(x, y, map_name): + cfg = map_config.get(map_name, {}) + bounds = cfg.get('bounds', {}) + img_size = cfg.get('image_size', {'width': 1000, 'height': 600}) + + min_x = bounds.get('min_x', 0) + max_x = bounds.get('max_x', 1) + min_y = bounds.get('min_y', 0) + max_y = bounds.get('max_y', 1) + + if max_x == min_x or max_y == min_y: + return None, None + + # Scale to image dimensions + px = ((x - min_x) / (max_x - min_x)) * img_size['width'] + py = ((y - min_y) / (max_y - min_y)) * img_size['height'] + + # Flip Y if needed (some coordinate systems have inverted Y) + if cfg.get('flip_y', False): + py = img_size['height'] - py + + return int(px), int(py) + + # Add pixel positions + for p in player_locations: + p['px'], p['py'] = to_pixel_coords(p['x'], p['y'], p.get('map', '')) + + for v in vehicle_locations: + v['px'], v['py'] = to_pixel_coords(v['x'], v['y'], v.get('map', '')) + + for b in building_locations: + b['px'], b['py'] = to_pixel_coords(b['x'], b['y'], b.get('map', '')) + return render_template('map.html', players=player_locations, vehicles=vehicle_locations, buildings=building_locations, - maps=maps) + maps=maps, + map_config=map_config, + default_map=default_map) except Exception as e: logger.exception("Error in map route") return render_template('map.html', db_error=f"{type(e).__name__}: {e}") diff --git a/check_bounds.py b/check_bounds.py new file mode 100644 index 0000000..f8f8df2 --- /dev/null +++ b/check_bounds.py @@ -0,0 +1,52 @@ +import sys +sys.path.insert(0, '.') +from app.config import load_settings +from app.services.database import DatabaseService +import re + +settings = load_settings() +db_config = { + 'host': settings['database']['host'], + 'port': settings['database']['port'], + 'user': settings['database']['user'], + 'password': settings['database']['password'], + 'database': settings['database']['name'], +} +db = DatabaseService(db_config, 2, 10) + +# Get count by map +counts = db.query(''' + SELECT map, COUNT(*) as cnt + FROM dune.actors + WHERE transform IS NOT NULL + GROUP BY map + ORDER BY cnt DESC +''') + +print('Map coordinate counts:') +for c in counts: + print(f" {c['map']}: {c['cnt']} items") + +# Get bounds for HaggaBasin (seems to have more) +print('\n=== HaggaBasin bounds ===') +coords = db.query(''' + SELECT transform FROM dune.actors + WHERE map = 'HaggaBasin' AND transform IS NOT NULL + LIMIT 500 +''') + +points = [] +for a in coords: + t = a.get('transform') + if t: + pos_match = re.search(r'\(([0-9.e+-]+),([0-9.e+-]+),([0-9.e+-]+)\)', str(t)) + if pos_match: + points.append((float(pos_match.group(1)), float(pos_match.group(2)))) + +if points: + x_vals = [p[0] for p in points] + y_vals = [p[1] for p in points] + print(f'Min X: {min(x_vals):.1f}, Max X: {max(x_vals):.1f}') + print(f'Min Y: {min(y_vals):.1f}, Max Y: {max(y_vals):.1f}') + print(f'X range: {max(x_vals) - min(x_vals):.1f}') + print(f'Y range: {max(y_vals) - min(y_vals):.1f}') \ No newline at end of file diff --git a/static/maps/Deep_Desert_Map1.jpg b/static/maps/Deep_Desert_Map1.jpg new file mode 100644 index 0000000..31f32ed Binary files /dev/null and b/static/maps/Deep_Desert_Map1.jpg differ diff --git a/templates/map.html b/templates/map.html index b7ff1f0..4479798 100644 --- a/templates/map.html +++ b/templates/map.html @@ -148,6 +148,88 @@ font-size: 13px; color: var(--text-muted); } + +.map-display { + position: relative; + width: 100%; + height: 100%; + overflow: auto; + background: #1a1a1a; +} + +.map-image-container { + position: relative; + display: inline-block; + min-width: 1200px; + min-height: 800px; +} + +.map-image { + width: 100%; + max-width: 100%; + height: auto; + display: block; +} + +.map-marker { + position: absolute; + width: 12px; + height: 12px; + border-radius: 50%; + cursor: pointer; + transform: translate(-50%, -50%); + border: 2px solid #fff; + box-shadow: 0 2px 4px rgba(0,0,0,0.5); + transition: transform 0.15s; + z-index: 10; +} + +.map-marker:hover { + transform: translate(-50%, -50%) scale(1.5); + z-index: 100; +} + +.map-marker.player { + background: var(--primary); +} + +.map-marker.vehicle { + background: #3498db; +} + +.map-marker.building { + background: var(--success); +} + +.map-marker-tooltip { + position: absolute; + bottom: 100%; + left: 50%; + transform: translateX(-50%); + background: rgba(0,0,0,0.85); + color: #fff; + padding: 4px 8px; + border-radius: 4px; + font-size: 11px; + white-space: nowrap; + display: none; + margin-bottom: 4px; +} + +.map-marker:hover .map-marker-tooltip { + display: block; +} + +.map-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100%; + color: var(--text-muted); + padding: 40px; + text-align: center; +}

World Map

@@ -240,22 +322,67 @@
+ {% set current_map = map_config.get(default_map, {}) %} + {% set map_image = current_map.get('image') %} + {% if map_image %} +
+
+ Map + + {# Players #} + {% if show_players is not defined %}{% set show_players = true %}{% endif %} + {% if show_players %} + {% for p in players %} + {% if p.px is not none and p.py is not none %} +
+ {{ p.name }} (Player) +
+ {% endif %} + {% endfor %} + {% endif %} + + {# Vehicles #} + {% if show_vehicles is not defined %}{% set show_vehicles = true %}{% endif %} + {% if show_vehicles %} + {% for v in vehicles %} + {% if v.px is not none and v.py is not none %} +
+ {{ v.class.split('/')[-1].split('.')[0] }} (Vehicle) +
+ {% endif %} + {% endfor %} + {% endif %} + + {# Buildings #} + {% if show_buildings is not defined %}{% set show_buildings = true %}{% endif %} + {% if show_buildings %} + {% for b in buildings[:30] %} + {% if b.px is not none and b.py is not none %} +
+ {{ b.class.split('/')[-1].split('.')[0] }} (Building) +
+ {% endif %} + {% endfor %} + {% endif %} +
+
+ {% else %}
🗺️
-

Map Image Coming Soon

-

This is a prototype showing coordinate data.
Once you source a map image, markers will be overlaid here.

+

No Map Configured

+

Configure a map in settings to display coordinates.

Data available:
- Players: {{ players|length }} locations
- Vehicles: {{ vehicles|length }} locations
- Buildings: {{ buildings|length }} locations

- Coordinates are extracted from the game world. Once a map image is added, these will appear as clickable markers. -
-
+ {% endif %} +