Skip to content

Commit 7fa41bd

Browse files
authored
Merge pull request #72 from TaskarCenterAtUW/ways-removed-emptytags
Removed empty tags.
2 parents 91315e6 + 7f9cdc1 commit 7fa41bd

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

GoInfoGame/GoInfoGame/AppQuestManager.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@ class AppQuestManager {
3232
// Fetch the quests for a bounding box
3333
func fetchData(fromBBOx bbox: BBox,completion: @escaping () -> Void){
3434
// Get the data from bbox
35-
let centralLocation = CLLocation(latitude: 37.7749, longitude: -122.4194) // San Francisco coords
36-
let distance = 100
35+
// let distance = 100
3736
//37.41465820658871,-122.0912196996173,37.42366839341129,-122.0799229003827
38-
let boundingCoordinates = centralLocation.boundingCoordinates(distance: CLLocationDistance(distance))
3937

4038
osmConnection.fetchMapData(left:bbox.minLon , bottom:bbox.minLat , right:bbox.maxLon , top:bbox.maxLat ) { result in
4139
switch result {
4240
case .success(let mapData):
4341
let response = Array(mapData.values)
4442
let allValues = response
45-
let allElements = allValues.filter({!$0.tags.isEmpty})
43+
// let allElements = allValues.filter({!$0.tags.isEmpty})
4644
print("Saving tags")
4745
DispatchQueue.main.async {
48-
self.dbInstance.saveOSMElements(allElements) // Save all where there are tags
46+
self.dbInstance.saveOSMElements(allValues) // Save all where there are tags
4947
completion()
5048
}
5149
case .failure(let error):

GoInfoGame/GoInfoGame/DataBase/DatabaseConnector.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class DatabaseConnector {
3131
func saveOSMElements(_ elements: [OSMElement]) {
3232
// Save the elements appropriately
3333
// Get the ways and nodes out
34-
let nodes = elements.filter({$0 is OSMNode}).filter({!$0.tags.isEmpty})
34+
//let nodes = elements.filter({$0 is OSMNode}).filter({$0.tags.isEmpty})
35+
let nodes = elements
3536
let ways = elements.filter({$0 is OSMWay}).filter({!$0.tags.isEmpty})
3637
let dateFormatter = DateFormatter()
3738
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99
import MapKit
1010
import CoreLocation
11+
import Combine
1112

1213
struct MapView: View {
1314

@@ -17,7 +18,8 @@ struct MapView: View {
1718
@Environment(\.presentationMode) private var presentationMode
1819
@AppStorage("isMapFromOnboarding") var isMapFromOnboarding: Bool = false
1920
@StateObject private var viewModel = MapViewModel()
20-
21+
@State private var isPresented = false
22+
2123
var body: some View {
2224

2325
ZStack {
@@ -26,6 +28,7 @@ struct MapView: View {
2628
MapAnnotation(coordinate: item.coordinateInfo) {
2729
Button {
2830
viewModel.selectedQuest = item.displayUnit
31+
isPresented = true
2932
print(viewModel.selectedQuest as Any, "selectedQuest quest")
3033
} label: {
3134
Image(uiImage: item.displayUnit.parent?.icon ?? UIImage(imageLiteralResourceName: "mapPoint"))
@@ -46,16 +49,27 @@ struct MapView: View {
4649
LoadingView()
4750
}
4851
}
49-
.sheet(item: $viewModel.selectedQuest) { selectedQuest in
52+
.sheet(isPresented: $isPresented, content: {
53+
let selectedQuest = self.viewModel.selectedQuest
5054
if #available(iOS 16.0, *) {
51-
selectedQuest.parent?.form.presentationDetents(getSheetSize(sheetSize: selectedQuest.sheetSize ?? .MEDIUM))
55+
selectedQuest?.parent?.form.presentationDetents(getSheetSize(sheetSize: selectedQuest?.sheetSize ?? .MEDIUM))
5256
} else {
5357
// Nothing here
5458
}
59+
})
60+
.onReceive(MapViewPublisher.shared.dismissSheet) { _ in
61+
isPresented = false
5562
}
5663
}
5764
}
5865

5966
#Preview {
6067
MapView()
6168
}
69+
70+
71+
public class MapViewPublisher: ObservableObject {
72+
public let dismissSheet = PassthroughSubject<Bool, Never>()
73+
static let shared = MapViewPublisher()
74+
private init() {}
75+
}

GoInfoGame/GoInfoGame/quests/QuestProtocols.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ class QuestBase {
4949

5050
DatasyncManager.shared.syncDataToOSM {
5151
print("SYNC DONE")
52+
DispatchQueue.main.async {
53+
MapViewPublisher.shared.dismissSheet.send(true)
54+
}
5255
}
5356
}
54-
5557
}
5658
// Adds default method and implementation
5759
extension Quest {

0 commit comments

Comments
 (0)