Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
MapMultiEngine
Commits
a3f59a6e
Commit
a3f59a6e
authored
Nov 04, 2025
by
p x
Browse files
加入预警和感知物管理类
parent
3ebc9c25
Changes
17
Hide whitespace changes
Inline
Side-by-side
.idea/misc.xml
View file @
a3f59a6e
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ExternalStorageConfigurationManager"
enabled=
"true"
/>
<component
name=
"ExternalStorageConfigurationManager"
enabled=
"true"
/>
<component
name=
"JavadocGenerationManager"
>
<component
name=
"JavadocGenerationManager"
>
...
...
app/src/main/java/com/sd/demo/ui/OnLineMapActivity.kt
View file @
a3f59a6e
...
@@ -9,7 +9,7 @@ import com.sd.api.maps.MethodAdv
...
@@ -9,7 +9,7 @@ import com.sd.api.maps.MethodAdv
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.VehicleModel
import
com.sd.api.scenario.VehicleModel
import
com.sd.api.scenario.VehiclePos
import
com.sd.api.scenario.
bean.
VehiclePos
import
com.sd.api.ui.MapMultiView.OnMapReadyLis
import
com.sd.api.ui.MapMultiView.OnMapReadyLis
import
com.sd.api.ui.MapReadyView
import
com.sd.api.ui.MapReadyView
import
com.sd.demo.bean.mock.MRoutes
import
com.sd.demo.bean.mock.MRoutes
...
...
app/src/main/java/com/sd/demo/ui/PartRoadActivity.kt
View file @
a3f59a6e
...
@@ -12,7 +12,10 @@ import com.sd.api.parkroad.OnPrAddCar
...
@@ -12,7 +12,10 @@ import com.sd.api.parkroad.OnPrAddCar
import
com.sd.api.parkroad.PartType
import
com.sd.api.parkroad.PartType
import
com.sd.api.parkroad.PtcBean
import
com.sd.api.parkroad.PtcBean
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.VehiclePos
import
com.sd.api.scenario.PerceptionManager
import
com.sd.api.scenario.V2xWarn
import
com.sd.api.scenario.bean.Percept
import
com.sd.api.scenario.bean.VehiclePos
import
com.sd.api.ui.MapMultiView.OnMapReadyLis
import
com.sd.api.ui.MapMultiView.OnMapReadyLis
import
com.sd.api.ui.MapReadyView
import
com.sd.api.ui.MapReadyView
import
com.sd.demo.bean.mock.MRoutes
import
com.sd.demo.bean.mock.MRoutes
...
@@ -39,7 +42,7 @@ class PartRoadActivity : AppCompatActivity() {
...
@@ -39,7 +42,7 @@ class PartRoadActivity : AppCompatActivity() {
override
fun
onMapReady
(
mapReadyView
:
MapReadyView
)
{
override
fun
onMapReady
(
mapReadyView
:
MapReadyView
)
{
this
@PartRoadActivity
.
mapReadView
=
mapReadyView
this
@PartRoadActivity
.
mapReadView
=
mapReadyView
//初始化局部视图控制器
//初始化局部视图控制器
MsParkRoad
.
setCarRoadVM
(
mapReadView
)
//
MsParkRoad.setCarRoadVM(mapReadView)
}
}
})
})
setLis
()
setLis
()
...
@@ -74,15 +77,15 @@ class PartRoadActivity : AppCompatActivity() {
...
@@ -74,15 +77,15 @@ class PartRoadActivity : AppCompatActivity() {
//mark点
//mark点
binding
.
bt6
.
setOnClickListener
{
binding
.
bt6
.
setOnClickListener
{
lifecycleScope
.
launch
{
lifecycleScope
.
launch
{
MsParkRoad
.
show
Mark
er
(
1
)
V2xWarn
.
setWarn
Mark
(
1
)
delay
(
2000
)
delay
(
2000
)
MsParkRoad
.
show
Mark
er
(
2
)
V2xWarn
.
setWarn
Mark
(
2
)
delay
(
2000
)
delay
(
2000
)
MsParkRoad
.
show
Mark
er
(
3
)
V2xWarn
.
setWarn
Mark
(
3
)
delay
(
2000
)
delay
(
2000
)
MsParkRoad
.
show
Mark
er
(
0
)
V2xWarn
.
setWarn
Mark
(
0
)
delay
(
2000
)
delay
(
2000
)
MsParkRoad
.
show
Mark
er
(-
1
)
V2xWarn
.
setWarn
Mark
(-
1
)
}
}
}
}
//预警雷达
//预警雷达
...
@@ -100,15 +103,16 @@ class PartRoadActivity : AppCompatActivity() {
...
@@ -100,15 +103,16 @@ class PartRoadActivity : AppCompatActivity() {
//预警车
//预警车
binding
.
bt9
.
setOnClickListener
{
binding
.
bt9
.
setOnClickListener
{
lifecycleScope
.
launch
{
lifecycleScope
.
launch
{
MsParkRoad
.
warnAlerm
(
"f117fdfa-feff-0100-85dc-35850000acb1"
,
true
,
0
)
V2xWarn
.
setWarning
(
"f117fdfa-feff-0100-85dc-35850000acb1"
)
delay
(
5000
)
delay
(
5000
)
MsParkRoad
.
warnAlerm
(
"f117fdfa-feff-0100-85dc-35850000acb1"
,
false
,
0
)
V2xWarn
.
stopWarning
(
)
}
}
}
}
//清除感知物
//清除感知物
binding
.
bt10
.
setOnClickListener
{
binding
.
bt10
.
setOnClickListener
{
// MsParkRoad.warnAlerm("50332456-3030-3030-3530-303334533954", true, 5)
// MsParkRoad.clearAllTargets()
MsParkRoad
.
clearAllTargets
()
//清除所有感知物
PerceptionManager
.
clearAllPerception
()
}
}
//预加载主车
//预加载主车
binding
.
bt11
.
setOnClickListener
{
binding
.
bt11
.
setOnClickListener
{
...
@@ -179,21 +183,21 @@ class PartRoadActivity : AppCompatActivity() {
...
@@ -179,21 +183,21 @@ class PartRoadActivity : AppCompatActivity() {
var
parts
=
perceptionBean
.
flatMap
{
it
->
it
.
participants
}
var
parts
=
perceptionBean
.
flatMap
{
it
->
it
.
participants
}
//转化sdk可用的感知物
//转化sdk可用的感知物
var
pres
=
parts
.
map
{
it
->
var
pres
=
parts
.
map
{
it
->
P
tcBean
().
apply
{
P
ercept
().
apply
{
ptc
I
d
=
it
.
ptcId
ptc
i
d
=
it
.
ptcId
if
(
it
.
ptcType
==
"car"
)
{
if
(
it
.
ptcType
==
"car"
)
{
p
tc
Type
=
1
pType
=
1
}
else
if
(
it
.
ptcType
==
"pedestrian"
)
{
}
else
if
(
it
.
ptcType
==
"pedestrian"
)
{
p
tc
Type
=
2
pType
=
2
}
else
{
}
else
{
p
tc
Type
=
1
pType
=
1
}
}
lat
=
it
.
latitude
lat
=
it
.
latitude
ln
g
=
it
.
longitude
l
o
n
=
it
.
longitude
heading
=
it
.
heading
heading
=
it
.
heading
}
}
}
}
MsParkRoad
.
upDatePreTarget
(
pres
)
PerceptionManager
.
upPerception
(
pres
,
1
)
delay
(
1000
)
delay
(
1000
)
}
}
}
catch
(
e
:
CancellationException
)
{
}
catch
(
e
:
CancellationException
)
{
...
...
app/src/main/java/com/sd/demo/ui/THighMapActivity.kt
View file @
a3f59a6e
...
@@ -12,7 +12,10 @@ import com.sd.api.highmap.WarnPtc
...
@@ -12,7 +12,10 @@ import com.sd.api.highmap.WarnPtc
import
com.sd.api.maps.MSCalcuMapUtil
import
com.sd.api.maps.MSCalcuMapUtil
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.VehiclePos
import
com.sd.api.scenario.PerceptionManager
import
com.sd.api.scenario.V2xWarn
import
com.sd.api.scenario.bean.Percept
import
com.sd.api.scenario.bean.VehiclePos
import
com.sd.api.ui.MapMultiView.OnMapReadyLis
import
com.sd.api.ui.MapMultiView.OnMapReadyLis
import
com.sd.api.ui.MapReadyView
import
com.sd.api.ui.MapReadyView
import
com.sd.demo.bean.mock.MRoutes
import
com.sd.demo.bean.mock.MRoutes
...
@@ -63,15 +66,15 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -63,15 +66,15 @@ class THighMapActivity : AppCompatActivity() {
var
str
=
var
str
=
FileIoUtils
.
getAsset
(
this
@THighMapActivity
,
"mock/Car_fangzhen.txt"
)
FileIoUtils
.
getAsset
(
this
@THighMapActivity
,
"mock/Car_fangzhen.txt"
)
val
mRoutes
=
gson
.
fromJson
<
MRoutes
>(
str
,
MRoutes
::
class
.
java
)
val
mRoutes
=
gson
.
fromJson
<
MRoutes
>(
str
,
MRoutes
::
class
.
java
)
//画出全局路径
//画出
车辆
全局路径
var
lines
=
mRoutes
.
rs
.
map
{
var
lines
=
mRoutes
.
rs
.
map
{
AllLine
(
it
[
1
],
it
[
0
])
AllLine
(
it
[
1
],
it
[
0
])
}
}
//
HighMapApi.setCarNavPath(lines, showdistance = 200)
//车辆路径特效对象
var
carNavPath
=
CarNavPath
().
apply
{
var
carNavPath
=
CarNavPath
().
apply
{
this
.
lines
=
lines
this
.
lines
=
lines
}
}
//设置
全局
路径
//设置
车辆
路径
CucsVehicle
.
setCarNaiPath
(
carNavPath
)
CucsVehicle
.
setCarNaiPath
(
carNavPath
)
//模拟车辆移动
//模拟车辆移动
var
head
=
0.0
var
head
=
0.0
...
@@ -88,6 +91,7 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -88,6 +91,7 @@ class THighMapActivity : AppCompatActivity() {
if
((
head
-
oldHead
).
absoluteValue
<
45
)
{
if
((
head
-
oldHead
).
absoluteValue
<
45
)
{
bearing
=
head
bearing
=
head
}
}
//车辆位置
VehiclePos
.
instance
.
apply
{
VehiclePos
.
instance
.
apply
{
lat
=
pc
[
1
]
lat
=
pc
[
1
]
lng
=
pc
[
0
]
lng
=
pc
[
0
]
...
@@ -95,7 +99,8 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -95,7 +99,8 @@ class THighMapActivity : AppCompatActivity() {
evel
=
20.80189
evel
=
20.80189
}
}
}
}
if
(
index
>
10
){
if
(
index
>
10
)
{
// 清除车辆路径
CucsVehicle
.
clearCarNaiPath
()
CucsVehicle
.
clearCarNaiPath
()
}
}
// HighMapApi.setCarPosition(head, it[1], it[0], 20.80189)
// HighMapApi.setCarPosition(head, it[1], it[0], 20.80189)
...
@@ -115,9 +120,9 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -115,9 +120,9 @@ class THighMapActivity : AppCompatActivity() {
val
perceptionBean
=
val
perceptionBean
=
gson
.
fromJson
<
PerceptionBean
>(
str
,
PerceptionBean
::
class
.
java
)
gson
.
fromJson
<
PerceptionBean
>(
str
,
PerceptionBean
::
class
.
java
)
var
parts
=
perceptionBean
.
flatMap
{
it
->
it
.
participants
}
var
parts
=
perceptionBean
.
flatMap
{
it
->
it
.
participants
}
//将感知物转成
API
能用的类型
//将感知物转成
sdk
能用的类型
var
pres
=
parts
.
map
{
it
->
var
pres
=
parts
.
map
{
it
->
UnityPtc
().
apply
{
Percept
().
apply
{
ptcid
=
it
.
ptcId
ptcid
=
it
.
ptcId
if
(
it
.
ptcType
==
"car"
)
{
if
(
it
.
ptcType
==
"car"
)
{
pType
=
1
pType
=
1
...
@@ -129,7 +134,10 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -129,7 +134,10 @@ class THighMapActivity : AppCompatActivity() {
heading
=
it
.
heading
heading
=
it
.
heading
}
}
}
}
HighMap
.
setPtcData
(
pres
)
/**更新感知物位置
* @param percepts 感知物列表
* @param upSoap(更新范围) 1:更新局部图感知物 2:更新高精图感知物 3:包含两者*/
PerceptionManager
.
upPerception
(
pres
,
2
)
delay
(
1000
)
delay
(
1000
)
}
}
...
@@ -151,17 +159,15 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -151,17 +159,15 @@ class THighMapActivity : AppCompatActivity() {
//开启预警特效
//开启预警特效
fun
startWarning
(
ptcId
:
String
)
{
fun
startWarning
(
ptcId
:
String
)
{
lifecycleScope
.
launch
{
lifecycleScope
.
launch
{
var
warnPtc
=
WarnPtc
().
apply
{
// * @param ptcId 感知物ID
ptcid
=
ptcId
// * @param time 感知物闪烁时间 0=不闪烁
isRed
=
true
// * @param dirent 雷达方向0=关闭 1=左前 2=正前 3=右前 4=右后 5=正后 6=左后
}
V2xWarn
.
setWarning
(
ptcId
,
0
,
2
)
var
warns
=
listOf
(
warnPtc
)
HighMap
.
setWarnPtc
(
warns
)
delay
(
5000
)
delay
(
5000
)
warnPtc
.
isRed
=
false
//停止预警
HighMap
.
setWarnPtc
(
warns
)
V2xWarn
.
stopWarning
(
)
}
}
toggleCircleRadar
(
2
)
//
toggleCircleRadar(2)
}
}
...
@@ -169,7 +175,7 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -169,7 +175,7 @@ class THighMapActivity : AppCompatActivity() {
* @param dirent 0=关闭 1=左前 2=正前 3=右前 4=右后 5=正后 6=左后
* @param dirent 0=关闭 1=左前 2=正前 3=右前 4=右后 5=正后 6=左后
* */
* */
fun
toggleCircleRadar
(
dirent
:
Int
)
{
fun
toggleCircleRadar
(
dirent
:
Int
)
{
HighMap
.
setCarBottomCircle
(
true
)
//
HighMap.setCarBottomCircle(true)
HighMap
.
setCarRadarDirection
(
dirent
)
HighMap
.
setCarRadarDirection
(
dirent
)
lifecycleScope
.
launch
{
lifecycleScope
.
launch
{
delay
(
5000
)
delay
(
5000
)
...
...
mapapi/build.gradle.kts
View file @
a3f59a6e
import
org.gradle.language.nativeplatform.internal.Dimensions.applicationVariants
plugins
{
plugins
{
alias
(
libs
.
plugins
.
android
.
library
)
alias
(
libs
.
plugins
.
android
.
library
)
alias
(
libs
.
plugins
.
kotlin
.
android
)
alias
(
libs
.
plugins
.
kotlin
.
android
)
...
@@ -15,6 +17,7 @@ android {
...
@@ -15,6 +17,7 @@ android {
namespace
=
"com.sd.api"
namespace
=
"com.sd.api"
compileSdk
=
35
compileSdk
=
35
defaultConfig
{
defaultConfig
{
minSdk
=
29
minSdk
=
29
...
...
mapapi/src/main/java/com/sd/api/fragments/PartRoadFragment.kt
View file @
a3f59a6e
...
@@ -55,7 +55,9 @@ class PartRoadFragment : Fragment() {
...
@@ -55,7 +55,9 @@ class PartRoadFragment : Fragment() {
// carRoadVM.webViewClient?.preloadMainCar(requireActivity().assets.open("truck.glb")) { v: Boolean ->
// carRoadVM.webViewClient?.preloadMainCar(requireActivity().assets.open("truck.glb")) { v: Boolean ->
// println("-----------v = ${v}")
// println("-----------v = ${v}")
// }
// }
//初始化局部视图控制器
MapReadyView
.
instance
.
carRoadVM
=
carRoadVM
MapReadyView
.
instance
.
carRoadVM
=
carRoadVM
MsParkRoad
.
setCarRoadVM
(
MapReadyView
.
instance
)
onMapReadyLis
?.
onMapReady
(
MapReadyView
.
instance
)
onMapReadyLis
?.
onMapReady
(
MapReadyView
.
instance
)
}
}
...
...
mapapi/src/main/java/com/sd/api/highmap/HighMap.kt
View file @
a3f59a6e
...
@@ -214,6 +214,8 @@ object HighMap :MsOperationParent() {
...
@@ -214,6 +214,8 @@ object HighMap :MsOperationParent() {
fun
setWarnPtc
(
warnPtc
:
List
<
WarnPtc
>)
{
fun
setWarnPtc
(
warnPtc
:
List
<
WarnPtc
>)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
if
(!
isLoadUnityPlayer
())
return
UnityPlayer
.
UnitySendMessage
(
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
MODELNAME
,
"SetWarnPre"
,
"SetWarnPre"
,
...
...
mapapi/src/main/java/com/sd/api/maps/MSNavi.kt
View file @
a3f59a6e
...
@@ -14,6 +14,8 @@ import com.sd.api.ui.MapReadyView
...
@@ -14,6 +14,8 @@ import com.sd.api.ui.MapReadyView
* 导航相关
* 导航相关
*/
*/
object
MSNavi
{
object
MSNavi
{
/**是否开启导航**/
var
mStartNav
=
false
fun
init
()
{
fun
init
()
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
...
...
mapapi/src/main/java/com/sd/api/maps/mine/MineNai.kt
View file @
a3f59a6e
...
@@ -28,7 +28,7 @@ import com.sd.api.ui.MapReadyView
...
@@ -28,7 +28,7 @@ import com.sd.api.ui.MapReadyView
import
com.sd.api.ui.MineNaiDirActivity
import
com.sd.api.ui.MineNaiDirActivity
/**
/**
* 四维导航
* 四维导航
实现
*/
*/
object
MineNai
{
object
MineNai
{
...
...
mapapi/src/main/java/com/sd/api/parkroad/MsParkRoad.kt
View file @
a3f59a6e
...
@@ -157,7 +157,8 @@ object MsParkRoad : MsOperationParent() {
...
@@ -157,7 +157,8 @@ object MsParkRoad : MsOperationParent() {
}
}
}
}
/**预警特效
/**
* 预警特效(单个)
* @param ptcId 感知物id
* @param ptcId 感知物id
* @param isRed 是否变红
* @param isRed 是否变红
* @param time 动画持续时间
* @param time 动画持续时间
...
@@ -165,8 +166,21 @@ object MsParkRoad : MsOperationParent() {
...
@@ -165,8 +166,21 @@ object MsParkRoad : MsOperationParent() {
fun
warnAlerm
(
ptcId
:
String
,
isRed
:
Boolean
,
time
:
Int
)
{
fun
warnAlerm
(
ptcId
:
String
,
isRed
:
Boolean
,
time
:
Int
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
var
car
=
Alarm
(
ptcId
,
isRed
,
time
)
var
alarm
=
Alarm
(
ptcId
,
isRed
,
time
)
carRoadVM
?.
webViewClient
?.
setAlarms
(
listOf
(
car
),
null
)
carRoadVM
?.
webViewClient
?.
setAlarms
(
listOf
(
alarm
),
null
)
}
MAP_TYPE
.
AMAP
->
{
}
}
}
/**
* 预警特效批量
*/
fun
warnAlerms
(
alarms
:
List
<
Alarm
>)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
carRoadVM
?.
webViewClient
?.
setAlarms
(
alarms
,
null
)
}
}
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
...
@@ -218,7 +232,7 @@ object MsParkRoad : MsOperationParent() {
...
@@ -218,7 +232,7 @@ object MsParkRoad : MsOperationParent() {
}
}
/**预加载主车
/**预加载主车
* @param fileName 模型文件
名称
* @param fileName 模型文件
路径
*/
*/
fun
preloadMainCar
(
assets
:
AssetManager
,
fileName
:
String
)
{
fun
preloadMainCar
(
assets
:
AssetManager
,
fileName
:
String
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
...
@@ -233,7 +247,10 @@ object MsParkRoad : MsOperationParent() {
...
@@ -233,7 +247,10 @@ object MsParkRoad : MsOperationParent() {
}
}
}
}
/**预加载感知物***/
/**
* 预加载感知物
* @param fileName 模型文件路径
*/
fun
preloadParticipant
(
assets
:
AssetManager
,
fileName
:
String
,
ptcType
:
PartType
)
{
fun
preloadParticipant
(
assets
:
AssetManager
,
fileName
:
String
,
ptcType
:
PartType
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
...
...
mapapi/src/main/java/com/sd/api/scenario/CucsVehicle.kt
View file @
a3f59a6e
package
com.sd.api.scenario
package
com.sd.api.scenario
import
androidx.lifecycle.viewModelScope
import
com.minedata.minenavi.mapdal.LatLng
import
com.minedata.minenavi.mapdal.LatLng
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.highmap.CarNavPath
import
com.sd.api.highmap.CarNavPath
import
com.sd.api.highmap.HighMap
import
com.sd.api.highmap.HighMap
import
com.sd.api.highmap.HighPos
import
com.sd.api.highmap.HighPos
import
com.sd.api.parkroad.MsParkRoad
import
com.sd.api.parkroad.MsParkRoad
import
com.sd.api.parkroad.RoadPos
import
com.sd.api.parkroad.RoadPos
import
com.sd.api.scenario.bean.VehiclePos
import
com.sd.api.utils.SmoothMoveUtils
import
com.sd.api.utils.SmoothMoveUtils
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
...
@@ -15,6 +17,7 @@ import kotlinx.coroutines.launch
...
@@ -15,6 +17,7 @@ import kotlinx.coroutines.launch
/**车辆管理类***/
/**车辆管理类***/
object
CucsVehicle
{
object
CucsVehicle
{
//控制车辆是否暂停移动
private
var
stopCar
=
false
private
var
stopCar
=
false
//动画是否开始
//动画是否开始
...
@@ -39,21 +42,34 @@ object CucsVehicle {
...
@@ -39,21 +42,34 @@ object CucsVehicle {
*/
*/
fun
moveCar
(
vPos
:
VehiclePos
,
moveType
:
Int
)
{
fun
moveCar
(
vPos
:
VehiclePos
,
moveType
:
Int
)
{
cvPos
=
vPos
cvPos
=
vPos
var
highPos
=
HighPos
.
instance
.
apply
{
if
(
stopCar
)
heading
=
vPos
.
heading
return
lat
=
vPos
.
lat
when
(
MSDKInitializer
.
getMapType
())
{
lon
=
vPos
.
lng
MAP_TYPE
.
MINE
->
{
evel
=
vPos
.
evel
mineCarMove
(
vPos
,
moveType
)
}
}
var
roadPos
=
RoadPos
.
instance
.
apply
{
lat
=
vPos
.
lat
MAP_TYPE
.
AMAP
->
{
lng
=
vPos
.
lng
}
bearing
=
vPos
.
heading
.
toFloat
()
}
}
}
//四维实现
private
fun
mineCarMove
(
vPos
:
VehiclePos
,
moveType
:
Int
)
{
if
(
moveType
==
1
)
{
if
(
moveType
==
1
)
{
var
highPos
=
HighPos
.
instance
.
apply
{
heading
=
vPos
.
heading
lat
=
vPos
.
lat
lon
=
vPos
.
lng
evel
=
vPos
.
evel
}
HighMap
.
setCarPosition
(
highPos
)
HighMap
.
setCarPosition
(
highPos
)
}
else
if
(
moveType
==
2
)
{
}
else
if
(
moveType
==
2
)
{
var
roadPos
=
RoadPos
.
instance
.
apply
{
lat
=
vPos
.
lat
lng
=
vPos
.
lng
bearing
=
vPos
.
heading
.
toFloat
()
}
MsParkRoad
.
updateMainCar
(
roadPos
,
null
)
MsParkRoad
.
updateMainCar
(
roadPos
,
null
)
}
else
if
(
moveType
==
3
)
{
}
else
if
(
moveType
==
3
)
{
if
(
fromLoc
==
null
||
fromLoc
?.
lng
==
0.0
)
{
if
(
fromLoc
==
null
||
fromLoc
?.
lng
==
0.0
)
{
...
@@ -73,6 +89,7 @@ object CucsVehicle {
...
@@ -73,6 +89,7 @@ object CucsVehicle {
}
}
}
}
//在线地图主车平滑移动
//在线地图主车平滑移动
private
var
sCarSmooth
=
object
:
SmoothMoveUtils
.
OnPositionUpdateListener
{
private
var
sCarSmooth
=
object
:
SmoothMoveUtils
.
OnPositionUpdateListener
{
override
fun
onUpdate
(
override
fun
onUpdate
(
...
@@ -119,16 +136,18 @@ object CucsVehicle {
...
@@ -119,16 +136,18 @@ object CucsVehicle {
}
}
}
}
/**
/**停止车辆移动*/
* 停止车辆移动
*/
fun
stopCar
()
{
fun
stopCar
()
{
stopCar
=
true
stopCar
=
true
}
}
fun
resumeCarMove
()
{
stopCar
=
false
}
/**
/**
*
设置
车辆移动路径
*
绘制
车辆移动路径
* @param carNavPath
* @param carNavPath
*/
*/
fun
setCarNaiPath
(
carNavPath
:
CarNavPath
)
{
fun
setCarNaiPath
(
carNavPath
:
CarNavPath
)
{
...
@@ -136,7 +155,7 @@ object CucsVehicle {
...
@@ -136,7 +155,7 @@ object CucsVehicle {
}
}
/**
/**
* 清除
导航
路径
* 清除
车辆移动
路径
*/
*/
fun
clearCarNaiPath
()
{
fun
clearCarNaiPath
()
{
var
carNavPath
=
CarNavPath
()
var
carNavPath
=
CarNavPath
()
...
...
mapapi/src/main/java/com/sd/api/scenario/PerceptionManager.kt
0 → 100644
View file @
a3f59a6e
package
com.sd.api.scenario
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.highmap.HighMap
import
com.sd.api.highmap.UnityPtc
import
com.sd.api.parkroad.MsParkRoad
import
com.sd.api.parkroad.PtcBean
import
com.sd.api.scenario.bean.Percept
/***感知物管理**/
object
PerceptionManager
{
/**更新感知物位置
* @param percepts 感知物列表
* @param upSoap(更新范围) 1:更新局部图感知物 2:更新高精图感知物 3:包含两者
*/
fun
upPerception
(
percepts
:
List
<
Percept
>,
upSoap
:
Int
)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
if
(
upSoap
==
1
)
{
refreshParkPerception
(
percepts
)
}
else
if
(
upSoap
==
2
)
{
refreshHighPerception
(
percepts
)
}
else
if
(
upSoap
==
3
)
{
refreshParkPerception
(
percepts
)
refreshHighPerception
(
percepts
)
}
}
MAP_TYPE
.
AMAP
->
{
}
}
}
//刷新局部图感知物
private
fun
refreshParkPerception
(
percepts
:
List
<
Percept
>)
{
//转化sdk可用的感知物
var
pres
=
percepts
.
map
{
it
->
PtcBean
().
apply
{
ptcId
=
it
.
ptcid
ptcType
=
it
.
pType
lat
=
it
.
lat
lng
=
it
.
lon
heading
=
it
.
heading
}
}
MsParkRoad
.
upDatePreTarget
(
pres
)
}
//刷新高精图感知物
private
fun
refreshHighPerception
(
percepts
:
List
<
Percept
>)
{
var
pres
=
percepts
.
map
{
it
->
UnityPtc
().
apply
{
ptcid
=
it
.
ptcid
pType
=
it
.
pType
lat
=
it
.
lat
lon
=
it
.
lon
heading
=
it
.
heading
}
}
HighMap
.
setPtcData
(
pres
)
}
/***清除所有感知物**/
fun
clearAllPerception
()
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MsParkRoad
.
clearAllTargets
()
HighMap
.
setPtcData
(
emptyList
())
}
MAP_TYPE
.
AMAP
->
{
}
}
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/V2xWarn.kt
0 → 100644
View file @
a3f59a6e
package
com.sd.api.scenario
import
com.example.car_and_road_3d.models.Alarm
import
com.sd.api.highmap.HighMap
import
com.sd.api.highmap.WarnPtc
import
com.sd.api.parkroad.MsParkRoad
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
/**预警管理类***/
object
V2xWarn
{
//高精地图预警对象
private
var
warnPtcs
=
mutableListOf
<
WarnPtc
>()
//局部地图预警对象
private
var
alarms
=
mutableListOf
<
Alarm
>()
/**
* 感知物预警(批量)
*/
fun
setWarningBatch
(
ptcIds
:
List
<
String
>,
time
:
Int
=
0
,
dirent
:
Int
=
0
)
{
startWarning
(
ptcIds
,
time
,
dirent
)
}
/**
* 感知物预警(单个)
* @param ptcId 感知物ID列表
* @param time 感知物闪烁时间 0=不闪烁
* @param dirent 雷达方向0=关闭 1=左前 2=正前 3=右前 4=右后 5=正后 6=左后
*/
fun
setWarning
(
ptcId
:
String
,
time
:
Int
=
0
,
dirent
:
Int
=
0
)
{
startWarning
(
listOf
(
ptcId
),
time
,
dirent
)
}
/***停止预警***/
fun
stopWarning
()
{
warnPtcs
.
forEach
{
it
.
isRed
=
false
it
.
isFlash
=
false
it
.
aniTime
=
0L
}
alarms
.
forEach
{
it
.
isAlarm
=
false
it
.
time
=
0
}
HighMap
.
setWarnPtc
(
warnPtcs
)
MsParkRoad
.
warnAlerms
(
alarms
)
}
private
fun
startWarning
(
ptcId
:
List
<
String
>,
time
:
Int
,
dirent
:
Int
)
{
warnPtcs
.
clear
()
alarms
.
clear
()
ptcId
.
forEach
{
ptcId
->
//构造高精地体预警类
warnPtcs
.
add
(
WarnPtc
().
apply
{
this
.
ptcid
=
ptcId
this
.
isRed
=
true
if
(
time
>
0
)
{
this
.
aniTime
=
time
.
toLong
()
this
.
isFlash
=
true
}
})
//构造局部地图预警类
alarms
.
add
(
Alarm
().
apply
{
this
.
participantId
=
ptcId
this
.
isAlarm
=
false
if
(
time
>
0
)
{
this
.
isAlarm
=
true
this
.
time
=
time
}
})
}
//高精图预警
HighMap
.
setWarnPtc
(
warnPtcs
)
CoroutineScope
(
Dispatchers
.
Main
).
launch
{
HighMap
.
setCarRadarDirection
(
dirent
)
HighMap
.
setCarBottomCircle
(
true
)
delay
(
5000
)
HighMap
.
setCarBottomCircle
(
false
)
HighMap
.
setCarRadarDirection
(
0
)
}
//局部图预警
MsParkRoad
.
warnAlerms
(
alarms
)
CoroutineScope
(
Dispatchers
.
Main
).
launch
{
MsParkRoad
.
toggleRadar
(
true
)
delay
(
5000
)
MsParkRoad
.
toggleRadar
(
false
)
}
}
/**
* 设置局部图预警点
* @param marker 1:结冰 2:施工 3:交叉路口慢行
* */
fun
setWarnMark
(
mark
:
Int
)
{
MsParkRoad
.
showMarker
(
mark
)
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/VehicleModel.kt
View file @
a3f59a6e
package
com.sd.api.scenario
package
com.sd.api.scenario
import
android.util.Log
import
androidx.lifecycle.viewModelScope
import
com.minedata.minenavi.map.Model
import
com.minedata.minenavi.map.ModelOptions
import
com.minedata.minenavi.map.Overlay
import
com.minedata.minenavi.mapdal.LatLng
import
com.sd.api.MAP_TYPE
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.MSDKInitializer
import
com.sd.api.UserCtx
import
com.sd.api.scenario.mine.MineVehicleModel
import
com.sd.api.maps.MsOperationParent
import
com.sd.api.utils.FileIoUtils
import
com.unity3d.player.UnityPlayer
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
java.io.File
import
java.io.IOException
/**网联车模型**/
/**网联车模型(在线地图)**/
object
VehicleModel
:
MsOperationParent
()
{
object
VehicleModel
{
//在线地图用户当前位置模型
private
var
mainCarMo
:
Model
?
=
null
//主车obj模型
private
var
objPath
=
""
//在线地图小车是否加载完毕
private
var
loadAddCar
=
false
/****加载主车特斯拉模型***/
suspend
fun
loadMainCar
()
{
var
context
=
UserCtx
.
instance
.
mContext
// CoroutineScope(Dispatchers.IO).launch {
try
{
var
parentFileDir
=
File
(
context
?.
filesDir
,
"models/car_model"
)
if
(!
parentFileDir
.
exists
())
parentFileDir
.
mkdirs
()
objPath
=
FileIoUtils
.
assetFilePath
(
context
!!
,
"models/car_model/gszh_xyz.obj"
)
// Log.d("-----", "✅ OBJ文件复制成功: " + objPath)
var
path
=
FileIoUtils
.
assetFilePath
(
context
,
"models/car_model/gszh_xyz.mtl"
)
// Log.d("-----", "✅ 纹理文件复制成功: " + path)
path
=
FileIoUtils
.
assetFilePath
(
context
,
"models/car_model/Binary_0.jpeg"
)
// Log.d("-----", "✅ 材质文件复制成功: " + path)
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
// }
}
/****更新模型位置**/
/****更新模型位置**/
fun
upMyLocCarModel
(
fun
upMyLocCarModel
(
...
@@ -59,16 +15,7 @@ object VehicleModel : MsOperationParent() {
...
@@ -59,16 +15,7 @@ object VehicleModel : MsOperationParent() {
)
{
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
CoroutineScope
(
Dispatchers
.
Default
).
launch
{
MineVehicleModel
.
upMyLocCarModel
(
lat
,
lng
,
heading
)
loadMainCar
()
if
(!
loadAddCar
)
{
loadAddCar
=
true
addMyLocCarModel
(
lat
,
lng
,
heading
)
}
var
cHeading
=
0f
-
180f
-
heading
mainCarMo
?.
setPosition
(
LatLng
(
lat
,
lng
))
mainCarMo
?.
setHeading
(
cHeading
)
}
}
}
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
...
@@ -76,33 +23,11 @@ object VehicleModel : MsOperationParent() {
...
@@ -76,33 +23,11 @@ object VehicleModel : MsOperationParent() {
}
}
}
}
//删除互联网地图上的车模型
/****添加我的定位小车模型
fun
deleteMyLocModel
()
{
* 这小车模型航向角0是冲下的
* ***/
suspend
fun
addMyLocCarModel
(
lat
:
Double
,
lng
:
Double
,
heading
:
Float
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
if
(
objPath
.
isEmpty
()
||
lat
==
0.0
||
lng
==
0.0
)
MineVehicleModel
.
deleteMyLocModel
()
return
if
(
mainCarMo
!=
null
)
return
var
mMineMap
=
getMapReadView
()
?.
mMineMap
// 模型文件相对路径
var
modelOptions
=
ModelOptions
()
.
objFile
(
objPath
)
.
position
(
LatLng
(
lat
,
lng
))
.
layer
(
Overlay
.
Layer
.
aboveMarker
)
.
heading
(
heading
)
.
keepScaleSize
(
8f
)
// 保持尺寸的比例尺
.
scaleFactor
(
0.007f
)
// 缩放因子
.
visible
(
true
)
mainCarMo
=
mMineMap
?.
addModel
(
modelOptions
)
}
}
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
...
@@ -110,13 +35,8 @@ object VehicleModel : MsOperationParent() {
...
@@ -110,13 +35,8 @@ object VehicleModel : MsOperationParent() {
}
}
}
}
//删除互联网地图上的车模型
fun
deleteMyLocModel
()
{
if
(
mainCarMo
!=
null
)
{
var
mMineMap
=
getMapReadView
()
?.
mMineMap
mMineMap
?.
removeOverlay
(
mainCarMo
)
mainCarMo
=
null
}
}
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/bean/Percept.kt
0 → 100644
View file @
a3f59a6e
package
com.sd.api.scenario.bean
/**感知物数据**/
class
Percept
{
/**感知物类型 1=车 2=人*/
var
pType
=
1
/**航向角*/
var
heading
=
0.0
/**纬度**/
var
lat
=
0.0
/**经度**/
var
lon
=
0.0
/**感知物id*/
var
ptcid
=
""
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/VehiclePos.kt
→
mapapi/src/main/java/com/sd/api/scenario/
bean/
VehiclePos.kt
View file @
a3f59a6e
package
com.sd.api.scenario
package
com.sd.api.scenario
.bean
/***车辆位置**/
/***车辆位置**/
class
VehiclePos
{
class
VehiclePos
{
...
@@ -7,6 +7,8 @@ class VehiclePos {
...
@@ -7,6 +7,8 @@ class VehiclePos {
}
}
var
lat
=
0.0
var
lat
=
0.0
var
lng
=
0.0
var
lng
=
0.0
/**航向角***/
var
heading
=
0.0
var
heading
=
0.0
/**高程***/
var
evel
=
20.80189
var
evel
=
20.80189
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/mine/MineVehicleModel.kt
0 → 100644
View file @
a3f59a6e
package
com.sd.api.scenario.mine
import
android.content.Context
import
com.minedata.minenavi.map.Model
import
com.minedata.minenavi.map.ModelOptions
import
com.minedata.minenavi.map.Overlay
import
com.minedata.minenavi.mapdal.LatLng
import
com.sd.api.UserCtx
import
com.sd.api.maps.MsOperationParent
import
com.sd.api.utils.FileIoUtils
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
java.io.File
import
java.io.IOException
//四维模型实现
object
MineVehicleModel
:
MsOperationParent
()
{
//在线地图用户当前位置模型
private
var
mainCarMo
:
Model
?
=
null
//主车obj模型
private
var
objPath
=
""
//在线地图小车是否加载完毕
private
var
loadAddCar
=
false
/****加载主车特斯拉模型***/
private
suspend
fun
loadMainCar
(
context
:
Context
?)
{
if
(
context
==
null
)
return
try
{
var
parentFileDir
=
File
(
context
?.
filesDir
,
"models/car_model"
)
if
(!
parentFileDir
.
exists
())
parentFileDir
.
mkdirs
()
objPath
=
FileIoUtils
.
assetFilePath
(
context
!!
,
"models/car_model/gszh_xyz.obj"
)
// Log.d("-----", "✅ OBJ文件复制成功: " + objPath)
var
path
=
FileIoUtils
.
assetFilePath
(
context
,
"models/car_model/gszh_xyz.mtl"
)
// Log.d("-----", "✅ 纹理文件复制成功: " + path)
path
=
FileIoUtils
.
assetFilePath
(
context
,
"models/car_model/Binary_0.jpeg"
)
// Log.d("-----", "✅ 材质文件复制成功: " + path)
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
/****添加我的定位小车模型
* 这小车模型航向角0是冲下的
* ***/
private
fun
addMyLocCarModel
(
lat
:
Double
,
lng
:
Double
,
heading
:
Float
)
{
if
(
objPath
.
isEmpty
()
||
lat
==
0.0
||
lng
==
0.0
)
return
if
(
mainCarMo
!=
null
)
return
var
mMineMap
=
getMapReadView
()
?.
mMineMap
// 模型文件相对路径
var
modelOptions
=
ModelOptions
()
.
objFile
(
objPath
)
.
position
(
LatLng
(
lat
,
lng
))
.
layer
(
Overlay
.
Layer
.
aboveMarker
)
.
heading
(
heading
)
.
keepScaleSize
(
8f
)
// 保持尺寸的比例尺
.
scaleFactor
(
0.007f
)
// 缩放因子
.
visible
(
true
)
mainCarMo
=
mMineMap
?.
addModel
(
modelOptions
)
}
/****更新模型位置**/
fun
upMyLocCarModel
(
lat
:
Double
,
lng
:
Double
,
heading
:
Float
)
{
CoroutineScope
(
Dispatchers
.
Default
).
launch
{
var
context
=
UserCtx
.
instance
.
mContext
loadMainCar
(
context
)
if
(!
loadAddCar
)
{
loadAddCar
=
true
addMyLocCarModel
(
lat
,
lng
,
heading
)
}
var
cHeading
=
0f
-
180f
-
heading
mainCarMo
?.
setPosition
(
LatLng
(
lat
,
lng
))
mainCarMo
?.
setHeading
(
cHeading
)
}
}
//删除互联网地图上的车模型
fun
deleteMyLocModel
()
{
if
(
mainCarMo
!=
null
)
{
var
mMineMap
=
getMapReadView
()
?.
mMineMap
mMineMap
?.
removeOverlay
(
mainCarMo
)
mainCarMo
=
null
}
}
}
\ No newline at end of file
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