mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
remove some print statements
This commit is contained in:
parent
e07277410f
commit
1e95694c7b
6 changed files with 1 additions and 73 deletions
|
|
@ -188,11 +188,7 @@ struct GeoJSONStyledFeature: Identifiable {
|
|||
if let geometry = mkFeature.geometry.first as? MKOverlay {
|
||||
// Successfully created overlay
|
||||
return geometry
|
||||
} else {
|
||||
Logger.services.warning("🗺️ GeoJSONStyledFeature: First geometry is not an MKOverlay: \(type(of: mkFeature.geometry.first))")
|
||||
}
|
||||
} else {
|
||||
Logger.services.warning("🗺️ GeoJSONStyledFeature: First feature is not an MKGeoJSONFeature: \(type(of: mkFeatures.first))")
|
||||
}
|
||||
} catch {
|
||||
Logger.services.error("🗺️ GeoJSONStyledFeature: Failed to convert feature to overlay: \(error.localizedDescription)")
|
||||
|
|
|
|||
|
|
@ -11,52 +11,38 @@ class GeoJSONOverlayManager {
|
|||
|
||||
/// Load raw GeoJSON feature collection from user uploads
|
||||
func loadFeatureCollection() -> GeoJSONFeatureCollection? {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: loadFeatureCollection() called")
|
||||
|
||||
if let cached = featureCollection {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: Returning cached feature collection with \(cached.features.count) features")
|
||||
return cached
|
||||
}
|
||||
|
||||
// Load user-uploaded feature collection
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: Loading feature collection from MapDataManager")
|
||||
if let userFeatures = MapDataManager.shared.loadFeatureCollection() {
|
||||
Logger.services.info("🗺️ GeoJSONOverlayManager: Loaded feature collection with \(userFeatures.features.count) features")
|
||||
featureCollection = userFeatures
|
||||
return userFeatures
|
||||
}
|
||||
|
||||
// No feature collection available
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: No feature collection available")
|
||||
return nil
|
||||
}
|
||||
|
||||
/// Load styled features for specific enabled configs
|
||||
func loadStyledFeaturesForConfigs(_ enabledConfigs: Set<UUID>) -> [GeoJSONStyledFeature] {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: loadStyledFeaturesForConfigs() called with \(enabledConfigs.count) configs")
|
||||
|
||||
// Get files that match the enabled configs
|
||||
let enabledFiles = MapDataManager.shared.getUploadedFiles().filter { enabledConfigs.contains($0.id) }
|
||||
|
||||
guard !enabledFiles.isEmpty else {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: No enabled files found, returning empty array")
|
||||
return []
|
||||
}
|
||||
|
||||
// Load feature collection from enabled files only
|
||||
guard let collection = MapDataManager.shared.loadFeatureCollectionForFiles(enabledFiles) else {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: No feature collection available for enabled files, returning empty array")
|
||||
return []
|
||||
}
|
||||
|
||||
var styledFeatures: [GeoJSONStyledFeature] = []
|
||||
|
||||
Logger.services.info("🗺️ GeoJSONOverlayManager: Processing \(collection.features.count) features from \(enabledFiles.count) enabled files")
|
||||
|
||||
for feature in collection.features {
|
||||
// Skip invisible features
|
||||
guard feature.isVisible else {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: Skipping invisible feature")
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -68,27 +54,20 @@ class GeoJSONOverlayManager {
|
|||
styledFeatures.append(styledFeature)
|
||||
}
|
||||
|
||||
Logger.services.info("🗺️ GeoJSONOverlayManager: Returning \(styledFeatures.count) styled features from enabled configs")
|
||||
return styledFeatures
|
||||
}
|
||||
|
||||
/// Load styled features for direct rendering (legacy method)
|
||||
func loadStyledFeatures() -> [GeoJSONStyledFeature] {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: loadStyledFeatures() called")
|
||||
|
||||
guard let collection = loadFeatureCollection() else {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: No feature collection available, returning empty array")
|
||||
return []
|
||||
}
|
||||
|
||||
var styledFeatures: [GeoJSONStyledFeature] = []
|
||||
|
||||
Logger.services.info("🗺️ GeoJSONOverlayManager: Processing \(collection.features.count) features")
|
||||
|
||||
for feature in collection.features {
|
||||
// Skip invisible features
|
||||
guard feature.isVisible else {
|
||||
Logger.services.debug("🗺️ GeoJSONOverlayManager: Skipping invisible feature")
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +79,6 @@ class GeoJSONOverlayManager {
|
|||
styledFeatures.append(styledFeature)
|
||||
}
|
||||
|
||||
Logger.services.info("🗺️ GeoJSONOverlayManager: Returning \(styledFeatures.count) styled features")
|
||||
return styledFeatures
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +108,6 @@ class GeoJSONOverlayManager {
|
|||
|
||||
/// Clear cached data (useful for testing or memory management)
|
||||
func clearCache() {
|
||||
Logger.services.info("🗺️ GeoJSONOverlayManager: Clearing cache")
|
||||
featureCollection = nil
|
||||
}
|
||||
|
||||
|
|
@ -164,10 +141,8 @@ class GeoJSONOverlayManager {
|
|||
|
||||
/// Toggle the active state of an uploaded file
|
||||
func toggleFileActive(_ fileId: UUID) {
|
||||
Logger.services.error("🚨 GeoJSONOverlayManager: ENTRY - Toggling active state for file: \(fileId)")
|
||||
MapDataManager.shared.toggleFileActive(fileId)
|
||||
// Clear cache to force reload with new file states
|
||||
clearCache()
|
||||
Logger.services.error("🚨 GeoJSONOverlayManager: EXIT - Completed toggle and cache clear for file: \(fileId)")
|
||||
}
|
||||
}
|
||||
|
|
@ -57,7 +57,6 @@ class MapDataManager {
|
|||
|
||||
/// Process and store an uploaded file
|
||||
func processUploadedFile(from sourceURL: URL) async throws -> MapDataMetadata {
|
||||
Logger.services.info("📁 Processing uploaded file: \(sourceURL.lastPathComponent, privacy: .public)")
|
||||
|
||||
// 1. Start accessing security-scoped resource
|
||||
let isAccessing = sourceURL.startAccessingSecurityScopedResource()
|
||||
|
|
@ -98,7 +97,6 @@ class MapDataManager {
|
|||
// 7. Clear cached configuration to force reload
|
||||
activeFeatureCollection = nil
|
||||
|
||||
Logger.services.info("📁 Successfully processed file: \(newFilename, privacy: .public)")
|
||||
return metadata
|
||||
}
|
||||
|
||||
|
|
@ -186,10 +184,7 @@ class MapDataManager {
|
|||
|
||||
/// Load combined feature collection from specific files
|
||||
func loadFeatureCollectionForFiles(_ files: [MapDataMetadata]) -> GeoJSONFeatureCollection? {
|
||||
Logger.services.debug("📁 MapDataManager: Loading feature collection for \(files.count) specific files")
|
||||
|
||||
guard !files.isEmpty else {
|
||||
Logger.services.debug("📁 MapDataManager: No files provided, returning nil")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +194,6 @@ class MapDataManager {
|
|||
do {
|
||||
if let featureCollection = try loadFeatureCollectionFromFile(file) {
|
||||
allFeatures.append(contentsOf: featureCollection.features)
|
||||
Logger.services.info("📁 MapDataManager: Successfully loaded \(featureCollection.features.count) features from \(file.filename, privacy: .public)")
|
||||
}
|
||||
} catch {
|
||||
Logger.services.error("📁 MapDataManager: Failed to load feature collection from \(file.filename, privacy: .public): \(error.localizedDescription, privacy: .public)")
|
||||
|
|
@ -208,27 +202,21 @@ class MapDataManager {
|
|||
}
|
||||
|
||||
guard !allFeatures.isEmpty else {
|
||||
Logger.services.debug("📁 MapDataManager: No features loaded from any files")
|
||||
return nil
|
||||
}
|
||||
|
||||
Logger.services.info("📁 MapDataManager: Successfully combined \(allFeatures.count) total features from \(files.count) files")
|
||||
return GeoJSONFeatureCollection(type: "FeatureCollection", features: allFeatures)
|
||||
}
|
||||
|
||||
/// Load and combine raw GeoJSON feature collections from all active files
|
||||
func loadFeatureCollection() -> GeoJSONFeatureCollection? {
|
||||
if let cached = activeFeatureCollection {
|
||||
Logger.services.debug("📁 MapDataManager: Returning cached feature collection")
|
||||
return cached
|
||||
}
|
||||
|
||||
// Find active user files
|
||||
let activeFiles = uploadedFiles.filter { $0.isActive }
|
||||
Logger.services.debug("📁 MapDataManager: Found \(activeFiles.count) active files out of \(self.uploadedFiles.count) total files")
|
||||
|
||||
guard !activeFiles.isEmpty else {
|
||||
Logger.services.debug("📁 MapDataManager: No active files found")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +224,6 @@ class MapDataManager {
|
|||
|
||||
// Load features from all active files
|
||||
for activeFile in activeFiles {
|
||||
Logger.services.info("📁 MapDataManager: Attempting to load active file: \(activeFile.filename, privacy: .public)")
|
||||
|
||||
guard let fileURL = getUserUploadedDirectory()?.appendingPathComponent(activeFile.filename) else {
|
||||
Logger.services.error("📁 MapDataManager: Could not construct file URL for: \(activeFile.filename, privacy: .public)")
|
||||
|
|
@ -246,14 +233,12 @@ class MapDataManager {
|
|||
// Check if file exists before trying to load it
|
||||
if !FileManager.default.fileExists(atPath: fileURL.path) {
|
||||
Logger.services.error("📁 MapDataManager: Active file does not exist at path: \(fileURL.path, privacy: .public)")
|
||||
Logger.services.info("📁 MapDataManager: Removing missing file from metadata")
|
||||
|
||||
// Remove the missing file from our metadata
|
||||
if let index = uploadedFiles.firstIndex(where: { $0.filename == activeFile.filename }) {
|
||||
uploadedFiles.remove(at: index)
|
||||
do {
|
||||
try saveMetadata()
|
||||
Logger.services.info("📁 MapDataManager: Successfully cleaned up missing file from metadata")
|
||||
} catch {
|
||||
Logger.services.error("📁 MapDataManager: Failed to save cleaned metadata: \(error.localizedDescription, privacy: .public)")
|
||||
}
|
||||
|
|
@ -266,7 +251,6 @@ class MapDataManager {
|
|||
let processedData = try processData(data, filename: activeFile.filename)
|
||||
let featureCollection = try JSONDecoder().decode(GeoJSONFeatureCollection.self, from: processedData)
|
||||
|
||||
Logger.services.info("📁 MapDataManager: Successfully loaded \(featureCollection.features.count) features from \(activeFile.filename, privacy: .public)")
|
||||
allFeatures.append(contentsOf: featureCollection.features)
|
||||
} catch {
|
||||
Logger.services.error("📁 MapDataManager: Failed to load feature collection from \(activeFile.filename, privacy: .public): \(error.localizedDescription, privacy: .public)")
|
||||
|
|
@ -279,7 +263,6 @@ class MapDataManager {
|
|||
features: allFeatures
|
||||
)
|
||||
|
||||
Logger.services.info("📁 MapDataManager: Successfully combined \(allFeatures.count) total features from \(activeFiles.count) active files")
|
||||
activeFeatureCollection = combinedCollection
|
||||
return combinedCollection
|
||||
}
|
||||
|
|
@ -293,39 +276,28 @@ class MapDataManager {
|
|||
|
||||
/// Toggle the active state of an uploaded file
|
||||
func toggleFileActive(_ fileId: UUID) {
|
||||
Logger.services.error("🚨 MapDataManager: ENTRY - Toggling active state for file: \(fileId)")
|
||||
|
||||
if let index = uploadedFiles.firstIndex(where: { $0.id == fileId }) {
|
||||
let oldState = uploadedFiles[index].isActive
|
||||
uploadedFiles[index].isActive.toggle()
|
||||
let newState = uploadedFiles[index].isActive
|
||||
Logger.services.error("🚨 MapDataManager: File '\(self.uploadedFiles[index].filename)' changed from \(oldState) to \(newState)")
|
||||
|
||||
// Save metadata changes
|
||||
do {
|
||||
try saveMetadata()
|
||||
// Clear cached data to force reload
|
||||
activeFeatureCollection = nil
|
||||
Logger.services.error("🚨 MapDataManager: Successfully saved metadata and cleared cache")
|
||||
} catch {
|
||||
Logger.services.error("🚨 MapDataManager: FAILED to save metadata after toggling file: \(error.localizedDescription)")
|
||||
}
|
||||
} else {
|
||||
Logger.services.error("🚨 MapDataManager: ERROR - Could not find file with ID: \(fileId)")
|
||||
}
|
||||
Logger.services.error("🚨 MapDataManager: EXIT - Completed toggle operation for file: \(fileId)")
|
||||
}
|
||||
|
||||
/// Delete uploaded file
|
||||
func deleteFile(_ metadata: MapDataMetadata) throws {
|
||||
Logger.services.info("🗑️ MapDataManager: Attempting to delete file: \(metadata.filename, privacy: .public)")
|
||||
|
||||
guard let fileURL = getUserUploadedDirectory()?.appendingPathComponent(metadata.filename) else {
|
||||
Logger.services.error("🗑️ MapDataManager: Could not construct file URL for: \(metadata.filename, privacy: .public)")
|
||||
throw MapDataError.fileNotFound
|
||||
}
|
||||
|
||||
Logger.services.debug("🗑️ MapDataManager: File URL: \(fileURL.path, privacy: .public)")
|
||||
|
||||
// Check if file exists before trying to delete
|
||||
if !FileManager.default.fileExists(atPath: fileURL.path) {
|
||||
|
|
@ -334,7 +306,6 @@ class MapDataManager {
|
|||
|
||||
do {
|
||||
try FileManager.default.removeItem(at: fileURL)
|
||||
Logger.services.info("🗑️ MapDataManager: Successfully removed file from filesystem")
|
||||
} catch {
|
||||
Logger.services.error("🗑️ MapDataManager: Failed to remove file: \(error.localizedDescription, privacy: .public)")
|
||||
throw error
|
||||
|
|
@ -342,14 +313,12 @@ class MapDataManager {
|
|||
|
||||
if let index = uploadedFiles.firstIndex(where: { $0.filename == metadata.filename }) {
|
||||
uploadedFiles.remove(at: index)
|
||||
Logger.services.debug("🗑️ MapDataManager: Removed file from uploadedFiles array at index \(index)")
|
||||
} else {
|
||||
Logger.services.warning("🗑️ MapDataManager: File not found in uploadedFiles array")
|
||||
}
|
||||
|
||||
do {
|
||||
try saveMetadata()
|
||||
Logger.services.debug("🗑️ MapDataManager: Successfully saved updated metadata")
|
||||
} catch {
|
||||
Logger.services.error("🗑️ MapDataManager: Failed to save metadata: \(error.localizedDescription, privacy: .public)")
|
||||
throw error
|
||||
|
|
@ -358,13 +327,11 @@ class MapDataManager {
|
|||
// Clear cache if this was the active file
|
||||
if activeFeatureCollection != nil {
|
||||
activeFeatureCollection = nil
|
||||
Logger.services.debug("🗑️ MapDataManager: Cleared active configuration cache")
|
||||
}
|
||||
|
||||
// Clear GeoJSON overlay manager cache
|
||||
GeoJSONOverlayManager.shared.clearCache()
|
||||
|
||||
Logger.services.info("🗑️ MapDataManager: Successfully deleted file: \(metadata.filename, privacy: .public)")
|
||||
}
|
||||
|
||||
/// Toggle file active status
|
||||
|
|
|
|||
|
|
@ -248,8 +248,6 @@ struct MeshMapContent: MapContent {
|
|||
// Get all features but filter by enabled configs
|
||||
let allStyledFeatures = GeoJSONOverlayManager.shared.loadStyledFeaturesForConfigs(enabledOverlayConfigs)
|
||||
|
||||
// Log with error level to make it visible
|
||||
print("🚨 MeshMapContent: overlayContent computed - \(enabledOverlayConfigs.count) enabled configs, \(allStyledFeatures.count) features")
|
||||
|
||||
return Group {
|
||||
ForEach(0..<allStyledFeatures.count, id: \.self) { index in
|
||||
|
|
|
|||
|
|
@ -139,9 +139,6 @@ struct MapSettingsForm: View {
|
|||
}
|
||||
.tint(.accentColor)
|
||||
.disabled(!hasUserData)
|
||||
.onChange(of: mapOverlaysEnabled) { oldValue, newValue in
|
||||
Logger.services.info("🔧 MapSettingsForm: Master overlay toggle changed from \(oldValue) to \(newValue)")
|
||||
}
|
||||
|
||||
// Show individual file toggles when overlays are enabled
|
||||
if mapOverlaysEnabled && hasUserData {
|
||||
|
|
@ -161,18 +158,14 @@ struct MapSettingsForm: View {
|
|||
ForEach(uploadedFiles) { file in
|
||||
Toggle(isOn: Binding(
|
||||
get: {
|
||||
let isEnabled = enabledOverlayConfigs.contains(file.id)
|
||||
Logger.services.debug("🔧 MapSettingsForm: File '\(file.originalName)' toggle getter - enabled: \(isEnabled)")
|
||||
return isEnabled
|
||||
return enabledOverlayConfigs.contains(file.id)
|
||||
},
|
||||
set: { newValue in
|
||||
Logger.services.error("🚨 SETTER CALLED: File '\(file.originalName)' toggle setter - changing to: \(newValue)")
|
||||
if newValue {
|
||||
enabledOverlayConfigs.insert(file.id)
|
||||
} else {
|
||||
enabledOverlayConfigs.remove(file.id)
|
||||
}
|
||||
Logger.services.error("🚨 SETTER COMPLETED: enabledOverlayConfigs now has \(enabledOverlayConfigs.count) items")
|
||||
}
|
||||
)) {
|
||||
Label {
|
||||
|
|
|
|||
|
|
@ -202,7 +202,6 @@ struct MeshMap: View {
|
|||
// Initialize enabled overlay configs with all active files
|
||||
let activeFiles = GeoJSONOverlayManager.shared.getUploadedFilesWithState().filter { $0.isActive }
|
||||
enabledOverlayConfigs = Set(activeFiles.map { $0.id })
|
||||
print("🚨 MeshMap: Initialized with \(enabledOverlayConfigs.count) enabled overlay configs")
|
||||
|
||||
// let wayPointEntity = getWaypoint(id: Int64(deepLinkManager.waypointId) ?? -1, context: context)
|
||||
// if wayPointEntity.id > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue