Commit 2b65e6f7 authored by p x's avatar p x
Browse files

最小矩形

parent 9d8a25ea
...@@ -42,12 +42,12 @@ ...@@ -42,12 +42,12 @@
<!-- 去UNITY广告--> <!-- 去UNITY广告-->
<meta-data <!-- <meta-data-->
android:name="unity.splash-mode" <!-- android:name="unity.splash-mode"-->
android:value="0" /> <!-- android:value="0" />-->
<meta-data <!-- <meta-data-->
android:name="unity.splash-enable" <!-- android:name="unity.splash-enable"-->
android:value="False" /> <!-- android:value="False" />-->
<uses-library <uses-library
android:name="org.apache.http.legacy" android:name="org.apache.http.legacy"
......
...@@ -162,12 +162,14 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() { ...@@ -162,12 +162,14 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() {
} }
override fun getToData() { override fun getToData() {
//开启websocket if (!mainVm.isMock) {
getTarget() //开启websocket
// getV2x() getTarget()
//开启2个HTTP sse getV2x()
// getCarVehicle() //开启2个HTTP sse
// getAvpStatus() getCarVehicle()
getAvpStatus()
}
//获取车位占用情况 //获取车位占用情况
// getSpaceInfo() // getSpaceInfo()
} }
...@@ -237,6 +239,8 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() { ...@@ -237,6 +239,8 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() {
mapOpt.showParkLight(businessType, businessStatus, avpStatu.space) mapOpt.showParkLight(businessType, businessStatus, avpStatu.space)
//判断在泊车状态下的倒挡绘制倒车路线,改变镜头视角,,判断车是否到达停车点 //判断在泊车状态下的倒挡绘制倒车路线,改变镜头视角,,判断车是否到达停车点
mapOpt.drawReversePark(businessType, businessStatus, gearType, avpStatu.space) mapOpt.drawReversePark(businessType, businessStatus, gearType, avpStatu.space)
//重置变量
resetVariable(businessStatus)
//根据AVP任务状态判停车特效是否关闭 //根据AVP任务状态判停车特效是否关闭
// mapOpt.showEffectAvpStatu(businessType, businessStatus) // mapOpt.showEffectAvpStatu(businessType, businessStatus)
} }
...@@ -283,7 +287,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() { ...@@ -283,7 +287,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() {
/***重置变量**/ /***重置变量**/
private fun resetVariable(businessStatus: String) { private fun resetVariable(businessStatus: String) {
if (businessStatus == AvpContants.TRANSPORT_COMPLETED) { if (businessStatus == AvpContants.TRANSPORT_COMPLETED || businessStatus == AvpContants.TRANSPORT_CANCELED) {
mainVm.isGetVehDetail = false mainVm.isGetVehDetail = false
// mapOpt.smallMapLine = false // mapOpt.smallMapLine = false
mapOpt.sliceIndex = 0 mapOpt.sliceIndex = 0
......
...@@ -102,7 +102,7 @@ class MainVm @Inject constructor( ...@@ -102,7 +102,7 @@ class MainVm @Inject constructor(
lateinit var mockVM: MockVM lateinit var mockVM: MockVM
//是否需要模拟 //是否需要模拟
var isMock = false var isMock = true
//车辆位姿数据 //车辆位姿数据
// var carVehicle = MutableLiveData<CarVehicle>() // var carVehicle = MutableLiveData<CarVehicle>()
...@@ -247,7 +247,7 @@ class MainVm @Inject constructor( ...@@ -247,7 +247,7 @@ class MainVm @Inject constructor(
fun subVehicle(): StateFlow<CarVehicle> { fun subVehicle(): StateFlow<CarVehicle> {
if (isMock) { if (isMock) {
// mockVM.subVehicle(carVehicle) // mockVM.subVehicle(carVehicle)
mockVM.onVehicleMock(carVehicle) mockVM.onVehicleMockPark(carVehicle)
} else { } else {
var url = "${MyContants.HOST}/api/avpweb/hmi/monitor/v1/monitorDrivenStatus" var url = "${MyContants.HOST}/api/avpweb/hmi/monitor/v1/monitorDrivenStatus"
carCb.url = url carCb.url = url
......
...@@ -3,6 +3,7 @@ package com.sd.cavphmi.viewmodels ...@@ -3,6 +3,7 @@ package com.sd.cavphmi.viewmodels
import android.content.Context import android.content.Context
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Point import android.graphics.Point
import android.graphics.Rect
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.minedata.minenavi.map.Marker import com.minedata.minenavi.map.Marker
...@@ -79,7 +80,8 @@ class MapOpt @Inject constructor( ...@@ -79,7 +80,8 @@ class MapOpt @Inject constructor(
//画全局路径 //画全局路径
fun drawAllLines(drivenDecision: DrivenDecision, businessStatus: String) { fun drawAllLines(drivenDecision: DrivenDecision, businessStatus: String) {
if (businessStatus == AvpContants.TRANSPORT_COMPLETED || businessStatus == AvpContants.TRANSPORT_CANCELED if (businessStatus == AvpContants.TRANSPORT_COMPLETED || businessStatus == AvpContants.TRANSPORT_CANCELED
|| businessStatus == AvpContants.PARK_COMPLETED) { || businessStatus == AvpContants.PARK_COMPLETED
) {
//清除全局路径 //清除全局路径
HighMapApi.setCarNavPath(emptyList()) HighMapApi.setCarNavPath(emptyList())
return return
...@@ -127,7 +129,7 @@ class MapOpt @Inject constructor( ...@@ -127,7 +129,7 @@ class MapOpt @Inject constructor(
if (mMineMap != null && car.vehiclePos != null) { if (mMineMap != null && car.vehiclePos != null) {
if (mSmallMapCar == null) { if (mSmallMapCar == null) {
var point = var point =
LatLng(car.vehiclePos?.get(1)?:0.0, car.vehiclePos?.get(0)?:0.0) LatLng(car.vehiclePos?.get(1) ?: 0.0, car.vehiclePos?.get(0) ?: 0.0)
mSmallMapCar = MyLocationStyle("res/icons/carIconInSmallMap.png", true) mSmallMapCar = MyLocationStyle("res/icons/carIconInSmallMap.png", true)
mSmallMapCar?.myLocationType(MyLocationStyle.LOCATION_TYPE_EXTERNAL) mSmallMapCar?.myLocationType(MyLocationStyle.LOCATION_TYPE_EXTERNAL)
val scaleFactor = - val scaleFactor = -
...@@ -149,7 +151,8 @@ class MapOpt @Inject constructor( ...@@ -149,7 +151,8 @@ class MapOpt @Inject constructor(
if (carVehicle.vehiclePos == null) if (carVehicle.vehiclePos == null)
return return
synchronized(NativeEnv.SyncObject) { synchronized(NativeEnv.SyncObject) {
var ndsLatLng = LatLng(carVehicle.vehiclePos?.get(1)?:0.0, carVehicle.vehiclePos?.get(0)?:0.0) var ndsLatLng =
LatLng(carVehicle.vehiclePos?.get(1) ?: 0.0, carVehicle.vehiclePos?.get(0) ?: 0.0)
var tHead = carVehicle.vehiclePos!!.get(2).toFloat() var tHead = carVehicle.vehiclePos!!.get(2).toFloat()
//刷新小地图自车位置 //刷新小地图自车位置
if (mSmallMapCar != null) { if (mSmallMapCar != null) {
...@@ -232,7 +235,21 @@ class MapOpt @Inject constructor( ...@@ -232,7 +235,21 @@ class MapOpt @Inject constructor(
} else { } else {
deleteSmapLine() deleteSmapLine()
} }
// } }
/**车到终点生成一个矩形*/
// fun drawEndArea(fromLng: Double, fromLat: Double, toLng: Double, toLat: Double) {
fun drawEndArea(lat1: Double, lon1: Double, lat2: Double, lon2: Double) {
var minLat = Math.min(lat1, lat2)
var maxLat = Math.max(lat1, lat2)
var minLon = minOf(lon1, lon2)
var maxLon = maxOf(lon1, lon2)
var rect = Rect(
minLat.toInt(), maxLat.toInt(),
minLon.toInt(), maxLon.toInt()
)
mMineMap?.fitWorldArea(rect)
} }
......
...@@ -3,6 +3,7 @@ package com.sd.cavphmi.viewmodels ...@@ -3,6 +3,7 @@ package com.sd.cavphmi.viewmodels
import android.content.Context import android.content.Context
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Point import android.graphics.Point
import android.graphics.Rect
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
...@@ -41,8 +42,11 @@ import kotlinx.coroutines.flow.MutableSharedFlow ...@@ -41,8 +42,11 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Polygon
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.absoluteValue import kotlin.math.max
import kotlin.math.min
@HiltViewModel @HiltViewModel
...@@ -67,11 +71,11 @@ class MockVM @Inject constructor( ...@@ -67,11 +71,11 @@ class MockVM @Inject constructor(
} }
/****** /******
* 模拟车辆位姿 * 模拟车辆位姿 泊车
* @param binding 里的航向角 * @param binding 里的航向角
* @param binding 里的速度 * @param binding 里的速度
* **/ * **/
fun onVehicleMock( fun onVehicleMockPark(
carVehicle: MutableStateFlow<CarVehicle> carVehicle: MutableStateFlow<CarVehicle>
) { ) {
// HighMapApi.setCameraAngle(30f) // HighMapApi.setCameraAngle(30f)
...@@ -88,6 +92,8 @@ class MockVM @Inject constructor( ...@@ -88,6 +92,8 @@ class MockVM @Inject constructor(
smallLineMock(mRoutes) smallLineMock(mRoutes)
//画终点 //画终点
addEndMarker(LatLng(39.809039362307594, 116.50254394816011)) addEndMarker(LatLng(39.809039362307594, 116.50254394816011))
//用矩形框柱
drawEndArea(39.81014469509955,116.50238005214746,39.809039362307594, 116.50254394816011)
//画出全局路径 //画出全局路径
var lines = mRoutes.rs.map { var lines = mRoutes.rs.map {
AllLine(it[1], it[0]) AllLine(it[1], it[0])
...@@ -164,7 +170,8 @@ class MockVM @Inject constructor( ...@@ -164,7 +170,8 @@ class MockVM @Inject constructor(
//改变镜头角度 //改变镜头角度
HighMapApi.setCameraAngle(60f) HighMapApi.setCameraAngle(60f)
HighMapApi.setCameraDistance(30f) HighMapApi.setCameraDistance(30f)
//前进 CarPanelBean.instance.speed.set(5)//减速
//从停车点再前进一点
var forword = parkPath.result.routes.find { it.gear == 3 } var forword = parkPath.result.routes.find { it.gear == 3 }
forword?.polyline?.forEach { poly -> forword?.polyline?.forEach { poly ->
cCar = CarVehicle().apply { cCar = CarVehicle().apply {
...@@ -242,6 +249,27 @@ class MockVM @Inject constructor( ...@@ -242,6 +249,27 @@ class MockVM @Inject constructor(
} }
fun drawEndArea(lat1: Double, lon1: Double, lat2: Double, lon2: Double) {
var minLat = Math.min(lat1, lat2).times(100000)
var maxLat = Math.max(lat1, lat2).times(100000)
var minLon = minOf(lon1, lon2).times(100000)
var maxLon = maxOf(lon1, lon2).times(100000)
var rect = Rect(
minLat.toInt(), maxLat.toInt(),
minLon.toInt(), maxLon.toInt()
)
mMineMap?.fitWorldArea(rect)
}
//召车
fun onVehicleMockCall(
carVehicle: MutableStateFlow<CarVehicle>
){
}
/***跑服务器的模拟数据**/ /***跑服务器的模拟数据**/
fun subVehicle( fun subVehicle(
carLiveData: MutableStateFlow<CarVehicle> carLiveData: MutableStateFlow<CarVehicle>
......
...@@ -61,13 +61,14 @@ ...@@ -61,13 +61,14 @@
android:layout_height="25dp" android:layout_height="25dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone"> android:visibility="visible">
<TextView <TextView
android:id="@+id/bt_vehicle" android:id="@+id/bt_vehicle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/text_blue" android:background="@color/text_blue"
android:gravity="center"
android:text="车辆位姿" android:text="车辆位姿"
android:textColor="@color/white" /> android:textColor="@color/white" />
...@@ -182,7 +183,7 @@ ...@@ -182,7 +183,7 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_marginEnd="@dimen/dp_10" android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_15" android:layout_marginBottom="@dimen/dp_35"
android:background="@drawable/rect_white_small_map_4" android:background="@drawable/rect_white_small_map_4"
android:padding="3dp"> android:padding="3dp">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment