[dev_arch_opt_3.0]

[Change]
[
1、删除旧版地图本定位注册
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-01-28 19:44:46 +08:00
parent 68a00f1239
commit 9a5def9afa
14 changed files with 0 additions and 594 deletions

View File

@@ -38,7 +38,6 @@ import com.mogo.eagle.core.function.call.map.CallerMapDevaListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapStyleListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
@@ -981,7 +980,6 @@ public class AMapViewWrapper implements IMogoMapView,
bean.setLat(lat);
// 使用外部定位数据修改自车位置
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
CallerMapUIServiceManager.INSTANCE.getSingletonLocationClient(getContext()).updateLocation(bean);
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
@@ -1121,7 +1119,6 @@ public class AMapViewWrapper implements IMogoMapView,
locationClient.updateLocation(lonLatPoint);//更新新自动驾驶RTK相关数据
CallerMapUIServiceManager.INSTANCE.getSingletonLocationClient(getContext()).updateLocation(lonLatPoint);
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
}

View File

@@ -1,10 +1,6 @@
package com.mogo.map;
import android.content.Context;
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;
@@ -32,17 +28,10 @@ public class CustomMapApiBuilder {
return sApiBuilder;
}
public IMogoLocationClient getLocationClient(Context context) {
return new ALocationClient(context);
}
public IMogoMapUIController getMapUIController() {
return AMapUIController.getInstance();
}
public static IMogoLocationClient getLocationClientDelegate(Context context) {
return getApiBuilder().getLocationClient(context);
}
public static IMogoMapUIController getMapUIControllerDelegate() {
return getApiBuilder().getMapUIController();

View File

@@ -1,88 +0,0 @@
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.map.location.MogoLocationListenerRegister;
/**
* @author congtaowang
* @since 2019-12-19
* <p>
*/
public class MogoLocationClient implements IMogoLocationClient {
private static volatile MogoLocationClient sInstance;
public MogoLocationClient( Context context ) {
mDelegate = CustomMapApiBuilder.getLocationClientDelegate( context );
}
public static MogoLocationClient getInstance( Context context ) {
if ( sInstance == null ) {
synchronized ( MogoLocationClient.class ) {
if ( sInstance == null ) {
sInstance = new MogoLocationClient( context );
}
}
}
return sInstance;
}
private IMogoLocationClient mDelegate;
@Override
public void start() {
if ( mDelegate != null ) {
mDelegate.start();
}
}
@Override
public void start( long interval ) {
if ( mDelegate != null ) {
mDelegate.start( interval );
}
}
@Override
public void stop() {
if ( mDelegate != null ) {
mDelegate.stop();
}
}
@Override
public void addLocationListener( IMogoLocationListener listener ) {
MogoLocationListenerRegister.getInstance().addLocationListener( listener );
}
@Override
public void removeLocationListener( IMogoLocationListener listener ) {
MogoLocationListenerRegister.getInstance().removeLocationListener( listener );
}
@Override
public MogoLocation getLastKnowLocation() {
if ( mDelegate != null ) {
return mDelegate.getLastKnowLocation();
}
return null;
}
@Override
public void destroy() {
if ( mDelegate != null ) {
mDelegate.destroy();
}
}
@Override
public void updateLocation(Object locationToUpdate) {
if (mDelegate != null) {
mDelegate.updateLocation(locationToUpdate);
}
}
}

View File

@@ -1,87 +0,0 @@
package com.mogo.map;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import java.util.List;
/**
* 道路数据缓存
*
* @author tongchenfei
*/
public class RoadCacheWrapper {
private List<LonLatPoint> road;
private double lastDistanceDiff;
private int roadLength = -1;
private float laneWidth = -1;
public RoadCacheWrapper(List<LonLatPoint> road) {
setRoad(road);
}
public List<LonLatPoint> getRoad() {
return road;
}
public void setRoad(List<LonLatPoint> road) {
this.road = road;
if(road!=null) {
roadLength = road.size();
}
}
public double getLastDistanceDiff() {
return lastDistanceDiff;
}
public void setLastDistanceDiff(double lastDistanceDiff) {
this.lastDistanceDiff = lastDistanceDiff;
}
public double getLastLat(){
if (roadLength != -1) {
return road.get(roadLength - 1).getLatitude();
}
return 0;
}
public double getLastLon(){
if (roadLength != -1) {
return road.get(roadLength - 1).getLongitude();
}
return 0;
}
public float getLaneWidth() {
return laneWidth;
}
public void setLaneWidth(float laneWidth) {
this.laneWidth = laneWidth;
}
public boolean inCache(double lon, double lat) {
if (roadLength > 0) {
LonLatPoint start = road.get(0);
LonLatPoint end = road.get(roadLength - 1);
boolean latInRoad = false;
boolean lonInRoad = false;
if (start.getLatitude() > end.getLatitude()) {
latInRoad = lat <= start.getLatitude() && lat >= end.getLatitude();
}else{
latInRoad = lat >= start.getLatitude() && lat <= end.getLatitude();
}
if (start.getLongitude() > end.getLongitude()) {
lonInRoad = lon <= start.getLongitude() && lon >= end.getLongitude();
}else{
lonInRoad = lon >= start.getLongitude() && lon <= end.getLongitude();
}
return latInRoad && lonInRoad;
}
return false;
}
}

View File

@@ -1,157 +0,0 @@
package com.mogo.map.location;
import android.content.Context;
import android.os.Trace;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.utils.ObjectUtils;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.Set;
/**
* @author congtaowang
* @since 2019-12-19
* <p>
* 自研定位
*/
public class ALocationClient implements IMogoLocationClient {
private static final String TAG = "ALocationClient";
private MogoLocation mLastLocation;
private final LocationListener mListener = new InternalLocationListener();
private boolean mIsDestroyed = false;
public ALocationClient( Context context ) {
mClient = new LocationClient( context );
mClient.registerListener( mListener );
mLastLocation = ObjectUtils.fromLocation( mClient.getLastKnownMogoLocation() );
if ( mLastLocation == null ) {
mLastLocation = new MogoLocation();
}
}
private LocationClient mClient;
@Override
public void start() {
start( 2_000L );
}
@Override
public void start( long interval ) {
if ( mIsDestroyed ) {
destroyWarming();
return;
}
if ( mClient != null ) {
mClient.start();
}
}
@Override
public void stop() {
if ( mIsDestroyed ) {
destroyWarming();
return;
}
if ( mClient != null && mClient.isAGpsStarted() ) {
mClient.stop();
}
}
@Override
public void addLocationListener( IMogoLocationListener listener ) {
// do not impl.
}
@Override
public void removeLocationListener( IMogoLocationListener listener ) {
// do not impl.
}
@Override
public MogoLocation getLastKnowLocation() {
if ( mIsDestroyed ) {
destroyWarming();
return null;
}
return mLastLocation;
}
@Override
public synchronized void destroy() {
mIsDestroyed = true;
if ( mClient != null ) {
mClient.unRegisterListener( mListener );
mClient.destory();
}
mClient = null;
mLastLocation = null;
}
private class InternalLocationListener implements LocationListener {
@Override
public void onLocationChanged( @NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location ) {
if ( mIsDestroyed ) {
destroyWarming();
return;
}
if ( location == null ||
location.getLat() == 0.0D ||
location.getLon() == 0.0D ) {
return;
}
Trace.beginSection( "timer.onLocationChanged" );
mLastLocation = ObjectUtils.fromLocation( location );
UiThreadHandler.post(() -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation, 0, false));
Set< IMogoLocationListener > listeners = MogoLocationListenerRegister.getInstance().getListeners();
synchronized ( listeners ) {
Iterator< IMogoLocationListener > listenerIterator = listeners.iterator();
while ( listenerIterator.hasNext() ) {
listenerIterator.next().onLocationChanged( mLastLocation.clone() );
}
}
Trace.endSection();
}
}
private void destroyWarming() {
CallerLogger.INSTANCE.w( TAG, "location client has destroyed." );
}
@Override
public void updateLocation(Object locationToUpdate) {
if (locationToUpdate == null) {
return;
}
if (locationToUpdate instanceof MogoLocation) {
return;
}
// if (locationToUpdate instanceof RTKAutopilotLocationBean) {
// RTKAutopilotLocationBean current = (RTKAutopilotLocationBean) locationToUpdate;
// if (mClient != null) {
// mClient.updateRTKAutoPilotLocation(current);
// }
// }
if (locationToUpdate instanceof com.zhidaoauto.map.sdk.open.query.LonLatPoint) {
LonLatPoint current = (LonLatPoint) locationToUpdate;
if (mClient != null) {
mClient.updateLocation(current);
}
}
}
}