[dev_arch_opt_3.0]

[Change]
[
1、删除地图中废弃的定位回掉方法
2、修改小地图监听位置更改的方式,设置为10HZ,更新地图解决跳变问题
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-02-07 18:45:58 +08:00
parent 7ae724c3f0
commit daf51c78ce
15 changed files with 261 additions and 296 deletions

View File

@@ -24,7 +24,6 @@ import android.view.View;
import androidx.annotation.NonNull;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
@@ -32,13 +31,12 @@ import com.mogo.eagle.core.data.map.CenterLine;
import com.mogo.eagle.core.data.map.MapRoadInfo;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager;
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.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.listener.MogoMapListenerHandler;
@@ -67,9 +65,7 @@ import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory;
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds;
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle;
import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
@@ -83,14 +79,12 @@ import com.zhjt.service.chain.TracingConstants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class AMapViewWrapper implements IMogoMapView,
IMogoMapUIController,
LocationListener,
OnMapLoadedListener,
MapStatusListener,
OnCameraChangeListener,
@@ -180,10 +174,6 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapLoadedListener(this);
mMapView.setOnMapTouchListener(this);
mMapView.setOnMapClickListener(this);
LocationClient client = mMapView.getLocationClient();
if (client != null) {
client.registerListener(this);
}
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
@@ -208,7 +198,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
MogoLocation carLoc = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
MogoLocation carLoc = CallerChassisLocationGCJ20ListenerManager.INSTANCE.getChassisLocationGCJ02();
if (stopLine != null && stopLine.road_id != null && !stopLine.road_id.isEmpty() && stopLine.points != null && stopLine.points.size() > 0) {
ArrayList<LonLatPoint> points = stopLine.points;
if (carLoc != null) {
@@ -316,7 +306,6 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapLoadedListener(null);
mMapView.setOnMapTouchListener(null);
mMapView.setOnMapClickListener(null);
mMapView.getLocationClient().unRegisterListener(this);
mMapView.setOnCameraChangeListener(null);
MapAutoApi.INSTANCE.unregisterLogListener(this);
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onDestroy");
@@ -694,37 +683,6 @@ public class AMapViewWrapper implements IMogoMapView,
CallerMapDevaListenerManager.INSTANCE.invokeUploadLogFile(filePath);
}
@Override
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
CallerMapLocationListenerManager.INSTANCE.setCurrentLocation(ObjectUtils.fromLocation(location));
// 将有效经纬度暂存本地提供给下一次的Http-DNS使用防止首次请求位置获取不到
if (location.getLat() > 0 && location.getLon() > 0) {
if (location.getCityCode() != null && !location.getCityCode().isEmpty()) {
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
}
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_LATITUDE, String.valueOf(location.getLat()));
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
}
if (checkAMapView() && mMapLoaded) {
// 地图初始化完成后每隔5s自动判断当前地图的模式
if (mIsFirstLocated) {
if (!mIsDelayed) {
mIsDelayed = true;
UiThreadHandler.postDelayed(() -> {
//CallerLogger.INSTANCE.d(M_MAP+TAG, "倒计时结束");
mIsFirstLocated = false;
}, 5_000L);
}
} else {
mIsFirstLocated = true;
mIsDelayed = false;
}
}
}
@Override
public void onMapClick(@Nullable LonLatPoint lonLatPoint) {
@@ -889,42 +847,6 @@ public class AMapViewWrapper implements IMogoMapView,
}
}
@Override
public void syncLocation2Map(JSONObject data) {
if (!checkAMapView()) {
return;
}
if (data == null) {
CallerLogger.INSTANCE.d(M_MAP + TAG, "停止使用rtk定位数据");
return;
}
double lon = data.optDouble("lon", -1);
double lat = data.optDouble("lat", -1);
double alt = data.optDouble("alt", -1);
double heading = data.optDouble("heading", -1);
double acceleration = data.optDouble("acceleration", -1);
double yawRate = data.optDouble("yawRate", -1);
double speed = data.optDouble("speed", -1);
long systemTime = data.optLong("systemTime");
long satelliteTime = data.optLong("satelliteTime");
if (lon == -1) {
return;
}
RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
bean.setYaw_rate(yawRate);
bean.setHeading(heading);
bean.setAcceleration(acceleration);
bean.setAlt(alt);
bean.setSystemTime(systemTime);
bean.setSatelliteTime(satelliteTime);
bean.setLon(lon);
bean.setGnss_speed(((float) speed));
bean.setLat(lat);
// 使用外部定位数据修改自车位置
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
@Override
public void stepInVrMode(boolean isDayMode) {