From 7dbbcad110801a7fef08751e131021357cdff80e Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 2 Jun 2023 19:08:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[3.2.0][Opt]=E4=BC=98=E5=8C=96=E5=85=A8?= =?UTF-8?q?=E8=A7=88=E5=9C=B0=E5=9B=BE=E8=A7=86=E8=A7=92=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=92=8C=E7=BB=98=E5=88=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 详情: 1. 处理定位和轨迹相差过远,甚至车定位飘到国外的情况 2. 优化车已走过轨迹在对向车道距离过近时出现的跳跃现象 --- .../core/function/smp/MarkerDrawerManager.kt | 25 ++++++++--- .../eagle/core/function/view/OverMapView.kt | 45 ++++++++++--------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt index 595ea91c96..fde74be4da 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt @@ -129,6 +129,8 @@ object MarkerDrawerManager { heading: Double ): Int { var currentIndex = 0 //记录疑似点 + // 是否超过200KM + var isLongDistance = false if (routePoints.isNotEmpty()) { //基础点 val baseLatLng = routePoints[0] @@ -136,11 +138,15 @@ object MarkerDrawerManager { var baseDiffDis = CoordinateUtils.calculateLineDistance( realLon, realLat, baseLatLng.longitude, baseLatLng.latitude ) // lon,lat, prelon, prelat + if (baseDiffDis > 200000) { + isLongDistance = true + } val size = routePoints.size for (i in 1 until size) { val latLng = routePoints[i] // 深拷贝数据用于高德地图上轨迹线的绘制 newPoints.add(LatLng(latLng.latitude, latLng.longitude)) + if (isLongDistance) continue val diff = CoordinateUtils.calculateLineDistance( realLon, realLat, latLng.longitude, latLng.latitude ) @@ -160,15 +166,20 @@ object MarkerDrawerManager { } } Log.d("MarkerDrawerManager", "当次计算已走过的点的索引为:$currentIndex,存储的上次索引为:$lastArrivedIndex") - if (currentIndex < lastArrivedIndex) { - if (lastArrivedIndex < size) { - currentIndex = lastArrivedIndex + if (!isLongDistance) { + // 过滤缓存的非当次轨迹的索引,并且出现车已走过索引跳跃过大时视为无效复用上一次计算结果 + if (currentIndex < lastArrivedIndex || (lastArrivedIndex >= 0 && currentIndex - lastArrivedIndex >= 10)) { + if (lastArrivedIndex < size) { + currentIndex = lastArrivedIndex + } + } else { + lastArrivedIndex = currentIndex + } + if (size >= 2) { + newPoints.add(currentIndex + 1, LatLng(realLat, realLon)) + return currentIndex + 1 } - } else { - lastArrivedIndex = currentIndex } - newPoints.add(currentIndex + 1, LatLng(realLat, realLon)) - return currentIndex + 1 } return 0 } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt index b2da8879df..19c63ce5ee 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt @@ -15,10 +15,7 @@ import android.widget.TextView import androidx.annotation.MainThread import androidx.core.graphics.drawable.toBitmap import ch.hsr.geohash.GeoHash -import com.amap.api.maps.AMap -import com.amap.api.maps.CameraUpdate -import com.amap.api.maps.CameraUpdateFactory -import com.amap.api.maps.TextureMapView +import com.amap.api.maps.* import com.amap.api.maps.model.* import com.mogo.eagle.core.data.map.Infrastructure import com.mogo.eagle.core.data.map.MogoLocation @@ -359,10 +356,7 @@ class OverMapView @JvmOverloads constructor( resources.getDrawable(R.drawable.transparent_background, null) .toBitmap(AutoSizeUtils.dp2px(context, 32f), AutoSizeUtils.dp2px(context, 230f)) ) - CallerPlanningRottingListenerManager.addListener(TAG, this) initAMapView(context) - // 注册定位监听 - CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) //设置全览模式 overLayerView?.setOnClickListener { displayCustomOverView() } overLayerView?.let { @@ -407,6 +401,9 @@ class OverMapView @JvmOverloads constructor( override fun onAttachedToWindow() { super.onAttachedToWindow() + CallerPlanningRottingListenerManager.addListener(TAG, this) + // 注册定位监听 + CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) CallerFuncBizListenerManager.addListener(TAG, object : IFuncBizProvider { override fun onInfStructures(map: HashMap>?) { geoHashInfMap = map @@ -718,14 +715,16 @@ class OverMapView @JvmOverloads constructor( */ private fun drawCarMarker(location: MogoLocation?) { if (location == null) return - if (mCarMarker != null) { - val currentLatLng = LatLng(location.latitude, location.longitude) - mCarMarker!!.rotateAngle = (360 - location.heading).toFloat() - mCarMarker!!.position = currentLatLng - mCarMarker!!.setToTop() - if (mCompassMarker != null) { - mCompassMarker!!.rotateAngle = (360 - location.heading).toFloat() - mCompassMarker!!.position = currentLatLng + singlePool.execute { + if (mCarMarker != null) { + val currentLatLng = LatLng(location.latitude, location.longitude) + mCarMarker!!.rotateAngle = (360 - location.heading).toFloat() + mCarMarker!!.position = currentLatLng + mCarMarker!!.setToTop() + if (mCompassMarker != null) { + mCompassMarker!!.rotateAngle = (360 - location.heading).toFloat() + mCompassMarker!!.position = currentLatLng + } } } } @@ -780,6 +779,7 @@ class OverMapView @JvmOverloads constructor( texIndexList.add(i - 1) } if (mAMap != null && coordinates.size > 2) { +// Log.d(TAG, "绘制时轨迹点数为:${coordinates.size},纹理数为:${textureList.size},车辆index为:$locIndex") //设置线段纹理 val polylineOptions = PolylineOptions() polylineOptions.addAll(coordinates) @@ -890,12 +890,15 @@ class OverMapView @JvmOverloads constructor( override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) { gnssInfo?.let { - mLocation = it - lonLatHeading = Triple(it.longitude, it.latitude, it.heading) - drawCarMarker(it) - if (isFirstLocation) { - displayCustomOverView() - isFirstLocation = false + // 在中国境内 + if (CoordinateConverter.isAMapDataAvailable(it.latitude, it.longitude)) { + mLocation = it + lonLatHeading = Triple(it.longitude, it.latitude, it.heading) + drawCarMarker(it) + if (isFirstLocation) { + displayCustomOverView() + isFirstLocation = false + } } } From 1270fdeb13a6c6c0544ffb9fec354e663ff40108 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Fri, 2 Jun 2023 19:39:29 +0800 Subject: [PATCH 2/3] [charter] [feature] [bus driver passenger need statusbar] --- app/script/productFlavors/bus.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/script/productFlavors/bus.gradle b/app/script/productFlavors/bus.gradle index 271d9e36e6..1aeb2c155d 100644 --- a/app/script/productFlavors/bus.gradle +++ b/app/script/productFlavors/bus.gradle @@ -19,8 +19,13 @@ project.android.productFlavors { // ②连接的工控机IP地址 buildConfigField 'String', 'ADAS_CONNECT_IP', "\"192.168.8.102\"" - // ③是否需要重写状态栏 - buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true' + if (isCurrentDriver("bus")) { + // ③是否需要重写状态栏 + buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'false' + } else if (isCurrentPassenger("bus")) { + // ③是否需要重写状态栏 + buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true' + } // ④构建 是否支持多屏异显异交互 buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false' From 8ebcdadb9a4e6181414bc2e5ab71959aed25daa1 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 2 Jun 2023 19:40:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[3.2.0][Fix]=E8=A7=A3=E5=86=B3=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eagle/core/function/view/OverMapView.kt | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt index 19c63ce5ee..94b9a31f2c 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt @@ -689,21 +689,25 @@ class OverMapView @JvmOverloads constructor( boundsBuilder.include(currentLatLng) val cameraPosition = CameraPosition.Builder().tilt(mTilt).build() //第二个参数为四周留空宽度 - mAMap!!.moveCamera( - CameraUpdateFactory.newLatLngBoundsRect( - boundsBuilder.build(), - AutoSizeUtils.dp2px(context, leftPadding.toFloat()), - AutoSizeUtils.dp2px(context, rightPadding.toFloat()), - AutoSizeUtils.dp2px(context, topPadding.toFloat()), - AutoSizeUtils.dp2px(context, bottomPadding.toFloat()) + if (mAMap != null) { + mAMap!!.moveCamera( + CameraUpdateFactory.newLatLngBoundsRect( + boundsBuilder.build(), + AutoSizeUtils.dp2px(context, leftPadding.toFloat()), + AutoSizeUtils.dp2px(context, rightPadding.toFloat()), + AutoSizeUtils.dp2px(context, topPadding.toFloat()), + AutoSizeUtils.dp2px(context, bottomPadding.toFloat()) + ) ) - ) - mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + } } else { - //设置希望展示的地图缩放级别 - val cameraPosition = CameraPosition.Builder() - .target(mCarMarker!!.position).tilt(mTilt).zoom(zoomLevel.toFloat()).build() - mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + if (mCarMarker != null && mAMap != null) { + //设置希望展示的地图缩放级别 + val cameraPosition = CameraPosition.Builder() + .target(mCarMarker!!.position).tilt(mTilt).zoom(zoomLevel.toFloat()).build() + mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + } } } } @@ -869,21 +873,25 @@ class OverMapView @JvmOverloads constructor( if (!isOnlyCarLocation) { val cameraPosition = CameraPosition.Builder().tilt(mTilt).build() //第二个参数为四周留空宽度 - mAMap!!.moveCamera( - CameraUpdateFactory.newLatLngBoundsRect( - boundsBuilder.build(), - AutoSizeUtils.dp2px(context, leftPadding.toFloat()), - AutoSizeUtils.dp2px(context, rightPadding.toFloat()), - AutoSizeUtils.dp2px(context, topPadding.toFloat()), - AutoSizeUtils.dp2px(context, bottomPadding.toFloat()) + if (mAMap != null) { + mAMap!!.moveCamera( + CameraUpdateFactory.newLatLngBoundsRect( + boundsBuilder.build(), + AutoSizeUtils.dp2px(context, leftPadding.toFloat()), + AutoSizeUtils.dp2px(context, rightPadding.toFloat()), + AutoSizeUtils.dp2px(context, topPadding.toFloat()), + AutoSizeUtils.dp2px(context, bottomPadding.toFloat()) + ) ) - ) - mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + } } else { //设置希望展示的地图缩放级别 - val cameraPosition = CameraPosition.Builder() - .target(mCarMarker!!.position).tilt(mTilt).zoom(zoomLevel.toFloat()).build() - mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + if (mCarMarker != null && mAMap != null) { + val cameraPosition = CameraPosition.Builder() + .target(mCarMarker!!.position).tilt(mTilt).zoom(zoomLevel.toFloat()).build() + mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + } } } }