Commit 6e93098a authored by sugita mamoru's avatar sugita mamoru

地図表示、タスク設定

parent 866c9797
......@@ -43,6 +43,7 @@
022789082AE1FE4C00A87787 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 022788F72AE1FE3C00A87787 /* Turf.xcframework */; };
022789092AE1FE4C00A87787 /* Turf.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 022788F72AE1FE3C00A87787 /* Turf.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
0227890C2AE22E0B00A87787 /* SharingData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0227890B2AE22E0B00A87787 /* SharingData.swift */; };
022A98202AF8B8960079C55A /* LocationCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 022A981F2AF8B8960079C55A /* LocationCalculation.swift */; };
02CD068F2AE6535F005F8D8F /* MapSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CD068E2AE6535F005F8D8F /* MapSource.swift */; };
02CD06912AE6536B005F8D8F /* LayerEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CD06902AE6536B005F8D8F /* LayerEnum.swift */; };
02CD06932AE88970005F8D8F /* ServerSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CD06922AE88970005F8D8F /* ServerSession.swift */; };
......@@ -61,7 +62,6 @@
D5AE351A2AEBA66A00059889 /* ReqLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AE35182AEBA66A00059889 /* ReqLogin.swift */; };
D5AE351B2AEBA66A00059889 /* ResLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AE35192AEBA66A00059889 /* ResLogin.swift */; };
D5AE351D2AEBA6FC00059889 /* SessionLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AE351C2AEBA6FC00059889 /* SessionLogin.swift */; };
D5EA864A2AF213C90032E810 /* LocationCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5EA86492AF213C90032E810 /* LocationCalculation.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -134,6 +134,7 @@
022788F92AE1FE3D00A87787 /* MapboxCommon.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = MapboxCommon.xcframework; sourceTree = "<group>"; };
022788FA2AE1FE3D00A87787 /* MapboxMaps.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = MapboxMaps.xcframework; sourceTree = "<group>"; };
0227890B2AE22E0B00A87787 /* SharingData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingData.swift; sourceTree = "<group>"; };
022A981F2AF8B8960079C55A /* LocationCalculation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LocationCalculation.swift; path = Sailassist/Location/LocationCalculation.swift; sourceTree = SOURCE_ROOT; };
02CD068E2AE6535F005F8D8F /* MapSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapSource.swift; sourceTree = "<group>"; };
02CD06902AE6536B005F8D8F /* LayerEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayerEnum.swift; sourceTree = "<group>"; };
02CD06922AE88970005F8D8F /* ServerSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSession.swift; sourceTree = "<group>"; };
......@@ -153,7 +154,6 @@
D5AE35182AEBA66A00059889 /* ReqLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ReqLogin.swift; path = Sailassist/Json/ReqLogin.swift; sourceTree = SOURCE_ROOT; };
D5AE35192AEBA66A00059889 /* ResLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ResLogin.swift; path = Sailassist/Json/ResLogin.swift; sourceTree = SOURCE_ROOT; };
D5AE351C2AEBA6FC00059889 /* SessionLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SessionLogin.swift; path = Sailassist/ServerSession/SessionLogin.swift; sourceTree = SOURCE_ROOT; };
D5EA86492AF213C90032E810 /* LocationCalculation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LocationCalculation.swift; path = ../../../../Sailassist_login/Seilassist/Sailassist/Location/LocationCalculation.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -473,7 +473,7 @@
D5EA86482AF2139D0032E810 /* Location */ = {
isa = PBXGroup;
children = (
D5EA86492AF213C90032E810 /* LocationCalculation.swift */,
022A981F2AF8B8960079C55A /* LocationCalculation.swift */,
);
path = Location;
sourceTree = "<group>";
......@@ -613,8 +613,8 @@
02CD06912AE6536B005F8D8F /* LayerEnum.swift in Sources */,
020B98532AD919180029DE4C /* LoginTypeSelectView.swift in Sources */,
D52D213F2AEBB7D700324D58 /* RegisteredEca.swift in Sources */,
D5EA864A2AF213C90032E810 /* LocationCalculation.swift in Sources */,
02CD06952AE895F5005F8D8F /* APIError.swift in Sources */,
022A98202AF8B8960079C55A /* LocationCalculation.swift in Sources */,
02CE4DC82ADF97E8002E79BC /* View+Extensions.swift in Sources */,
020B98412AD8C3810029DE4C /* LoginView.swift in Sources */,
D5AE351D2AEBA6FC00059889 /* SessionLogin.swift in Sources */,
......@@ -828,7 +828,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = test.sugita.sailassist;
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
......@@ -860,7 +860,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = test.sugita.sailassist;
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
......
......@@ -4336,7 +4336,7 @@ class EcaCoordinatesTable : NSObject {
func setEcaData() {
for data in ecaDataTable {
if !SharingData.shared.ecaArea.keys.contains(data.name) {
let reg = RegisteredEca(ecaName: data.name)!
var reg = RegisteredEca(ecaName: data.name)!
reg.color = "0xFF0000" //ライン色(ARGB)
reg.points = data.table
SharingData.shared.ecaArea.updateValue(reg, forKey: data.name)
......
......@@ -8,18 +8,18 @@
import Foundation
import CoreLocation
class RegisteredEca: ObservableObject {
@Published var id: UInt32 = 0
@Published var isEnable: Bool = false //ECA有効
@Published var isRunning: Bool = false //ECA実行中
@Published var name: String = "" //ECA名称
@Published var swNotice: UInt32 = 6 //ECA通知[NM]
@Published var swStart: UInt32 = 5 //ECA開始[NM]
@Published var swFinish: UInt32 = 4 //ECA終了[NM]
@Published var datetime: String = "" //時刻(UTC ISO8601準拠)
@Published var color: String = "" //ライン色(ARGB)
@Published var width: UInt32 = 1 //ライン幅
@Published var points: [CLLocationCoordinate2D] = []
struct RegisteredEca {
var id: UInt32 = 0
var isEnable: Bool = false //ECA有効
var isRunning: Bool = false //ECA実行中
var name: String = "" //ECA名称
var swNotice: Float = 6 //ECA通知[NM]
var swStart: Float = 5 //ECA開始[NM]
var swFinish: Float = 4 //ECA終了[NM]
var datetime: String = "" //時刻(UTC ISO8601準拠)
var color: String = "" //ライン色(ARGB)
var width: UInt32 = 1 //ライン幅
var points: [CLLocationCoordinate2D] = []
init?( ecaName: String ) {
self.name = ecaName
......
......@@ -9,4 +9,5 @@ import Foundation
enum LayerEnum: String{
case OwnShip
case EcaLine
}
......@@ -11,14 +11,17 @@ import MapboxMaps
import UIKit
struct MapRepresentable: UIViewControllerRepresentable{
@ObservedObject var sharingData = SharingData.shared
let mapVC = MapViewController()
@State var mapVC = MapViewController()
func makeUIViewController(context: Context) -> some UIViewController {
mapVC
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
if let ecaArea = sharingData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
mapVC.updateEcaLine(line: ecaArea.points)
}
}
}
......@@ -26,7 +29,8 @@ class MapViewController : UIViewController{
internal var mapView: MapView!
public var ownShipSymbol = MapSource(layer: .OwnShip)
var ownShipSymbol = MapSource(layer: .OwnShip)
var ecaLine = MapSource(layer: .EcaLine)
override func viewDidLoad() {
super.viewDidLoad()
......@@ -43,7 +47,6 @@ class MapViewController : UIViewController{
mapView.mapboxMap.onNext(event: .mapLoaded) { [self] _ in
self.addLayers()
self.updateOwnShip(location: CLLocationCoordinate2D(latitude: 45, longitude: 100))
}
}
......@@ -71,6 +74,19 @@ class MapViewController : UIViewController{
try! mapView.mapboxMap.style.addSource(ownShipSymbol.source, id: ownShipSymbol.sourceId)
try? mapView.mapboxMap.style.addLayer(ownShipSymbolLayer)
let ecaLineString = LineString([LocationCoordinate2D(latitude: 0, longitude: 0)])
var ecaLinefeature = Feature(geometry: ecaLineString)
ecaLine.source.data = .feature(ecaLinefeature)
var ecaLineLayer = LineLayer(id: ecaLine.layerId)
ecaLineLayer.source = ecaLine.sourceId
ecaLineLayer.lineColor = .expression(Exp(.get) {
PropertyKey.Color.rawValue
})
ecaLineLayer.lineDasharray = .constant([2,1])
try! mapView.mapboxMap.style.addSource(ecaLine.source, id: ecaLine.sourceId)
try? mapView.mapboxMap.style.addLayer(ecaLineLayer)
}
func updateOwnShip(location: CLLocationCoordinate2D){
......@@ -80,6 +96,18 @@ class MapViewController : UIViewController{
try! self.mapView.mapboxMap.style.updateGeoJSONSource(withId: self.ownShipSymbol.sourceId,
geoJSON: .feature(geoJSON))
}
func updateEcaLine(line: [CLLocationCoordinate2D]){
do{
var geoJson = Feature(geometry: LineString(line))
geoJson.properties = [PropertyKey.Color.rawValue: .string(Color.blue.description)]
try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: ecaLine.sourceId, geoJSON: .feature(geoJson))
}catch{
}
}
......@@ -87,6 +115,7 @@ class MapViewController : UIViewController{
enum PropertyKey : String {
case IconImage
case Bearing
case Color
}
enum IconImage: String, CaseIterable{
......
......@@ -18,8 +18,9 @@ struct EcaListView: View {
Spacer()
if !eca.isEnable{
Button(action: {
eca.isEnable.toggle()
sharingData.editEcaArea(key: eca.name, value: eca)
var newData = eca
newData.isEnable.toggle()
sharingData.editEcaArea(key: eca.name, value: newData)
}, label: {
Image("icon_plus")
.padding()
......
......@@ -8,43 +8,21 @@
import SwiftUI
struct EcaSettingView: View {
@Binding var isShowSettingEca: Bool
@State var edittingEca: RegisteredEca
// @State var ecaArea: RegisteredEca = RegisteredEca(ecaName: "eca")!
var body: some View {
VStack{
VStack(alignment: .leading){
Text("Switching Finish - ECA")
.foregroundColor(ColorSet.Body.color)
HStack{
Text("17")
Text("NM")
}
.foregroundColor(ColorSet.Body.color)
HStack{
Button(action: {
}, label: {
Image(systemName: "minus.circle")
})
Slider(value: .constant(1))
Button(action: {
}, label: {
Image(systemName: "plus.circle")
})
}
}
SliderView(param: $edittingEca.swFinish, title: "Switching Finish - ECA")
Divider()
SliderView(param: $edittingEca.swStart, title: "Switching Start - ECA")
Divider()
SliderView(param: $edittingEca.swNotice, title: "Switching Notice - ECA")
Button(action: {
SharingData.shared.editEcaArea(key: edittingEca.name, value: edittingEca)
isShowSettingEca = false
}, label: {
Text("Register")
.padding()
......@@ -57,6 +35,42 @@ struct EcaSettingView: View {
}
}
fileprivate struct SliderView: View {
@Binding var param: Float
let title: String
var min : Float = 1
var max : Float = 10
var body: some View {
VStack(alignment: .leading){
Text(title)
.foregroundColor(ColorSet.Body.color)
HStack{
Text(String(format: "%d", Int(param)))
Text("NM")
}
.foregroundColor(ColorSet.Body.color)
HStack{
Button(action: {
param -= 1
}, label: {
Image(systemName: "minus.circle")
})
.disabled(param <= min)
Slider(value: $param, in: min...max, step: 1)
Button(action: {
param += 1
}, label: {
Image(systemName: "plus.circle")
})
.disabled(param >= max)
}
}
}
}
#Preview {
EcaSettingView()
EcaSettingView(isShowSettingEca: .constant(true), edittingEca: RegisteredEca(ecaName: "eca")!)
}
......@@ -10,7 +10,6 @@ import SwiftUI
enum TaskViewMode{
case SwitchingMenu
case EcaList
case EcaSetting
var title: String{
switch self{
......@@ -18,8 +17,6 @@ enum TaskViewMode{
"Fuel Switching"
case .EcaList:
"ECA List"
case .EcaSetting:
""
}
}
}
......@@ -27,6 +24,8 @@ enum TaskViewMode{
struct MapTaskView: View {
@State var viewMode: TaskViewMode = .SwitchingMenu
@State var edittingEcaArea: RegisteredEca? = nil
@State var isShowSettingView : Bool = false
var body: some View {
VStack{
Capsule()
......@@ -75,11 +74,13 @@ struct MapTaskView: View {
ScrollView(.vertical){
switch viewMode {
case .SwitchingMenu:
TaskSwitchingMenuView(viewMode: $viewMode)
if let edittingEcaArea = edittingEcaArea, isShowSettingView{
EcaSettingView(isShowSettingEca: $isShowSettingView, edittingEca: edittingEcaArea)
}else{
TaskSwitchingMenuView(viewMode: $viewMode, edittingEcaArea: $edittingEcaArea, isShowSettingEca: $isShowSettingView)
}
case .EcaList:
EcaListView()
case .EcaSetting:
EcaSettingView()
}
}
......@@ -87,7 +88,7 @@ struct MapTaskView: View {
.padding(.trailing, 10)
Spacer()
.frame(height: 100)
.frame(height: 55)
}.onAppear{
EcaCoordinatesTable().setEcaData()
......
......@@ -9,7 +9,11 @@ import SwiftUI
struct TaskSwitchingMenuView: View {
@Binding var viewMode: TaskViewMode
@Binding var edittingEcaArea: RegisteredEca?
@Binding var isShowSettingEca : Bool
@ObservedObject var sharingData = SharingData.shared
@State var isDeleteAlert : Bool = false
var body: some View {
VStack{
ForEach(sharingData.ecaArea.map{ $0.1 }.filter{ $0.isEnable }, id: \.name){ eca in
......@@ -17,12 +21,14 @@ struct TaskSwitchingMenuView: View {
VStack {
HStack {
Button {
for running in sharingData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{
running.isRunning = false
sharingData.editEcaArea(key: running.name, value: running)
for runningEca in sharingData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{
var newData = runningEca
newData.isRunning = false
sharingData.editEcaArea(key: runningEca.name, value: newData)
}
eca.isRunning = true
sharingData.editEcaArea(key: eca.name, value: eca)
var newData = eca
newData.isRunning = true
sharingData.editEcaArea(key: eca.name, value: newData)
} label: {
Circle()
.frame(width: 10)
......@@ -34,38 +40,54 @@ struct TaskSwitchingMenuView: View {
Spacer()
Menu {
Label{
Text(eca.name)
} icon: {
Image("closeIcon")
}
Text(eca.name)
Button{
viewMode = .EcaSetting
edittingEcaArea = eca
isShowSettingEca = true
} label: {
Text("Edit Notice Setting")
}
Button{
edittingEcaArea = eca
isDeleteAlert = true
} label: {
Text("Delete ECA Task")
}
} label: {
Image(systemName: "ellipsis")
.padding()
}
.disabled(eca.isRunning)
.alert("delete", isPresented: $isDeleteAlert) {
Button(role: .destructive) {
if let ecaArea = edittingEcaArea{
var newData = ecaArea
newData.isEnable = false
sharingData.editEcaArea(key: ecaArea.name, value: newData)
}
edittingEcaArea = nil
} label: {
Text("delete")
}
Button(role: .cancel) {
} label: {
Text("cancel")
}
} message: {
Text("eca delete")
}
}
.frame(height: 50)
Divider()
}
}
// TaskEcaView()
//AddECAボタン
Button(action: {
viewMode = .EcaList
......@@ -84,5 +106,5 @@ struct TaskSwitchingMenuView: View {
#Preview {
TaskSwitchingMenuView(viewMode: .constant(.SwitchingMenu))
TaskSwitchingMenuView(viewMode: .constant(.SwitchingMenu), edittingEcaArea: .constant(nil), isShowSettingEca: .constant(false))
}
......@@ -62,7 +62,7 @@ struct MainTabView: View {
}
.zIndex(0)
.presentationDragIndicator(.hidden)
.presentationDetents([.height(100), .medium, .fraction(0.99)])
.presentationDetents([.height(155), .medium, .fraction(0.99)])
.presentationCornerRadius(15)
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
.presentationBackground(ColorSet.ModalWindowBack.color)
......
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