From 193454cc6cfbe7f8e4f4920c3897ff23c60f3194 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 11 Jan 2023 19:28:34 +0800 Subject: [PATCH] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20[Change]=20[=201?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E5=BA=95=E7=9B=98=E6=95=B0=E6=8D=AE?= =?UTF-8?q?Gnss=E5=9B=9E=E8=B0=83=E4=B8=BA=E5=AE=9A=E4=BD=8D=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=202=E3=80=81=E5=A2=9E=E5=8A=A0WGS84=E8=BD=ACGCJ02?= =?UTF-8?q?=E9=AB=98=E5=BE=B7=E5=9D=90=E6=A0=87=E7=B3=BB=E6=96=B9=E6=B3=95?= =?UTF-8?q?=203=E3=80=81=E5=A2=9E=E5=8A=A0=E5=BA=95=E7=9B=98=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BD=AC=E6=8D=A2=E4=B8=BAGCJ02=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E5=90=8E=E7=9A=84=E5=9B=9E=E8=B0=83=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../mogo/launcher/stageone/ConfigStartUp.kt | 5 + .../autopilot/adapter/MoGoAdasListenerImpl.kt | 37 +++-- .../badcase/biz/AIDataCollectWindow.kt | 12 +- .../badcase/biz/InitiativeBadCaseWindow.kt | 12 +- .../badcase/biz/PassiveBadCaseWindow.kt | 12 +- .../status/flow/rtk/RTKImpl.kt | 29 ++-- .../hmi/ui/setting/DebugSettingView.kt | 8 +- .../function/main/MainMoGoApplication.java | 2 +- .../eagle/core/function/map/MapFragment.kt | 12 +- .../autopilot/IMoGoChassisGnssInfoListener.kt | 18 --- .../IMoGoChassisLocationGCJ02Listener.kt | 18 +++ .../IMoGoChassisLocationWGS84Listener.kt | 18 +++ ...llerChassisLocationGCJ20ListenerManager.kt | 51 ++++++ ...lerChassisLocationWGS84ListenerManager.kt} | 14 +- .../utilcode/util/CoordinateTransform.java | 153 ++++++++++++++++++ .../java/com/mogo/map/IMogoMapApiBuilder.java | 25 --- .../com/mogo/map/CustomMapApiBuilder.java | 68 +++----- .../java/com/mogo/map/MogoLocationClient.java | 4 +- .../com/mogo/map/MogoMapDelegateFactory.java | 49 ------ .../com/mogo/map/MogoMapUIController.java | 2 +- .../main/java/com/mogo/map/MogoMapView.java | 16 +- 21 files changed, 351 insertions(+), 214 deletions(-) delete mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisGnssInfoListener.kt create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationGCJ02Listener.kt create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt create mode 100644 core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ20ListenerManager.kt rename core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/{CallerChassisGnssInfoListenerManager.kt => CallerChassisLocationWGS84ListenerManager.kt} (50%) create mode 100644 core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CoordinateTransform.java delete mode 100644 libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapApiBuilder.java delete mode 100644 libraries/mogo-map/src/main/java/com/mogo/map/MogoMapDelegateFactory.java diff --git a/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt index 1ef6a62b0c..55c8949fd4 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt @@ -160,6 +160,11 @@ class ConfigStartUp : AndroidStartup() { } else { mapParams.setStyleMode(MapParams.MAP_STYLE_NIGHT_VR) } + //todo 临时放在这 @梁利辉 + if (AppIdentityModeUtils.isBusPassenger(FunctionBuildConfig.appIdentityMode)) { + mapParams.setShadowEnable(false) + } + MapAutoApi.init(context, mapParams) } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt index 90b3da6225..9945d62461 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -42,11 +42,12 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListe import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotIdentifyDataUpdate import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotIdentifyPlanningObj import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotWarnMessage -import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager.invokePNCActions import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordConfig import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordResult import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager.invokeAutopilotStatistics -import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager.invokeAutopilotCarStateData +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02 +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84 +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager.invokePNCActions import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager.invokeAutopilotRotting import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListenerManager.invokeAutopilotTrajectory import com.mogo.eagle.core.function.call.autopilot.CallerStartAutopilotFailedListenerManager.invokeStartAutopilotFailed @@ -128,7 +129,10 @@ class MoGoAdasListenerImpl : OnAdasListener { clientPkFileName = "sn" ) override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo?) { - invokeAutopilotCarStateData(gnssInfo) + // WGS84坐标系高精度位置信息 + invokeChassisLocationWGS84(gnssInfo) + // GCJ02高德坐标系位置信息 + invokeChassisLocationGCJ02(gnssInfo) if (gnssInfo != null) { if (1 == FunctionBuildConfig.gpsProvider) { // 同步给MAP地图 @@ -153,12 +157,12 @@ class MoGoAdasListenerImpl : OnAdasListener { * @param vehicleState 数据 */ @ChainLog( - linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE, - linkCode = CHAIN_LINK_ADAS, - endpoint = PAD, - nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE, - paramIndexes = [0, 1], - clientPkFileName = "sn" + linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE, + linkCode = CHAIN_LINK_ADAS, + endpoint = PAD, + nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE, + paramIndexes = [0, 1], + clientPkFileName = "sn" ) override fun onVehicleState(header: MessagePad.Header, vehicleState: VehicleStateOuterClass.VehicleState?) { if (vehicleState != null) { @@ -196,12 +200,12 @@ class MoGoAdasListenerImpl : OnAdasListener { * @param vehicleState 数据 */ @ChainLog( - linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE, - linkCode = CHAIN_LINK_ADAS, - endpoint = PAD, - nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE, - paramIndexes = [0, 1], - clientPkFileName = "sn" + linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE, + linkCode = CHAIN_LINK_ADAS, + endpoint = PAD, + nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE, + paramIndexes = [0, 1], + clientPkFileName = "sn" ) override fun onChassisStates(header: MessagePad.Header, chassisStates: ChassisStatesOuterClass.ChassisStates?) { if (chassisStates != null) { @@ -503,6 +507,7 @@ class MoGoAdasListenerImpl : OnAdasListener { invokePNCActions(it) } } + /** * 重构后的功能状态 * @@ -512,6 +517,7 @@ class MoGoAdasListenerImpl : OnAdasListener { override fun onFunctionStates(header: MessagePad.Header?, functionStates: FunctionStates.FSMFunctionStates?) { } + /** * 清扫车指标数据 * @@ -521,6 +527,7 @@ class MoGoAdasListenerImpl : OnAdasListener { override fun onSweeperTaskIndexData(header: MessagePad.Header?, roboSweeperTaskIndex: RoboSweeperTaskIndexOuterClass.RoboSweeperTaskIndex?) { } + /** * Bag管理应答 * diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt index ea6953e00d..a37d4520a6 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt @@ -10,10 +10,10 @@ import android.widget.RadioButton import android.widget.TextView import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.eagle.core.data.app.AppConfigInfo -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager -import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA @@ -37,7 +37,7 @@ import java.util.* * @since: 2022/7/12 */ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener, - IMoGoAutopilotRecordListener, IMoGoChassisGnssInfoListener { + IMoGoAutopilotRecordListener, IMoGoChassisLocationWGS84Listener { companion object { const val TAG = "AIDataCollectWindow" @@ -117,7 +117,7 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener //采集结果回调监听 CallerAutopilotRecordListenerManager.addListener(this.hashCode().toString(), this) // 添加 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.addListener(this.hashCode().toString(), this) + CallerChassisLocationWGS84ListenerManager.addListener(this.hashCode().toString(), this) //开始录制AI数据采集Bag包 CallerAutoPilotManager.recordPackage( 99, @@ -341,7 +341,7 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener //注销采集结果回调监听 CallerAutopilotRecordListenerManager.removeListener(this.hashCode().toString()) // 移除 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.removeListener(this.hashCode().toString()) + CallerChassisLocationWGS84ListenerManager.removeListener(this.hashCode().toString()) if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout) } @@ -353,7 +353,7 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener fun closeWindow() } - override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { latitude = gnssInfo?.latitude longitude = gnssInfo?.longitude } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt index 7227543af4..4ab9e49463 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt @@ -14,10 +14,10 @@ import android.widget.TextView import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.badcase.RecordCaseEntity -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager -import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA @@ -47,7 +47,7 @@ import java.util.* * @since: 2022/7/13 */ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchListener, - IMoGoAutopilotRecordListener, IMoGoChassisGnssInfoListener { + IMoGoAutopilotRecordListener, IMoGoChassisLocationWGS84Listener { companion object { const val TAG = "InitiativeBadCaseWindow" @@ -140,7 +140,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList //采集结果回调监听 CallerAutopilotRecordListenerManager.addListener(this.hashCode().toString(), this) // 添加 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.addListener(this.hashCode().toString(), this) + CallerChassisLocationWGS84ListenerManager.addListener(this.hashCode().toString(), this) viewAudioButton.setOnClickListener { audioStatus = !audioStatus setAudio(audioStatus) @@ -367,7 +367,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList //注销采集结果回调监听 CallerAutopilotRecordListenerManager.removeListener(this.hashCode().toString()) // 移除 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.removeListener(this.hashCode().toString()) + CallerChassisLocationWGS84ListenerManager.removeListener(this.hashCode().toString()) if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout) } @@ -393,7 +393,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList fun closeWindow() } - override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { latitude = gnssInfo?.latitude longitude = gnssInfo?.longitude } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt index 24bcb28ac5..f2f2355594 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt @@ -17,8 +17,8 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.msgbox.MsgBoxBean import com.mogo.eagle.core.data.msgbox.RecordBagMsg -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener -import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA @@ -44,7 +44,7 @@ import java.io.File * @since: 2022/7/17 */ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListener, - IMoGoChassisGnssInfoListener, CompoundButton.OnCheckedChangeListener { + IMoGoChassisLocationWGS84Listener, CompoundButton.OnCheckedChangeListener { companion object { const val TAG = "PassiveBadCaseWindow" @@ -117,7 +117,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene "时间:${millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat())}" tvPassiveIdentity.text = "身份:${BadCaseConfig.identity}" // 添加 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.addListener(TAG, this) + CallerChassisLocationWGS84ListenerManager.addListener(TAG, this) viewAudioButton.setOnClickListener { audioStatus = !audioStatus setAudio(audioStatus) @@ -361,7 +361,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene fun hideFloatWindow() { // 移除 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.removeListener(TAG) + CallerChassisLocationWGS84ListenerManager.removeListener(TAG) if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout) } @@ -380,7 +380,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene fun closeWindow() } - override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { latitude = gnssInfo?.latitude longitude = gnssInfo?.longitude } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt index c2aa5368b1..825574fb98 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt @@ -1,20 +1,27 @@ package com.zhjt.mogo_core_function_devatools.status.flow.rtk -import android.content.* -import android.util.* -import com.mogo.eagle.core.function.api.autopilot.* -import com.mogo.eagle.core.function.call.autopilot.* +import android.content.Context +import android.util.Log +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA import com.zhjt.mogo_core_function_devatools.status.entity.RTKStatus import com.zhjt.mogo_core_function_devatools.status.flow.IFlow -import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch import mogo.telematics.pad.MessagePad.GnssInfo import system_master.SystemStatusInfo.HealthInfo import system_master.SystemStatusInfo.StatusInfo -import java.util.concurrent.atomic.* +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicReference -internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatusListener, IMoGoChassisGnssInfoListener { +internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatusListener, IMoGoChassisLocationWGS84Listener { companion object { const val TAG = "RTKImpl" } @@ -34,7 +41,7 @@ internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatu send(RTKStatus(getDesc(), getCode())) CallerLogger.d("$M_DEVA$TAG", "-- onCreate --") CallerAutoPilotStatusListenerManager.addListener(TAG, this) - CallerChassisGnssInfoListenerManager.addListener(TAG, this) + CallerChassisLocationWGS84ListenerManager.addListener(TAG, this) if (CallerAutoPilotManager.isConnected()) { check() } @@ -78,7 +85,7 @@ internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatu } } - override fun onAutopilotCarStateData(gnssInfo: GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: GnssInfo?) { if (isOldVersion.get()) { if (isRTKEnabled()) { send(RTKStatus("RTK", 0)) @@ -95,7 +102,7 @@ internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatu private fun isRTKEnabled(): Boolean { val code = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode() - val gnssInfo = CallerChassisGnssInfoListenerManager.getCurrentGnssInfo() + val gnssInfo = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() return CallerAutoPilotManager.isConnected() && ( code != "EHW_RTK" && code != "EHW_GNSS" && @@ -117,6 +124,6 @@ internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatu isOldVersion.set(false) CallerLogger.d("$M_DEVA$TAG", "-- onDestroy --") CallerAutoPilotStatusListenerManager.removeListener(TAG) - CallerChassisGnssInfoListenerManager.removeListener(TAG) + CallerChassisLocationWGS84ListenerManager.removeListener(TAG) } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 1ba35e6b2e..7fc0626836 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -101,7 +101,7 @@ class DebugSettingView @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoObuStatusListener, IMoGoAutopilotStatusListener, - IMoGoChassisGnssInfoListener, + IMoGoChassisLocationWGS84Listener, IMoGoMapLocationListener, IMoGoAutopilotIdentifyListener, IMoGoPlanningRottingListener, @@ -198,7 +198,7 @@ class DebugSettingView @JvmOverloads constructor( // 添加 ADAS状态 监听 CallerAutoPilotStatusListenerManager.addListener(TAG, this) // 添加 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.addListener(TAG, this) + CallerChassisLocationWGS84ListenerManager.addListener(TAG, this) // 添加 地图样式改变 监听 CallerMapLocationListenerManager.addListener(TAG, this, false) // 添加 域控制器感知数据 监听 @@ -241,7 +241,7 @@ class DebugSettingView @JvmOverloads constructor( // 移除 ADAS状态 监听 CallerAutoPilotStatusListenerManager.removeListener(TAG) // 移除 ADAS车辆状态&定位 监听 - CallerChassisGnssInfoListenerManager.removeListener(TAG) + CallerChassisLocationWGS84ListenerManager.removeListener(TAG) // 移除 地图样式改变 监听 CallerMapLocationListenerManager.removeListener(TAG, false) // 移除 域控制器感知数据 监听 @@ -1973,7 +1973,7 @@ class DebugSettingView @JvmOverloads constructor( } } - override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { mGnssInfo = gnssInfo //实时加速度列表 ThreadUtils.runOnUiThread { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index d4bd696b6f..7c194abb85 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -226,7 +226,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { // MogoModulePaths.addModuleFunction(new MogoModule("/driver/api", "IMoGoFunctionProvider")); // MogoModulePaths.addModuleFunction(new MogoModule("/passenger/api", "IMoGoFunctionProvider")); - MogoModulePaths.addBaseModule(new MogoModule(MapApiPath.PATH, "CustomMapApiBuilder")); +// MogoModulePaths.addBaseModule(new MogoModule(MapApiPath.PATH, "CustomMapApiBuilder")); // MogoModulePaths.addBaseModule(new MogoModule(V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME)); // OBU 模块 diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt index 7423afe1ef..f85f0c028c 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt @@ -9,7 +9,7 @@ import com.mogo.commons.mvp.MvpFragment import com.mogo.eagle.core.data.constants.MoGoConfig import com.mogo.eagle.core.data.constants.MoGoFragmentPaths import com.mogo.eagle.core.data.map.CenterLine -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider @@ -17,7 +17,7 @@ import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener import com.mogo.eagle.core.function.business.MapPointCloudSubscriber import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager -import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight @@ -54,7 +54,7 @@ class MapFragment : MvpFragment(), MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener, - IMoGoChassisGnssInfoListener, + IMoGoChassisLocationWGS84Listener, IMoGoPlanningRottingListener, IMoGoChassisLamplightListener { @@ -115,7 +115,7 @@ class MapFragment : MvpFragment(), // 添加换肤监听 CallerSkinModeListenerManager.addListener(Companion.functionName, this) CallerPlanningRottingListenerManager.addListener(Companion.functionName, this) - CallerChassisGnssInfoListenerManager.addListener(Companion.functionName, this) + CallerChassisLocationWGS84ListenerManager.addListener(Companion.functionName, this) CallerChassisLamplightListenerManager.addListener(Companion.functionName, this) } @@ -234,7 +234,7 @@ class MapFragment : MvpFragment(), override fun onDestroyView() { CallerSkinModeListenerManager.removeListener(Companion.functionName) CallerPlanningRottingListenerManager.removeListener(Companion.functionName) - CallerChassisGnssInfoListenerManager.removeListener(Companion.functionName) + CallerChassisLocationWGS84ListenerManager.removeListener(Companion.functionName) CallerChassisLamplightListenerManager.removeListener(Companion.functionName) if (mMogoMapView != null) { @@ -361,7 +361,7 @@ class MapFragment : MvpFragment(), private var isShowTurnLight = false private var brakeLight = -1 - override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { if (gnssInfo != null) { //设置刹车信息 if (gnssInfo.acceleration < SharedPrefsMgr.getInstance(Utils.getApp()).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5f)) { diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisGnssInfoListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisGnssInfoListener.kt deleted file mode 100644 index bd9e945b73..0000000000 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisGnssInfoListener.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.mogo.eagle.core.function.api.autopilot - -import mogo.telematics.pad.MessagePad - -/** - *@author xiaoyuzhou - *@date 2021/11/2 2:06 下午 - * 车辆定位 数据 数据 回调监听 - */ -interface IMoGoChassisGnssInfoListener { - - /** - * 车辆状态&定位 数据 - * - * @param gnssInfo - */ - fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) -} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationGCJ02Listener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationGCJ02Listener.kt new file mode 100644 index 0000000000..8cff2a917c --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationGCJ02Listener.kt @@ -0,0 +1,18 @@ +package com.mogo.eagle.core.function.api.autopilot + +import mogo.telematics.pad.MessagePad + +/** + * @author donghongyu + * @date 2023/1/11 2:06 下午 + * 车辆定位 GCJ02 坐标系-高德坐标系 数据 回调监听 + */ +interface IMoGoChassisLocationGCJ02Listener { + + /** + * 车辆定位 GCJ02 坐标系-高德坐标系 数据 + * + * @param gnssInfo + */ + fun onChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt new file mode 100644 index 0000000000..6786ce6430 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt @@ -0,0 +1,18 @@ +package com.mogo.eagle.core.function.api.autopilot + +import mogo.telematics.pad.MessagePad + +/** + * @author donghongyu + * @date 2023/1/11 2:06 下午 + * 车辆定位 WGS84 坐标系-高精度坐标系 数据 回调监听 + */ +interface IMoGoChassisLocationWGS84Listener { + + /** + * 车辆定位 WGS84 坐标系-高精度坐标系 数据 + * + * @param gnssInfo + */ + fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ20ListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ20ListenerManager.kt new file mode 100644 index 0000000000..39686e6854 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ20ListenerManager.kt @@ -0,0 +1,51 @@ +package com.mogo.eagle.core.function.call.autopilot + +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.call.base.CallerBase +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.mogo.eagle.core.utilcode.util.CoordinateTransform +import mogo.telematics.pad.MessagePad + +/** + * @author xiaoyuzhou + * @date 2021/9/30 5:48 下午 + * 车辆定位 WGS84 坐标系-高精度坐标系 数据 回调监听 + */ +object CallerChassisLocationGCJ20ListenerManager : CallerBase() { + + val TAG = "CallerChassisLocationGCJ20ListenerManager" + + @Volatile + private var mGnssInfo: MessagePad.GnssInfo? = null + + fun getChassisLocationGCJ02(): MessagePad.GnssInfo? { + return mGnssInfo + } + + /** + * 车辆定位 WGS84 坐标系-高精度坐标系 数据 + * @param gnssInfo + */ + @Synchronized + fun invokeChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) { + gnssInfo?.let { + // 转换 WGS84-->GCJ02 坐标 + val gcj20Location = CoordinateTransform.WGS84ToGCJ02(gnssInfo.longitude, gnssInfo.latitude) + + val gnssBuilder = gnssInfo.toBuilder() + gnssBuilder.longitude = gcj20Location[0] + gnssBuilder.latitude = gcj20Location[1] + + this.mGnssInfo = gnssBuilder.build() + + M_LISTENERS.forEach { + val tag = it.key + val listener = it.value + listener.onChassisLocationGCJ02(this.mGnssInfo) + } + } ?: let { + Logger.e(TAG, "定位数据为Null") + } + } + +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisGnssInfoListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt similarity index 50% rename from core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisGnssInfoListenerManager.kt rename to core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt index 5d948f4b55..577718120d 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisGnssInfoListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt @@ -1,34 +1,34 @@ package com.mogo.eagle.core.function.call.autopilot -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener import com.mogo.eagle.core.function.call.base.CallerBase import mogo.telematics.pad.MessagePad /** * @author xiaoyuzhou * @date 2021/9/30 5:48 下午 - * 车辆状态&定位 数据 数据 回调监听 + * 车辆定位 WGS84 坐标系-高精度坐标系 数据 回调监听 */ -object CallerChassisGnssInfoListenerManager : CallerBase() { +object CallerChassisLocationWGS84ListenerManager : CallerBase() { @Volatile private var gnssInfo: MessagePad.GnssInfo? = null - fun getCurrentGnssInfo(): MessagePad.GnssInfo? { + fun getChassisLocationWGS84(): MessagePad.GnssInfo? { return gnssInfo } /** - * 车辆状态数据 回调 + * 车辆定位 WGS84 坐标系-高精度坐标系 数据 * @param gnssInfo */ @Synchronized - fun invokeAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + fun invokeChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { this.gnssInfo = gnssInfo M_LISTENERS.forEach { val tag = it.key val listener = it.value - listener.onAutopilotCarStateData(gnssInfo) + listener.onChassisLocationWGS84(gnssInfo) } } diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CoordinateTransform.java b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CoordinateTransform.java new file mode 100644 index 0000000000..f09ce83bd0 --- /dev/null +++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CoordinateTransform.java @@ -0,0 +1,153 @@ +package com.mogo.eagle.core.utilcode.util; + +/** + * + * ----------------------------------------------------------------------------------------- + * 坐标系 |解释 |使用地图 + * ----------------------------------------------------------------------------------------- + * WGS84 |地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取 |GPS/谷歌地图卫星 + * |的经纬度为WGS84地理坐标系,最基础的坐标,谷歌地图在非中国地区使用的坐标系 | + * ----------------------------------------------------------------------------------------- + * GCJ02 |火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。 |腾讯(搜搜)地图, + * |并要求在中国使用的地图产品使用的都必须是加密后的坐标, |阿里云地图,高德地图, + * |而这套WGS84加密后的坐标就是gcj02。 |谷歌国内地图 + * ----------------------------------------------------------------------------------------- + * BD09 |百度坐标系,百度在GCJ02的基础上进行了二次加密, |百度地图 + * |官方解释是为了进一步保护用户隐私(我差点就信了) | + * ----------------------------------------------------------------------------------------- + * 小众坐标系 |类似于百度地图,在GCJ02基础上使用自己的加密算法进行二次加密的坐标系 |搜狗地图、图吧地图 等 + * ----------------------------------------------------------------------------------------- + * 墨卡托坐标 |墨卡托投影以整个世界范围,赤道作为标准纬线,本初子午线作为中央经线, + * |两者交点为坐标原点,向东向北为正,向西向南为负。 + * |南北极在地图的正下、上方,而东西方向处于地图的正右、左。 + * + * 你可以通过这个工具类将上述坐标系进行互相转换。 + * + * 百度地图地图投影采用的依然是Web Mercator投影,地图瓦片的切片规则遵循TMS标准,瓦片坐标原点在经纬度为0的附近, + * 但却做了一定的偏移处理,经测算此偏移量约为(-865,15850), + * 即地图瓦片(0, 0)是从Web Mercator投影坐标系的(-865,15850)点开始的。 + * + * 顺便提供百度地图的地图等级从18级到1级 + * 18级,1个像素代表1米,17级,1个像素代表2米,16级代表4米,依此类推 + * Author: kong + */ +public class CoordinateTransform { + private static double x_PI = 3.14159265358979324 * 3000.0 / 180.0; + private static double PI = 3.1415926535897932384626; + private static double a = 6378245.0; + private static double ee = 0.00669342162296594323; + + /** + * 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换 + * 即 百度 转 谷歌、高德 + * + * @param bd_lon + * @param bd_lat + * @return Double[lon, lat] + */ + public static Double[] BD09ToGCJ02(Double bd_lon, Double bd_lat) { + double x = bd_lon - 0.0065; + double y = bd_lat - 0.006; + double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI); + double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI); + Double[] arr = new Double[2]; + arr[0] = z * Math.cos(theta); + arr[1] = z * Math.sin(theta); + return arr; + } + + /** + * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换 + * 即谷歌、高德 转 百度 + * + * @param gcj_lon + * @param gcj_lat + * @return Double[lon, lat] + */ + public static Double[] GCJ02ToBD09(Double gcj_lon, Double gcj_lat) { + double z = Math.sqrt(gcj_lon * gcj_lon + gcj_lat * gcj_lat) + 0.00002 * Math.sin(gcj_lat * x_PI); + double theta = Math.atan2(gcj_lat, gcj_lon) + 0.000003 * Math.cos(gcj_lon * x_PI); + Double[] arr = new Double[2]; + arr[0] = z * Math.cos(theta) + 0.0065; + arr[1] = z * Math.sin(theta) + 0.006; + return arr; + } + + /** + * WGS84转GCJ02 + * + * @param wgs_lon + * @param wgs_lat + * @return Double[lon, lat] + */ + public static Double[] WGS84ToGCJ02(Double wgs_lon, Double wgs_lat) { + if (outOfChina(wgs_lon, wgs_lat)) { + return new Double[]{wgs_lon, wgs_lat}; + } + double dlat = transformlat(wgs_lon - 105.0, wgs_lat - 35.0); + double dlng = transformlng(wgs_lon - 105.0, wgs_lat - 35.0); + double radlat = wgs_lat / 180.0 * PI; + double magic = Math.sin(radlat); + magic = 1 - ee * magic * magic; + double sqrtmagic = Math.sqrt(magic); + dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); + dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); + Double[] arr = new Double[2]; + arr[0] = wgs_lon + dlng; + arr[1] = wgs_lat + dlat; + return arr; + } + + /** + * GCJ02转WGS84 + * + * @param gcj_lon + * @param gcj_lat + * @return Double[lon, lat] + */ + public static Double[] GCJ02ToWGS84(Double gcj_lon, Double gcj_lat) { + if (outOfChina(gcj_lon, gcj_lat)) { + return new Double[]{gcj_lon, gcj_lat}; + } + double dlat = transformlat(gcj_lon - 105.0, gcj_lat - 35.0); + double dlng = transformlng(gcj_lon - 105.0, gcj_lat - 35.0); + double radlat = gcj_lat / 180.0 * PI; + double magic = Math.sin(radlat); + magic = 1 - ee * magic * magic; + double sqrtmagic = Math.sqrt(magic); + dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); + dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); + double mglat = gcj_lat + dlat; + double mglng = gcj_lon + dlng; + return new Double[]{gcj_lon * 2 - mglng, gcj_lat * 2 - mglat}; + } + + private static Double transformlat(double lng, double lat) { + double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)); + ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0; + ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0; + return ret; + } + + private static Double transformlng(double lng, double lat) { + double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)); + ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0; + ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0; + return ret; + } + + /** + * outOfChina + * + * @param lng + * @param lat + * @return {boolean} + * @描述: 判断是否在国内,不在国内则不做偏移 + */ + private static boolean outOfChina(Double lng, Double lat) { + return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false); + } + +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapApiBuilder.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapApiBuilder.java deleted file mode 100644 index 765f1df1a4..0000000000 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapApiBuilder.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mogo.map; - -import android.content.Context; - -import com.alibaba.android.arouter.facade.template.IProvider; -import com.mogo.map.location.IMogoLocationClient; -import com.mogo.map.uicontroller.IMogoMapUIController; - -/** - * @author congtaowang - * @since 2020/12/9 - * - * 地图实例构建 - */ -public interface IMogoMapApiBuilder extends IProvider { - - IMogoLocationClient getLocationClient( Context context ); - - IMogoMapUIController getMapUIController(); - - void destroy(); - - IMogoMapView getMapView( Context context ); - -} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/CustomMapApiBuilder.java b/libraries/mogo-map/src/main/java/com/mogo/map/CustomMapApiBuilder.java index 00472095d0..0da12910e2 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/CustomMapApiBuilder.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/CustomMapApiBuilder.java @@ -2,13 +2,11 @@ package com.mogo.map; import android.content.Context; -import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.map.location.ALocationClient; import com.mogo.map.location.IMogoLocationClient; import com.mogo.map.uicontroller.AMapUIController; import com.mogo.map.uicontroller.IMogoMapUIController; -import com.zhidaoauto.map.sdk.open.view.MapAutoView; /** * @author congtaowang @@ -16,66 +14,40 @@ import com.zhidaoauto.map.sdk.open.view.MapAutoView; *

