Commit faecedf5 authored by shigemi miura's avatar shigemi miura

Cloud時の位置情報取得見直し

NGAデータ更新不具合修正
parent 695c323b
...@@ -1307,7 +1307,7 @@ ...@@ -1307,7 +1307,7 @@
CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements; CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 43; CURRENT_PROJECT_VERSION = 44;
DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\"";
DEVELOPMENT_TEAM = D2DC7QNNJ8; DEVELOPMENT_TEAM = D2DC7QNNJ8;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
...@@ -1353,7 +1353,7 @@ ...@@ -1353,7 +1353,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements; CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 43; CURRENT_PROJECT_VERSION = 44;
DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\"";
DEVELOPMENT_TEAM = D2DC7QNNJ8; DEVELOPMENT_TEAM = D2DC7QNNJ8;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
...@@ -1536,7 +1536,7 @@ ...@@ -1536,7 +1536,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements; CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 43; CURRENT_PROJECT_VERSION = 44;
DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\"";
DEVELOPMENT_TEAM = D2DC7QNNJ8; DEVELOPMENT_TEAM = D2DC7QNNJ8;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
......
...@@ -63,6 +63,8 @@ class GetMessage { ...@@ -63,6 +63,8 @@ class GetMessage {
* 既読通知 * 既読通知
*/ */
func readNotification() { func readNotification() {
// let id = SharingData.my.id
// let msg = SharingData.message.messages
for message in SharingData.message.messages { for message in SharingData.message.messages {
//Sail Assist側で既読が無い場合(既読確認) //Sail Assist側で既読が無い場合(既読確認)
var unRead = true var unRead = true
......
...@@ -11,6 +11,7 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate { ...@@ -11,6 +11,7 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
@Published var authorizationStatus: CLAuthorizationStatus @Published var authorizationStatus: CLAuthorizationStatus
var lastSeenLocation: CLLocation? var lastSeenLocation: CLLocation?
var serverLocationInterval: Int64 = 0 var serverLocationInterval: Int64 = 0
var serverDataUpdateInterval: Int64 = 0
private let locationManager: CLLocationManager private let locationManager: CLLocationManager
let ecaTask = EcaTask() let ecaTask = EcaTask()
...@@ -76,26 +77,29 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate { ...@@ -76,26 +77,29 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
} }
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let eca = EcaTask()
eca.start()
let ngaList = GetNgaList()
ngaList.start()
if let newLocation = locations.first { if let newLocation = locations.first {
// print(debug: "called locationManager")
lastSeenLocation = newLocation lastSeenLocation = newLocation
let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate
SharingData.location.gps = targetCoordinate SharingData.location.gps = targetCoordinate
SharingData.location.setLocation() SharingData.location.setLocation()
//Mobile Phone GPS
if Preferences.LocationType == 0 { if Preferences.LocationType == 0 {
ecaTask.checkEca() if serverLocationInterval <= DateTextLib.Date2UnixTime(date: Date()) {
ngaTask.checkNga() self.ecaTask.checkEca()
self.ngaTask.checkNga()
serverLocationInterval = DateTextLib.Date2UnixTime(date: Date()) + Int64(TimerInterval)
}
} }
} }
//Cloud GPS
if Preferences.LocationType == 1 { if Preferences.LocationType == 1 {
//位置情報更新
let eca = EcaTask()
eca.start()
if serverLocationInterval <= DateTextLib.Date2UnixTime(date: Date()) { if serverLocationInterval <= DateTextLib.Date2UnixTime(date: Date()) {
self.ecaTask.checkEca() self.ecaTask.checkEca()
self.ngaTask.checkNga() self.ngaTask.checkNga()
...@@ -103,6 +107,15 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate { ...@@ -103,6 +107,15 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
serverLocationInterval = DateTextLib.Date2UnixTime(date: Date()) + Int64(TimerInterval) serverLocationInterval = DateTextLib.Date2UnixTime(date: Date()) + Int64(TimerInterval)
} }
} }
//データ更新
if serverDataUpdateInterval <= DateTextLib.Date2UnixTime(date: Date()) {
print(debug: "update data")
let ngaList = GetNgaList()
ngaList.start()
serverDataUpdateInterval = DateTextLib.Date2UnixTime(date: Date()) + Int64(UpdateTime)
}
} }
// func filterLocation(_ location: CLLocation) -> Bool { // func filterLocation(_ location: CLLocation) -> Bool {
......
...@@ -32,6 +32,7 @@ class LoginViewParam: ObservableObject{ ...@@ -32,6 +32,7 @@ class LoginViewParam: ObservableObject{
} }
let TimerInterval = 60.0 let TimerInterval = 60.0
let UpdateTime = 360.0
struct LoginView: View { struct LoginView: View {
@ObservedObject var scannerViewModel = ScannerViewModel() @ObservedObject var scannerViewModel = ScannerViewModel()
......
...@@ -52,9 +52,9 @@ struct MenuGpsSelectView: View { ...@@ -52,9 +52,9 @@ struct MenuGpsSelectView: View {
Button{ Button{
selected = content selected = content
if content == .Mobile { if content == .Mobile {
Preferences.LocationType = 0 Preferences.LocationType = 0 //Mobile Phone GPS
} else { } else {
Preferences.LocationType = 1 Preferences.LocationType = 1 //Cloud GPS
} }
SharingData.location.setLocation() SharingData.location.setLocation()
}label:{ }label:{
......
...@@ -23,22 +23,10 @@ class GetNgaList { ...@@ -23,22 +23,10 @@ class GetNgaList {
let serverSession = ServerSession() let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ReqNgaList].self) let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ReqNgaList].self)
if let res = resjson { if let res = resjson {
var ngaAreas = ngaData.ngaArea var ngaTmp: Dictionary<UUID, RegisteredNga> = [:]
for ngaList in res { for ngaList in res {
if let id = NSUUID(uuidString: ngaList.id) { if let id = NSUUID(uuidString: ngaList.id) {
if var nga = ngaAreas[id as UUID] { if var nga = RegisteredNga(areaName: "") {
if let name = ngaList.name {
nga.name = name
}
nga.isLock = ngaList.lock
nga.points.removeAll()
for pos in ngaList.geometry{
let point = CLLocationCoordinate2D(latitude: pos.lat!, longitude: pos.lon!)
nga.points.append(point)
}
ngaAreas.updateValue(nga, forKey: nga.areaId)
} else {
if var nga = RegisteredNga(areaName: "test dammy") { //TODO: 名称はダミー
nga.areaId = id as UUID nga.areaId = id as UUID
if let name = ngaList.name { if let name = ngaList.name {
nga.name = name nga.name = name
...@@ -53,15 +41,53 @@ class GetNgaList { ...@@ -53,15 +41,53 @@ class GetNgaList {
let point = CLLocationCoordinate2D(latitude: pos.lat!, longitude: pos.lon!) let point = CLLocationCoordinate2D(latitude: pos.lat!, longitude: pos.lon!)
nga.points.append(point) nga.points.append(point)
} }
ngaAreas.updateValue(nga, forKey: nga.areaId) ngaTmp.updateValue(nga, forKey: nga.areaId)
}
}
} }
for ares in ngaAreas {
ngaData.setNgaArea(key: ares.value.areaId, value: ares.value)
} }
} }
ngaData.ngaArea = [:]
ngaData.ngaArea = ngaTmp
} }
// if let res = resjson {
// var ngaAreas = ngaData.ngaArea
// for ngaList in res {
// if let id = NSUUID(uuidString: ngaList.id) {
// if var nga = ngaAreas[id as UUID] {
// if let name = ngaList.name {
// nga.name = name
// }
// nga.isLock = ngaList.lock
// nga.points.removeAll()
// for pos in ngaList.geometry{
// let point = CLLocationCoordinate2D(latitude: pos.lat!, longitude: pos.lon!)
// nga.points.append(point)
// }
// ngaAreas.updateValue(nga, forKey: nga.areaId)
// } else {
// if var nga = RegisteredNga(areaName: "test dammy") { //TODO: 名称はダミー
// nga.areaId = id as UUID
// if let name = ngaList.name {
// nga.name = name
// }
// nga.isLock = ngaList.lock
// nga.isRunning = ngaList.enabled
// if !ngaList.enabled {
// nga.passingCnt = 0
// }
// nga.color = Color.green.description
// for pos in ngaList.geometry{
// let point = CLLocationCoordinate2D(latitude: pos.lat!, longitude: pos.lon!)
// nga.points.append(point)
// }
// ngaAreas.updateValue(nga, forKey: nga.areaId)
// }
// }
// }
// for ares in ngaAreas {
// ngaData.setNgaArea(key: ares.value.areaId, value: ares.value)
// }
// }
// }
case .failure(let errorCode): case .failure(let errorCode):
print(debug: errorCode) print(debug: errorCode)
break break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment