diff --git a/Meshtastic/Helpers/GeoJSONOverlayManager.swift b/Meshtastic/Helpers/GeoJSONOverlayManager.swift index 48feecdb..78187fc3 100644 --- a/Meshtastic/Helpers/GeoJSONOverlayManager.swift +++ b/Meshtastic/Helpers/GeoJSONOverlayManager.swift @@ -16,55 +16,32 @@ class GeoJSONOverlayManager { } guard let url = Bundle.main.url(forResource: "BurningManGeoJSONMapConfig", withExtension: "json.zlib") else { - print("GeoJSONOverlayManager: No compressed configuration file found") return nil } do { let compressedData = try Data(contentsOf: url) - print("GeoJSONOverlayManager: Loaded compressed data size: \(compressedData.count) bytes") - let decompressedData = try compressedData.zlibDecompressed() - print("GeoJSONOverlayManager: Decompressed data size: \(decompressedData.count) bytes") - - // Debug: Check the first few characters of decompressed data - if let decompressedString = String(data: decompressedData, encoding: .utf8) { - let firstChars = String(decompressedString.prefix(100)) - print("GeoJSONOverlayManager: First 100 chars of decompressed data: \(firstChars)") - } else { - print("GeoJSONOverlayManager: Decompressed data is not valid UTF-8") - // Show first few bytes as hex - let firstBytes = decompressedData.prefix(20).map { String(format: "%02x", $0) }.joined() - print("GeoJSONOverlayManager: First 20 bytes (hex): \(firstBytes)") - } - let config = try JSONDecoder().decode(GeoJSONOverlayConfiguration.self, from: decompressedData) - print("GeoJSONOverlayManager: Loaded configuration with \(config.overlays.count) overlays") configuration = config return config } catch { - print("GeoJSONOverlayManager: Failed to load configuration: \(error)") return nil } } /// Load overlays for a specific overlay ID func loadOverlays(for overlayId: String) -> [MKOverlay] { - print("GeoJSONOverlayManager: Attempting to load overlays for \(overlayId)") - if let cached = overlays[overlayId] { - print("GeoJSONOverlayManager: Returning cached overlays for \(overlayId), count: \(cached.count)") return cached } guard let config = loadConfiguration() else { - print("GeoJSONOverlayManager: Failed to load configuration") return [] } guard let overlayDef = config.overlays.first(where: { $0.id == overlayId }) else { - print("GeoJSONOverlayManager: No overlay found for ID: \(overlayId)") return [] } @@ -78,48 +55,35 @@ class GeoJSONOverlayManager { "geometry": [ "type": feature.geometry.type, "coordinates": feature.geometry.coordinates.toAnyObject() - ] + ], + "properties": [:] ] if let id = feature.id { featureDict["id"] = id } - if let properties = feature.properties { - featureDict["properties"] = properties.mapValues { $0.toAnyObject() } - } - return featureDict } ] let geojsonData = try JSONSerialization.data(withJSONObject: standardGeoJSON) let features = try MKGeoJSONDecoder().decode(geojsonData) - print("GeoJSONOverlayManager: Decoded \(features.count) features for \(overlayId)") var allOverlays: [MKOverlay] = [] for (index, feature) in features.enumerated() { if let mkFeature = feature as? MKGeoJSONFeature { - print("GeoJSONOverlayManager: Feature \(index) has \(mkFeature.geometry.count) geometries") for (geoIndex, geometry) in mkFeature.geometry.enumerated() { - print("GeoJSONOverlayManager: Geometry \(geoIndex): \(Swift.type(of: geometry))") if let overlay = geometry as? MKOverlay { allOverlays.append(overlay) - print("GeoJSONOverlayManager: Added as overlay") - } else { - print("GeoJSONOverlayManager: Could not cast to MKOverlay") } } - } else { - print("GeoJSONOverlayManager: Feature \(index) could not be cast to MKGeoJSONFeature") } } - print("GeoJSONOverlayManager: Created \(allOverlays.count) total overlays for \(overlayId)") - overlays[overlayId] = allOverlays + overlays[overlayId] = allOverlays return allOverlays } catch { - print("GeoJSONOverlayManager: Failed to decode overlays for \(overlayId): \(error)") return [] } } diff --git a/Meshtastic/Resources/BurningManGeoJSONMapConfig.json.zlib b/Meshtastic/Resources/BurningManGeoJSONMapConfig.json.zlib index 773128ca..c07ee6f6 100644 Binary files a/Meshtastic/Resources/BurningManGeoJSONMapConfig.json.zlib and b/Meshtastic/Resources/BurningManGeoJSONMapConfig.json.zlib differ diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 85d88838..04f8c2e9 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -231,18 +231,16 @@ struct MeshMapContent: MapContent { } } - /// GeoJSON Overlays (Configuration-Driven) + /// GeoJSON Overlays (Configuration-Driven) if showBurningMan { let overlayManager = GeoJSONOverlayManager.shared let availableOverlays = overlayManager.getAvailableOverlayIds() - ForEach(availableOverlays, id: \.self) { overlayId in + ForEach(Array(availableOverlays.enumerated()), id: \.element) { _, overlayId in let overlays = overlayManager.loadOverlays(for: overlayId) let rendering = overlayManager.getRenderingProperties(for: overlayId) - ForEach(overlays.map { IdentifiableOverlay(overlay: $0) }) { identifiable in - let overlay = identifiable.overlay - + ForEach(Array(overlays.enumerated()), id: \.offset) { _, overlay in if let polygon = overlay as? MKPolygon { MapPolygon(polygon) .stroke(