* 描述 */ -@Route(path = MapApiPath.PATH) -public class CustomMapApiBuilder implements IMogoMapApiBuilder { +public class CustomMapApiBuilder { private static final String TAG = "CustomMapApiBuilder"; - @Override + private static CustomMapApiBuilder sApiBuilder; + + private static CustomMapApiBuilder getApiBuilder() { + if (sApiBuilder == null) { + synchronized (CustomMapApiBuilder.class) { + if (sApiBuilder == null) { + CallerLogger.INSTANCE.d(TAG, "init"); + sApiBuilder = new CustomMapApiBuilder(); + } + } + } + return sApiBuilder; + } + public IMogoLocationClient getLocationClient(Context context) { return new ALocationClient(context); } - @Override public IMogoMapUIController getMapUIController() { return AMapUIController.getInstance(); } - - @Override - public IMogoMapView getMapView(Context context) { -// MapParams mapParams = MapParams.Companion.init(); -// mapParams.setDebugMode(false) -// //todo 1-使用本地地图数据,0-使用在线地图数据 -// //.setDataFileSource(1) -// .setCoordinateType(MapParams.COORDINATETYPE_GCJ02) -// .setPerspectiveMode(MapParams.MAP_PERSPECTIVE_3D) -// .setHDVisibileArray(new int[]{HDTypes.DIVIDER.type, -// HDTypes.ROAD_AREA.type, -// HDTypes.STOP_LINE.type, -// HDTypes.ARROW.type, -// HDTypes.STATION_BRIDGE.type, -// HDTypes.ZEBRA_LINE.type, -// HDTypes.GREEN_BELT.type, -// HDTypes.DIVERSION.type, -// HDTypes.SAFE_ISLAND.type, -// HDTypes.ALPHANUMERIC.type, -// HDTypes.GUARDBAR.type, -// HDTypes.TRAFFIC_DEVICE.type, -// HDTypes.CABLE.type, -// HDTypes.SIGNAL_LINE.type}) -// // .setZoom( 20 ) -// // .setPointToCenter( 0.734375f, 0.5f ) -// //todo 2D模式下需要注意ADAS部分遮挡 -// //.setPointToCenter(0.5f, 0.5f) -// // 根据 FunctionBuildConfig 配置的皮肤样式设置题图的样式 -// .setStyleMode(FunctionBuildConfig.skinMode == 0 ? MapParams.MAP_STYLE_NIGHT_VR : MapParams.MAP_STYLE_DAY_VR); -// -// MapAutoApi.INSTANCE.init(context, mapParams); -// - MapAutoView mapAutoView = new MapAutoView(context); - //mapAutoView.registerRenderListener(l -> Log.i(TAG, "renderTime: " + l)); - IMogoMapView mapView = new AMapViewWrapper(mapAutoView); - return mapView; + public static IMogoLocationClient getLocationClientDelegate(Context context) { + return getApiBuilder().getLocationClient(context); } - @Override - public void destroy() { - + public static IMogoMapUIController getMapUIControllerDelegate() { + return getApiBuilder().getMapUIController(); } - @Override - public void init(Context context) { - CallerLogger.INSTANCE.d(TAG, "init"); + public static void destroy() { } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java index cf1a304533..5d9fbc2d9a 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java @@ -2,9 +2,9 @@ package com.mogo.map; import android.content.Context; +import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.map.location.IMogoLocationClient; import com.mogo.map.location.IMogoLocationListener; -import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.map.location.MogoLocationListenerRegister; /** @@ -17,7 +17,7 @@ public class MogoLocationClient implements IMogoLocationClient { private static volatile MogoLocationClient sInstance; public MogoLocationClient( Context context ) { - mDelegate = MogoMapDelegateFactory.getLocationClientDelegate( context ); + mDelegate = CustomMapApiBuilder.getLocationClientDelegate( context ); } public static MogoLocationClient getInstance( Context context ) { diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapDelegateFactory.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapDelegateFactory.java deleted file mode 100644 index 42fee86fd7..0000000000 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapDelegateFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.mogo.map; - -import android.content.Context; - -import com.alibaba.android.arouter.launcher.ARouter; -import com.mogo.map.location.IMogoLocationClient; -import com.mogo.map.uicontroller.IMogoMapUIController; - - -/** - * @author congtaowang - * @since 2020/6/17 - *

- * 描述 - */ -class MogoMapDelegateFactory { - - private static final String TAG = "MogoMapDelegateFactory"; - - private static IMogoMapApiBuilder sApiBuilder; - - private static IMogoMapApiBuilder getApiBuilder() { - if (sApiBuilder == null) { - synchronized (MogoMapDelegateFactory.class) { - if (sApiBuilder == null) { - sApiBuilder = ARouter.getInstance().navigation(IMogoMapApiBuilder.class); - } - } - } - return sApiBuilder; - } - - public static IMogoLocationClient getLocationClientDelegate(Context context) { - return getApiBuilder().getLocationClient(context); - } - - public static IMogoMapUIController getMapUIControllerDelegate() { - return getApiBuilder().getMapUIController(); - } - - public static void destroy() { - getApiBuilder().destroy(); - } - - public static IMogoMapView getMapView(Context context) { - return getApiBuilder().getMapView(context); - } - -} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java index 59f027a55e..d002863eed 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -40,7 +40,7 @@ public class MogoMapUIController implements IMogoMapUIController { private void initDelegate() { if (mDelegate == null) { - mDelegate = MogoMapDelegateFactory.getMapUIControllerDelegate(); + mDelegate = CustomMapApiBuilder.getMapUIControllerDelegate(); } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java index a990e856e7..ddb46ccc25 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java @@ -10,6 +10,7 @@ import android.widget.FrameLayout; import androidx.annotation.Nullable; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.zhidaoauto.map.sdk.open.view.MapAutoView; /** * @author congtaowang @@ -33,27 +34,24 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle { super(context, attrs, defStyleAttr); } - private boolean mIsVrMode = false; + private MapAutoView mapAutoView; @Override protected void addMapView(Context context) { - mMapView = MogoMapDelegateFactory.getMapView(context); - if (mMapView != null) { + if (mapAutoView == null) { + mapAutoView = new MapAutoView(context); + } + if (mMapView == null) { + mMapView = new AMapViewWrapper(mapAutoView); final View mapView = mMapView.getMapView(); if (mapView != null) { addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } else { CallerLogger.INSTANCE.e(TAG, "create MapView instance failed."); } - } else { - CallerLogger.INSTANCE.e(TAG, "create IMogoMapView instance failed."); } } - public boolean isVrMode() { - return mIsVrMode; - } - @Override public void onCreate(Bundle bundle) { super.onCreate(bundle);