Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sailassist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
54
Merge Requests
54
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gr-ssv
Sailassist
Commits
f1b96f97
Commit
f1b96f97
authored
Nov 16, 2023
by
sugita mamoru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
マップ表示処理追加
parent
86fc559a
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
253 additions
and
29 deletions
+253
-29
Contents.json
Seilassist/Sailassist/Assets.xcassets/Map/Contents.json
+6
-0
Contents.json
...t/Assets.xcassets/Map/swFinishBack.imageset/Contents.json
+35
-0
swFinishBack.png
...ssets.xcassets/Map/swFinishBack.imageset/swFinishBack.png
+0
-0
Contents.json
...t/Assets.xcassets/Map/swNoticeBack.imageset/Contents.json
+35
-0
swNoticeBack.png
...ssets.xcassets/Map/swNoticeBack.imageset/swNoticeBack.png
+0
-0
Contents.json
...st/Assets.xcassets/Map/swStartBack.imageset/Contents.json
+35
-0
swStartBack.png
.../Assets.xcassets/Map/swStartBack.imageset/swStartBack.png
+0
-0
RegisteredEca.swift
Seilassist/Sailassist/ECA/RegisteredEca.swift
+1
-1
LocationCalculation.swift
Seilassist/Sailassist/Location/LocationCalculation.swift
+0
-12
LayerEnum.swift
Seilassist/Sailassist/Map/LayerEnum.swift
+2
-0
MapRepresentable.swift
Seilassist/Sailassist/Map/MapRepresentable.swift
+133
-9
SharingData.swift
Seilassist/Sailassist/SharingData/SharingData.swift
+6
-7
No files found.
Seilassist/Sailassist/Assets.xcassets/Map/Contents.json
0 → 100644
View file @
f1b96f97
{
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
Seilassist/Sailassist/Assets.xcassets/Map/swFinishBack.imageset/Contents.json
0 → 100644
View file @
f1b96f97
{
"images"
:
[
{
"filename"
:
"swFinishBack.png"
,
"idiom"
:
"universal"
,
"resizing"
:
{
"cap-insets"
:
{
"bottom"
:
5
,
"left"
:
5
,
"right"
:
5
,
"top"
:
5
},
"center"
:
{
"height"
:
1
,
"mode"
:
"tile"
,
"width"
:
1
},
"mode"
:
"9-part"
},
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
Seilassist/Sailassist/Assets.xcassets/Map/swFinishBack.imageset/swFinishBack.png
0 → 100644
View file @
f1b96f97
864 Bytes
Seilassist/Sailassist/Assets.xcassets/Map/swNoticeBack.imageset/Contents.json
0 → 100644
View file @
f1b96f97
{
"images"
:
[
{
"filename"
:
"swNoticeBack.png"
,
"idiom"
:
"universal"
,
"resizing"
:
{
"cap-insets"
:
{
"bottom"
:
5
,
"left"
:
5
,
"right"
:
5
,
"top"
:
5
},
"center"
:
{
"height"
:
1
,
"mode"
:
"tile"
,
"width"
:
1
},
"mode"
:
"9-part"
},
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
Seilassist/Sailassist/Assets.xcassets/Map/swNoticeBack.imageset/swNoticeBack.png
0 → 100644
View file @
f1b96f97
851 Bytes
Seilassist/Sailassist/Assets.xcassets/Map/swStartBack.imageset/Contents.json
0 → 100644
View file @
f1b96f97
{
"images"
:
[
{
"filename"
:
"swStartBack.png"
,
"idiom"
:
"universal"
,
"resizing"
:
{
"cap-insets"
:
{
"bottom"
:
5
,
"left"
:
5
,
"right"
:
5
,
"top"
:
5
},
"center"
:
{
"height"
:
1
,
"mode"
:
"tile"
,
"width"
:
1
},
"mode"
:
"9-part"
},
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
Seilassist/Sailassist/Assets.xcassets/Map/swStartBack.imageset/swStartBack.png
0 → 100644
View file @
f1b96f97
862 Bytes
Seilassist/Sailassist/ECA/RegisteredEca.swift
View file @
f1b96f97
...
...
@@ -10,7 +10,7 @@ import CoreLocation
struct
RegisteredEca
{
var
id
:
UInt32
=
0
var
isEnable
:
Bool
=
fals
e
//ECA有効
var
isEnable
:
Bool
=
tru
e
//ECA有効
var
isRunning
:
Bool
=
false
//ECA実行中
var
name
:
String
=
""
//ECA名称
var
swNotice
:
Float
=
6
//ECA通知[NM]
...
...
Seilassist/Sailassist/Location/LocationCalculation.swift
View file @
f1b96f97
...
...
@@ -344,18 +344,6 @@ class LocationCalculation{
}
}
///
///自船の周囲5NMより外にいるか
///外→true
///内→false
static
func
isOutOf5nm
(
lat
:
Double
,
lon
:
Double
)
->
Bool
{
let
myLat
=
SharingData
.
My
.
location
?
.
latitude
??
0
let
mylon
=
SharingData
.
My
.
location
?
.
longitude
??
0
let
distance
=
distance
(
posAlat
:
lat
,
posAlon
:
lon
,
posBlat
:
myLat
,
posBlon
:
mylon
)
return
distance
/
nm
>
5
}
///時計回りか
///return: 1 -> 時計回り
/// -1 -> 反時計回り
...
...
Seilassist/Sailassist/Map/LayerEnum.swift
View file @
f1b96f97
...
...
@@ -10,4 +10,6 @@ import Foundation
enum
LayerEnum
:
String
{
case
OwnShip
case
EcaLine
case
SwitchingLine
case
SwLineLabel
}
Seilassist/Sailassist/Map/MapRepresentable.swift
View file @
f1b96f97
...
...
@@ -19,9 +19,18 @@ struct MapRepresentable: UIViewControllerRepresentable{
}
func
updateUIViewController
(
_
uiViewController
:
UIViewControllerType
,
context
:
Context
)
{
if
let
ecaArea
=
sharingData
.
ecaArea
.
map
{
$0
.
1
}
.
filter
{
$0
.
isRunning
}
.
first
{
let
ecaArea
=
sharingData
.
ecaArea
.
map
{
$0
.
1
}
.
filter
{
$0
.
isRunning
}
.
first
if
let
ecaArea
=
ecaArea
{
mapVC
.
updateEcaLine
(
line
:
ecaArea
.
points
)
}
if
let
mylocation
=
sharingData
.
location
{
mapVC
.
updateOwnShip
(
location
:
mylocation
,
bearing
:
sharingData
.
bearing
)
if
let
ecaArea
=
ecaArea
{
mapVC
.
updateEcaSwitchingLine
(
center
:
mylocation
,
notice
:
ecaArea
.
swNotice
,
start
:
ecaArea
.
swStart
,
finish
:
ecaArea
.
swFinish
)
}
}
}
}
...
...
@@ -31,6 +40,8 @@ class MapViewController : UIViewController{
var
ownShipSymbol
=
MapSource
(
layer
:
.
OwnShip
)
var
ecaLine
=
MapSource
(
layer
:
.
EcaLine
)
var
ecaSwitchingLine
=
MapSource
(
layer
:
.
SwitchingLine
)
var
ecaSwLineLabel
=
MapSource
(
layer
:
.
SwLineLabel
)
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -51,9 +62,26 @@ class MapViewController : UIViewController{
}
func
addImage
(){
do
{
if
let
image
=
UIImage
(
named
:
"account"
){
try
mapView
.
mapboxMap
.
style
.
addImage
(
image
,
id
:
IconImage
.
OwnShip
.
rawValue
)
}
if
let
image
=
UIImage
(
named
:
"swNoticeBack"
){
try
mapView
.
mapboxMap
.
style
.
addImage
(
image
,
id
:
IconImage
.
SwNoticeBack
.
rawValue
)
}
if
let
image
=
UIImage
(
named
:
"swStartBack"
){
try
mapView
.
mapboxMap
.
style
.
addImage
(
image
,
id
:
IconImage
.
SwStartBack
.
rawValue
)
}
if
let
image
=
UIImage
(
named
:
"swFinishBack"
){
try
mapView
.
mapboxMap
.
style
.
addImage
(
image
,
id
:
IconImage
.
SwFinisheBack
.
rawValue
)
}
}
catch
{}
}
func
addLayers
(){
try!
mapView
.
mapboxMap
.
style
.
addImage
(
UIImage
(
named
:
"account"
)
!
,
id
:
IconImage
.
OwnShip
.
rawValue
)
addImage
(
)
let
point
=
Point
(
LocationCoordinate2D
(
latitude
:
0
,
longitude
:
0
))
var
feature
=
Feature
(
geometry
:
point
)
...
...
@@ -87,14 +115,108 @@ class MapViewController : UIViewController{
try!
mapView
.
mapboxMap
.
style
.
addSource
(
ecaLine
.
source
,
id
:
ecaLine
.
sourceId
)
try
?
mapView
.
mapboxMap
.
style
.
addLayer
(
ecaLineLayer
)
ecaSwitchingLine
.
source
.
data
=
.
featureCollection
(
FeatureCollection
(
features
:
[]))
var
ecaSwitchingLineLayer
=
LineLayer
(
id
:
ecaSwitchingLine
.
layerId
)
ecaSwitchingLineLayer
.
source
=
ecaSwitchingLine
.
sourceId
ecaSwitchingLineLayer
.
lineColor
=
.
expression
(
Exp
(
.
get
)
{
PropertyKey
.
Color
.
rawValue
})
ecaSwitchingLineLayer
.
lineDasharray
=
.
constant
([
2
,
1
])
try!
mapView
.
mapboxMap
.
style
.
addSource
(
ecaSwitchingLine
.
source
,
id
:
ecaSwitchingLine
.
sourceId
)
try
?
mapView
.
mapboxMap
.
style
.
addLayer
(
ecaSwitchingLineLayer
)
ecaSwLineLabel
.
source
.
data
=
.
featureCollection
(
FeatureCollection
(
features
:
[]))
var
ecaSwLabelLayer
=
SymbolLayer
(
id
:
ecaSwLineLabel
.
layerId
)
ecaSwLabelLayer
.
source
=
ecaSwLineLabel
.
sourceId
ecaSwLabelLayer
.
textField
=
.
expression
(
Exp
(
.
get
)
{
PropertyKey
.
Text
.
rawValue
})
ecaSwLabelLayer
.
iconImage
=
.
expression
(
Exp
(
.
get
)
{
PropertyKey
.
IconImage
.
rawValue
})
ecaSwLabelLayer
.
iconColor
=
.
expression
(
Exp
(
.
get
)
{
PropertyKey
.
Color
.
rawValue
})
ecaSwLabelLayer
.
iconTextFit
=
.
constant
(
.
both
)
ecaSwLabelLayer
.
iconTextFitPadding
=
.
constant
([
0
,
6
,
0
,
6
])
try!
mapView
.
mapboxMap
.
style
.
addSource
(
ecaSwLineLabel
.
source
,
id
:
ecaSwLineLabel
.
sourceId
)
try
?
mapView
.
mapboxMap
.
style
.
addLayer
(
ecaSwLabelLayer
)
}
func
updateOwnShip
(
location
:
CLLocationCoordinate2D
){
func
updateOwnShip
(
location
:
CLLocationCoordinate2D
,
bearing
:
Double
){
do
{
var
geoJSON
=
Feature
(
geometry
:
Point
(
location
))
geoJSON
.
properties
=
[
PropertyKey
.
Bearing
.
rawValue
:
.
number
(
90
),
geoJSON
.
properties
=
[
PropertyKey
.
Bearing
.
rawValue
:
.
number
(
bearing
),
PropertyKey
.
IconImage
.
rawValue
:
.
string
(
IconImage
.
OwnShip
.
rawValue
)]
try!
self
.
mapView
.
mapboxMap
.
style
.
updateGeoJSONSource
(
withId
:
self
.
ownShipSymbol
.
sourceId
,
geoJSON
:
.
feature
(
geoJSON
))
try
self
.
mapView
.
mapboxMap
.
style
.
updateGeoJSONSource
(
withId
:
self
.
ownShipSymbol
.
sourceId
,
geoJSON
:
.
feature
(
geoJSON
))
}
catch
{}
}
func
updateEcaSwitchingLine
(
center
:
CLLocationCoordinate2D
,
notice
:
Float
,
start
:
Float
,
finish
:
Float
){
do
{
var
switchingLines
:
[
Feature
]
=
[]
var
switchingLabels
:
[
Feature
]
=
[]
let
circlePoints_notice
=
getCirclePoints
(
center
:
center
,
radiusKm
:
LocationCalculation
.
nm2km
(
nm
:
Double
(
notice
)))
var
noticeLine
=
Feature
(
geometry
:
LineString
(
circlePoints_notice
))
noticeLine
.
properties
=
[
PropertyKey
.
Color
.
rawValue
:
.
string
(
"#62AB28"
)]
switchingLines
.
append
(
noticeLine
)
if
let
point
=
circlePoints_notice
.
first
{
var
label
=
Feature
(
geometry
:
Point
(
point
))
label
.
properties
=
[
PropertyKey
.
Text
.
rawValue
:
.
string
(
"Advance Notice"
),
PropertyKey
.
IconImage
.
rawValue
:
.
string
(
IconImage
.
SwNoticeBack
.
rawValue
),
PropertyKey
.
Color
.
rawValue
:
.
string
(
"#62AB28"
)]
switchingLabels
.
append
(
label
)
}
let
circlePoints_start
=
getCirclePoints
(
center
:
center
,
radiusKm
:
LocationCalculation
.
nm2km
(
nm
:
Double
(
start
)))
var
startLine
=
Feature
(
geometry
:
LineString
(
circlePoints_start
))
startLine
.
properties
=
[
PropertyKey
.
Color
.
rawValue
:
.
string
(
"#ECD932"
)]
switchingLines
.
append
(
startLine
)
if
let
point
=
circlePoints_start
.
first
{
var
label
=
Feature
(
geometry
:
Point
(
point
))
label
.
properties
=
[
PropertyKey
.
Text
.
rawValue
:
.
string
(
"Switching Start"
),
PropertyKey
.
IconImage
.
rawValue
:
.
string
(
IconImage
.
SwStartBack
.
rawValue
),
PropertyKey
.
Color
.
rawValue
:
.
string
(
"#ECD932"
)]
switchingLabels
.
append
(
label
)
}
let
circlePoints_finish
=
getCirclePoints
(
center
:
center
,
radiusKm
:
LocationCalculation
.
nm2km
(
nm
:
Double
(
finish
)))
var
finishLine
=
Feature
(
geometry
:
LineString
(
circlePoints_finish
))
finishLine
.
properties
=
[
PropertyKey
.
Color
.
rawValue
:
.
string
(
"#EF6135"
)]
switchingLines
.
append
(
finishLine
)
if
let
point
=
circlePoints_finish
.
first
{
var
label
=
Feature
(
geometry
:
Point
(
point
))
label
.
properties
=
[
PropertyKey
.
Text
.
rawValue
:
.
string
(
"Switching Finish"
),
PropertyKey
.
IconImage
.
rawValue
:
.
string
(
IconImage
.
SwFinisheBack
.
rawValue
),
PropertyKey
.
Color
.
rawValue
:
.
string
(
"#EF6135"
)]
switchingLabels
.
append
(
label
)
}
var
lineGeoJson
=
FeatureCollection
(
features
:
switchingLines
)
var
labelGeoJson
=
FeatureCollection
(
features
:
switchingLabels
)
try
self
.
mapView
.
mapboxMap
.
style
.
updateGeoJSONSource
(
withId
:
ecaSwitchingLine
.
sourceId
,
geoJSON
:
.
featureCollection
(
lineGeoJson
))
try
self
.
mapView
.
mapboxMap
.
style
.
updateGeoJSONSource
(
withId
:
ecaSwLineLabel
.
sourceId
,
geoJSON
:
.
featureCollection
(
labelGeoJson
))
}
catch
{}
}
///円の位置情報を返す
private
func
getCirclePoints
(
center
:
CLLocationCoordinate2D
,
radiusKm
:
Double
)
->
[
CLLocationCoordinate2D
]{
var
circlePoints
:
[
CLLocationCoordinate2D
]
=
[]
for
deg
in
stride
(
from
:
0
,
through
:
360
,
by
:
6
)
{
let
point
=
LocationCalculation
.
findPointAtDistanceFrom
(
startPointLat
:
center
.
latitude
,
startPointLon
:
center
.
longitude
,
initialBearing
:
Double
(
deg
),
distanceKilometers
:
radiusKm
)
circlePoints
.
append
(
point
)
}
return
circlePoints
}
...
...
@@ -104,9 +226,7 @@ class MapViewController : UIViewController{
geoJson
.
properties
=
[
PropertyKey
.
Color
.
rawValue
:
.
string
(
Color
.
blue
.
description
)]
try
self
.
mapView
.
mapboxMap
.
style
.
updateGeoJSONSource
(
withId
:
ecaLine
.
sourceId
,
geoJSON
:
.
feature
(
geoJson
))
}
catch
{
}
}
catch
{}
}
...
...
@@ -116,10 +236,14 @@ class MapViewController : UIViewController{
case
IconImage
case
Bearing
case
Color
case
Text
}
enum
IconImage
:
String
,
CaseIterable
{
case
OwnShip
case
SwNoticeBack
case
SwStartBack
case
SwFinisheBack
}
}
Seilassist/Sailassist/SharingData/SharingData.swift
View file @
f1b96f97
...
...
@@ -10,18 +10,17 @@ import CoreLocation
class
SharingData
:
ObservableObject
{
static
let
shared
=
SharingData
()
class
My
{
static
var
location
:
CLLocationCoordinate2D
?
=
nil
static
var
speedKnot
:
Double
=
0.0
static
var
bearing
:
Double
=
0.0
// 自船進行方向
static
var
compass
:
Double
?
=
nil
// 端末の方位
@Published
var
location
:
CLLocationCoordinate2D
?
=
CLLocationCoordinate2D
(
latitude
:
0
,
longitude
:
0
)
//nil
@Published
var
speedKnot
:
Double
=
0.0
@Published
var
bearing
:
Double
=
0.0
// 自船進行方向
@Published
var
compass
:
Double
?
=
nil
// 端末の方位
static
func
reset
()
{
func
reset
()
{
location
=
nil
speedKnot
=
0.0
bearing
=
0.0
}
}
/**
* Eca
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment