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
a0061ae5
Commit
a0061ae5
authored
Oct 31, 2025
by
p x
Browse files
优化一些调用
parent
1fced44e
Changes
22
Show whitespace changes
Inline
Side-by-side
app/src/main/java/com/sd/demo/MainActivity.kt
View file @
a0061ae5
...
@@ -57,7 +57,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -57,7 +57,7 @@ class MainActivity : AppCompatActivity() {
DemoDetails
(
"切换地图图层"
,
TLayersActivity
::
class
.
java
),
DemoDetails
(
"切换地图图层"
,
TLayersActivity
::
class
.
java
),
// DemoDetails("显示定位蓝点", ShowMyLocLandian::class.java),
// DemoDetails("显示定位蓝点", ShowMyLocLandian::class.java),
DemoDetails
(
"手势控制"
,
GestureDemo
::
class
.
java
),
DemoDetails
(
"手势控制"
,
GestureDemo
::
class
.
java
),
DemoDetails
(
"控件
控制
"
,
ControlActivity
::
class
.
java
),
DemoDetails
(
"控件
交互
"
,
ControlActivity
::
class
.
java
),
DemoDetails
(
"改变地图中心点,缩放级别"
,
ChangeMapCenterAct
::
class
.
java
),
DemoDetails
(
"改变地图中心点,缩放级别"
,
ChangeMapCenterAct
::
class
.
java
),
DemoDetails
(
"绘制Marker点"
,
TMarkerActivity
::
class
.
java
),
DemoDetails
(
"绘制Marker点"
,
TMarkerActivity
::
class
.
java
),
DemoDetails
(
"绘制一条线(实线、虚线)"
,
TLineActivity
::
class
.
java
),
DemoDetails
(
"绘制一条线(实线、虚线)"
,
TLineActivity
::
class
.
java
),
...
...
app/src/main/java/com/sd/demo/ui/PartRoadActivity.kt
View file @
a0061ae5
...
@@ -4,13 +4,15 @@ import android.os.Bundle
...
@@ -4,13 +4,15 @@ import android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.sd.api.
bean.MyCLoc
import
com.sd.api.
parkroad.RoadPos
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.parkroad.MsParkRoad
import
com.sd.api.parkroad.MsParkRoad
import
com.sd.api.parkroad.OnPrAddCar
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.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
...
@@ -138,23 +140,32 @@ class PartRoadActivity : AppCompatActivity() {
...
@@ -138,23 +140,32 @@ class PartRoadActivity : AppCompatActivity() {
MSLatLng
(
p1
[
1
],
p1
[
0
]),
MSLatLng
(
p1
[
1
],
p1
[
0
]),
MSLatLng
(
pc
[
1
],
pc
[
0
])
MSLatLng
(
pc
[
1
],
pc
[
0
])
)
)
MyCLoc
.
instance
.
apply
{
VehiclePos
.
instance
.
apply
{
lat
=
it
[
1
]
lat
=
pc
[
1
]
lng
=
it
[
0
]
lng
=
pc
[
0
]
if
((
head
-
oldHead
).
absoluteValue
<
45
)
{
if
((
head
-
oldHead
).
absoluteValue
<
45
)
{
b
ea
r
ing
=
head
.
toFloat
()
h
ea
d
ing
=
head
}
}
// println("-----bearing = ${bearing}")
// evel = 20.80189
//高程
altitude
=
20.802828
}
}
// RoadPos.instance.apply {
// lat = it[1]
// lng = it[0]
// if ((head - oldHead).absoluteValue < 45) {
// bearing = head.toFloat()
// }
// // println("-----bearing = ${bearing}")
// //高程
//// altitude = 20.802828
// }
CucsVehicle
.
moveCar
(
VehiclePos
.
instance
,
2
)
//更新车辆位置.主车是否添加回调
//更新车辆位置.主车是否添加回调
MsParkRoad
.
updateMainCar
(
MyCLoc
.
instance
,
object
:
OnPrAddCar
{
//
MsParkRoad.updateMainCar(
RoadPos
.instance, object : OnPrAddCar {
override
fun
onPrAddCar
(
isAdd
:
Boolean
)
{
//
override fun onPrAddCar(isAdd: Boolean) {
println
(
"------------isAdd = ${isAdd}"
)
//
println("------------isAdd = ${isAdd}")
}
//
}
})
//
})
oldHead
=
head
oldHead
=
head
delay
(
600
)
delay
(
600
)
}
}
...
...
app/src/main/java/com/sd/demo/ui/THighMapActivity.kt
View file @
a0061ae5
...
@@ -3,32 +3,25 @@ package com.sd.demo.ui
...
@@ -3,32 +3,25 @@ package com.sd.demo.ui
import
android.os.Bundle
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.viewModelScope
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.minedata.minenavi.mapdal.LatLng
import
com.minedata.minenavi.util.Tools
import
com.sd.api.highmap.AllLine
import
com.sd.api.highmap.AllLine
import
com.sd.api.highmap.CarNavPath
import
com.sd.api.highmap.HighMapApi
import
com.sd.api.highmap.HighMapApi
import
com.sd.api.highmap.TileJsonBean
import
com.sd.api.highmap.UnityPtc
import
com.sd.api.highmap.UnityPtc
import
com.sd.api.highmap.WarnPtc
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.parkroad.PtcBean
import
com.sd.api.scenario.CucsVehicle
import
com.sd.api.scenario.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
import
com.sd.demo.bean.mock.PerceptionBean
import
com.sd.demo.bean.mock.PerceptionBean
import
com.sd.demo.databinding.ActivityHighMapBinding
import
com.sd.demo.databinding.ActivityHighMapBinding
import
com.sd.demo.utils.FileIoUtils
import
com.sd.demo.utils.FileIoUtils
import
com.sd.demo.utils.MyMapUtils
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlin.collections.get
import
kotlin.compareTo
import
kotlin.math.absoluteValue
import
kotlin.math.absoluteValue
import
kotlin.text.compareTo
import
kotlin.text.get
/**
/**
*
*
...
@@ -47,24 +40,8 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -47,24 +40,8 @@ class THighMapActivity : AppCompatActivity() {
binding
.
mapMultiView
.
addMapRenderCallback
(
object
:
OnMapReadyLis
{
binding
.
mapMultiView
.
addMapRenderCallback
(
object
:
OnMapReadyLis
{
override
fun
onMapReady
(
mapReadyView
:
MapReadyView
)
{
override
fun
onMapReady
(
mapReadyView
:
MapReadyView
)
{
this
@THighMapActivity
.
mapReadView
=
mapReadyView
this
@THighMapActivity
.
mapReadView
=
mapReadyView
//传入3d tile加载地图
//传入3d tile加载地图 1= 亦庄示范区
var
tileJsonBean
=
TileJsonBean
().
apply
{
HighMapApi
.
setTileInit
(
1
)
host
=
"https://itg-yz.cu-sc.com:13443"
tiles3d
=
listOf
(
"/gis_data/3dtiles/road/LanePolygon/tileset.json"
,
"/gis_data/3dtiles/road/RoadSection/tileset.json"
,
"/gis_data/3dtiles/road/SafetyIsland/tileset.json"
,
"/gis_data/3dtiles/road/SepStrip/tileset.json"
,
"/gis_data/3dtiles/road/SideWalk/tileset.json"
,
"/gis_data/3dtiles/road/TraMarkA/tileset.json"
,
"/gis_data/3dtiles/road/TraMarkL/tileset.json"
,
"/gis_data/3dtiles/road/TraMarkP/tileset.json"
,
"/gis_data/3dtiles/roadequip/yidongronghe/tileset.json"
,
"/gis_data/3dtiles/buildings/tileset.json"
,
"/gis_data/3dtiles/ground/tileset.json"
)
}
HighMapApi
.
setTileInit
(
tileJsonBean
)
}
}
})
})
...
@@ -90,11 +67,15 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -90,11 +67,15 @@ class THighMapActivity : AppCompatActivity() {
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
)
// HighMapApi.setCarNavPath(lines, showdistance = 200)
var
carNavPath
=
CarNavPath
().
apply
{
this
.
lines
=
lines
}
CucsVehicle
.
setCarNaiPath
(
carNavPath
)
//模拟车辆移动
//模拟车辆移动
var
head
=
0.0
var
head
=
0.0
var
oldHead
=
0.0
var
oldHead
=
0.0
var
bearing
=
0
f
var
bearing
=
0
.0
mRoutes
.
rs
.
forEachIndexed
{
index
,
it
->
mRoutes
.
rs
.
forEachIndexed
{
index
,
it
->
if
(
index
>
0
)
{
if
(
index
>
0
)
{
var
p1
=
mRoutes
.
rs
.
get
(
index
-
1
)
var
p1
=
mRoutes
.
rs
.
get
(
index
-
1
)
...
@@ -104,10 +85,17 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -104,10 +85,17 @@ class THighMapActivity : AppCompatActivity() {
MSLatLng
(
pc
[
1
],
pc
[
0
])
MSLatLng
(
pc
[
1
],
pc
[
0
])
)
)
if
((
head
-
oldHead
).
absoluteValue
<
45
)
{
if
((
head
-
oldHead
).
absoluteValue
<
45
)
{
bearing
=
head
.
toFloat
()
bearing
=
head
}
}
VehiclePos
.
instance
.
apply
{
lat
=
pc
[
1
]
lng
=
pc
[
0
]
heading
=
bearing
evel
=
20.80189
}
}
HighMapApi
.
setCarPosition
(
head
,
it
[
1
],
it
[
0
],
20.80189
)
}
// HighMapApi.setCarPosition(head, it[1], it[0], 20.80189)
CucsVehicle
.
moveCar
(
VehiclePos
.
instance
,
1
)
oldHead
=
head
oldHead
=
head
delay
(
300
)
delay
(
300
)
}
}
...
@@ -187,5 +175,4 @@ class THighMapActivity : AppCompatActivity() {
...
@@ -187,5 +175,4 @@ class THighMapActivity : AppCompatActivity() {
}
}
}
}
\ No newline at end of file
app/src/main/java/com/sd/demo/ui/TLayersActivity.kt
View file @
a0061ae5
...
@@ -3,7 +3,7 @@ package com.sd.demo.ui
...
@@ -3,7 +3,7 @@ package com.sd.demo.ui
import
android.os.Bundle
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
com.sd.api.maps.Layer
import
com.sd.api.maps.
MS
Layer
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.R
import
com.sd.demo.R
...
@@ -30,18 +30,16 @@ class TLayersActivity : AppCompatActivity() {
...
@@ -30,18 +30,16 @@ class TLayersActivity : AppCompatActivity() {
// MSMethodAdv.setMapCenter(mapReadView, 39.999391, 116.135972)
// MSMethodAdv.setMapCenter(mapReadView, 39.999391, 116.135972)
}
}
})
})
//获取接口功能实例
//获取接口功能实例
// var mapCoreApi = MapCoreApi.mapCoreApi
// var mapCoreApi = MapCoreApi.mapCoreApi
binding
.
rg
.
setOnCheckedChangeListener
{
group
,
checkedId
->
binding
.
rg
.
setOnCheckedChangeListener
{
group
,
checkedId
->
when
(
checkedId
)
{
when
(
checkedId
)
{
R
.
id
.
rb1
->
{
//普通
R
.
id
.
rb1
->
{
//普通
Layer
.
toggleLayers
(
1
)
MS
Layer
.
toggleLayers
(
1
)
}
}
R
.
id
.
rb2
->
{
//卫星
R
.
id
.
rb2
->
{
//卫星
Layer
.
toggleLayers
(
2
)
MS
Layer
.
toggleLayers
(
2
)
}
}
}
}
}
}
...
...
app/src/main/java/com/sd/demo/ui/TReGeocodeActivity.kt
View file @
a0061ae5
...
@@ -28,7 +28,7 @@ class TReGeocodeActivity : AppCompatActivity() {
...
@@ -28,7 +28,7 @@ class TReGeocodeActivity : AppCompatActivity() {
var
lat
=
binding
.
et2
.
text
.
toString
().
toDouble
()
var
lat
=
binding
.
et2
.
text
.
toString
().
toDouble
()
var
lng
=
binding
.
et1
.
text
.
toString
().
toDouble
()
var
lng
=
binding
.
et1
.
text
.
toString
().
toDouble
()
//逆地理编码
//逆地理编码
MSRegeoCode
.
geoCoder
(
lat
,
lng
,
object
:
MSRegeoCode
.
MS
OnRegeo
{
MSRegeoCode
.
geoCoder
(
lat
,
lng
,
object
:
MSRegeoCode
.
On
Ms
Regeo
{
override
fun
onRegeo
(
regeocodeRes
:
RegeocodeRes
?)
{
override
fun
onRegeo
(
regeocodeRes
:
RegeocodeRes
?)
{
var
sb
=
StringBuilder
()
var
sb
=
StringBuilder
()
sb
.
append
(
regeocodeRes
?.
province
+
" "
)
sb
.
append
(
regeocodeRes
?.
province
+
" "
)
...
...
mapapi/src/main/java/com/sd/api/fragments/UnityFragment.kt
View file @
a0061ae5
...
@@ -7,6 +7,7 @@ import android.view.View
...
@@ -7,6 +7,7 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
com.sd.api.UserCtx
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.unity3d.player.IUnityPlayerLifecycleEvents
import
com.unity3d.player.IUnityPlayerLifecycleEvents
...
@@ -84,6 +85,8 @@ class UnityFragment : Fragment(), IUnityPlayerLifecycleEvents {
...
@@ -84,6 +85,8 @@ class UnityFragment : Fragment(), IUnityPlayerLifecycleEvents {
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
// 视图创建完成后,可以在这里进行最终设置
// 视图创建完成后,可以在这里进行最终设置
mUnityPlayer
.
windowFocusChanged
(
true
)
mUnityPlayer
.
windowFocusChanged
(
true
)
MapReadyView
.
instance
.
mUnityPlayer
=
mUnityPlayer
UserCtx
.
instance
.
mapReadyView
=
MapReadyView
.
instance
onMapReadyLis
?.
onMapReady
(
MapReadyView
.
instance
)
onMapReadyLis
?.
onMapReady
(
MapReadyView
.
instance
)
}
}
...
...
mapapi/src/main/java/com/sd/api/highmap/CarNavPath.kt
View file @
a0061ae5
...
@@ -5,15 +5,19 @@ package com.sd.api.highmap
...
@@ -5,15 +5,19 @@ package com.sd.api.highmap
*/
*/
class
CarNavPath
{
class
CarNavPath
{
var
lines
:
List
<
AllLine
>?
=
null
var
lines
:
List
<
AllLine
>?
=
null
var
through
=
"8e959e"
//通过路的颜色颜色HEX RRGGBB
/***通过路的颜色颜色HEX RRGGBB*/
var
notthrough
=
"2868D8"
//未通过路的颜色颜色HEX RRGGBB
var
through
=
"8e959e"
var
drawpassed
=
true
//绘制通过路
/****未通过路的颜色颜色HEX RRGGBB*/
var
showdistance
=
45
//显示路径的距离,超过这个范围的路径点不绘制
var
notthrough
=
"2868D8"
/****绘制通过路*/
var
drawpassed
=
true
/***显示路径的距离,超过这个范围的路径点不绘制*/
var
showdistance
=
45
//注意,目前的是否通过是程序根据点的顺序判断距离车最近的点为当前点,后面的未通过,前面的点为已通过
//注意,目前的是否通过是程序根据点的顺序判断距离车最近的点为当前点,后面的未通过,前面的点为已通过
}
}
/**
/**
* 路径点列表
*
全局
路径点列表
*/
*/
class
AllLine
{
class
AllLine
{
// val evel: Int,
// val evel: Int,
...
...
mapapi/src/main/java/com/sd/api/highmap/HighMapApi.kt
View file @
a0061ae5
...
@@ -3,24 +3,30 @@ package com.sd.api.highmap
...
@@ -3,24 +3,30 @@ package com.sd.api.highmap
import
com.google.gson.Gson
import
com.google.gson.Gson
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.maps.MsOperationParent
import
com.unity3d.player.UnityPlayer
import
com.unity3d.player.UnityPlayer
/**
/**
* 四维高精地图Api
* 四维高精地图Api
*/
*/
object
HighMapApi
{
object
HighMapApi
:
MsOperationParent
()
{
private
var
gson
=
Gson
()
private
var
gson
=
Gson
()
private
const
val
MODELNAME
=
"MsgBridge"
private
const
val
MODELNAME
=
"MsgBridge"
/**
/**
* 给unity读取3d tile json配置
* 加载3D Tiles
* @param tileType 1=亦庄示范区
*/
*/
fun
setTileInit
(
tile
JsonBean
:
TileJsonBean
)
{
fun
setTileInit
(
tile
Type
:
Int
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
if
(!
isLoadUnityPlayer
())
return
var
tileJsonBean
=
TileJsonBean
(
tileType
)
tileJsonBean
.
getTileJson
()
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetTileInit"
,
gson
.
toJson
(
tileJsonBean
))
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetTileInit"
,
gson
.
toJson
(
tileJsonBean
))
}
}
...
@@ -42,7 +48,9 @@ object HighMapApi {
...
@@ -42,7 +48,9 @@ object HighMapApi {
)
{
)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
val
carPos
=
CarPos
().
apply
{
if
(!
isLoadUnityPlayer
())
return
val
carPos
=
HighPos
().
apply
{
this
.
heading
=
heading
this
.
heading
=
heading
this
.
lat
=
lat
this
.
lat
=
lat
this
.
lon
=
lon
this
.
lon
=
lon
...
@@ -56,6 +64,23 @@ object HighMapApi {
...
@@ -56,6 +64,23 @@ object HighMapApi {
}
}
}
}
/**
* @param highPos 车辆位置对象
*/
fun
setCarPosition
(
highPos
:
HighPos
)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
if
(!
isLoadUnityPlayer
())
return
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetCarPosition"
,
gson
.
toJson
(
highPos
))
}
MAP_TYPE
.
AMAP
->
{
}
}
}
/**
/**
* 开启(关闭)绘制主车底盘下的光圈
* 开启(关闭)绘制主车底盘下的光圈
* @param isOn true:显示 false:隐藏
* @param isOn true:显示 false:隐藏
...
@@ -128,6 +153,23 @@ object HighMapApi {
...
@@ -128,6 +153,23 @@ object HighMapApi {
}
}
}
}
/**
* 设置主车导航路径
* @param carNavPath 导航路径选项
*/
fun
setCarNavPath
(
carNavPath
:
CarNavPath
)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
if
(!
isLoadUnityPlayer
())
return
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetCarNavPath"
,
gson
.
toJson
(
carNavPath
))
}
MAP_TYPE
.
AMAP
->
{
}
}
}
/**
/**
* 设置告警线
* 设置告警线
* @param alertLins 路径点
* @param alertLins 路径点
...
@@ -152,7 +194,11 @@ object HighMapApi {
...
@@ -152,7 +194,11 @@ object HighMapApi {
fun
setPtcData
(
ptcList
:
List
<
UnityPtc
>)
{
fun
setPtcData
(
ptcList
:
List
<
UnityPtc
>)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
var
ptcData
=
PtcData
(
ptcList
)
if
(!
isLoadUnityPlayer
())
return
var
ptcData
=
PtcData
.
instance
.
apply
{
this
.
ptcList
=
ptcList
}
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetPtcData"
,
gson
.
toJson
(
ptcData
))
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetPtcData"
,
gson
.
toJson
(
ptcData
))
}
}
...
@@ -219,7 +265,11 @@ object HighMapApi {
...
@@ -219,7 +265,11 @@ object HighMapApi {
var
parkRoundLight
=
ParkRoundLight
().
apply
{
var
parkRoundLight
=
ParkRoundLight
().
apply
{
this
.
spaceCode
=
spaceCode
this
.
spaceCode
=
spaceCode
}
}
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"parkRoundLight"
,
gson
.
toJson
(
parkRoundLight
))
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"parkRoundLight"
,
gson
.
toJson
(
parkRoundLight
)
)
}
}
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
...
@@ -250,7 +300,11 @@ object HighMapApi {
...
@@ -250,7 +300,11 @@ object HighMapApi {
var
parkComplete
=
ParkComplete
().
apply
{
var
parkComplete
=
ParkComplete
().
apply
{
this
.
complete
=
complete
this
.
complete
=
complete
}
}
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetParkComplete"
,
gson
.
toJson
(
parkComplete
))
UnityPlayer
.
UnitySendMessage
(
MODELNAME
,
"SetParkComplete"
,
gson
.
toJson
(
parkComplete
)
)
}
}
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
...
...
mapapi/src/main/java/com/sd/api/highmap/
Car
Pos.kt
→
mapapi/src/main/java/com/sd/api/highmap/
High
Pos.kt
View file @
a0061ae5
package
com.sd.api.highmap
package
com.sd.api.highmap
import
com.sd.api.parkroad.RoadPos
/**
/**
*
根据外界传入的坐标,航向角,速度使主车移动
*
高精地图车辆位置
* {
* {
* "lat": 116.50272672296624, //纬度
* "lat": 116.50272672296624, //纬度
* "lon": 116.49886019, //经度
* "lon": 116.49886019, //经度
...
@@ -9,7 +11,11 @@ package com.sd.api.highmap
...
@@ -9,7 +11,11 @@ package com.sd.api.highmap
* "heading": 0, //汽车姿态方向角度
* "heading": 0, //汽车姿态方向角度
* }
* }
*/
*/
class
CarPos
{
class
HighPos
{
companion
object
{
val
instance
:
HighPos
by
lazy
{
HighPos
()
}
}
var
evel
=
20.80189
var
evel
=
20.80189
var
heading
=
0.0
var
heading
=
0.0
var
lat
=
0.0
var
lat
=
0.0
...
...
mapapi/src/main/java/com/sd/api/highmap/PtcData.kt
View file @
a0061ae5
...
@@ -4,9 +4,12 @@ package com.sd.api.highmap
...
@@ -4,9 +4,12 @@ package com.sd.api.highmap
/**
/**
* 感知物请求数据
* 感知物请求数据
*/
*/
data class
PtcData
(
class
PtcData
{
val
ptcList
:
List
<
UnityPtc
>
companion
object
{
)
val
instance
:
PtcData
by
lazy
{
PtcData
()
}
}
var
ptcList
:
List
<
UnityPtc
>?=
null
}
class
UnityPtc
{
class
UnityPtc
{
/**感知物类型 1=车 2=人*/
/**感知物类型 1=车 2=人*/
...
...
mapapi/src/main/java/com/sd/api/highmap/TileJsonBean.kt
View file @
a0061ae5
...
@@ -4,7 +4,27 @@ package com.sd.api.highmap
...
@@ -4,7 +4,27 @@ package com.sd.api.highmap
/**
/**
* 地图初始化,加载 3D Tiles。
* 地图初始化,加载 3D Tiles。
*/
*/
class
TileJsonBean
{
class
TileJsonBean
(
var
tileType
:
Int
)
{
var
host
=
""
var
host
=
""
var
tiles3d
:
List
<
String
>?
=
null
var
tiles3d
:
List
<
String
>?
=
null
fun
getTileJson
()
{
if
(
tileType
==
1
)
{
host
=
"https://itg-yz.cu-sc.com:13443"
tiles3d
=
listOf
(
"/gis_data/3dtiles/road/LanePolygon/tileset.json"
,
"/gis_data/3dtiles/road/RoadSection/tileset.json"
,
"/gis_data/3dtiles/road/SafetyIsland/tileset.json"
,
"/gis_data/3dtiles/road/SepStrip/tileset.json"
,
"/gis_data/3dtiles/road/SideWalk/tileset.json"
,
"/gis_data/3dtiles/road/TraMarkA/tileset.json"
,
"/gis_data/3dtiles/road/TraMarkL/tileset.json"
,
"/gis_data/3dtiles/road/TraMarkP/tileset.json"
,
"/gis_data/3dtiles/roadequip/yidongronghe/tileset.json"
,
"/gis_data/3dtiles/buildings/tileset.json"
,
"/gis_data/3dtiles/ground/tileset.json"
)
}
}
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/DrawInMap.kt
View file @
a0061ae5
...
@@ -40,13 +40,17 @@ class MsCircleOptions {
...
@@ -40,13 +40,17 @@ class MsCircleOptions {
var
strokeWidth
=
15f
var
strokeWidth
=
15f
}
}
/***绘制一个面选项**/
class
MsPolygonOptions
{
class
MsPolygonOptions
{
/***填充颜色**/
/***填充颜色**/
var
fillColor
=
"#10FF00FF"
.
toColorInt
()
var
fillColor
=
"#10FF00FF"
.
toColorInt
()
/***边框颜色**/
/***边框颜色**/
var
strokeColor
=
"#500000FF"
.
toColorInt
()
var
strokeColor
=
"#500000FF"
.
toColorInt
()
/***边框宽度**/
/***边框宽度**/
var
strokeWidth
=
5f
var
strokeWidth
=
5f
/***是否为虚线,默认为false**/
/***是否为虚线,默认为false**/
var
dLine
=
false
var
dLine
=
false
}
}
...
@@ -140,7 +144,7 @@ object DrawInMap : MsOperationParent() {
...
@@ -140,7 +144,7 @@ object DrawInMap : MsOperationParent() {
*/
*/
fun
drawPolygon
(
fun
drawPolygon
(
msLatLng
:
List
<
MSLatLng
>,
msLatLng
:
List
<
MSLatLng
>,
msPolygonOptions
:
MsPolygonOptions
msPolygonOptions
:
MsPolygonOptions
):
MSOverlay
{
):
MSOverlay
{
val
mapReadView
=
getMapReadView
()
val
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
...
@@ -154,7 +158,7 @@ object DrawInMap : MsOperationParent() {
...
@@ -154,7 +158,7 @@ object DrawInMap : MsOperationParent() {
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
return
AmapDrawInMap
.
drawPolygon
(
return
AmapDrawInMap
.
drawPolygon
(
mapReadView
,
msLatLng
,
mapReadView
,
msLatLng
,
msPolygonOptions
msPolygonOptions
)
)
}
}
...
...
mapapi/src/main/java/com/sd/api/maps/Layer.kt
→
mapapi/src/main/java/com/sd/api/maps/
MS
Layer.kt
View file @
a0061ae5
...
@@ -8,7 +8,7 @@ import com.sd.api.maps.mine.MineLayers
...
@@ -8,7 +8,7 @@ import com.sd.api.maps.mine.MineLayers
/**
/**
* 图层操作
* 图层操作
*/
*/
object
Layer
:
MsOperationParent
()
{
object
MS
Layer
:
MsOperationParent
()
{
/**
/**
* 切换地图图层
* 切换地图图层
...
...
mapapi/src/main/java/com/sd/api/maps/MSRegeoCode.kt
View file @
a0061ae5
...
@@ -16,10 +16,10 @@ import com.amap.api.services.geocoder.GeocodeResult as AGeocodeResult
...
@@ -16,10 +16,10 @@ import com.amap.api.services.geocoder.GeocodeResult as AGeocodeResult
/**逆地理编码*/
/**逆地理编码*/
object
MSRegeoCode
:
GeocodeSearch
.
OnGeocodeSearchListener
,
AGeocodeSearch
.
OnGeocodeSearchListener
{
object
MSRegeoCode
:
GeocodeSearch
.
OnGeocodeSearchListener
,
AGeocodeSearch
.
OnGeocodeSearchListener
{
private
var
mSOnRegeo
:
MS
OnRegeo
?
=
null
private
var
mSOnRegeo
:
On
Ms
Regeo
?
=
null
/**逆地理编码信息回调*/
/**逆地理编码信息回调*/
interface
MS
OnRegeo
{
interface
On
Ms
Regeo
{
fun
onRegeo
(
regeocodeRes
:
RegeocodeRes
?)
fun
onRegeo
(
regeocodeRes
:
RegeocodeRes
?)
}
}
...
@@ -31,7 +31,7 @@ object MSRegeoCode : GeocodeSearch.OnGeocodeSearchListener, AGeocodeSearch.OnGeo
...
@@ -31,7 +31,7 @@ object MSRegeoCode : GeocodeSearch.OnGeocodeSearchListener, AGeocodeSearch.OnGeo
fun
geoCoder
(
fun
geoCoder
(
lat
:
Double
,
lat
:
Double
,
lng
:
Double
,
lng
:
Double
,
msOnRegeo
:
MS
OnRegeo
msOnRegeo
:
On
Ms
Regeo
)
{
)
{
if
(
lat
==
0.0
||
lng
==
0.0
)
if
(
lat
==
0.0
||
lng
==
0.0
)
return
return
...
...
mapapi/src/main/java/com/sd/api/maps/MsOperationParent.kt
View file @
a0061ae5
...
@@ -16,4 +16,14 @@ open class MsOperationParent {
...
@@ -16,4 +16,14 @@ open class MsOperationParent {
}
}
return
UserCtx
.
instance
.
mapReadyView
return
UserCtx
.
instance
.
mapReadyView
}
}
//UNityPlayer是否加载完成
fun
isLoadUnityPlayer
():
Boolean
{
if
(
UserCtx
.
instance
.
mapReadyView
?.
mUnityPlayer
==
null
){
return
false
}
else
{
return
true
}
}
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/parkroad/MsParkRoad.kt
View file @
a0061ae5
...
@@ -7,7 +7,6 @@ import com.example.car_and_road_3d.models.Participant
...
@@ -7,7 +7,6 @@ import com.example.car_and_road_3d.models.Participant
import
com.example.car_and_road_3d.models.Position
import
com.example.car_and_road_3d.models.Position
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.bean.MyCLoc
import
com.sd.api.maps.MsOperationParent
import
com.sd.api.maps.MsOperationParent
import
com.sd.api.ui.MapReadyView
import
com.sd.api.ui.MapReadyView
import
com.sd.api.vms.CarRoadVM
import
com.sd.api.vms.CarRoadVM
...
@@ -52,13 +51,13 @@ object MsParkRoad : MsOperationParent() {
...
@@ -52,13 +51,13 @@ object MsParkRoad : MsOperationParent() {
/**
/**
*更新主车我只
*更新主车我只
* @param
myloc
当前位置
* @param
roadPos
当前位置
* @param onPrAddCar 回调
* @param onPrAddCar 回调
*/
*/
fun
updateMainCar
(
myloc
:
MyCLoc
,
onPrAddCar
:
OnPrAddCar
?)
{
fun
updateMainCar
(
roadPos
:
RoadPos
,
onPrAddCar
:
OnPrAddCar
?)
{
when
(
MSDKInitializer
.
getMapType
())
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MAP_TYPE
.
MINE
->
{
carRoadVM
?.
updateMainCar
(
myloc
,
onPrAddCar
)
carRoadVM
?.
updateMainCar
(
roadPos
,
onPrAddCar
)
}
}
MAP_TYPE
.
AMAP
->
{
MAP_TYPE
.
AMAP
->
{
...
...
mapapi/src/main/java/com/sd/api/
bean/MyCLoc
.kt
→
mapapi/src/main/java/com/sd/api/
parkroad/RoadPos
.kt
View file @
a0061ae5
package
com.sd.api.
bean
package
com.sd.api.
parkroad
/**
我的
当前位置**/
/**
局部图
当前位置**/
class
MyCLoc
{
class
RoadPos
{
companion
object
{
companion
object
{
val
instance
:
MyCLoc
by
lazy
{
MyCLoc
()
}
val
instance
:
RoadPos
by
lazy
{
RoadPos
()
}
}
}
/***当前经纬度***/
/***当前经纬度***/
...
@@ -13,8 +13,6 @@ class MyCLoc {
...
@@ -13,8 +13,6 @@ class MyCLoc {
var
speed
=
0f
var
speed
=
0f
/***航向角*/
/***航向角*/
var
bearing
=
0f
var
bearing
=
0f
//精度
var
accuracy
=
0f
/****高程*/
/****高程*/
var
altitude
=
0.0
//
var altitude = 0.0
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/CucsVehicle.kt
0 → 100644
View file @
a0061ae5
package
com.sd.api.scenario
import
com.sd.api.highmap.CarNavPath
import
com.sd.api.highmap.HighMapApi
import
com.sd.api.highmap.HighPos
import
com.sd.api.parkroad.MsParkRoad
import
com.sd.api.parkroad.RoadPos
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
/**车辆管理类***/
object
CucsVehicle
{
private
var
stopCar
=
false
/**
* 移动车辆
* @param carPos 车辆位置
* @param moveType 1=高精地图 2= 局部地图 -1=两者都包括
*/
fun
moveCar
(
vehiclePos
:
VehiclePos
,
moveType
:
Int
)
{
var
highPos
=
HighPos
.
instance
.
apply
{
heading
=
vehiclePos
.
heading
lat
=
vehiclePos
.
lat
lon
=
vehiclePos
.
lng
evel
=
vehiclePos
.
evel
}
var
roadPos
=
RoadPos
.
instance
.
apply
{
lat
=
vehiclePos
.
lat
lng
=
vehiclePos
.
lng
bearing
=
vehiclePos
.
heading
.
toFloat
()
}
if
(
moveType
==
1
)
{
HighMapApi
.
setCarPosition
(
highPos
)
}
else
if
(
moveType
==
2
)
{
MsParkRoad
.
updateMainCar
(
roadPos
,
null
)
}
else
if
(
moveType
==
-
1
)
{
CoroutineScope
(
Dispatchers
.
Default
).
launch
{
HighMapApi
.
setCarPosition
(
highPos
)
MsParkRoad
.
updateMainCar
(
roadPos
,
null
)
}
}
}
fun
stopCar
()
{
stopCar
=
true
}
/**
* 设置车辆移动路径
* @param carNavPath
*/
fun
setCarNaiPath
(
carNavPath
:
CarNavPath
)
{
HighMapApi
.
setCarNavPath
(
carNavPath
)
}
/**
* 清除导航路径
*/
fun
clearCarNaiPath
()
{
var
carNavPath
=
CarNavPath
()
HighMapApi
.
setCarNavPath
(
carNavPath
)
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/scenario/VehiclePos.kt
0 → 100644
View file @
a0061ae5
package
com.sd.api.scenario
/***车辆位置**/
class
VehiclePos
{
companion
object
{
val
instance
:
VehiclePos
by
lazy
{
VehiclePos
()
}
}
var
lat
=
0.0
var
lng
=
0.0
var
heading
=
0.0
var
evel
=
20.80189
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/ui/MapReadyView.kt
View file @
a0061ae5
...
@@ -4,6 +4,7 @@ import com.amap.api.maps.AMap
...
@@ -4,6 +4,7 @@ import com.amap.api.maps.AMap
import
com.minedata.minenavi.map.MapView
import
com.minedata.minenavi.map.MapView
import
com.minedata.minenavi.map.MineMap
import
com.minedata.minenavi.map.MineMap
import
com.sd.api.vms.CarRoadVM
import
com.sd.api.vms.CarRoadVM
import
com.unity3d.player.UnityPlayer
/**
/**
* 地图准备就绪的视图对象
* 地图准备就绪的视图对象
...
@@ -23,6 +24,9 @@ class MapReadyView private constructor() {
...
@@ -23,6 +24,9 @@ class MapReadyView private constructor() {
//四维局部图操作类
//四维局部图操作类
var
carRoadVM
:
CarRoadVM
?
=
null
var
carRoadVM
:
CarRoadVM
?
=
null
//高精地图
var
mUnityPlayer
:
UnityPlayer
?=
null
/**高德在线地图*/
/**高德在线地图*/
var
aMap
:
AMap
?
=
null
var
aMap
:
AMap
?
=
null
...
...
Prev
1
2
Next
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