[dev_arch_opt_3.0]

[Change]
[
1、修改了高精地图的设置外部坐标的方法
2、修改了基础、出租车、Bus小地图中的位置回调,使用IMoGoChassisLocationGCJ02Listener。
3、TODO 有些需要高德地图的地方需要改为使用IMoGoChassisLocationGCJ02Listener,WGS84的坐标使用IMoGoChassisLocationWGS84Listener
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-01-13 17:44:04 +08:00
parent 1f3a71e782
commit dd8428fb97
15 changed files with 171 additions and 244 deletions

View File

@@ -1,5 +1,7 @@
package com.mogo.och.bus.passenger.ui;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
@@ -25,9 +27,8 @@ import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.bus.passenger.R;
import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback;
@@ -36,14 +37,16 @@ import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
import mogo.telematics.pad.MessagePad;
/**
* 乘客屏小地图
*/
public class BusPassengerMapDirectionView
extends RelativeLayout
implements IMoGoMapLocationListener, IBusPassengerMapDirectionView, AMap.OnCameraChangeListener {
implements IMoGoChassisLocationGCJ02Listener,
IBusPassengerMapDirectionView,
AMap.OnCameraChangeListener {
//小地图名称
public static final String TAG = "TPMapDirectionView";
@@ -101,14 +104,14 @@ public class BusPassengerMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
}
private void initAMapView() {
@@ -171,19 +174,18 @@ public class BusPassengerMapDirectionView
return true;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null) {
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
if (gnssInfo == null) {
return;
}
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onCarLocationChanged2 :" + location.getLatitude() + ":" + location.getLongitude());
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
//更新车辆位置
if (mCarMarker != null) {
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "location.getBearing() = " + location.getBearing());
mCarMarker.setRotateAngle(360 - location.getBearing());
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
}
@@ -208,7 +210,6 @@ public class BusPassengerMapDirectionView
}
@Override
public void drawablePolyline() {
if (mPolyline != null) {

View File

@@ -29,9 +29,8 @@ import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.taxi.passenger.R;
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback;
@@ -40,12 +39,14 @@ import com.mogo.och.taxi.passenger.utils.TaxiPassengerMapAssetStyleUtil;
import java.util.ArrayList;
import java.util.List;
import mogo.telematics.pad.MessagePad;
/**
* 乘客屏小地图
*/
public class TaxiPassengerMapDirectionView
extends RelativeLayout
implements IMoGoMapLocationListener, ITaxiPassengerMapDirectionView, AMap.OnCameraChangeListener {
implements IMoGoChassisLocationGCJ02Listener, ITaxiPassengerMapDirectionView, AMap.OnCameraChangeListener {
//小地图名称
public static final String TAG = "TPMapDirectionView";
@@ -104,14 +105,14 @@ public class TaxiPassengerMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
}
private void initAMapView() {
@@ -178,13 +179,12 @@ public class TaxiPassengerMapDirectionView
return true;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null){
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
if (gnssInfo == null){
return;
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
if (mCoordinatesLatLng.size() > 1) {
//圈定地图显示范围
@@ -200,13 +200,13 @@ public class TaxiPassengerMapDirectionView
} else {
//设置希望展示的地图缩放级别
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
.target(mCarMarker.getPosition()).tilt(0).bearing((float) gnssInfo.getHeading()).zoom(zoomLevel).build();
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
//更新车辆位置
if (mCarMarker != null) {
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "location.getBearing() = " + location.getBearing());
mCarMarker.setRotateAngle(360 - location.getBearing());
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
mCarMarker.setPosition(currentLatLng);
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--loacation :" + location.getLatitude()+", "+location.getLongitude());
mCarMarker.setToTop();

View File

@@ -29,9 +29,8 @@ import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.och.taxi.R;
import com.mogo.och.taxi.utils.TaxiMapAssetStyleUtil;
@@ -39,12 +38,14 @@ import com.mogo.och.taxi.utils.TaxiMapAssetStyleUtil;
import java.util.ArrayList;
import java.util.List;
import mogo.telematics.pad.MessagePad;
/**
* taxi司机端前往目的地小地图导航
*/
public class TaxiMapDirectionView
extends RelativeLayout
implements IMoGoMapLocationListener, ITaxiMapDirectionView, AMap.OnCameraChangeListener {
implements IMoGoChassisLocationGCJ02Listener, ITaxiMapDirectionView, AMap.OnCameraChangeListener {
//小地图名称
public static final String TAG = "TPMapDirectionView";
@@ -98,14 +99,14 @@ public class TaxiMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
}
private void initAMapView() {
@@ -174,13 +175,12 @@ public class TaxiMapDirectionView
return true;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null){
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
if (gnssInfo == null){
return;
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
if (mCoordinatesLatLng.size() > 1) {
//圈定地图显示范围
@@ -196,13 +196,13 @@ public class TaxiMapDirectionView
} else {
//设置希望展示的地图缩放级别
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
.target(mCarMarker.getPosition()).tilt(0).bearing((float) gnssInfo.getHeading()).zoom(zoomLevel).build();
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
//更新车辆位置
if (mCarMarker != null) {
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "location.getBearing() = " + location.getBearing());
mCarMarker.setRotateAngle(360 - location.getBearing());
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
mCarMarker.setPosition(currentLatLng);
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--loacation :" + location.getLatitude()+", "+location.getLongitude());
mCarMarker.setToTop();

View File

@@ -136,7 +136,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
if (gnssInfo != null) {
if (1 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(gnssInfo)
//CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(gnssInfo)
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
gnssInfo.satelliteTime,

View File

@@ -5,13 +5,13 @@ import android.graphics.Color
import android.util.AttributeSet
import android.view.Gravity
import android.widget.FrameLayout
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import mogo.telematics.pad.MessagePad
import java.util.*
/**
@@ -22,7 +22,7 @@ class SpeedPanelView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr), IMoGoMapLocationListener {
) : FrameLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener {
companion object {
const val TAG = "SpeedPanelView"
@@ -30,7 +30,7 @@ class SpeedPanelView @JvmOverloads constructor(
var mContext: Context
var mSpeedChartView: SpeedChartView
var mLatLng: MogoLocation? = null
var mLatLng: MessagePad.GnssInfo? = null
var mSpeedLimit = 60
private val timer by lazy {
@@ -63,15 +63,17 @@ class SpeedPanelView @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow() // 注册位置回调
CallerMapLocationListenerManager.addListener(TAG, this, false)
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this)
// 开启定时查询速度
timerTask?.cancel()
val task = object : TimerTask() {
override fun run() {
mLatLng?.let {
mSpeedLimit = CallerMapUIServiceManager.getMapUIController()!!.getLimitSpeed(it.longitude, it.latitude, it.bearing)
mSpeedLimit = CallerMapUIServiceManager.getMapUIController()!!.getLimitSpeed(it.longitude, it.latitude,
it.heading.toFloat()
)
UiThreadHandler.post {
val speed = (it.speed * 3.6f).toInt()
val speed = (it.gnssSpeed * 3.6f).toInt()
mSpeedChartView.setArcColor(Color.parseColor(if (speed > mSpeedLimit) "#DB3137" else "#3E77F6"))
mSpeedChartView.setValues(speed)
setBackgroundResource(if (speed > mSpeedLimit) R.drawable.yi_biao_pan_bg_speeding else R.drawable.yi_biao_pan_bg_nor)
@@ -83,16 +85,16 @@ class SpeedPanelView @JvmOverloads constructor(
timer.schedule(task, Date(), 100)
}
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
location?.let {
mLatLng = location
override fun onChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) {
gnssInfo?.let {
mLatLng = gnssInfo
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
// 解除注册
CallerMapLocationListenerManager.removeListener(TAG, false)
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
try {
timerTask?.cancel()
} catch (e: Exception) {
@@ -100,4 +102,5 @@ class SpeedPanelView @JvmOverloads constructor(
}
}
}

View File

@@ -23,6 +23,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight
import com.mogo.eagle.core.function.call.map.CallerHDMapManager
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
import com.mogo.eagle.core.function.overview.InfStructureManager
import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData
@@ -362,6 +364,9 @@ class MapFragment : MvpFragment<MapView?, MapPresenter?>(),
private var brakeLight = -1
override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) {
// 跟新地图控件
mMogoMapView?.setExtraGPSData(gnssInfo)
if (gnssInfo != null) {
//设置刹车信息
if (gnssInfo.acceleration < SharedPrefsMgr.getInstance(Utils.getApp()).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5f)) {

View File

@@ -31,12 +31,11 @@ import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.map.Infrastructure;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.overview.InfStructureManager;
import com.mogo.eagle.core.function.overview.remote.Center;
@@ -64,7 +63,7 @@ import mogo.telematics.pad.MessagePad;
*/
public class AMapCustomView
extends RelativeLayout
implements IMoGoMapLocationListener {
implements IMoGoChassisLocationGCJ02Listener {
public static final String TAG = "AMapCustomView";
private TextureMapView mAMapView;
private AMap mAMap;
@@ -93,7 +92,7 @@ public class AMapCustomView
private List<BitmapDescriptor> textureList = new ArrayList<>();
private List<Integer> texIndexList = new ArrayList<>();
private MogoLocation mLocation;
private MessagePad.GnssInfo mLocation;
private boolean isFirstLocation = true;
CustomMapStyleOptions mCustomMapStyleOptions;
@@ -133,7 +132,7 @@ public class AMapCustomView
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
initAMapView(context);
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
//设置全览模式
overLayerView.setOnClickListener(v -> {
displayCustomOverView();
@@ -300,7 +299,7 @@ public class AMapCustomView
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG);
}
@@ -309,18 +308,6 @@ public class AMapCustomView
return false;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
mLocation = location;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(location.getLongitude(), location.getLatitude()));
drawCarMarker(location);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
}
public void onCreateView(Bundle savedInstanceState) {
if (mAMapView != null) {
mAMapView.onCreate(savedInstanceState);
@@ -435,7 +422,6 @@ public class AMapCustomView
*/
private void displayCustomOverView() {
ArrayList<LatLng> linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints();
MogoLocation location = mLocation;
if (linePointsLatLng.size() > 1) {
//圈定地图显示范围
//存放经纬度
@@ -443,7 +429,7 @@ public class AMapCustomView
for (int i = 0; i < linePointsLatLng.size(); i++) {
boundsBuilder.include(linePointsLatLng.get(i));
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
boundsBuilder.include(currentLatLng);
CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build();
@@ -463,15 +449,15 @@ public class AMapCustomView
*
* @param location
*/
private void drawCarMarker(MogoLocation location) {
private void drawCarMarker(MessagePad.GnssInfo location) {
if (location == null) return;
if (mCarMarker != null) {
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
mCarMarker.setRotateAngle(360 - location.getBearing());
mCarMarker.setRotateAngle((float) (360 - location.getHeading()));
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
if (mCompassMarker != null) {
mCompassMarker.setRotateAngle(360 - location.getBearing());
mCompassMarker.setRotateAngle((float) (360 - location.getHeading()));
mCompassMarker.setPosition(currentLatLng);
}
}
@@ -539,4 +525,15 @@ public class AMapCustomView
}
}
}
@Override
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
mLocation = gnssInfo;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(gnssInfo.getLongitude(), gnssInfo.getLatitude()));
drawCarMarker(gnssInfo);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
}
}

View File

@@ -32,9 +32,8 @@ import com.amap.api.maps.model.PolylineOptions;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
@@ -48,6 +47,8 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import mogo.telematics.pad.MessagePad;
/**
* 小地图的方向View
*
@@ -56,7 +57,7 @@ import java.util.TimerTask;
*/
public class SmallMapDirectionView
extends RelativeLayout
implements IMoGoMapLocationListener, ISmallMapDirectionView {
implements IMoGoChassisLocationGCJ02Listener, ISmallMapDirectionView {
//小地图名称
public static final String TAG = "SmallMapDirectionView";
@@ -74,7 +75,7 @@ public class SmallMapDirectionView
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private Context mContext;
private MogoLocation mLocation;
private MessagePad.GnssInfo mLocation;
public SmallMapDirectionView(Context context) {
this(context, null);
@@ -104,7 +105,7 @@ public class SmallMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
startTask();
}
@@ -117,7 +118,7 @@ public class SmallMapDirectionView
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
}
private void initAMapView() {
@@ -130,11 +131,11 @@ public class SmallMapDirectionView
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap.setTrafficEnabled(false);
// 设置 锚点 图标
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
.anchor(0.5f, 0.5f));
}else{
} else {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
.anchor(0.5f, 0.5f));
@@ -177,30 +178,28 @@ public class SmallMapDirectionView
return true;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null) {
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
if (gnssInfo == null) {
return;
}
mLocation = location;
mLocation = gnssInfo;
}
private class UpdateLocationTask extends TimerTask {
@Override
public void run() {
if (mLocation != null) {
MogoLocation location = mLocation;
if (mCarMarker == null){
if (mCarMarker == null) {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f));
}
if(mCarMarker == null){
if (mCarMarker == null) {
return;
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
float bearing = (float) Math.floor(location.getBearing());
LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
float bearing = (float) Math.floor(mLocation.getHeading());
//更新车辆位置
mCarMarker.setPosition(currentLatLng);

View File

@@ -42,14 +42,14 @@ public interface IMogoMap {
* @param options
* @return
*/
IMogoMarker addMarker( String tag, MogoMarkerOptions options );
IMogoMarker addMarker(String tag, MogoMarkerOptions options);
/**
* 批量更新锚点位置
*
* @param optionsArrayList 锚点集合
*/
void updateBatchMarkerPosition(HashMap<String,MessagePad.TrackedObject> optionsArrayList);
void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList);
/**
* 添加感知使用到的3d模型
@@ -74,7 +74,7 @@ public interface IMogoMap {
* @param moveToCenter
* @return
*/
ArrayList< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter );
ArrayList<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter);
/**
* 从地图上删除所有的overlaymarkercirclepolyline 等对象)。
@@ -86,7 +86,7 @@ public interface IMogoMap {
*
* @param isKeepMyLocationOverlay
*/
void clear( boolean isKeepMyLocationOverlay );
void clear(boolean isKeepMyLocationOverlay);
/**
* 设置屏幕上的某个像素点为地图中心点。
@@ -94,47 +94,7 @@ public interface IMogoMap {
* @param x
* @param y
*/
void setPointToCenter( int x, int y );
/**
* 设置地图POI是否允许点击。
*
* @param touchPoiEnable
*/
void setTouchPoiEnable( boolean touchPoiEnable );
/**
* 设置是否打开交通路况图层。
*
* @param enable
*/
void setTrafficEnable( boolean enable );
/**
* 设置是否显示3D建筑物默认显示。
*
* @param enabled
*/
void showBuildings( boolean enabled );
/**
* 设置是否显示室内地图,默认不显示。
*
* @param enable
*/
void showIndoorMap( boolean enable );
/**
* 设置是否显示底图文字标注,默认显示。
*
* @param enable
*/
void showMapText( boolean enable );
/**
* 停止当前执行的改变地图状态的动画。
*/
void stopAnimation();
void setPointToCenter(int x, int y);
/**
* 获取比例尺
@@ -148,7 +108,7 @@ public interface IMogoMap {
*
* @param zoom
*/
void changeZoom( float zoom );
void changeZoom(float zoom);
/**
* 获取缩放比例
@@ -168,13 +128,14 @@ public interface IMogoMap {
* @param options
* @return
*/
IMogoPolyline addPolyline( MogoPolylineOptions options );
IMogoPolyline addPolyline(MogoPolylineOptions options);
/**
* 获取行驶方向一定长度的中心线
* @param lon 经度
* @param lat 纬
* @param angle 航向角
*
* @param lon 经
* @param lat 纬度
* @param angle 航向角
* @param distance 获取车道中心线的长度,> 0: 行驶方向前方距离, <0 行驶方向后方距离
* @return 中心线相关数据
*/
@@ -183,10 +144,13 @@ public interface IMogoMap {
/**
* 根据自车经纬度和航向角,获取道路名称
* @param lon 经度
* @param lat 纬
*
* @param lon 经
* @param lat 纬度
* @param angle 航向角
* @return 道路名称等相关信息
*/
RoadNameInfo getRoadName(double lon, double lat, float angle);
}

View File

@@ -272,9 +272,6 @@ public interface IMogoMapUIController {
}
default void syncLocation2Map(MessagePad.GnssInfo gnssInfo) {
}
/**
* 获取车速资源缓存 id
@@ -329,4 +326,10 @@ public interface IMogoMapUIController {
*/
void setAllGesturesEnabled(boolean isEnable);
/**
* 设置外界坐标系
*
* @param gnssInfo RTK 高精坐标,车辆惯导数据
*/
void setExtraGPSData(MessagePad.GnssInfo gnssInfo);
}

View File

@@ -985,39 +985,6 @@ public class AMapViewWrapper implements IMogoMapView,
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
@Override
public void syncLocation2Map(MessagePad.GnssInfo gnssInfo) {
if (!checkAMapView()) {
return;
}
if (gnssInfo.getLongitude() == -1) {
return;
}
LonLatPoint bean = new LonLatPoint();
bean.setAngle(gnssInfo.getHeading());
bean.setAltitude(gnssInfo.getAltitude());
bean.setLongitude(gnssInfo.getLongitude());
bean.setLatitude(gnssInfo.getLatitude());
bean.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime() * 1000).longValue());
bean.setSpeed((float) gnssInfo.getGnssSpeed());
// RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
// bean.setYaw_rate(gnssInfo.getYawRate());
// bean.setHeading(gnssInfo.getHeading());
// bean.setAcceleration(gnssInfo.getAcceleration());
// bean.setAlt(gnssInfo.getAltitude());
// bean.setSystemTime(Double.valueOf(gnssInfo.getSystemTime()).longValue());
// bean.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime() * 1000).longValue());
// bean.setLon(gnssInfo.getLongitude());
// bean.setLat(gnssInfo.getLatitude());
// bean.setGnss_speed(((float) gnssInfo.getGnssSpeed()));
// bean.setReceiverDataTime(System.currentTimeMillis());
// 使用外部定位数据修改自车位置
// mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
mMapView.getLocationClient().updateLocation(bean);
CallerMapUIServiceManager.INSTANCE.getSingletonLocationClient(getContext()).updateLocation(bean);
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
@Override
public void stepInVrMode(boolean isDayMode) {
// try {
@@ -1135,4 +1102,29 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.getMapAutoViewHelper().setAllGesturesEnabled(isEnable);
}
}
@Override
public void setExtraGPSData(MessagePad.GnssInfo gnssInfo) {
LocationClient locationClient = mMapView.getLocationClient();
if (locationClient != null) {
locationClient.setIsUseExtraGPSData(true);//设置是否使用外界坐标
locationClient.rtkEnable(true);//设置是否是高精定位
LonLatPoint lonLatPoint = new LonLatPoint();
lonLatPoint.setAngle(gnssInfo.getHeading());
lonLatPoint.setAltitude(gnssInfo.getAltitude());
lonLatPoint.setLongitude(gnssInfo.getLongitude());
lonLatPoint.setLatitude(gnssInfo.getLatitude());
lonLatPoint.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime() * 1000).longValue());
lonLatPoint.setSpeed((float) gnssInfo.getGnssSpeed());
locationClient.updateLocation(lonLatPoint);//更新新自动驾驶RTK相关数据
CallerMapUIServiceManager.INSTANCE.getSingletonLocationClient(getContext()).updateLocation(lonLatPoint);
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
}
}

View File

@@ -53,7 +53,7 @@ public class AMapWrapper implements IMogoMap {
private static final String TAG = "AMapWrapper";
private static MapAutoViewHelper sAMap;
private IMogoMapUIController mUIcontroller;
private IMogoMapUIController mMapUIController;
private MapAutoViewHelper mAMap;
private MapAutoView mMapView;
private IMogoUiSettings mUiSettings;
@@ -63,10 +63,10 @@ public class AMapWrapper implements IMogoMap {
this.mAMap = map;
sAMap = map;
this.mMapView = mapView;
mUIcontroller = controller;
mMapUIController = controller;
// 设置实现自定义 info window
MapAutoApi.INSTANCE.setInfoWindowAdapter(new AMapInfoWindowAdapter());
AMapUIController.getInstance().initClient(mUIcontroller);
AMapUIController.getInstance().initClient(mMapUIController);
}
public static MapAutoViewHelper getAMap() {
@@ -86,7 +86,7 @@ public class AMapWrapper implements IMogoMap {
@Override
public IMogoMapUIController getUIController() {
return mUIcontroller;
return mMapUIController;
}
@Override
@@ -211,48 +211,6 @@ public class AMapWrapper implements IMogoMap {
}
}
@Override
public void setTouchPoiEnable(boolean touchPoiEnable) {
if (checkAMap()) {
mAMap.setTouchPoiEnable(touchPoiEnable);
}
}
@Override
public void setTrafficEnable(boolean enable) {
if (checkAMap()) {
mAMap.setTraffic(enable);
}
}
@Override
public void showBuildings(boolean enabled) {
if (checkAMap()) {
mAMap.showBuildings(enabled);
}
}
@Override
public void showIndoorMap(boolean enable) {
if (checkAMap()) {
// mAMap.showIndoorMap( enable );
}
}
@Override
public void showMapText(boolean enable) {
if (checkAMap()) {
mAMap.showMapText(enable);
}
}
@Override
public void stopAnimation() {
if (checkAMap()) {
// mAMap.stopAnimation();
}
}
@Override
public float getScalePerPixel() {
if (checkAMap()) {
@@ -279,8 +237,6 @@ public class AMapWrapper implements IMogoMap {
}
}
return 0;
}
@Override

View File

@@ -334,14 +334,6 @@ public class MogoMapUIController implements IMogoMapUIController {
}
}
@Override
public void syncLocation2Map(MessagePad.GnssInfo gnssInfo) {
initDelegate();
if (mDelegate != null) {
mDelegate.syncLocation2Map(gnssInfo);
}
}
@Override
public void destroy() {
mDelegate = null;
@@ -420,4 +412,12 @@ public class MogoMapUIController implements IMogoMapUIController {
mDelegate.setAllGesturesEnabled(isEnable);
}
}
@Override
public void setExtraGPSData(MessagePad.GnssInfo gnssInfo) {
initDelegate();
if (mDelegate != null) {
mDelegate.setExtraGPSData(gnssInfo);
}
}
}

View File

@@ -10,8 +10,11 @@ import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.map.uicontroller.AMapUIController;
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
import mogo.telematics.pad.MessagePad;
/**
* @author congtaowang
* @since 2019-12-18
@@ -85,4 +88,9 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
public void onLowMemory() {
super.onLowMemory();
}
public void setExtraGPSData(MessagePad.GnssInfo gnssInfo) {
AMapUIController.getInstance().setExtraGPSData(gnssInfo);
}
}

View File

@@ -287,14 +287,6 @@ public class AMapUIController implements IMogoMapUIController {
}
}
@Override
public void syncLocation2Map(MessagePad.GnssInfo gnssInfo) {
if (mClient != null) {
mClient.syncLocation2Map(gnssInfo);
}
}
@Override
public void stepInVrMode(boolean isDayMode) {
if (mClient != null) {
@@ -361,4 +353,11 @@ public class AMapUIController implements IMogoMapUIController {
mClient.setAllGesturesEnabled(isEnable);
}
}
@Override
public void setExtraGPSData(MessagePad.GnssInfo gnssInfo) {
if (mClient != null) {
mClient.setExtraGPSData(gnssInfo);
}
}
}