Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HTAnticollision
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
0
Merge Requests
0
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
马乐
HTAnticollision
Commits
caa4d969
Commit
caa4d969
authored
May 19, 2023
by
马乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加地图annotation
parent
552c8ce0
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
1239 additions
and
648 deletions
+1239
-648
build.gradle
app/build.gradle
+6
-4
mapBoxStyle.json
app/src/main/assets/mapBoxStyle.json
+29
-0
style.json
app/src/main/assets/style.json
+40
-0
style.json
app/src/main/assets/styles/Dark/style.json
+46
-0
style.json
app/src/main/assets/styles/SatelliteStreets/style.json
+40
-0
style.json
app/src/main/assets/styles/Street/style.json
+39
-0
MapDataSourceWrapper.kt
...va/com/waytous/anticollision/bean/MapDataSourceWrapper.kt
+2
-2
MapDataDao.kt
...ain/java/com/waytous/anticollision/database/MapDataDao.kt
+1
-1
MainRepository.kt
...va/com/waytous/anticollision/repository/MainRepository.kt
+171
-111
BaseFragment.kt
...rc/main/java/com/waytous/anticollision/ui/BaseFragment.kt
+115
-14
MainViewModel.kt
...c/main/java/com/waytous/anticollision/ui/MainViewModel.kt
+26
-14
MapBoxLayout.kt
...rc/main/java/com/waytous/anticollision/ui/MapBoxLayout.kt
+64
-456
HomeFragment.kt
...in/java/com/waytous/anticollision/ui/home/HomeFragment.kt
+46
-40
BitmapUtils.kt
.../main/java/com/waytous/anticollision/utils/BitmapUtils.kt
+43
-0
Extensions.kt
...c/main/java/com/waytous/anticollision/utils/Extensions.kt
+367
-0
VehicleAnnotation.kt
...in/java/com/waytous/anticollision/vo/VehicleAnnotation.kt
+6
-0
background_view_annotation_current_vehicle.xml
...able-night/background_view_annotation_current_vehicle.xml
+8
-0
background_view_annotation_other_vehicle.xml
...awable-night/background_view_annotation_other_vehicle.xml
+8
-0
background_view_annotation_other_vehicle_distance.xml
...ght/background_view_annotation_other_vehicle_distance.xml
+8
-0
background_view_annotation_other_vehicle_speed.xml
...-night/background_view_annotation_other_vehicle_speed.xml
+8
-0
background_view_annotation_current_vehicle.xml
...s/drawable/background_view_annotation_current_vehicle.xml
+8
-0
background_view_annotation_other_vehicle.xml
...res/drawable/background_view_annotation_other_vehicle.xml
+8
-0
background_view_annotation_other_vehicle_distance.xml
...ble/background_view_annotation_other_vehicle_distance.xml
+8
-0
background_view_annotation_other_vehicle_speed.xml
...awable/background_view_annotation_other_vehicle_speed.xml
+8
-0
current_vehicle_view_annotation_layout.xml
...ain/res/layout/current_vehicle_view_annotation_layout.xml
+25
-0
fragment_home.xml
app/src/main/res/layout/fragment_home.xml
+2
-1
other_vehicle_view_annotation_layout.xml
.../main/res/layout/other_vehicle_view_annotation_layout.xml
+69
-0
themes.xml
app/src/main/res/values-night/themes.xml
+7
-0
colors.xml
app/src/main/res/values/colors.xml
+13
-0
strings.xml
app/src/main/res/values/strings.xml
+3
-0
themes.xml
app/src/main/res/values/themes.xml
+7
-0
build.gradle
build.gradle
+3
-2
gradle.properties
gradle.properties
+4
-2
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-1
No files found.
app/build.gradle
View file @
caa4d969
...
@@ -35,18 +35,20 @@ android {
...
@@ -35,18 +35,20 @@ android {
}
}
}
}
compileOptions
{
compileOptions
{
sourceCompatibility
JavaVersion
.
VERSION_1
_8
sourceCompatibility
JavaVersion
.
VERSION_1
7
targetCompatibility
JavaVersion
.
VERSION_1
_8
targetCompatibility
JavaVersion
.
VERSION_1
7
}
}
kotlinOptions
{
kotlinOptions
{
jvmTarget
=
'1
.8
'
jvmTarget
=
'1
7
'
}
}
buildFeatures
{
buildFeatures
{
viewBinding
true
viewBinding
true
dataBinding
true
dataBinding
true
}
}
packagingOptions
{
packagingOptions
{
exclude
'META-INF/io.netty.versions.properties'
resources
{
excludes
+=
[
'META-INF/io.netty.versions.properties'
]
}
}
}
}
}
...
...
app/src/main/assets/mapBoxStyle.json
0 → 100644
View file @
caa4d969
{
"draft"
:
false
,
"glyphs"
:
"http://192.168.9.152:8089/map/glyphs/{fontstack}/{range}.pbf"
,
"id"
:
"pk.eyJ1IjoibWFybGxlciIsImEiOiJjbGVhMXlmeXIwdmRzM29vNmM4aDA1M202In0.tfLD_AOs1OPmg5rLERcbfw"
,
"layers"
:
[
{
"id"
:
"background"
,
"interactive"
:
true
,
"paint"
:
{
"background-color"
:
"black"
},
"type"
:
"background"
}
],
"metadata"
:
{
"mapbox:autocomposite"
:
true
,
"mapbox:sdk-support"
:
{
"android"
:
"10.11.0"
,
"ios"
:
"4.0.0"
,
"js"
:
"0.46.0"
},
"mapbox:type"
:
"default"
},
"name"
:
"Dark"
,
"owner"
:
"HT"
,
"sprite"
:
"http://192.168.9.152:8089/map/sprite/street/sprite"
,
"version"
:
8
,
"visibility"
:
"private"
}
app/src/main/assets/style.json
0 → 100644
View file @
caa4d969
{
"version"
:
8
,
"name"
:
"Satellite"
,
"metadata"
:
{
"mapbox:autocomposite"
:
true
,
"mapbox:type"
:
"default"
},
"sources"
:
{
"composite"
:
{
"tiles"
:
[
"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
],
"type"
:
"raster"
,
"tileSize"
:
256
}
},
"sprite"
:
"http://192.168.9.152:8089/map/sprite/street/sprite"
,
"glyphs"
:
"http://192.168.9.152:8089/map/glyphs/{fontstack}/{range}.pbf"
,
"layers"
:
[{
"id"
:
"background"
,
"type"
:
"background"
,
"paint"
:
{
"background-color"
:
"#3c3d3f"
},
"interactive"
:
true
},
{
"id"
:
"satellite"
,
"type"
:
"raster"
,
"source"
:
"composite"
,
"interactive"
:
true
}],
"created"
:
"2019-02-22T17:58:57.291Z"
,
"id"
:
"sk.eyJ1IjoibWFybGxlciIsImEiOiJjbGVjNHZhdWgwd3U4M29uMjJrY3BqYXpkIn0.cqcw1CHYVGwESBqsfWcm7w"
,
"modified"
:
"2019-02-22T17:58:57.291Z"
,
"owner"
:
"scfjp"
,
"visibility"
:
"private"
,
"draft"
:
false
}
\ No newline at end of file
app/src/main/assets/styles/Dark/style.json
0 → 100644
View file @
caa4d969
{
"version"
:
8
,
"name"
:
"Dark"
,
"metadata"
:
{
"mapbox:autocomposite"
:
true
,
"mapbox:type"
:
"default"
,
"mapbox:sdk-support"
:
{
"js"
:
"0.46.0"
,
"android"
:
"6.0.0"
,
"ios"
:
"4.0.0"
}
},
"sources"
:
{
},
"sprite"
:
"http://192.168.9.198:8089/map/sprite/street/sprite"
,
"glyphs"
:
"http://192.168.9.198:8089/map/glyphs/{fontstack}/{range}.pbf"
,
"layers"
:
[{
"id"
:
"background"
,
"type"
:
"background"
,
"layout"
:
{},
"paint"
:
{
"background-color"
:
{
"base"
:
1
,
"stops"
:
[
[
6
,
"hsl(215, 17%, 35%)"
],
[
8
,
"#030b22"
]
]
}
},
"interactive"
:
true
}],
"created"
:
"2018-07-25T01:43:01.085Z"
,
"id"
:
"cjk0gss0a1n872rlia7papueg"
,
"modified"
:
"2018-07-25T01:43:01.085Z"
,
"owner"
:
"scfjp"
,
"visibility"
:
"private"
,
"draft"
:
false
}
\ No newline at end of file
app/src/main/assets/styles/SatelliteStreets/style.json
0 → 100644
View file @
caa4d969
{
"version"
:
8
,
"name"
:
"Satellite"
,
"metadata"
:
{
"mapbox:autocomposite"
:
true
,
"mapbox:type"
:
"default"
},
"sources"
:
{
"composite"
:
{
"tiles"
:
[
"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
],
"type"
:
"raster"
,
"tileSize"
:
256
}
},
"sprite"
:
"http://192.168.9.198:8089/map/sprite/street/sprite"
,
"glyphs"
:
"http://192.168.9.198:8089/map/glyphs/{fontstack}/{range}.pbf"
,
"layers"
:
[{
"id"
:
"background"
,
"type"
:
"background"
,
"paint"
:
{
"background-color"
:
"#3c3d3f"
},
"interactive"
:
true
},
{
"id"
:
"satellite"
,
"type"
:
"raster"
,
"source"
:
"composite"
,
"interactive"
:
true
}],
"created"
:
"2019-02-22T17:58:57.291Z"
,
"id"
:
"cjsgd0f6w0ndu1fo4trxeh4na"
,
"modified"
:
"2019-02-22T17:58:57.291Z"
,
"owner"
:
"scfjp"
,
"visibility"
:
"private"
,
"draft"
:
false
}
\ No newline at end of file
app/src/main/assets/styles/Street/style.json
0 → 100644
View file @
caa4d969
{
"version"
:
8
,
"name"
:
"Street"
,
"metadata"
:
{
"mapbox:origin"
:
"basic-template-v1"
,
"mapbox:autocomposite"
:
true
,
"mapbox:type"
:
"template"
,
"mapbox:sdk-support"
:
{
"js"
:
"0.50.0"
,
"android"
:
"6.7.0"
,
"ios"
:
"4.6.0"
}
},
"sources"
:
{},
"sprite"
:
"http://192.168.9.198:8089/map/sprite/street/sprite"
,
"glyphs"
:
"http://192.168.9.198:8089/map/glyphs/{fontstack}/{range}.pbf"
,
"layers"
:
[{
"id"
:
"background"
,
"type"
:
"background"
,
"layout"
:
{},
"paint"
:
{
"background-color"
:
[
"interpolate"
,
[
"linear"
],
[
"zoom"
],
5
,
"hsl(38, 43%, 89%)"
,
7
,
"hsl(38, 48%, 86%)"
]
}
}],
"created"
:
"2019-01-02T03:16:28.622Z"
,
"id"
:
"cjqem145mg5gh2sqi37v0gmhm"
,
"modified"
:
"2019-01-02T03:16:28.622Z"
,
"owner"
:
"scfjp"
,
"visibility"
:
"private"
,
"draft"
:
false
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/bean/MapDataSourceWrapper.kt
View file @
caa4d969
package
com.waytous.anticollision.bean
package
com.waytous.anticollision.bean
data class
MapDataSourceWrapper
(
val
mapDataSource
:
MapDataSource
,
val
abort
:
Boolean
)
data class
MapDataSourceWrapper
(
val
mapDataSource
:
MapDataSource
?,
val
abort
:
Boolean
)
\ No newline at end of file
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/database/MapDataDao.kt
View file @
caa4d969
...
@@ -7,7 +7,7 @@ import com.waytous.anticollision.bean.MapDataSource
...
@@ -7,7 +7,7 @@ import com.waytous.anticollision.bean.MapDataSource
interface
MapDataDao
{
interface
MapDataDao
{
@Query
(
"SELECT * FROM map_source WHERE sourceId = :sourceId"
)
@Query
(
"SELECT * FROM map_source WHERE sourceId = :sourceId"
)
suspend
fun
findById
(
sourceId
:
String
):
MapDataSource
suspend
fun
findById
(
sourceId
:
String
):
MapDataSource
?
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
suspend
fun
insertAll
(
vararg
sources
:
MapDataSource
)
suspend
fun
insertAll
(
vararg
sources
:
MapDataSource
)
...
...
app/src/main/java/com/waytous/anticollision/repository/MainRepository.kt
View file @
caa4d969
...
@@ -27,21 +27,25 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -27,21 +27,25 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteObstaclesVersion
(
version
:
String
=
"-1"
)
=
suspend
{
mapApi
.
obstaclesVersion
(
version
)
}
fun
remoteObstaclesVersion
(
version
:
String
=
"-1"
)
=
suspend
{
mapApi
.
obstaclesVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
LogUtils
.
d
(
"remoteObstaclesVersion"
)
val
tempSource
=
mapDao
.
findById
(
OBSTACLES_SOURCE
)
source
?.
let
{
if
(
tempSource
.
version
!=
it
.
version
)
{
val
dbSource
=
mapDao
.
findById
(
OBSTACLES_SOURCE
)
mapDao
.
deleteSource
(
tempSource
)
if
(
dbSource
==
null
)
{
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
OBSTACLES_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
OBSTACLES_SOURCE
})
LogUtils
.
d
(
"remoteObstaclesVersion"
)
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
LogUtils
.
d
(
"remoteObstaclesVersion"
)
if
(
dbSource
.
version
!=
it
.
version
)
{
MapDataSourceWrapper
(
it
,
false
)
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
OBSTACLES_SOURCE
})
LogUtils
.
d
(
"remoteObstaclesVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteObstaclesVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的障碍物图层数据为空!"
)
throw
Exception
(
"获取到的障碍物图层数据为空!"
)
}
}
}
fun
localObstaclesVersion
()
=
flow
{
fun
localObstaclesVersion
()
=
flow
{
...
@@ -49,21 +53,27 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -49,21 +53,27 @@ class MainRepository@Inject constructor(context:Context) {
emit
(
MapDataSourceWrapper
(
source
,
false
))
emit
(
MapDataSourceWrapper
(
source
,
false
))
}
}
fun
remoteElectronicFenceVersion
(
version
:
String
=
"-"
)=
suspend
{
mapApi
.
electronicFenceVersion
(
version
)
}
fun
remoteElectronicFenceVersion
(
version
:
String
=
"-
1
"
)=
suspend
{
mapApi
.
electronicFenceVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
val
tempSource
=
mapDao
.
findById
(
ELECTRONIC_FENCE_SOURCE
)
source
?.
let
{
if
(
tempSource
.
version
!=
it
.
version
)
{
val
dbSource
=
mapDao
.
findById
(
ELECTRONIC_FENCE_SOURCE
)
mapDao
.
deleteSource
(
tempSource
)
if
(
dbSource
==
null
)
{
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
ELECTRONIC_FENCE_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
ELECTRONIC_FENCE_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
ELECTRONIC_FENCE_SOURCE
})
LogUtils
.
d
(
"remoteElectronicFenceVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteElectronicFenceVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的电子围栏地图数据为空!"
)
throw
Exception
(
"获取到的电子围栏地图数据为空!"
)
}
}
}
fun
localElectronicFenceVersion
()
=
flow
{
fun
localElectronicFenceVersion
()
=
flow
{
...
@@ -73,19 +83,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -73,19 +83,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteWetAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
wetAreaVersion
(
version
)
}
fun
remoteWetAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
wetAreaVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
WET_AREA_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
WET_AREA_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
WET_AREA_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
WET_AREA_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
WET_AREA_SOURCE
})
LogUtils
.
d
(
"remoteWetAreaVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteWetAreaVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的湿滑区域地图数据为空!"
)
throw
Exception
(
"获取到的湿滑区域地图数据为空!"
)
}
}
}
fun
localWetAreaVersion
()
=
flow
{
fun
localWetAreaVersion
()
=
flow
{
...
@@ -95,19 +110,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -95,19 +110,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteLaneNodeVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
laneNodeVersion
(
version
)
}
fun
remoteLaneNodeVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
laneNodeVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
LANE_NODE_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
LANE_NODE_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
LANE_NODE_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
LANE_NODE_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
LANE_NODE_SOURCE
})
LogUtils
.
d
(
"remoteLaneNodeVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteLaneNodeVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的湿滑区域地图数据为空!"
)
throw
Exception
(
"获取到的车道节点地图数据为空!"
)
}
}
}
fun
localLaneNodeVersion
()
=
flow
{
fun
localLaneNodeVersion
()
=
flow
{
...
@@ -117,19 +137,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -117,19 +137,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteLaneVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
laneVersion
(
version
)
}
fun
remoteLaneVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
laneVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
LANE_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
LANE_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
LANE_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
LANE_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
LANE_SOURCE
})
LogUtils
.
d
(
"remoteLaneVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteLaneVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的车道图层地图数据为空!"
)
throw
Exception
(
"获取到的车道图层地图数据为空!"
)
}
}
}
fun
localLaneVersion
()
=
flow
{
fun
localLaneVersion
()
=
flow
{
...
@@ -139,19 +164,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -139,19 +164,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteRunnableAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
runnableAreaVersion
(
version
)
}
fun
remoteRunnableAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
runnableAreaVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
RUNNABLE_AREA_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
RUNNABLE_AREA_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
RUNNABLE_AREA_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
RUNNABLE_AREA_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
RUNNABLE_AREA_SOURCE
})
LogUtils
.
d
(
"remoteRunnableAreaVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteRunnableAreaVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的可行使区域地图数据为空!"
)
throw
Exception
(
"获取到的可行使区域地图数据为空!"
)
}
}
}
fun
localRunnableAreaVersion
()
=
flow
{
fun
localRunnableAreaVersion
()
=
flow
{
...
@@ -161,19 +191,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -161,19 +191,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteDumpAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
dumpAreaVersion
(
version
)
}
fun
remoteDumpAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
dumpAreaVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
DUMP_AREA_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
DUMP_AREA_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
DUMP_AREA_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
DUMP_AREA_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
DUMP_AREA_SOURCE
})
LogUtils
.
d
(
"remoteDumpAreaVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteDumpAreaVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的卸载区地图数据为空!"
)
throw
Exception
(
"获取到的卸载区地图数据为空!"
)
}
}
}
fun
localDumpAreaVersion
()
=
flow
{
fun
localDumpAreaVersion
()
=
flow
{
...
@@ -183,19 +218,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -183,19 +218,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteDiggingWorkAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
diggingWorkAreaVersion
(
version
)
}
fun
remoteDiggingWorkAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
diggingWorkAreaVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
DIGGING_WORK_AREA_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
DIGGING_WORK_AREA_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
DIGGING_WORK_AREA_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
DIGGING_WORK_AREA_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
DIGGING_WORK_AREA_SOURCE
})
LogUtils
.
d
(
"remoteDiggingWorkAreaVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteDiggingWorkAreaVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的装载区地图数据为空!"
)
throw
Exception
(
"获取到的装载区地图数据为空!"
)
}
}
}
fun
localDiggingAreaVersion
()
=
flow
{
fun
localDiggingAreaVersion
()
=
flow
{
...
@@ -205,19 +245,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -205,19 +245,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteBarricadeVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
barricadeVersion
(
version
)
}
fun
remoteBarricadeVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
barricadeVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
BARRICADE_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
BARRICADE_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
BARRICADE_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
BARRICADE_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
BARRICADE_SOURCE
})
LogUtils
.
d
(
"remoteBarricadeVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteBarricadeVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的挡墙区域地图数据为空!"
)
throw
Exception
(
"获取到的挡墙区域地图数据为空!"
)
}
}
}
fun
localBarricadeVersion
()
=
flow
{
fun
localBarricadeVersion
()
=
flow
{
...
@@ -227,19 +272,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -227,19 +272,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteStationAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
stationAreaVersion
(
version
)
}
fun
remoteStationAreaVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
stationAreaVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
STATION_AREA_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
STATION_AREA_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
STATION_AREA_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
STATION_AREA_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
STATION_AREA_SOURCE
})
LogUtils
.
d
(
"remoteStationAreaVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteStationAreaVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的静态区域地图数据为空!"
)
throw
Exception
(
"获取到的静态区域地图数据为空!"
)
}
}
}
fun
localStationAreaVersion
()
=
flow
{
fun
localStationAreaVersion
()
=
flow
{
...
@@ -249,19 +299,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -249,19 +299,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteParkSpotVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
parkSpotVersion
(
version
)
}
fun
remoteParkSpotVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
parkSpotVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
PARK_SPOT_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
PARK_SPOT_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
PARK_SPOT_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
PARK_SPOT_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
PARK_SPOT_SOURCE
})
LogUtils
.
d
(
"remoteParkSpotVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteParkSpotVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的停车位图层地图数据为空!"
)
throw
Exception
(
"获取到的停车位图层地图数据为空!"
)
}
}
}
fun
localParkSpotVersion
()
=
flow
{
fun
localParkSpotVersion
()
=
flow
{
...
@@ -271,19 +326,24 @@ class MainRepository@Inject constructor(context:Context) {
...
@@ -271,19 +326,24 @@ class MainRepository@Inject constructor(context:Context) {
fun
remoteStaticObjectsVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
staticObjectsVersion
(
version
)
}
fun
remoteStaticObjectsVersion
(
version
:
String
=
"-1"
)=
suspend
{
mapApi
.
staticObjectsVersion
(
version
)
}
.
asFlow
()
.
asFlow
()
.
map
{
.
map
{
source
->
if
(
it
!=
null
)
{
source
?.
let
{
val
tempSource
=
mapDao
.
findById
(
STATIC_OBJECTS_SOURCE
)
val
dbSource
=
mapDao
.
findById
(
STATIC_OBJECTS_SOURCE
)
if
(
tempSource
.
version
!=
it
.
version
)
{
if
(
dbSource
==
null
)
{
mapDao
.
deleteSource
(
tempSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
STATIC_OBJECTS_SOURCE
})
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
STATIC_OBJECTS_SOURCE
})
MapDataSourceWrapper
(
it
,
true
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
}
else
{
MapDataSourceWrapper
(
it
,
false
)
if
(
dbSource
.
version
!=
it
.
version
)
{
mapDao
.
deleteSource
(
dbSource
)
mapDao
.
insertAll
(
it
.
apply
{
sourceId
=
STATIC_OBJECTS_SOURCE
})
LogUtils
.
d
(
"remoteStaticObjectsVersion"
)
MapDataSourceWrapper
(
it
,
true
)
}
else
{
LogUtils
.
d
(
"remoteStaticObjectsVersion"
)
MapDataSourceWrapper
(
it
,
false
)
}
}
}
}
else
{
}
?:
throw
Exception
(
"获取到的静态区域地图数据为空!"
)
throw
Exception
(
"获取到的静态区域地图数据为空!"
)
}
}
}
fun
localStaticObjectsVersion
()
=
flow
{
fun
localStaticObjectsVersion
()
=
flow
{
...
...
app/src/main/java/com/waytous/anticollision/ui/BaseFragment.kt
View file @
caa4d969
package
com.waytous.anticollision.ui
package
com.waytous.anticollision.ui
import
android.annotation.SuppressLint
import
android.graphics.Bitmap
import
android.graphics.Bitmap
import
android.graphics.Color
import
android.graphics.Color
import
android.os.Bundle
import
android.os.Bundle
import
androidx.core.graphics.scale
import
android.view.View
import
androidx.appcompat.widget.AppCompatTextView
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.viewModels
import
androidx.fragment.app.viewModels
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
...
@@ -11,6 +13,7 @@ import androidx.lifecycle.withStarted
...
@@ -11,6 +13,7 @@ import androidx.lifecycle.withStarted
import
com.mapbox.geojson.Point
import
com.mapbox.geojson.Point
import
com.mapbox.maps.CameraOptions
import
com.mapbox.maps.CameraOptions
import
com.mapbox.maps.MapView
import
com.mapbox.maps.MapView
import
com.mapbox.maps.ViewAnnotationAnchor
import
com.mapbox.maps.extension.style.expressions.dsl.generated.get
import
com.mapbox.maps.extension.style.expressions.dsl.generated.get
import
com.mapbox.maps.extension.style.layers.generated.circleLayer
import
com.mapbox.maps.extension.style.layers.generated.circleLayer
import
com.mapbox.maps.extension.style.layers.generated.fillLayer
import
com.mapbox.maps.extension.style.layers.generated.fillLayer
...
@@ -24,11 +27,16 @@ import com.mapbox.maps.plugin.annotation.generated.PointAnnotation
...
@@ -24,11 +27,16 @@ import com.mapbox.maps.plugin.annotation.generated.PointAnnotation
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions
import
com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager
import
com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager
import
com.mapbox.maps.plugin.scalebar.scalebar
import
com.mapbox.maps.viewannotation.ViewAnnotationManager
import
com.mapbox.maps.viewannotation.ViewAnnotationManager
import
com.mapbox.maps.viewannotation.viewAnnotationOptions
import
com.waytous.anticollision.R
import
com.waytous.anticollision.R
import
com.waytous.anticollision.api.ApiService
import
com.waytous.anticollision.api.ApiService
import
com.waytous.anticollision.databinding.CurrentVehicleViewAnnotationLayoutBinding
import
com.waytous.anticollision.databinding.OtherVehicleViewAnnotationLayoutBinding
import
com.waytous.anticollision.repository.MainRepository
import
com.waytous.anticollision.repository.MainRepository
import
com.waytous.anticollision.utils.getBitmapFromVectorDrawable
import
com.waytous.anticollision.utils.BitmapUtils
import
com.waytous.anticollision.vo.VehicleAnnotation
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
...
@@ -39,16 +47,37 @@ open class BaseFragment : Fragment() {
...
@@ -39,16 +47,37 @@ open class BaseFragment : Fragment() {
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
}
}
val
iconCurrentNormalVehicleBitmap
by
lazy
{
BitmapUtils
.
bitmapFromDrawableRes
(
requireContext
(),
R
.
drawable
.
my_vehicle_normal
)
}
private
val
iconOtherAlarmVehicleBitmap
by
lazy
{
BitmapUtils
.
bitmapFromDrawableRes
(
requireContext
(),
R
.
drawable
.
other_vehicle_normal
)
}
private
lateinit
var
viewAnnotation
:
View
private
lateinit
var
viewAnnotationManager
:
ViewAnnotationManager
private
lateinit
var
viewAnnotationManager
:
ViewAnnotationManager
private
lateinit
var
pointAnnotationManager
:
PointAnnotationManager
private
lateinit
var
pointAnnotationManager
:
PointAnnotationManager
private
lateinit
var
pointAnnotation
:
PointAnnotation
private
lateinit
var
pointAnnotation
:
PointAnnotation
companion
object
{
private
val
scaleLengths
=
listOf
(
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
1000000
,
2000000
)
private
const
val
MINIMUM_ZOOM_LEVEL
=
11.0
private
const
val
MAXIMUM_ZOOM_LEVEL
=
26.0
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
}
}
fun
initAnnotationManager
(
mapView
:
MapView
){
viewAnnotationManager
=
mapView
.
viewAnnotationManager
pointAnnotationManager
=
mapView
.
annotations
.
createPointAnnotationManager
()
}
fun
updateMapBox
(
mapView
:
MapView
){
fun
updateMapBox
(
mapView
:
MapView
){
mapView
.
getMapboxMap
().
setCamera
(
mapView
.
getMapboxMap
().
setCamera
(
CameraOptions
.
Builder
().
center
(
CameraOptions
.
Builder
().
center
(
...
@@ -350,22 +379,93 @@ open class BaseFragment : Fragment() {
...
@@ -350,22 +379,93 @@ open class BaseFragment : Fragment() {
}
}
}
}
){
){
val
bitmap
:
Bitmap
?
=
// prepareAnnotationMarker(mapView,iconCurrentNormalVehicleBitmap!!)
activity
?.
getBitmapFromVectorDrawable
(
R
.
drawable
.
my_vehicle_normal
,
4
)
// prepareViewAnnotation()
val
annotationPlugin
=
mapView
.
annotations
val
otherAnnotation
=
VehicleAnnotation
(
"KK-01"
,
36
,
25
,
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
),
true
)
.
withPoint
(
mapModel
.
center
.
value
!!
)
addCurrentVehicleAnnotation
(
otherAnnotation
)
.
withIconImage
(
bitmap
!!
.
apply
{
val
otherAnnotation1
=
VehicleAnnotation
(
"KK-02"
,
24
,
25
,
Point
.
fromLngLat
(
119.76019
,
49.37932
),
true
)
scale
(
bitmap
.
width
/
4
,
bitmap
.
height
/
4
)
addOtherVehicleAnnotation
(
otherAnnotation1
)
})
val
otherAnnotation2
=
VehicleAnnotation
(
"KK-03"
,
36
,
20
,
Point
.
fromLngLat
(
119.75694
,
49.38632
),
true
)
.
withIconAnchor
(
IconAnchor
.
BOTTOM
)
addOtherVehicleAnnotation
(
otherAnnotation2
)
.
withDraggable
(
false
)
pointAnnotationManager
=
annotationPlugin
.
createPointAnnotationManager
()
pointAnnotation
=
pointAnnotationManager
.
create
(
pointAnnotationOptions
)
}
}
}
}
}
}
}
}
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
prepareViewAnnotation
()
{
viewAnnotation
=
viewAnnotationManager
.
addViewAnnotation
(
resId
=
R
.
layout
.
current_vehicle_view_annotation_layout
,
options
=
viewAnnotationOptions
{
geometry
(
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
))
associatedFeatureId
(
pointAnnotation
.
featureIdentifier
)
anchor
(
ViewAnnotationAnchor
.
BOTTOM
)
offsetY
((
pointAnnotation
.
iconImageBitmap
?.
height
!!
*
0.25
).
toInt
())
}
)
val
binding
=
CurrentVehicleViewAnnotationLayoutBinding
.
bind
(
viewAnnotation
)
binding
.
annotationCurrentVehicleNo
.
text
=
context
?.
getString
(
R
.
string
.
annotation_vehicle_no
,
"KK-001"
)
binding
.
annotationCurrentVehicleSpeed
.
text
=
context
?.
getString
(
R
.
string
.
annotation_vehicle_speed
,
36
)
}
fun
prepareAnnotationMarker
(
mapView
:
MapView
,
iconBitmap
:
Bitmap
)
{
val
annotationPlugin
=
mapView
.
annotations
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
.
withPoint
(
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
))
.
withIconImage
(
iconBitmap
)
.
withIconSize
(
0.25
)
.
withIconAnchor
(
IconAnchor
.
BOTTOM
)
.
withDraggable
(
false
)
pointAnnotationManager
=
annotationPlugin
.
createPointAnnotationManager
()
pointAnnotation
=
pointAnnotationManager
.
create
(
pointAnnotationOptions
)
}
fun
addCurrentVehicleAnnotation
(
otherAnnotation
:
VehicleAnnotation
){
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
.
withPoint
(
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
))
.
withIconImage
(
iconCurrentNormalVehicleBitmap
!!
)
.
withIconSize
(
0.25
)
.
withIconAnchor
(
IconAnchor
.
BOTTOM
)
.
withDraggable
(
false
)
val
pointAnnotation
=
pointAnnotationManager
.
create
(
pointAnnotationOptions
)
val
viewAnnotation
=
viewAnnotationManager
.
addViewAnnotation
(
resId
=
R
.
layout
.
current_vehicle_view_annotation_layout
,
options
=
viewAnnotationOptions
{
geometry
(
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
))
associatedFeatureId
(
pointAnnotation
.
featureIdentifier
)
anchor
(
ViewAnnotationAnchor
.
BOTTOM
)
offsetY
((
pointAnnotation
.
iconImageBitmap
?.
height
!!
*
0.25
).
toInt
())
}
)
val
binding
=
CurrentVehicleViewAnnotationLayoutBinding
.
bind
(
viewAnnotation
)
binding
.
annotationCurrentVehicleNo
.
text
=
context
?.
getString
(
R
.
string
.
annotation_vehicle_no
,
"KK-001"
)
binding
.
annotationCurrentVehicleSpeed
.
text
=
context
?.
getString
(
R
.
string
.
annotation_vehicle_speed
,
36
)
}
fun
addOtherVehicleAnnotation
(
otherAnnotation
:
VehicleAnnotation
){
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
.
withPoint
(
otherAnnotation
.
point
)
.
withIconImage
(
iconOtherAlarmVehicleBitmap
!!
)
.
withIconSize
(
0.25
)
.
withIconAnchor
(
IconAnchor
.
BOTTOM
)
.
withDraggable
(
false
)
val
pointAnnotation
=
pointAnnotationManager
.
create
(
pointAnnotationOptions
)
val
viewAnnotation
=
viewAnnotationManager
.
addViewAnnotation
(
resId
=
R
.
layout
.
other_vehicle_view_annotation_layout
,
options
=
viewAnnotationOptions
{
geometry
(
otherAnnotation
.
point
)
associatedFeatureId
(
otherAnnotation
.
vehicleNo
)
anchor
(
ViewAnnotationAnchor
.
BOTTOM
)
offsetY
((
pointAnnotation
.
iconImageBitmap
?.
height
!!
*
0.25
).
toInt
())
}
)
val
binding
=
OtherVehicleViewAnnotationLayoutBinding
.
bind
(
viewAnnotation
)
binding
.
annotationOtherVehicleNo
.
text
=
context
?.
getString
(
R
.
string
.
annotation_vehicle_no
,
otherAnnotation
.
vehicleNo
)
binding
.
annotationOtherVehicleSpeed
.
text
=
24
.
toString
()
binding
.
annotationOtherVehicleDistance
.
text
=
25
.
toString
()
}
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/ui/MainViewModel.kt
View file @
caa4d969
...
@@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
...
@@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.viewmodel.CreationExtras
import
androidx.lifecycle.viewmodel.CreationExtras
import
com.blankj.utilcode.util.LogUtils
import
com.mapbox.geojson.Point
import
com.mapbox.geojson.Point
import
com.waytous.anticollision.repository.MainRepository
import
com.waytous.anticollision.repository.MainRepository
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
...
@@ -28,24 +29,25 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -28,24 +29,25 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
fun
electronicFenceSource
()
=
flowOf
(
fun
electronicFenceSource
()
=
flowOf
(
mainRepository
.
localElectronicFenceVersion
(),
mainRepository
.
localElectronicFenceVersion
(),
mainRepository
.
remoteElectronicFenceVersion
()
mainRepository
.
remoteElectronicFenceVersion
()
)
).
flattenMerge
()
.
flattenMerge
()
.
transformWhile
{
.
transformWhile
{
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -56,9 +58,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -56,9 +58,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -69,9 +72,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -69,9 +72,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -81,9 +85,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -81,9 +85,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -95,9 +100,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -95,9 +100,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -108,9 +114,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -108,9 +114,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -122,9 +129,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -122,9 +129,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -135,9 +143,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -135,9 +143,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -148,9 +157,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -148,9 +157,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -161,9 +171,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -161,9 +171,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
@@ -175,9 +186,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
...
@@ -175,9 +186,10 @@ class MainViewModel @Inject constructor(private val mainRepository: MainReposito
emit
(
it
.
mapDataSource
)
emit
(
it
.
mapDataSource
)
!
it
.
abort
!
it
.
abort
}.
map
{
}.
map
{
it
.
geojson
it
?
.
geojson
}.
flowOn
(
Dispatchers
.
IO
)
}.
flowOn
(
Dispatchers
.
IO
)
.
catch
{
.
catch
{
LogUtils
.
e
(
it
.
message
)
emit
(
""
)
emit
(
""
)
}
}
...
...
app/src/main/java/com/waytous/anticollision/ui/MapBoxLayout.kt
View file @
caa4d969
package
com.waytous.anticollision.ui
package
com.waytous.anticollision.ui
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context
import
android.graphics.Color
import
android.graphics.Bitmap
import
android.text.Spannable
import
android.text.SpannableString
import
android.text.style.ForegroundColorSpan
import
android.util.AttributeSet
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.widget.FrameLayout
import
androidx.appcompat.content.res.AppCompatResources
import
androidx.appcompat.widget.AppCompatImageView
import
androidx.appcompat.widget.AppCompatTextView
import
com.blankj.utilcode.util.LogUtils
import
com.mapbox.geojson.Point
import
com.mapbox.geojson.Point
import
com.mapbox.maps.CameraOptions
import
com.mapbox.maps.MapView
import
com.mapbox.maps.MapView
import
com.mapbox.maps.MapboxMap
import
com.mapbox.maps.Style
import
com.mapbox.maps.Style
import
com.mapbox.maps.extension.style.expressions.dsl.generated.get
import
com.mapbox.maps.ViewAnnotationAnchor
import
com.mapbox.maps.extension.style.layers.generated.circleLayer
import
com.mapbox.maps.extension.style.expressions.dsl.generated.interpolate
import
com.mapbox.maps.extension.style.layers.generated.fillLayer
import
com.mapbox.maps.extension.style.layers.generated.lineLayer
import
com.mapbox.maps.extension.style.layers.generated.symbolLayer
import
com.mapbox.maps.extension.style.layers.properties.generated.*
import
com.mapbox.maps.extension.style.layers.properties.generated.*
import
com.mapbox.maps.
extension.style.projection.generated.projection
import
com.mapbox.maps.
plugin.LocationPuck2D
import
com.mapbox.maps.
extension.style.sources.addSource
import
com.mapbox.maps.
plugin.annotation.annotations
import
com.mapbox.maps.
extension.style.sources.generated.geoJsonSource
import
com.mapbox.maps.
plugin.annotation.generated.PointAnnotation
import
com.mapbox.maps.
extension.style.style
import
com.mapbox.maps.
plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.an
imation.flyTo
import
com.mapbox.maps.plugin.an
notation.generated.PointAnnotationOptions
import
com.mapbox.maps.plugin.a
ttribution.attribution
import
com.mapbox.maps.plugin.a
nnotation.generated.createPointAnnotationManager
import
com.mapbox.maps.plugin.
compass.compass
import
com.mapbox.maps.plugin.
locationcomponent.location
import
com.mapbox.maps.
plugin.logo.logo
import
com.mapbox.maps.
viewannotation.ViewAnnotationManager
import
com.
waytous.anticollision.BuildConfig
import
com.
mapbox.maps.viewannotation.viewAnnotationOptions
import
com.waytous.anticollision.R
import
com.waytous.anticollision.R
import
com.waytous.anticollision.databinding.CurrentVehicleViewAnnotationLayoutBinding
import
com.waytous.anticollision.utils.BitmapUtils
/**
/**
* mapbox及控制组件封装
* mapbox及控制组件封装
* @author male
* @author male
* @param context
* @param context
* @param attributeSet
* */
* */
class
MapBoxLayout
(
context
:
Context
,
private
val
attributeSet
:
AttributeSet
):
FrameLayout
(
context
,
attributeSet
)
{
class
MapBoxLayout
(
private
val
context
:
Context
,
private
val
mapView
:
MapView
)
{
/**
* mapbox地图
* */
private
var
mapView
:
MapView
/**
* mapbox
* */
private
var
mapBox
:
MapboxMap
/**
* sos按钮
* */
private
var
sosButton
:
AppCompatImageView
/**
* 急停按钮
* */
private
var
emergency
:
AppCompatImageView
/**
* 放大按钮
* */
private
var
zoomOut
:
AppCompatImageView
/**
* 缩小按钮
* */
private
var
zoomIn
:
AppCompatImageView
/**
* 定位车辆位置
* */
private
var
locationTruck
:
AppCompatImageView
/**
* 关闭&显示安全距离
* */
private
var
toggleSafetyRange
:
AppCompatImageView
/**
* 地图采集信息文本
* */
private
var
collectDataText
:
AppCompatTextView
private
var
cameraOptions
:
CameraOptions
private
var
zoomLevel
:
Double
=
14.0
private
var
zoomLevel
:
Double
=
14.0
private
lateinit
var
style
:
Style
private
lateinit
var
style
:
Style
companion
object
{
private
lateinit
var
viewAnnotationManager
:
ViewAnnotationManager
private
val
scaleLengths
=
listOf
(
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
1000000
,
2000000
)
private
const
val
MINIMUM_ZOOM_LEVEL
=
11.0
private
const
val
MAXIMUM_ZOOM_LEVEL
=
26.0
}
init
{
private
lateinit
var
pointAnnotationManager
:
PointAnnotationManager
val
root
:
View
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
layout_map_box
,
this
,
true
)
mapView
=
root
.
findViewById
<
MapView
>(
R
.
id
.
mapView
).
also
{
it
.
logo
.
enabled
=
false
it
.
compass
.
enabled
=
false
it
.
attribution
.
enabled
=
false
}
mapBox
=
mapView
.
getMapboxMap
().
also
{
mapbox
->
mapbox
.
loadStyle
(
style
(
MainViewModel
.
MY_MAP_BOX_STYLE
){
+
projection
(
ProjectionName
.
GLOBE
)
}){
style
=
it
addTruckPathSource
()
}
}
cameraOptions
=
CameraOptions
.
Builder
().
center
(
Point
.
fromLngLat
(
BuildConfig
.
DEFAULT_LONGITUDE
,
BuildConfig
.
DEFAULT_LATITUDE
)).
zoom
(
zoomLevel
).
build
()
sosButton
=
root
.
findViewById
<
AppCompatImageView
?>(
R
.
id
.
sos
).
also
{
it
.
setOnClickListener
{
}
private
lateinit
var
pointAnnotation
:
PointAnnotation
}
emergency
=
root
.
findViewById
(
R
.
id
.
emergency
)
zoomOut
=
root
.
findViewById
<
AppCompatImageView
?>(
R
.
id
.
zoomOut
).
also
{
it
.
setOnClickListener
{
}
private
lateinit
var
viewAnnotation
:
View
}
zoomIn
=
root
.
findViewById
<
AppCompatImageView
?>(
R
.
id
.
zoomIn
).
also
{
}
locationTruck
=
root
.
findViewById
<
AppCompatImageView
?>(
R
.
id
.
locationTruck
).
also
{
}
toggleSafetyRange
=
root
.
findViewById
<
AppCompatImageView
?>(
R
.
id
.
toggleSafetyRange
).
also
{
}
collectDataText
=
root
.
findViewById
(
R
.
id
.
collectDataText
)
}
fun
updateCenter
(
center
:
Point
){
mapBox
.
flyTo
(
cameraOptions
.
toBuilder
().
center
(
center
).
build
())
}
private
fun
calculateScale
(){
companion
object
{
private
val
scaleLengths
=
listOf
(
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
1000000
,
2000000
)
}
private
const
val
MINIMUM_ZOOM_LEVEL
=
11.0
private
const
val
MAXIMUM_ZOOM_LEVEL
=
26.0
fun
addRunnableAreaSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
RUNNABLE_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
RUNNABLE_AREA_LAYER
,
MainViewModel
.
RUNNABLE_AREA_SOURCE
){
fillColor
(
"#98a0a0"
)
fillOpacity
(
0.85
)
fillOutlineColor
(
"#FFFF00"
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addLaneSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
LANE_SOURCE
)
{
data
(
source
)
}
lineLayer
(
MainViewModel
.
LANE_LAYER
,
MainViewModel
.
LANE_SOURCE
){
lineColor
(
"white"
)
lineWidth
(
3.0
)
lineJoin
(
LineJoin
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addStaticObjectsSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
STATIC_OBJECTS_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
STATIC_OBJECTS_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
fillColor
(
"#98a0a0"
)
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
STATIC_OBJECTS_TEXT_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addDiggingWorkAreaSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
DIGGING_WORK_AREA_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
fillColor
(
"#886e26"
)
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
DIGGING_WORK_AREA_TEXT_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addBarricadeSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
BARRICADE_SOURCE
)
{
data
(
source
)
}
lineLayer
(
MainViewModel
.
BARRICADE_LAYER
,
MainViewModel
.
BARRICADE_SOURCE
){
lineColor
(
"blue"
)
lineWidth
(
4.0
)
lineJoin
(
LineJoin
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addObstaclesSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
OBSTACLES_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
OBSTACLES_LAYER
,
MainViewModel
.
OBSTACLES_SOURCE
){
fillColor
(
"#6f9bdd"
)
fillOpacity
(
0.8
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
OBSTACLES_TEXT_LAYER
,
MainViewModel
.
OBSTACLES_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addStationAreaSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
STATION_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
STATION_AREA_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
fillColor
(
"lightgreen"
)
fillOpacity
(
0.8
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
STATION_AREA_TEXT_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxWidth
(
10.0
)
}
}
}
}
fun
addLaneNodeSource
(
source
:
String
){
private
val
iconCurrentNormalVehicleBitmap
by
lazy
{
style
.
addSource
{
BitmapUtils
.
bitmapFromDrawableRes
(
context
,
R
.
drawable
.
my_vehicle_normal
)
geoJsonSource
(
MainViewModel
.
LANE_NODE_SOURCE
)
{
data
(
source
)
}
circleLayer
(
MainViewModel
.
LANE_NODE_LAYER
,
MainViewModel
.
LANE_NODE_SOURCE
){
circleColor
(
"red"
)
circleRadius
(
6.0
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
LANE_TEXT_LAYER
,
MainViewModel
.
LANE_NODE_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
9.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
fun
addParkSpotSource
(
source
:
String
){
private
val
iconOtherAlarmVehicleBitmap
by
lazy
{
style
.
addSource
{
BitmapUtils
.
bitmapFromDrawableRes
(
context
,
R
.
drawable
.
other_vehicle_normal
)
geoJsonSource
(
MainViewModel
.
PARK_SPOT_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
PARK_SPOT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
){
fillColor
(
get
(
"#7e8185"
))
fillOpacity
(
0.8
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
PARK_SPOT_TEXT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
9.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
fun
addElectronicFenceSource
(
source
:
String
){
fun
updateTruckLocation
(
drawable
:
Int
){
style
.
addSource
{
mapView
.
location
.
locationPuck
=
LocationPuck2D
(
AppCompatResources
.
getDrawable
(
context
,
drawable
),
scaleExpression
=
interpolate
{
geoJsonSource
(
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
)
{
linear
()
data
(
source
)
zoom
()
}
stop
{
fillLayer
(
literal
(
MINIMUM_ZOOM_LEVEL
)
MainViewModel
.
ELECTRONIC_FENCE_LAYER
,
literal
(
0.6
)
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
fillColor
(
get
(
"color"
))
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
ELECTRONIC_FENCE_TEXT_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
stop
{
textColor
(
Color
.
BLACK
)
literal
(
MAXIMUM_ZOOM_LEVEL
)
textField
(
get
(
"name"
))
literal
(
1.2
)
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
.
toJson
())
}
}
fun
addWetAreaSource
(
source
:
String
){
fun
updateRoundTrucks
(
vararg
points
:
Point
){
style
.
addSource
{
points
.
forEach
{
geoJsonSource
(
MainViewModel
.
WET_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
WET_AREA_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
){
fillColor
(
get
(
"color"
))
fillOpacity
(
0.8
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
WET_AREA_TEXT_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
addDumpAreaSource
(
source
:
String
){
style
.
addSource
{
geoJsonSource
(
MainViewModel
.
DUMP_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
DUMP_AREA_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
){
fillColor
(
"#886e26"
)
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
DUMP_AREA_TEXT_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
private
fun
addTruckPathSource
(){
@SuppressLint
(
"SetTextI18n"
)
style
.
addSource
{
private
fun
prepareViewAnnotation
()
{
geoJsonSource
(
"truckPathSource"
)
{
viewAnnotation
=
viewAnnotationManager
.
addViewAnnotation
(
data
(
"{ \"type\": \"FeatureCollection\", \"features\":[]}"
)
resId
=
R
.
layout
.
current_vehicle_view_annotation_layout
,
}
options
=
viewAnnotationOptions
{
lineLayer
(
geometry
(
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
))
"truckPathLayer"
,
associatedFeatureId
(
pointAnnotation
.
featureIdentifier
)
"truckPathSource"
anchor
(
ViewAnnotationAnchor
.
BOTTOM
)
){
offsetY
((
pointAnnotation
.
iconImageBitmap
?.
height
!!
).
toInt
())
lineColor
(
"green"
)
lineWidth
(
8.0
)
lineOpacity
(
0.8
)
lineJoin
(
LineJoin
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
)
}
CurrentVehicleViewAnnotationLayoutBinding
.
bind
(
viewAnnotation
)
fun
formatCollectionData
(
text
:
String
){
val
tagSpan
=
ForegroundColorSpan
(
Color
.
parseColor
(
"#666666"
))
val
contentSpan
=
ForegroundColorSpan
(
Color
.
parseColor
(
"#000000"
))
val
spannableString
=
SpannableString
(
text
)
spannableString
.
setSpan
(
tagSpan
,
0
,
4
,
Spannable
.
SPAN_INCLUSIVE_INCLUSIVE
)
val
textPointIndex
=
text
.
indexOf
(
"采集点数"
)
spannableString
.
setSpan
(
contentSpan
,
5
,
textPointIndex
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
)
spannableString
.
setSpan
(
tagSpan
,
textPointIndex
,
textPointIndex
+
4
,
Spannable
.
SPAN_INCLUSIVE_INCLUSIVE
)
val
textPositionIndex
=
text
.
indexOf
(
"当前位置"
)
spannableString
.
setSpan
(
contentSpan
,
textPointIndex
+
1
,
textPositionIndex
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
)
spannableString
.
setSpan
(
tagSpan
,
textPositionIndex
,
textPositionIndex
+
4
,
Spannable
.
SPAN_INCLUSIVE_INCLUSIVE
)
val
textAltitudeIndex
=
text
.
indexOf
(
"高程"
)
spannableString
.
setSpan
(
contentSpan
,
textPositionIndex
+
1
,
textAltitudeIndex
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
)
spannableString
.
setSpan
(
tagSpan
,
textAltitudeIndex
,
textAltitudeIndex
+
2
,
Spannable
.
SPAN_INCLUSIVE_INCLUSIVE
)
collectDataText
.
text
=
spannableString
}
}
override
fun
onAttachedToWindow
()
{
private
fun
prepareAnnotationMarker
(
mapView
:
MapView
,
iconBitmap
:
Bitmap
)
{
super
.
onAttachedToWindow
()
val
annotationPlugin
=
mapView
.
annotations
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
.
withPoint
(
Point
.
fromLngLat
(
MainViewModel
.
LONGITUDE
,
MainViewModel
.
LATITUDE
))
.
withIconImage
(
iconBitmap
)
.
withIconAnchor
(
IconAnchor
.
BOTTOM
)
pointAnnotationManager
=
annotationPlugin
.
createPointAnnotationManager
()
pointAnnotation
=
pointAnnotationManager
.
create
(
pointAnnotationOptions
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/ui/home/HomeFragment.kt
View file @
caa4d969
package
com.waytous.anticollision.ui.home
package
com.waytous.anticollision.ui.home
import
android.graphics.Color
import
android.os.Bundle
import
android.os.Bundle
import
android.text.SpannableString
import
android.text.SpannableString
import
android.util.Log
import
android.view.Gravity
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.fragment.app.viewModels
import
androidx.fragment.app.viewModels
import
androidx.lifecycle.*
import
androidx.lifecycle.*
import
com.blankj.utilcode.util.LogUtils
import
com.blankj.utilcode.util.LogUtils
import
com.mapbox.geojson.Point
import
com.mapbox.maps.CameraOptions
import
com.mapbox.maps.MapView
import
com.mapbox.maps.MapView
import
com.mapbox.maps.MapboxMap
import
com.mapbox.maps.MapboxMap
import
com.mapbox.maps.extension.style.expressions.dsl.generated.get
import
com.mapbox.maps.extension.style.layers.generated.circleLayer
import
com.mapbox.maps.extension.style.layers.generated.fillLayer
import
com.mapbox.maps.extension.style.layers.generated.lineLayer
import
com.mapbox.maps.extension.style.layers.generated.symbolLayer
import
com.mapbox.maps.extension.style.layers.properties.generated.LineCap
import
com.mapbox.maps.extension.style.layers.properties.generated.LineJoin
import
com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor
import
com.mapbox.maps.extension.style.layers.properties.generated.TextRotationAlignment
import
com.mapbox.maps.extension.style.layers.properties.generated.Visibility
import
com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import
com.mapbox.maps.extension.style.style
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotation
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotation
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.attribution.attribution
import
com.mapbox.maps.plugin.attribution.attribution
import
com.mapbox.maps.plugin.compass.compass
import
com.mapbox.maps.plugin.compass.compass
import
com.mapbox.maps.plugin.logo.logo
import
com.mapbox.maps.plugin.logo.logo
import
com.mapbox.maps.plugin.scalebar.scalebar
import
com.mapbox.maps.viewannotation.ViewAnnotationManager
import
com.mapbox.maps.viewannotation.ViewAnnotationManager
import
com.waytous.anticollision.R
import
com.waytous.anticollision.R
import
com.waytous.anticollision.databinding.FragmentHomeBinding
import
com.waytous.anticollision.databinding.FragmentHomeBinding
...
@@ -24,7 +44,21 @@ import com.waytous.anticollision.ui.BaseFragment
...
@@ -24,7 +44,21 @@ import com.waytous.anticollision.ui.BaseFragment
import
com.waytous.anticollision.ui.MainViewModel
import
com.waytous.anticollision.ui.MainViewModel
import
com.waytous.anticollision.ui.view.MoreFeaturesPopup
import
com.waytous.anticollision.ui.view.MoreFeaturesPopup
import
com.waytous.anticollision.ui.view.WorkStatusEditPopup
import
com.waytous.anticollision.ui.view.WorkStatusEditPopup
import
com.waytous.anticollision.utils.addBarricadeSource
import
com.waytous.anticollision.utils.addDiggingWorkAreaSource
import
com.waytous.anticollision.utils.addDumpAreaSource
import
com.waytous.anticollision.utils.addElectronicFenceSource
import
com.waytous.anticollision.utils.addLaneNodeSource
import
com.waytous.anticollision.utils.addLaneSource
import
com.waytous.anticollision.utils.addObstaclesSource
import
com.waytous.anticollision.utils.addParkSpotSource
import
com.waytous.anticollision.utils.addRunnableAreaSource
import
com.waytous.anticollision.utils.addStaticObjectsSource
import
com.waytous.anticollision.utils.addStationAreaSource
import
com.waytous.anticollision.utils.addTruckPathSource
import
com.waytous.anticollision.utils.addWetAreaSource
import
com.waytous.anticollision.utils.setTextSize
import
com.waytous.anticollision.utils.setTextSize
import
kotlinx.coroutines.flow.collect
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
class
HomeFragment
:
BaseFragment
()
{
class
HomeFragment
:
BaseFragment
()
{
...
@@ -35,27 +69,16 @@ class HomeFragment : BaseFragment() {
...
@@ -35,27 +69,16 @@ class HomeFragment : BaseFragment() {
private
lateinit
var
mapView
:
MapView
private
lateinit
var
mapView
:
MapView
private
lateinit
var
mapBox
:
MapboxMap
private
var
count
=
0
private
lateinit
var
viewAnnotationManager
:
ViewAnnotationManager
private
lateinit
var
pointAnnotationManager
:
PointAnnotationManager
private
lateinit
var
pointAnnotation
:
PointAnnotation
private
lateinit
var
moreFeaturesPopup
:
MoreFeaturesPopup
private
lateinit
var
moreFeaturesPopup
:
MoreFeaturesPopup
private
lateinit
var
workStatusEditPopup
:
WorkStatusEditPopup
private
lateinit
var
workStatusEditPopup
:
WorkStatusEditPopup
private
val
mapModel
:
MainViewModel
by
viewModels
{
private
val
mapModel
:
MainViewModel
by
viewModels
{
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
}
override
fun
onCreateView
(
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
container
:
ViewGroup
?,
...
@@ -64,7 +87,7 @@ class HomeFragment : BaseFragment() {
...
@@ -64,7 +87,7 @@ class HomeFragment : BaseFragment() {
val
homeViewModel
=
val
homeViewModel
=
ViewModelProvider
(
this
)[
HomeViewModel
::
class
.
java
]
ViewModelProvider
(
this
)[
HomeViewModel
::
class
.
java
]
_binding
=
FragmentHomeBinding
.
inflate
(
inflater
,
container
,
false
)
_binding
=
FragmentHomeBinding
.
inflate
(
inflater
,
container
,
false
)
context
?:
return
binding
.
root
context
?:
return
binding
.
root
workStatusEditPopup
=
WorkStatusEditPopup
(
context
).
also
{
workStatusEditPopup
=
WorkStatusEditPopup
(
context
).
also
{
it
.
setOutSideDismiss
(
true
)
it
.
setOutSideDismiss
(
true
)
it
.
popupGravity
=
Gravity
.
TOP
or
Gravity
.
CENTER
it
.
popupGravity
=
Gravity
.
TOP
or
Gravity
.
CENTER
...
@@ -76,15 +99,16 @@ class HomeFragment : BaseFragment() {
...
@@ -76,15 +99,16 @@ class HomeFragment : BaseFragment() {
it
.
maskOffsetY
=
20
it
.
maskOffsetY
=
20
it
.
setBackgroundColor
(
R
.
color
.
color_99000000
)
it
.
setBackgroundColor
(
R
.
color
.
color_99000000
)
}
}
mapView
=
binding
.
root
.
findViewById
<
MapView
?>(
R
.
id
.
mapView
).
also
{
mapView
=
binding
.
root
.
findViewById
<
MapView
?>(
R
.
id
.
mapView
).
also
{
it
->
it
.
logo
.
enabled
=
false
it
.
logo
.
enabled
=
false
it
.
compass
.
enabled
=
false
it
.
compass
.
enabled
=
false
it
.
attribution
.
enabled
=
false
it
.
attribution
.
enabled
=
false
it
.
scalebar
.
enabled
=
false
}
}
viewAnnotationManager
=
mapView
.
viewAnnotationManager
initAnnotationManager
(
mapView
)
updateMapBox
(
mapView
)
updateMapBox
(
mapView
)
mapView
.
addRendererSetupErrorListener
{
mapView
.
addRendererSetupErrorListener
{
error
->
error
->
LogUtils
.
e
(
"RendererSetupErrorListener:${error}"
)
LogUtils
.
e
(
"RendererSetupErrorListener:${error}"
)
}
}
setTodayCarriedNum
(
18
)
setTodayCarriedNum
(
18
)
setTodayIllegallyNum
(
1
)
setTodayIllegallyNum
(
1
)
...
@@ -94,37 +118,19 @@ class HomeFragment : BaseFragment() {
...
@@ -94,37 +118,19 @@ class HomeFragment : BaseFragment() {
binding
.
defaultToggleMore
.
setOnClickListener
{
binding
.
defaultToggleMore
.
setOnClickListener
{
moreFeaturesPopup
.
showPopupWindow
(
binding
.
defaultToggleMore
)
moreFeaturesPopup
.
showPopupWindow
(
binding
.
defaultToggleMore
)
}
}
viewLifecycleOwner
.
lifecycleScope
.
launch
{
repeatOnLifecycle
(
Lifecycle
.
State
.
STARTED
){
mapModel
.
obstaclesSource
().
collect
{
binding
.
defaultMapLayout
.
addObstaclesSource
(
it
)}
mapModel
.
runnableAreaSource
().
collect
{
binding
.
defaultMapLayout
.
addRunnableAreaSource
(
it
)}
mapModel
.
laneSource
().
collect
{
binding
.
defaultMapLayout
.
addLaneSource
(
it
)}
mapModel
.
laneNodeSource
().
collect
{
binding
.
defaultMapLayout
.
addLaneNodeSource
(
it
)}
mapModel
.
staticObjectsSource
().
collect
{
binding
.
defaultMapLayout
.
addStaticObjectsSource
(
it
)}
mapModel
.
diggingWorkAreaSource
().
collect
{
binding
.
defaultMapLayout
.
addDiggingWorkAreaSource
(
it
)}
mapModel
.
barricadeSource
().
collect
{
binding
.
defaultMapLayout
.
addBarricadeSource
(
it
)}
mapModel
.
stationAreaSource
().
collect
{
binding
.
defaultMapLayout
.
addStationAreaSource
(
it
)}
mapModel
.
parkSpotSource
().
collect
{
binding
.
defaultMapLayout
.
addParkSpotSource
(
it
)}
mapModel
.
electronicFenceSource
().
collect
{
binding
.
defaultMapLayout
.
addElectronicFenceSource
(
it
)}
mapModel
.
wetAreaSource
().
collect
{
binding
.
defaultMapLayout
.
addWetAreaSource
(
it
)}
mapModel
.
dumpAreaSource
().
collect
{
binding
.
defaultMapLayout
.
addDumpAreaSource
(
it
)}
}
}
return
binding
.
root
return
binding
.
root
}
}
private
fun
setTodayCarriedNum
(
num
:
Int
)
{
private
fun
setTodayCarriedNum
(
num
:
Int
){
val
templateString
=
getString
(
R
.
string
.
today_carried_text
,
num
)
val
templateString
=
getString
(
R
.
string
.
today_carried_text
,
num
)
val
spannableString
=
SpannableString
(
templateString
)
val
spannableString
=
SpannableString
(
templateString
)
binding
.
todayCarried
.
setTextSize
(
spannableString
,
templateString
,
"今日运载(车)"
)
binding
.
todayCarried
.
setTextSize
(
spannableString
,
templateString
,
"今日运载(车)"
)
}
}
private
fun
setTodayIllegallyNum
(
num
:
Int
)
{
private
fun
setTodayIllegallyNum
(
num
:
Int
)
{
val
templateString
=
getString
(
R
.
string
.
today_illegally_text
,
num
)
val
templateString
=
getString
(
R
.
string
.
today_illegally_text
,
num
)
val
spannableString
=
SpannableString
(
templateString
)
val
spannableString
=
SpannableString
(
templateString
)
binding
.
illegallyNum
.
setTextSize
(
spannableString
,
templateString
,
"违章/警告(次)"
)
binding
.
illegallyNum
.
setTextSize
(
spannableString
,
templateString
,
"违章/警告(次)"
)
}
}
override
fun
onDestroyView
()
{
override
fun
onDestroyView
()
{
...
...
app/src/main/java/com/waytous/anticollision/utils/BitmapUtils.kt
0 → 100644
View file @
caa4d969
package
com.waytous.anticollision.utils
import
android.content.Context
import
android.graphics.Bitmap
import
android.graphics.Canvas
import
android.graphics.drawable.BitmapDrawable
import
android.graphics.drawable.Drawable
import
androidx.annotation.DrawableRes
import
androidx.appcompat.content.res.AppCompatResources
/**
* Utility class to work with bitmaps and drawables.
*/
object
BitmapUtils
{
/**
* Convert given drawable id to bitmap.
*/
fun
bitmapFromDrawableRes
(
context
:
Context
,
@DrawableRes
resourceId
:
Int
)
=
convertDrawableToBitmap
(
AppCompatResources
.
getDrawable
(
context
,
resourceId
))
private
fun
convertDrawableToBitmap
(
sourceDrawable
:
Drawable
?):
Bitmap
?
{
if
(
sourceDrawable
==
null
)
{
return
null
}
return
if
(
sourceDrawable
is
BitmapDrawable
)
{
sourceDrawable
.
bitmap
}
else
{
// copying drawable object to not manipulate on the same reference
val
constantState
=
sourceDrawable
.
constantState
?:
return
null
val
drawable
=
constantState
.
newDrawable
().
mutate
()
val
bitmap
:
Bitmap
=
Bitmap
.
createBitmap
(
drawable
.
intrinsicWidth
,
drawable
.
intrinsicHeight
,
Bitmap
.
Config
.
ARGB_8888
)
val
canvas
=
Canvas
(
bitmap
)
drawable
.
setBounds
(
0
,
0
,
canvas
.
width
,
canvas
.
height
)
drawable
.
draw
(
canvas
)
bitmap
}
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/utils/Extensions.kt
View file @
caa4d969
...
@@ -3,6 +3,7 @@ package com.waytous.anticollision.utils
...
@@ -3,6 +3,7 @@ package com.waytous.anticollision.utils
import
android.content.Context
import
android.content.Context
import
android.graphics.Bitmap
import
android.graphics.Bitmap
import
android.graphics.Canvas
import
android.graphics.Canvas
import
android.graphics.Color
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Build
import
android.os.Build
import
android.text.Spannable
import
android.text.Spannable
...
@@ -13,6 +14,21 @@ import androidx.appcompat.app.AppCompatActivity
...
@@ -13,6 +14,21 @@ import androidx.appcompat.app.AppCompatActivity
import
androidx.core.app.ActivityCompat
import
androidx.core.app.ActivityCompat
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
androidx.core.graphics.drawable.DrawableCompat
import
androidx.core.graphics.drawable.DrawableCompat
import
com.blankj.utilcode.util.LogUtils
import
com.mapbox.maps.Style
import
com.mapbox.maps.extension.style.expressions.dsl.generated.get
import
com.mapbox.maps.extension.style.layers.generated.circleLayer
import
com.mapbox.maps.extension.style.layers.generated.fillLayer
import
com.mapbox.maps.extension.style.layers.generated.lineLayer
import
com.mapbox.maps.extension.style.layers.generated.symbolLayer
import
com.mapbox.maps.extension.style.layers.properties.generated.LineCap
import
com.mapbox.maps.extension.style.layers.properties.generated.LineJoin
import
com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor
import
com.mapbox.maps.extension.style.layers.properties.generated.TextRotationAlignment
import
com.mapbox.maps.extension.style.layers.properties.generated.Visibility
import
com.mapbox.maps.extension.style.sources.addSource
import
com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import
com.waytous.anticollision.ui.MainViewModel
const
val
databaseName
=
"anti_collision.db"
const
val
databaseName
=
"anti_collision.db"
...
@@ -69,6 +85,357 @@ fun Context.getBitmapFromVectorDrawable(drawableId:Int,scale:Int = 2): Bitmap? {
...
@@ -69,6 +85,357 @@ fun Context.getBitmapFromVectorDrawable(drawableId:Int,scale:Int = 2): Bitmap? {
return
bitmap
return
bitmap
}
}
fun
Style
.
addRunnableAreaSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addRunnableAreaSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
RUNNABLE_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
RUNNABLE_AREA_LAYER
,
MainViewModel
.
RUNNABLE_AREA_SOURCE
){
fillColor
(
"#98a0a0"
)
fillOpacity
(
0.85
)
fillOutlineColor
(
"#FFFF00"
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addLaneSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addLaneSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
LANE_SOURCE
)
{
data
(
source
)
}
lineLayer
(
MainViewModel
.
LANE_LAYER
,
MainViewModel
.
LANE_SOURCE
){
lineColor
(
"white"
)
lineWidth
(
3.0
)
lineJoin
(
LineJoin
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addStaticObjectsSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStaticObjectsSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
STATIC_OBJECTS_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
STATIC_OBJECTS_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
fillColor
(
"#98a0a0"
)
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
STATIC_OBJECTS_TEXT_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addDiggingWorkAreaSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addDiggingWorkAreaSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
DIGGING_WORK_AREA_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
fillColor
(
"#886e26"
)
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
DIGGING_WORK_AREA_TEXT_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addBarricadeSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addBarricadeSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
BARRICADE_SOURCE
)
{
data
(
source
)
}
lineLayer
(
MainViewModel
.
BARRICADE_LAYER
,
MainViewModel
.
BARRICADE_SOURCE
){
lineColor
(
"blue"
)
lineWidth
(
4.0
)
lineJoin
(
LineJoin
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addObstaclesSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addObstaclesSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
OBSTACLES_SOURCE
)
{
url
(
source
)
}
fillLayer
(
MainViewModel
.
OBSTACLES_LAYER
,
MainViewModel
.
OBSTACLES_SOURCE
){
fillColor
(
"#6f9bdd"
)
fillOpacity
(
0.8
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
OBSTACLES_TEXT_LAYER
,
MainViewModel
.
OBSTACLES_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addStationAreaSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStationAreaSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
STATION_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
STATION_AREA_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
fillColor
(
"lightgreen"
)
fillOpacity
(
0.8
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
STATION_AREA_TEXT_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxWidth
(
10.0
)
}
}
}
fun
Style
.
addLaneNodeSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addLaneNodeSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
LANE_NODE_SOURCE
)
{
data
(
source
)
}
circleLayer
(
MainViewModel
.
LANE_NODE_LAYER
,
MainViewModel
.
LANE_NODE_SOURCE
){
circleColor
(
"red"
)
circleRadius
(
6.0
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
LANE_TEXT_LAYER
,
MainViewModel
.
LANE_NODE_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
9.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addParkSpotSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addParkSpotSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
PARK_SPOT_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
PARK_SPOT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
){
fillColor
(
get
(
"#7e8185"
))
fillOpacity
(
0.8
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
PARK_SPOT_TEXT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
9.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addElectronicFenceSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addElectronicFenceSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
ELECTRONIC_FENCE_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
fillColor
(
get
(
"color"
))
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
ELECTRONIC_FENCE_TEXT_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addWetAreaSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addWetAreaSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
WET_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
WET_AREA_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
){
fillColor
(
get
(
"color"
))
fillOpacity
(
0.8
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
WET_AREA_TEXT_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addDumpAreaSource
(
source
:
String
){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addDumpAreaSource"
)
addSource
{
geoJsonSource
(
MainViewModel
.
DUMP_AREA_SOURCE
)
{
data
(
source
)
}
fillLayer
(
MainViewModel
.
DUMP_AREA_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
){
fillColor
(
"#886e26"
)
fillOpacity
(
0.85
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
}
symbolLayer
(
MainViewModel
.
DUMP_AREA_TEXT_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textLineHeight
(
1.0
)
textPadding
(
1.0
)
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
Style
.
addTruckPathSource
(){
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addTruckPathSource"
)
addSource
{
geoJsonSource
(
"truckPathSource"
)
{
data
(
"{ \"type\": \"FeatureCollection\", \"features\":[]}"
)
}
lineLayer
(
"truckPathLayer"
,
"truckPathSource"
){
lineColor
(
"green"
)
lineWidth
(
8.0
)
lineOpacity
(
0.8
)
lineJoin
(
LineJoin
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
fun
AppCompatActivity
.
checkSelfPermissionCompat
(
permission
:
String
)
=
fun
AppCompatActivity
.
checkSelfPermissionCompat
(
permission
:
String
)
=
ActivityCompat
.
checkSelfPermission
(
this
,
permission
)
ActivityCompat
.
checkSelfPermission
(
this
,
permission
)
...
...
app/src/main/java/com/waytous/anticollision/vo/VehicleAnnotation.kt
0 → 100644
View file @
caa4d969
package
com.waytous.anticollision.vo
import
com.mapbox.geojson.Point
data class
VehicleAnnotation
(
val
vehicleNo
:
String
,
val
speed
:
Int
,
val
distance
:
Int
,
val
point
:
Point
,
val
isShow
:
Boolean
)
\ No newline at end of file
app/src/main/res/drawable-night/background_view_annotation_current_vehicle.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_140"
android:height=
"@dimen/dp_54"
/>
<solid
android:color=
"@color/color_e6114da5"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable-night/background_view_annotation_other_vehicle.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_140"
android:height=
"@dimen/dp_64"
/>
<solid
android:color=
"@color/color_cc1c1c1c"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable-night/background_view_annotation_other_vehicle_distance.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_52"
android:height=
"@dimen/dp_26"
/>
<solid
android:color=
"@color/color_80f97c36"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable-night/background_view_annotation_other_vehicle_speed.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_66"
android:height=
"@dimen/dp_26"
/>
<solid
android:color=
"@color/color_803684f9"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/background_view_annotation_current_vehicle.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_140"
android:height=
"@dimen/dp_54"
/>
<solid
android:color=
"@color/color_ff005aff"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/background_view_annotation_other_vehicle.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_140"
android:height=
"@dimen/dp_64"
/>
<solid
android:color=
"@color/color_ccffffff"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/background_view_annotation_other_vehicle_distance.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_52"
android:height=
"@dimen/dp_26"
/>
<solid
android:color=
"@color/color_33f97c36"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/background_view_annotation_other_vehicle_speed.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<size
android:width=
"@dimen/dp_66"
android:height=
"@dimen/dp_26"
/>
<solid
android:color=
"@color/color_333684f9"
/>
<corners
android:radius=
"@dimen/dp_6"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/current_vehicle_view_annotation_layout.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:background=
"@drawable/background_view_annotation_current_vehicle"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/annotationCurrentVehicleNo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/dp_13"
android:layout_marginTop=
"@dimen/dp_4"
android:textColor=
"@color/white"
android:textSize=
"@dimen/sp_16"
android:text=
"@string/annotation_vehicle_no"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/annotationCurrentVehicleSpeed"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/dp_13"
android:textColor=
"@color/white"
android:textSize=
"@dimen/sp_16"
android:text=
"@string/annotation_vehicle_speed"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file
app/src/main/res/layout/fragment_home.xml
View file @
caa4d969
...
@@ -282,8 +282,9 @@
...
@@ -282,8 +282,9 @@
app:layout_constraintTop_toTopOf=
"@id/defaultToggleMore"
app:layout_constraintTop_toTopOf=
"@id/defaultToggleMore"
app:layout_constraintEnd_toEndOf=
"@id/defaultMapLayout"
/>
app:layout_constraintEnd_toEndOf=
"@id/defaultMapLayout"
/>
<
com.waytous.anticollision.ui.MapBoxLayout
<
include
android:id=
"@+id/defaultMapLayout"
android:id=
"@+id/defaultMapLayout"
layout=
"@layout/layout_map_box"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:layout_marginEnd=
"16dp"
android:layout_marginEnd=
"16dp"
...
...
app/src/main/res/layout/other_vehicle_view_annotation_layout.xml
0 → 100644
View file @
caa4d969
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:background=
"@drawable/background_view_annotation_other_vehicle"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/annotationOtherVehicleNo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/dp_10"
android:layout_marginTop=
"@dimen/dp_7"
android:textColor=
"@color/color_ff333333"
android:textSize=
"@dimen/sp_16"
android:text=
"@string/annotation_vehicle_no"
/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_2"
>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/dp_10"
android:background=
"@drawable/background_view_annotation_other_vehicle_speed"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/annotationOtherVehicleSpeed"
style=
"@style/OtherVehicleSpeed"
android:layout_width=
"@dimen/dp_30"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:layout_marginStart=
"@dimen/dp_8"
android:textSize=
"@dimen/sp_16"
android:text=
"24"
/>
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/OtherVehicleSpeed"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:textSize=
"@dimen/sp_10"
android:text=
"@string/current_speed_unit"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/dp_5"
android:background=
"@drawable/background_view_annotation_other_vehicle_distance"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/annotationOtherVehicleDistance"
style=
"@style/OtherVehicleDistance"
android:layout_width=
"@dimen/dp_30"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:layout_marginStart=
"@dimen/dp_8"
android:textSize=
"@dimen/sp_16"
android:text=
"25"
/>
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/OtherVehicleDistance"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:textSize=
"@dimen/sp_10"
android:text=
"@string/other_distance_unit"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file
app/src/main/res/values-night/themes.xml
View file @
caa4d969
...
@@ -47,4 +47,10 @@
...
@@ -47,4 +47,10 @@
<item
name=
"android:maxLength"
>
8
</item>
<item
name=
"android:maxLength"
>
8
</item>
<item
name=
"android:textSize"
>
10sp
</item>
<item
name=
"android:textSize"
>
10sp
</item>
</style>
</style>
<style
name=
"OtherVehicleSpeed"
parent=
"Theme.HTAnticollision"
>
<item
name=
"android:textColor"
>
@color/color_ffebf0ff
</item>
</style>
<style
name=
"OtherVehicleDistance"
parent=
"Theme.HTAnticollision"
>
<item
name=
"android:textColor"
>
@color/color_ffffdbc7
</item>
</style>
</resources>
</resources>
\ No newline at end of file
app/src/main/res/values/colors.xml
View file @
caa4d969
...
@@ -33,4 +33,16 @@
...
@@ -33,4 +33,16 @@
<color
name=
"color_1a000000"
>
#1a000000
</color>
<color
name=
"color_1a000000"
>
#1a000000
</color>
<color
name=
"color_ff3684F9"
>
#ff3684F9
</color>
<color
name=
"color_ff3684F9"
>
#ff3684F9
</color>
<color
name=
"color_green"
>
#00ff00
</color>
<color
name=
"color_green"
>
#00ff00
</color>
<color
name=
"color_ff005aff"
>
#ff005aff
</color>
<color
name=
"color_e6114da5"
>
#e6114da5
</color>
<color
name=
"color_cc1c1c1c"
>
#cc1c1c1c
</color>
<color
name=
"color_333684f9"
>
#333684f9
</color>
<color
name=
"color_33f97c36"
>
#33f97c36
</color>
<color
name=
"color_803684f9"
>
#803684f9
</color>
<color
name=
"color_80f97c36"
>
#80f97c36
</color>
<color
name=
"color_1352C5"
>
#1352C5
</color>
<color
name=
"color_ffebf0ff"
>
#ffebf0ff
</color>
<color
name=
"color_fff06313"
>
#fff06313
</color>
<color
name=
"color_ffffdbc7"
>
#ffffdbc7
</color>
</resources>
</resources>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
caa4d969
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
<string
name=
"today_illegally_text"
>
%1d\n违章/警告(次)
</string>
<string
name=
"today_illegally_text"
>
%1d\n违章/警告(次)
</string>
<string
name=
"current_speed2"
>
32
</string>
<string
name=
"current_speed2"
>
32
</string>
<string
name=
"current_speed_unit"
>
km/h
</string>
<string
name=
"current_speed_unit"
>
km/h
</string>
<string
name=
"other_distance_unit"
>
m
</string>
<string
name=
"toggle_more"
>
toggle more
</string>
<string
name=
"toggle_more"
>
toggle more
</string>
<string
name=
"work_status_edit"
>
修改
</string>
<string
name=
"work_status_edit"
>
修改
</string>
<string
name=
"work_status_mark"
>
当前
</string>
<string
name=
"work_status_mark"
>
当前
</string>
...
@@ -71,6 +72,8 @@
...
@@ -71,6 +72,8 @@
<string
name=
"collect_data_text"
>
采集状态:%1s 采集点数:%2d 速度:%3dKM/h 当前位置:%4f,%5f 高程:%6fm
</string>
<string
name=
"collect_data_text"
>
采集状态:%1s 采集点数:%2d 速度:%3dKM/h 当前位置:%4f,%5f 高程:%6fm
</string>
<string
name=
"confirm"
>
确定
</string>
<string
name=
"confirm"
>
确定
</string>
<string
name=
"cancel"
>
取消
</string>
<string
name=
"cancel"
>
取消
</string>
<string
name=
"annotation_vehicle_no"
>
编号:%1s
</string>
<string
name=
"annotation_vehicle_speed"
>
时速:%1d km/h
</string>
<string-array
name=
"collectRange"
>
<string-array
name=
"collectRange"
>
...
...
app/src/main/res/values/themes.xml
View file @
caa4d969
...
@@ -63,4 +63,10 @@
...
@@ -63,4 +63,10 @@
<item
name=
"android:clickable"
>
true
</item>
<item
name=
"android:clickable"
>
true
</item>
<item
name=
"android:focusable"
>
true
</item>
<item
name=
"android:focusable"
>
true
</item>
</style>
</style>
<style
name=
"OtherVehicleSpeed"
parent=
"Theme.HTAnticollision"
>
<item
name=
"android:textColor"
>
@color/color_1352C5
</item>
</style>
<style
name=
"OtherVehicleDistance"
parent=
"Theme.HTAnticollision"
>
<item
name=
"android:textColor"
>
@color/color_fff06313
</item>
</style>
</resources>
</resources>
\ No newline at end of file
build.gradle
View file @
caa4d969
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins
{
plugins
{
id
'com.android.application'
version
'
7.4.2
'
apply
false
id
'com.android.application'
version
'
8.0.1
'
apply
false
id
'com.android.library'
version
'
7.4.2
'
apply
false
id
'com.android.library'
version
'
8.0.1
'
apply
false
id
'org.jetbrains.kotlin.android'
version
'1.8.0'
apply
false
id
'org.jetbrains.kotlin.android'
version
'1.8.0'
apply
false
id
'com.google.dagger.hilt.android'
version
'2.44'
apply
false
id
'com.google.dagger.hilt.android'
version
'2.44'
apply
false
}
}
\ No newline at end of file
gradle.properties
View file @
caa4d969
...
@@ -22,4 +22,6 @@ kotlin.code.style=official
...
@@ -22,4 +22,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass
=
true
android.nonTransitiveRClass
=
true
MAPBOX_DOWNLOADS_TOKEN
=
sk.eyJ1IjoibWFybGxlciIsImEiOiJjbGVjNHZhdWgwd3U4M29uMjJrY3BqYXpkIn0.cqcw1CHYVGwESBqsfWcm7w
MAPBOX_DOWNLOADS_TOKEN
=
sk.eyJ1IjoibWFybGxlciIsImEiOiJjbGVjNHZhdWgwd3U4M29uMjJrY3BqYXpkIn0.cqcw1CHYVGwESBqsfWcm7w
\ No newline at end of file
android.defaults.buildfeatures.buildconfig
=
true
android.nonFinalResIds
=
false
\ No newline at end of file
gradle/wrapper/gradle-wrapper.properties
View file @
caa4d969
#Thu May 04 15:47:53 CST 2023
#Thu May 04 15:47:53 CST 2023
distributionBase
=
GRADLE_USER_HOME
distributionBase
=
GRADLE_USER_HOME
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
7.5
-bin.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
8.0
-bin.zip
distributionPath
=
wrapper/dists
distributionPath
=
wrapper/dists
zipStorePath
=
wrapper/dists
zipStorePath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStoreBase
=
GRADLE_USER_HOME
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