Commit becc590d authored by shigemi miura's avatar shigemi miura

サーバーからECA領域を取得

parent e2778fbf
...@@ -7,12 +7,59 @@ ...@@ -7,12 +7,59 @@
import Foundation import Foundation
import CoreLocation import CoreLocation
import SwiftUI
struct ecaInfo {
var areaId: Int
var name: String
var centerPosition: CLLocationCoordinate2D
var zoomLevel: CGFloat
}
var ecaDataTable:[ecaInfo] = [
ecaInfo(areaId: 1, name: "Iceland", centerPosition: CLLocationCoordinate2D(latitude: 62.56528431, longitude: -18.48170601), zoomLevel: 4.0),
ecaInfo(areaId: 11, name: "North American Atlantic Coasts", centerPosition: CLLocationCoordinate2D(latitude: 17.89000000, longitude: -79.69611111), zoomLevel: 1.0),
ecaInfo(areaId: 12, name: "North American Hawai", centerPosition: CLLocationCoordinate2D(latitude: 15.85444444, longitude: -158.32055556), zoomLevel: 4.0),
ecaInfo(areaId: 13, name: "North American Pacific Coasts", centerPosition: CLLocationCoordinate2D(latitude: 37.22750000, longitude: -128.67277778), zoomLevel: 1.0),
ecaInfo(areaId: 21, name: "North Sea 1", centerPosition: CLLocationCoordinate2D(latitude: 54.00000000, longitude: -4.00000000), zoomLevel: 3.0),
ecaInfo(areaId: 22, name: "North Sea 2", centerPosition: CLLocationCoordinate2D(latitude: 43.50000000, longitude: -4.78333333), zoomLevel: 4.0),
ecaInfo(areaId: 31, name: "Unites States Caribbean", centerPosition: CLLocationCoordinate2D(latitude: 13.37083333, longitude: -64.70083333), zoomLevel: 4.0),
ecaInfo(areaId: 41, name: "China Shore", centerPosition: CLLocationCoordinate2D(latitude: 12.13420000, longitude: 115.21700000), zoomLevel: 2.0),
ecaInfo(areaId: 42, name: "China Hainan", centerPosition: CLLocationCoordinate2D(latitude: 16.21260000, longitude: 110.15700000), zoomLevel: 5.0),
ecaInfo(areaId: 43, name: "China Yangtzi Shuifu,Yunnan", centerPosition: CLLocationCoordinate2D(latitude: 28.60531667, longitude: 104.40085000), zoomLevel: 11.0),
ecaInfo(areaId: 44, name: "China Yangtzi Liuhekou,Jiangsu1", centerPosition: CLLocationCoordinate2D(latitude: 31.52461111, longitude: 121.37808333), zoomLevel: 10.0),
ecaInfo(areaId: 45, name: "China Yangtzi Liuhekou,Jiangsu2", centerPosition: CLLocationCoordinate2D(latitude: 30.20172222, longitude: 121.32094444), zoomLevel: 8.0),
ecaInfo(areaId: 46, name: "China Xijiang Nanning,Guangxi", centerPosition: CLLocationCoordinate2D(latitude: 22.75000000, longitude: 108.31303333), zoomLevel: 11.0),
ecaInfo(areaId: 47, name: "China Xijiang Zhaoqing,Guangdong", centerPosition: CLLocationCoordinate2D(latitude: 23.08005000, longitude: 112.77791667), zoomLevel: 11.0),
ecaInfo(areaId: 51, name: "Korea Incheon, PyeongtaekDangjin Port", centerPosition: CLLocationCoordinate2D(latitude: 36.88996667, longitude: 126.05833333), zoomLevel: 7.0),
ecaInfo(areaId: 52, name: "Korea Yeosu, Gwangyang Port", centerPosition: CLLocationCoordinate2D(latitude: 34.21166667, longitude: 128.00022222), zoomLevel: 8.0),
ecaInfo(areaId: 53, name: "Korea Busan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.81029311, longitude: 128.89994528), zoomLevel: 8.0),
ecaInfo(areaId: 54, name: "Korea Busan Port West", centerPosition: CLLocationCoordinate2D(latitude: 34.82819444, longitude: 128.82208333), zoomLevel: 9.0),
ecaInfo(areaId: 55, name: "Korea Ulsan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.98933675, longitude: 129.52881635), zoomLevel: 8.0),
ecaInfo(areaId: 61, name: "Panama Canal Atlantic Entrance", centerPosition: CLLocationCoordinate2D(latitude: 7.09898818, longitude: -79.99448871), zoomLevel: 6.0),
ecaInfo(areaId: 62, name: "Panama Canal Pacific Entrance", centerPosition: CLLocationCoordinate2D(latitude: 6.65073570, longitude: -79.42740275), zoomLevel: 6.0)
]
class EcaArea { class EcaArea {
@ObservedObject var ecaData = SharingData.eca
var sessionEcaArea = SessionEcaArea() var sessionEcaArea = SessionEcaArea()
private func tableInit() {
for data in ecaDataTable {
if !ecaData.ecaArea.keys.contains(data.areaId) {
var reg = RegisteredEca(id: data.areaId, ecaName: data.name)!
reg.color = "0xFF0000" //ライン色(ARGB)
reg.centerPosition = data.centerPosition
reg.zoomLevel = data.zoomLevel
SharingData.eca.ecaArea.updateValue(reg, forKey: data.areaId)
}
}
}
func start() { func start() {
print(debug: "called") print(debug: "called")
tableInit()
sessionEcaArea.RequestEcaArea(responseEcaArea) sessionEcaArea.RequestEcaArea(responseEcaArea)
} }
...@@ -24,6 +71,18 @@ class EcaArea { ...@@ -24,6 +71,18 @@ class EcaArea {
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResEcaArea].self) let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResEcaArea].self)
if let res = resjson { if let res = resjson {
print(debug: res) print(debug: res)
for ecaList in res {
if let position = ecaList.geometry {
var points: [CLLocationCoordinate2D] = []
position.forEach { point in
var ecaPoint: CLLocationCoordinate2D = CLLocationCoordinate2D()
ecaPoint.latitude = CLLocationDegrees(point.lat ?? 0.0)
ecaPoint.longitude = CLLocationDegrees(point.lon ?? 0.0)
points.append(ecaPoint)
}
SharingData.eca.ecaArea[ecaList.areaId]?.points = points
}
}
} }
case .failure(let errorCode): case .failure(let errorCode):
print(debug: errorCode) print(debug: errorCode)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
import CoreLocation import CoreLocation
#if true #if false
//ECA Coordinates China //ECA Coordinates China
var chinaShore:[CLLocationCoordinate2D] = [ var chinaShore:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333), CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333),
...@@ -4283,7 +4283,7 @@ var panamaCanalAtlanticEntrance:[CLLocationCoordinate2D] = [ ...@@ -4283,7 +4283,7 @@ var panamaCanalAtlanticEntrance:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 9.44860967, longitude: -79.77336823), CLLocationCoordinate2D(latitude: 9.44860967, longitude: -79.77336823),
CLLocationCoordinate2D(latitude: 9.44550000, longitude: -79.77202778) CLLocationCoordinate2D(latitude: 9.44550000, longitude: -79.77202778)
] ]
#endif
var panamaCanalPacificEntrance:[CLLocationCoordinate2D] = [ var panamaCanalPacificEntrance:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 9.02033333, longitude: -79.36930556), CLLocationCoordinate2D(latitude: 9.02033333, longitude: -79.36930556),
CLLocationCoordinate2D(latitude: 9.01445114, longitude: -79.36883975), CLLocationCoordinate2D(latitude: 9.01445114, longitude: -79.36883975),
...@@ -4330,7 +4330,7 @@ var panamaCanalPacificEntrance:[CLLocationCoordinate2D] = [ ...@@ -4330,7 +4330,7 @@ var panamaCanalPacificEntrance:[CLLocationCoordinate2D] = [
class EcaCoordinatesTable : NSObject { class EcaCoordinatesTable : NSObject {
struct ecaData { struct ecaData {
var id: Int var areaId: Int
var name: String var name: String
var centerPosition: CLLocationCoordinate2D var centerPosition: CLLocationCoordinate2D
var zoomLevel: CGFloat var zoomLevel: CGFloat
...@@ -4338,39 +4338,40 @@ class EcaCoordinatesTable : NSObject { ...@@ -4338,39 +4338,40 @@ class EcaCoordinatesTable : NSObject {
} }
var ecaDataTable:[ecaData] = [ var ecaDataTable:[ecaData] = [
ecaData(id: 1, name: "Iceland", centerPosition: CLLocationCoordinate2D(latitude: 62.56528431, longitude: -18.48170601), zoomLevel: 4.0, table: iceland), ecaData(areaId: 1, name: "Iceland", centerPosition: CLLocationCoordinate2D(latitude: 62.56528431, longitude: -18.48170601), zoomLevel: 4.0, table: iceland),
ecaData(id: 11, name: "North American Atlantic Coasts", centerPosition: CLLocationCoordinate2D(latitude: 17.89000000, longitude: -79.69611111), zoomLevel: 1.0, table: northAmericanAtlanticCoasts), ecaData(areaId: 11, name: "North American Atlantic Coasts", centerPosition: CLLocationCoordinate2D(latitude: 17.89000000, longitude: -79.69611111), zoomLevel: 1.0, table: northAmericanAtlanticCoasts),
ecaData(id: 12, name: "North American Hawai", centerPosition: CLLocationCoordinate2D(latitude: 15.85444444, longitude: -158.32055556), zoomLevel: 4.0, table: northAmericanHawai), ecaData(areaId: 12, name: "North American Hawai", centerPosition: CLLocationCoordinate2D(latitude: 15.85444444, longitude: -158.32055556), zoomLevel: 4.0, table: northAmericanHawai),
ecaData(id: 13, name: "North American Pacific Coasts", centerPosition: CLLocationCoordinate2D(latitude: 37.22750000, longitude: -128.67277778), zoomLevel: 1.0, table: northAmericanPacificCoasts), ecaData(areaId: 13, name: "North American Pacific Coasts", centerPosition: CLLocationCoordinate2D(latitude: 37.22750000, longitude: -128.67277778), zoomLevel: 1.0, table: northAmericanPacificCoasts),
ecaData(id: 21, name: "North Sea 1", centerPosition: CLLocationCoordinate2D(latitude: 54.00000000, longitude: -4.00000000), zoomLevel: 3.0, table: northSea1), ecaData(areaId: 21, name: "North Sea 1", centerPosition: CLLocationCoordinate2D(latitude: 54.00000000, longitude: -4.00000000), zoomLevel: 3.0, table: northSea1),
ecaData(id: 22, name: "North Sea 2", centerPosition: CLLocationCoordinate2D(latitude: 43.50000000, longitude: -4.78333333), zoomLevel: 4.0, table: northSea2), ecaData(areaId: 22, name: "North Sea 2", centerPosition: CLLocationCoordinate2D(latitude: 43.50000000, longitude: -4.78333333), zoomLevel: 4.0, table: northSea2),
ecaData(id: 31, name: "Unites States Caribbean", centerPosition: CLLocationCoordinate2D(latitude: 13.37083333, longitude: -64.70083333), zoomLevel: 4.0, table: unitesStatesCaribbean), ecaData(areaId: 31, name: "Unites States Caribbean", centerPosition: CLLocationCoordinate2D(latitude: 13.37083333, longitude: -64.70083333), zoomLevel: 4.0, table: unitesStatesCaribbean),
ecaData(id: 41, name: "China Shore", centerPosition: CLLocationCoordinate2D(latitude: 12.13420000, longitude: 115.21700000), zoomLevel: 2.0, table: chinaShore), ecaData(areaId: 41, name: "China Shore", centerPosition: CLLocationCoordinate2D(latitude: 12.13420000, longitude: 115.21700000), zoomLevel: 2.0, table: chinaShore),
ecaData(id: 42, name: "China Hainan", centerPosition: CLLocationCoordinate2D(latitude: 16.21260000, longitude: 110.15700000), zoomLevel: 5.0, table: chinaHainan), ecaData(areaId: 42, name: "China Hainan", centerPosition: CLLocationCoordinate2D(latitude: 16.21260000, longitude: 110.15700000), zoomLevel: 5.0, table: chinaHainan),
ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", centerPosition: CLLocationCoordinate2D(latitude: 28.60531667, longitude: 104.40085000), zoomLevel: 11.0, table: chinaYangtziShuifuYunnan), ecaData(areaId: 43, name: "China Yangtzi Shuifu,Yunnan", centerPosition: CLLocationCoordinate2D(latitude: 28.60531667, longitude: 104.40085000), zoomLevel: 11.0, table: chinaYangtziShuifuYunnan),
ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", centerPosition: CLLocationCoordinate2D(latitude: 31.52461111, longitude: 121.37808333), zoomLevel: 10.0, table: chinaYangtziLiuhekouJiangsu1), ecaData(areaId: 44, name: "China Yangtzi Liuhekou,Jiangsu1", centerPosition: CLLocationCoordinate2D(latitude: 31.52461111, longitude: 121.37808333), zoomLevel: 10.0, table: chinaYangtziLiuhekouJiangsu1),
ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", centerPosition: CLLocationCoordinate2D(latitude: 30.20172222, longitude: 121.32094444), zoomLevel: 8.0, table: chinaYangtziLiuhekouJiangsu2), ecaData(areaId: 45, name: "China Yangtzi Liuhekou,Jiangsu2", centerPosition: CLLocationCoordinate2D(latitude: 30.20172222, longitude: 121.32094444), zoomLevel: 8.0, table: chinaYangtziLiuhekouJiangsu2),
ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", centerPosition: CLLocationCoordinate2D(latitude: 22.75000000, longitude: 108.31303333), zoomLevel: 11.0, table: chinaXijiangNanningGuangxi), ecaData(areaId: 46, name: "China Xijiang Nanning,Guangxi", centerPosition: CLLocationCoordinate2D(latitude: 22.75000000, longitude: 108.31303333), zoomLevel: 11.0, table: chinaXijiangNanningGuangxi),
ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", centerPosition: CLLocationCoordinate2D(latitude: 23.08005000, longitude: 112.77791667), zoomLevel: 11.0, table: chinaXijiangNanningGuangdong), ecaData(areaId: 47, name: "China Xijiang Zhaoqing,Guangdong", centerPosition: CLLocationCoordinate2D(latitude: 23.08005000, longitude: 112.77791667), zoomLevel: 11.0, table: chinaXijiangNanningGuangdong),
ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", centerPosition: CLLocationCoordinate2D(latitude: 36.88996667, longitude: 126.05833333), zoomLevel: 7.0, table: incheonPyeongtaekDanjinPort), ecaData(areaId: 51, name: "Korea Incheon, PyeongtaekDangjin Port", centerPosition: CLLocationCoordinate2D(latitude: 36.88996667, longitude: 126.05833333), zoomLevel: 7.0, table: incheonPyeongtaekDanjinPort),
ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", centerPosition: CLLocationCoordinate2D(latitude: 34.21166667, longitude: 128.00022222), zoomLevel: 8.0, table: yeosuGwangyangPort), ecaData(areaId: 52, name: "Korea Yeosu, Gwangyang Port", centerPosition: CLLocationCoordinate2D(latitude: 34.21166667, longitude: 128.00022222), zoomLevel: 8.0, table: yeosuGwangyangPort),
ecaData(id: 53, name: "Korea Busan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.81029311, longitude: 128.89994528), zoomLevel: 8.0, table: koreaBusanPort), ecaData(areaId: 53, name: "Korea Busan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.81029311, longitude: 128.89994528), zoomLevel: 8.0, table: koreaBusanPort),
ecaData(id: 54, name: "Korea Busan Port West", centerPosition: CLLocationCoordinate2D(latitude: 34.82819444, longitude: 128.82208333), zoomLevel: 9.0, table: koreaBusanPortWest), ecaData(areaId: 54, name: "Korea Busan Port West", centerPosition: CLLocationCoordinate2D(latitude: 34.82819444, longitude: 128.82208333), zoomLevel: 9.0, table: koreaBusanPortWest),
ecaData(id: 55, name: "Korea Ulsan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.98933675, longitude: 129.52881635), zoomLevel: 8.0, table: koreaUlsanPort), ecaData(areaId: 55, name: "Korea Ulsan Port", centerPosition: CLLocationCoordinate2D(latitude: 34.98933675, longitude: 129.52881635), zoomLevel: 8.0, table: koreaUlsanPort),
ecaData(id: 61, name: "Panama Canal Atlantic Entrance", centerPosition: CLLocationCoordinate2D(latitude: 7.09898818, longitude: -79.99448871), zoomLevel: 6.0, table: panamaCanalAtlanticEntrance), ecaData(areaId: 61, name: "Panama Canal Atlantic Entrance", centerPosition: CLLocationCoordinate2D(latitude: 7.09898818, longitude: -79.99448871), zoomLevel: 6.0, table: panamaCanalAtlanticEntrance),
ecaData(id: 62, name: "Panama Canal Pacific Entrance", centerPosition: CLLocationCoordinate2D(latitude: 6.65073570, longitude: -79.42740275), zoomLevel: 6.0, table: panamaCanalPacificEntrance) ecaData(areaId: 62, name: "Panama Canal Pacific Entrance", centerPosition: CLLocationCoordinate2D(latitude: 6.65073570, longitude: -79.42740275), zoomLevel: 6.0, table: panamaCanalPacificEntrance)
] ]
func setEcaData() { func setEcaData() {
for data in ecaDataTable { for data in ecaDataTable {
if !SharingData.eca.ecaArea.keys.contains(data.name) { if !SharingData.eca.ecaArea.keys.contains(data.areaId) {
var reg = RegisteredEca(id: data.id, ecaName: data.name)! var reg = RegisteredEca(id: data.areaId, ecaName: data.name)!
reg.color = "0xFF0000" //ライン色(ARGB) reg.color = "0xFF0000" //ライン色(ARGB)
reg.points = data.table reg.points = data.table
reg.centerPosition = data.centerPosition reg.centerPosition = data.centerPosition
reg.zoomLevel = data.zoomLevel reg.zoomLevel = data.zoomLevel
SharingData.eca.ecaArea.updateValue(reg, forKey: data.name) SharingData.eca.ecaArea.updateValue(reg, forKey: data.areaId)
} }
} }
} }
} }
#endif
...@@ -115,16 +115,16 @@ class EcaTask { ...@@ -115,16 +115,16 @@ class EcaTask {
newData.status = status newData.status = status
if status == EcaState.noticePass{ //ECA通知円到達 if status == EcaState.noticePass{ //ECA通知円到達
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Notice) SharingData.eca.editEcaArea(key: eca.areaId, value: newData, type: EcaOperation.Notice)
} }
if status == EcaState.startPass{ //ECA開始円到達 if status == EcaState.startPass{ //ECA開始円到達
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Start) SharingData.eca.editEcaArea(key: eca.areaId, value: newData, type: EcaOperation.Start)
} }
if status == EcaState.finishPass{ //ECAタスク終了円到達 if status == EcaState.finishPass{ //ECAタスク終了円到達
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Finish) SharingData.eca.editEcaArea(key: eca.areaId, value: newData, type: EcaOperation.Finish)
} }
if status == EcaState.end{ //ECAタスク完了(燃料切替実施済み) if status == EcaState.end{ //ECAタスク完了(燃料切替実施済み)
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.End) SharingData.eca.editEcaArea(key: eca.areaId, value: newData, type: EcaOperation.End)
} }
} }
} }
......
...@@ -28,10 +28,10 @@ class GetEcaList { ...@@ -28,10 +28,10 @@ class GetEcaList {
for ares in ecaData.ecaArea { for ares in ecaData.ecaArea {
var eca = ares.value var eca = ares.value
eca.isEnable = false eca.isEnable = false
ecaAreas.updateValue(eca, forKey: eca.name) ecaAreas.updateValue(eca, forKey: eca.areaId)
} }
for ecaList in res{ for ecaList in res {
if var value = ecaAreas[ecaList.taskName]{ if var value = ecaAreas[ecaList.areaId]{
value.isEnable = true value.isEnable = true
value.swNotice = ecaList.noticeRange value.swNotice = ecaList.noticeRange
value.swStart = ecaList.startRange value.swStart = ecaList.startRange
...@@ -43,11 +43,11 @@ class GetEcaList { ...@@ -43,11 +43,11 @@ class GetEcaList {
value.isRunning = false value.isRunning = false
value.status = EcaState.register value.status = EcaState.register
} }
ecaAreas.updateValue(value, forKey: ecaList.taskName) ecaAreas.updateValue(value, forKey: ecaList.areaId)
} }
} }
for ares in ecaAreas{ for ares in ecaAreas{
ecaData.setEcaArea(key: ares.value.name, value: ares.value) ecaData.setEcaArea(key: ares.value.areaId, value: ares.value)
} }
} }
case .failure(let errorCode): case .failure(let errorCode):
......
...@@ -29,7 +29,7 @@ let serverIncomplete = 0x00000200 //ECAタスク未完了 (燃料切替未実 ...@@ -29,7 +29,7 @@ let serverIncomplete = 0x00000200 //ECAタスク未完了 (燃料切替未実
let serverCancel = 0x00000400 //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル) let serverCancel = 0x00000400 //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル)
struct RegisteredEca { struct RegisteredEca {
var id: Int = 0 var areaId: Int = 0
var isEnable: Bool = false //ECA有効 var isEnable: Bool = false //ECA有効
var isRunning: Bool = false //ECA実行中 var isRunning: Bool = false //ECA実行中
var name: String = "" //ECA名称 var name: String = "" //ECA名称
...@@ -45,7 +45,7 @@ struct RegisteredEca { ...@@ -45,7 +45,7 @@ struct RegisteredEca {
var points: [CLLocationCoordinate2D] = [] var points: [CLLocationCoordinate2D] = []
init?(id: Int, ecaName: String ) { init?(id: Int, ecaName: String ) {
self.id = id self.areaId = id
self.name = ecaName self.name = ecaName
} }
} }
...@@ -200,8 +200,8 @@ struct LoginView: View { ...@@ -200,8 +200,8 @@ struct LoginView: View {
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date()) Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
viewMode = .InputUserName viewMode = .InputUserName
// let ecaArea = EcaArea() let ecaArea = EcaArea()
// ecaArea.start() ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: TimerInterval, repeats: true) { _ in timer = Timer.scheduledTimer(withTimeInterval: TimerInterval, repeats: true) { _ in
print(debug: "called timer") print(debug: "called timer")
...@@ -261,11 +261,8 @@ struct LoginView: View { ...@@ -261,11 +261,8 @@ struct LoginView: View {
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date()) Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isLogin = true isLogin = true
// let ecaArea = EcaArea() let ecaArea = EcaArea()
// ecaArea.start() ecaArea.start()
let eca = EcaTask()
eca.start()
timer = Timer.scheduledTimer(withTimeInterval: TimerInterval, repeats: true) { _ in timer = Timer.scheduledTimer(withTimeInterval: TimerInterval, repeats: true) { _ in
print(debug: "called timer") print(debug: "called timer")
......
...@@ -29,7 +29,7 @@ struct MapRepresentable: UIViewControllerRepresentable{ ...@@ -29,7 +29,7 @@ struct MapRepresentable: UIViewControllerRepresentable{
mapVC.removeEcaLine() mapVC.removeEcaLine()
} }
if let focusEcaName = ecaData.focusEca, let focusEca = ecaData.ecaArea[focusEcaName]{ if let focusEcaAreaId = ecaData.focusEca, let focusEca = ecaData.ecaArea[focusEcaAreaId]{
mapVC.updateCamera(location: focusEca.centerPosition, zoomlevel: focusEca.zoomLevel) mapVC.updateCamera(location: focusEca.centerPosition, zoomlevel: focusEca.zoomLevel)
mapVC.updateOneTimeEca(eca: focusEca.points) mapVC.updateOneTimeEca(eca: focusEca.points)
//10秒後削除 //10秒後削除
...@@ -135,6 +135,7 @@ class MapViewController : UIViewController{ ...@@ -135,6 +135,7 @@ class MapViewController : UIViewController{
addImage() addImage()
//自船
let point = Point(LocationCoordinate2D(latitude: 0, longitude: 0)) let point = Point(LocationCoordinate2D(latitude: 0, longitude: 0))
ownShipSymbol.source.data = .feature(Feature(geometry: point)) ownShipSymbol.source.data = .feature(Feature(geometry: point))
var ownShipSymbolLayer = SymbolLayer(id: ownShipSymbol.layerId) var ownShipSymbolLayer = SymbolLayer(id: ownShipSymbol.layerId)
...@@ -152,7 +153,7 @@ class MapViewController : UIViewController{ ...@@ -152,7 +153,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ownShipSymbol.source, id: ownShipSymbol.sourceId) try! mapView.mapboxMap.style.addSource(ownShipSymbol.source, id: ownShipSymbol.sourceId)
try? mapView.mapboxMap.style.addLayer(ownShipSymbolLayer) try? mapView.mapboxMap.style.addLayer(ownShipSymbolLayer)
//ECA
let ecaLineString = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)]) let ecaLineString = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)])
let ecaLinefeature = Feature(geometry: ecaLineString) let ecaLinefeature = Feature(geometry: ecaLineString)
ecaLine.source.data = .feature(ecaLinefeature) ecaLine.source.data = .feature(ecaLinefeature)
...@@ -166,6 +167,7 @@ class MapViewController : UIViewController{ ...@@ -166,6 +167,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ecaLine.source, id: ecaLine.sourceId) try! mapView.mapboxMap.style.addSource(ecaLine.source, id: ecaLine.sourceId)
try? mapView.mapboxMap.style.addLayer(ecaLineLayer) try? mapView.mapboxMap.style.addLayer(ecaLineLayer)
//
_ = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)]) _ = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)])
let oneTimeEcaLinefeature = Feature(geometry: ecaLineString) let oneTimeEcaLinefeature = Feature(geometry: ecaLineString)
oneTimeEca.source.data = .feature(oneTimeEcaLinefeature) oneTimeEca.source.data = .feature(oneTimeEcaLinefeature)
...@@ -179,6 +181,7 @@ class MapViewController : UIViewController{ ...@@ -179,6 +181,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(oneTimeEca.source, id: oneTimeEca.sourceId) try! mapView.mapboxMap.style.addSource(oneTimeEca.source, id: oneTimeEca.sourceId)
try? mapView.mapboxMap.style.addLayer(oneTimeEcaLayer) try? mapView.mapboxMap.style.addLayer(oneTimeEcaLayer)
//
ecaSwitchingLine.source.data = .featureCollection(FeatureCollection(features: [])) ecaSwitchingLine.source.data = .featureCollection(FeatureCollection(features: []))
var ecaSwitchingLineLayer = LineLayer(id: ecaSwitchingLine.layerId) var ecaSwitchingLineLayer = LineLayer(id: ecaSwitchingLine.layerId)
ecaSwitchingLineLayer.source = ecaSwitchingLine.sourceId ecaSwitchingLineLayer.source = ecaSwitchingLine.sourceId
...@@ -190,6 +193,7 @@ class MapViewController : UIViewController{ ...@@ -190,6 +193,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ecaSwitchingLine.source, id: ecaSwitchingLine.sourceId) try! mapView.mapboxMap.style.addSource(ecaSwitchingLine.source, id: ecaSwitchingLine.sourceId)
try? mapView.mapboxMap.style.addLayer(ecaSwitchingLineLayer) try? mapView.mapboxMap.style.addLayer(ecaSwitchingLineLayer)
//ECA ラベル
ecaSwLineLabel.source.data = .featureCollection(FeatureCollection(features: [])) ecaSwLineLabel.source.data = .featureCollection(FeatureCollection(features: []))
var ecaSwLabelLayer = SymbolLayer(id: ecaSwLineLabel.layerId) var ecaSwLabelLayer = SymbolLayer(id: ecaSwLineLabel.layerId)
ecaSwLabelLayer.source = ecaSwLineLabel.sourceId ecaSwLabelLayer.source = ecaSwLineLabel.sourceId
...@@ -208,6 +212,7 @@ class MapViewController : UIViewController{ ...@@ -208,6 +212,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ecaSwLineLabel.source, id: ecaSwLineLabel.sourceId) try! mapView.mapboxMap.style.addSource(ecaSwLineLabel.source, id: ecaSwLineLabel.sourceId)
try? mapView.mapboxMap.style.addLayer(ecaSwLabelLayer) try? mapView.mapboxMap.style.addLayer(ecaSwLabelLayer)
//航路
wakeLines.source.data = .featureCollection(FeatureCollection(features: [])) wakeLines.source.data = .featureCollection(FeatureCollection(features: []))
var wakeLineLayer = LineLayer(id: wakeLines.layerId) var wakeLineLayer = LineLayer(id: wakeLines.layerId)
wakeLineLayer.source = wakeLines.sourceId wakeLineLayer.source = wakeLines.sourceId
...@@ -218,6 +223,7 @@ class MapViewController : UIViewController{ ...@@ -218,6 +223,7 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(wakeLines.source, id: wakeLines.sourceId) try! mapView.mapboxMap.style.addSource(wakeLines.source, id: wakeLines.sourceId)
try? mapView.mapboxMap.style.addLayer(wakeLineLayer) try? mapView.mapboxMap.style.addLayer(wakeLineLayer)
//WayPoint
wayPoints.source.data = .featureCollection(FeatureCollection(features: [])) wayPoints.source.data = .featureCollection(FeatureCollection(features: []))
var wayPointsLayer = SymbolLayer(id: wayPoints.layerId) var wayPointsLayer = SymbolLayer(id: wayPoints.layerId)
wayPointsLayer.source = wayPoints.sourceId wayPointsLayer.source = wayPoints.sourceId
......
...@@ -12,20 +12,20 @@ struct EcaListView: View { ...@@ -12,20 +12,20 @@ struct EcaListView: View {
@ObservedObject var ecaData = SharingData.eca @ObservedObject var ecaData = SharingData.eca
var body: some View { var body: some View {
ForEach(ecaData.ecaArea.map{ $0.1 }.sorted{ $0.id < $1.id }, id: \.name){ eca in ForEach(ecaData.ecaArea.map{ $0.1 }.sorted{ $0.areaId < $1.areaId }, id: \.name){ eca in
HStack { HStack {
Text(eca.name) Text(eca.name)
.font(FontStyle.DefaultText.font) .font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.Body.color) .foregroundColor(ColorSet.Body.color)
.onTapGesture { .onTapGesture {
ecaData.focusEca = eca.name ecaData.focusEca = eca.areaId
} }
Spacer() Spacer()
if !eca.isEnable{ if !eca.isEnable{
Button(action: { Button(action: {
var newData = eca var newData = eca
newData.isEnable.toggle() newData.isEnable.toggle()
ecaData.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Insert) ecaData.editEcaArea(key: eca.areaId, value: newData, type: EcaOperation.Insert)
taskViewModel.viewMode = .SwitchingMenu taskViewModel.viewMode = .SwitchingMenu
taskViewModel.edittingEcaArea = eca taskViewModel.edittingEcaArea = eca
taskViewModel.isShowSettingView = true taskViewModel.isShowSettingView = true
......
...@@ -39,7 +39,7 @@ struct EcaSettingView: View { ...@@ -39,7 +39,7 @@ struct EcaSettingView: View {
Button(action: { Button(action: {
var ecaData = edittingEca var ecaData = edittingEca
ecaData.isEnable = true ecaData.isEnable = true
SharingData.eca.editEcaArea(key: edittingEca.name, value: ecaData, type: EcaOperation.Change) SharingData.eca.editEcaArea(key: edittingEca.areaId, value: ecaData, type: EcaOperation.Change)
isShowSettingEca = false isShowSettingEca = false
}, label: { }, label: {
Text("Register") Text("Register")
......
...@@ -16,7 +16,7 @@ struct TaskSwitchingMenuView: View { ...@@ -16,7 +16,7 @@ struct TaskSwitchingMenuView: View {
var body: some View { var body: some View {
VStack{ VStack{
ForEach(ecaData.ecaArea.map{ $0.1 }.filter{ $0.isEnable }.sorted{ $0.id < $1.id }, id: \.name){ eca in ForEach(ecaData.ecaArea.map{ $0.1 }.filter{ $0.isEnable }.sorted{ $0.areaId < $1.areaId }, id: \.name){ eca in
VStack { VStack {
HStack { HStack {
//ECA開始・終了ボタン //ECA開始・終了ボタン
...@@ -30,7 +30,7 @@ struct TaskSwitchingMenuView: View { ...@@ -30,7 +30,7 @@ struct TaskSwitchingMenuView: View {
var newData = eca var newData = eca
newData.isRunning = true newData.isRunning = true
newData.status = EcaState.running newData.status = EcaState.running
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Running) SharingData.eca.editEcaArea(key: eca.areaId, value: newData, type: EcaOperation.Running)
} }
} label: { } label: {
HStack { HStack {
...@@ -46,7 +46,7 @@ struct TaskSwitchingMenuView: View { ...@@ -46,7 +46,7 @@ struct TaskSwitchingMenuView: View {
.font(FontStyle.DefaultText.font) .font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.Body.color) .foregroundColor(ColorSet.Body.color)
.onTapGesture { .onTapGesture {
ecaData.focusEca = eca.name ecaData.focusEca = eca.areaId
} }
Spacer() Spacer()
...@@ -82,8 +82,8 @@ struct TaskSwitchingMenuView: View { ...@@ -82,8 +82,8 @@ struct TaskSwitchingMenuView: View {
newData.isEnable = false newData.isEnable = false
newData.status = EcaState.cancel newData.status = EcaState.cancel
ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Delete) ecaData.editEcaArea(key: ecaArea.areaId, value: newData, type: EcaOperation.Delete)
deleteEcaArea.start(ecaId: ecaArea.id) deleteEcaArea.start(ecaId: ecaArea.areaId)
} }
taskViewModel.edittingEcaArea = nil taskViewModel.edittingEcaArea = nil
} }
...@@ -97,7 +97,7 @@ struct TaskSwitchingMenuView: View { ...@@ -97,7 +97,7 @@ struct TaskSwitchingMenuView: View {
var newData = ecaArea var newData = ecaArea
newData.isRunning = false newData.isRunning = false
newData.status = EcaState.end newData.status = EcaState.end
ecaData.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.End) ecaData.editEcaArea(key: ecaArea.areaId, value: newData, type: EcaOperation.End)
} }
taskViewModel.edittingEcaArea = nil taskViewModel.edittingEcaArea = nil
} }
......
...@@ -127,21 +127,21 @@ class SharingData{ ...@@ -127,21 +127,21 @@ class SharingData{
*/ */
static var eca = Eca() static var eca = Eca()
class Eca: ObservableObject{ class Eca: ObservableObject{
@Published var ecaArea: Dictionary<String, RegisteredEca> = [:] @Published var ecaArea: Dictionary<Int, RegisteredEca> = [:]
@Published var focusEca: String? = nil @Published var focusEca: Int? = nil
@Published var isShowEcaAlert: Bool = false @Published var isShowEcaAlert: Bool = false
func setEcaArea(key: String, value: RegisteredEca) { func setEcaArea(key: Int, value: RegisteredEca) {
ecaArea.updateValue(value, forKey: key) ecaArea.updateValue(value, forKey: key)
} }
func editEcaArea(key: String, value: RegisteredEca, type: EcaOperation) { func editEcaArea(key: Int, value: RegisteredEca, type: EcaOperation) {
let setEcaArea = SetEcaArea() let setEcaArea = SetEcaArea()
var task = ReqTaskList(Id: value.id) var task = ReqTaskList(Id: value.areaId)
switch type { switch type {
case EcaOperation.Running: case EcaOperation.Running:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -149,7 +149,7 @@ class SharingData{ ...@@ -149,7 +149,7 @@ class SharingData{
task.status = serverRunning task.status = serverRunning
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Insert: case EcaOperation.Insert:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -158,9 +158,9 @@ class SharingData{ ...@@ -158,9 +158,9 @@ class SharingData{
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Delete: case EcaOperation.Delete:
let deleteEcaArea = DeleteEcaArea() let deleteEcaArea = DeleteEcaArea()
deleteEcaArea.start(ecaId: value.id) deleteEcaArea.start(ecaId: value.areaId)
case EcaOperation.Notice: case EcaOperation.Notice:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -170,7 +170,7 @@ class SharingData{ ...@@ -170,7 +170,7 @@ class SharingData{
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Start: case EcaOperation.Start:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -180,7 +180,7 @@ class SharingData{ ...@@ -180,7 +180,7 @@ class SharingData{
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Finish: case EcaOperation.Finish:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -190,7 +190,7 @@ class SharingData{ ...@@ -190,7 +190,7 @@ class SharingData{
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.End: case EcaOperation.End:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -200,7 +200,7 @@ class SharingData{ ...@@ -200,7 +200,7 @@ class SharingData{
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Incomplete: case EcaOperation.Incomplete:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -210,7 +210,7 @@ class SharingData{ ...@@ -210,7 +210,7 @@ class SharingData{
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Cancel: case EcaOperation.Cancel:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
...@@ -220,7 +220,7 @@ class SharingData{ ...@@ -220,7 +220,7 @@ class SharingData{
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Change: case EcaOperation.Change:
task.areaId = value.id task.areaId = value.areaId
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
......
...@@ -24,15 +24,13 @@ struct MainTabView: View { ...@@ -24,15 +24,13 @@ struct MainTabView: View {
@EnvironmentObject var selectedTabModel: SelectedTabModel @EnvironmentObject var selectedTabModel: SelectedTabModel
@EnvironmentObject private var sceneDelegate: SceneDelegate @EnvironmentObject private var sceneDelegate: SceneDelegate
@State var isSignout = false @State var isSignout = false
@State var isLogin = false
@State var isEcaTask = SharingData.my.isFuelSwitchTask
init() { init() {
let appearance: UITabBarAppearance = UITabBarAppearance() let appearance: UITabBarAppearance = UITabBarAppearance()
appearance.backgroundColor = .clear appearance.backgroundColor = .clear
UITabBar.appearance().scrollEdgeAppearance = appearance UITabBar.appearance().scrollEdgeAppearance = appearance
UITabBar.appearance().standardAppearance = appearance UITabBar.appearance().standardAppearance = appearance
EcaCoordinatesTable().setEcaData() // EcaCoordinatesTable().setEcaData()
} }
var body: some View { var body: some View {
...@@ -56,7 +54,7 @@ struct MainTabView: View { ...@@ -56,7 +54,7 @@ struct MainTabView: View {
.tag(Tab.menu) .tag(Tab.menu)
} }
.hideNativeTabBar() .hideNativeTabBar()
.sheet(isPresented: .constant(isTaskSel && isTabShow && isEcaTask), content: { .sheet(isPresented: .constant(isTaskSel && isTabShow && SharingData.my.isFuelSwitchTask), content: {
MapTaskView() MapTaskView()
.zIndex(0) .zIndex(0)
.presentationDragIndicator(.hidden) .presentationDragIndicator(.hidden)
...@@ -85,7 +83,7 @@ struct MainTabView: View { ...@@ -85,7 +83,7 @@ struct MainTabView: View {
.tag(Tab.menu) .tag(Tab.menu)
} }
.hideNativeTabBar() .hideNativeTabBar()
.popover(isPresented: .constant(isPopover && isEcaTask), attachmentAnchor: .point(.bottom)) { .popover(isPresented: .constant(isPopover && SharingData.my.isFuelSwitchTask), attachmentAnchor: .point(.bottom)) {
MapTaskView() MapTaskView()
.presentationCompactAdaptation(.none) .presentationCompactAdaptation(.none)
.zIndex(0) .zIndex(0)
......
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