diff --git a/gradle.properties b/gradle.properties index 05d6b408b6..e01c49e2f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -80,7 +80,7 @@ MOGO_TRAFFICLIVE_VERSION=1.3.15 MOGO_LOCATION_VERSION=1.3.15 ######## MogoAiCloudSDK Version ######## # 自研地图 -MAP_SDK_VERSION=2.0.0.18 +MAP_SDK_VERSION=2.0.0.20 # websocket WEBSOCKET_VERSION=1.1.7 ## 产品库必备配置,产品库自动对versionCode和versionName版本进行升级 diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java index c6027d1739..c232f274e4 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java @@ -1144,4 +1144,8 @@ public class AMapViewWrapper implements IMogoMapView, ResIdCache.putVal(speedVal, val); } + @Override + public void onMapInit() { + + } } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/MogoRouteOverlayManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/MogoRouteOverlayManager.java index 7c04820b4d..ebf88fc8c5 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/MogoRouteOverlayManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/MogoRouteOverlayManager.java @@ -1,6 +1,8 @@ package com.mogo.module.service.routeoverlay; import android.content.Context; +import android.location.Location; +import android.os.SystemClock; import android.util.Log; import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo; @@ -9,10 +11,14 @@ import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo; import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.map.MogoLatLng; +import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; +import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; +import com.mogo.map.navi.IMogoCarLocationChangedListener2; import com.mogo.module.common.MogoApisHandler; import org.jetbrains.annotations.NotNull; @@ -21,13 +27,14 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener{ +public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener, IMoGoMapLocationListener { private static volatile MogoRouteOverlayManager sInstance; private Context mContext; private String TAG = "MogoRouteOverlayManager"; private String TAG2 = "MogoRouteOverlayManager routes"; private int STATUS_AUTOPILOT = 0;//0 非自动驾驶 ; 1 自动驾驶 private MogoLatLng mEnding; + private MogoLocation mLocation; private MogoRouteOverlayManager(Context context) { mContext = context; } @@ -35,6 +42,8 @@ public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener, public void init() { CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this); CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); + CallerMapLocationListenerManager.INSTANCE.addListener(TAG,this); +// intiDrawer(); } public static MogoRouteOverlayManager getInstance(Context context) { @@ -48,24 +57,42 @@ public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener, return sInstance; } + private void intiDrawer(){ + RouteOverlayDrawer.getInstance(mContext).initdraw(); + } + @Override public void onAutopilotTrajectory(ArrayList trajectoryInfos) { if (trajectoryInfos == null || trajectoryInfos.size() == 0) { return; } - ADASTrajectoryInfo adasTrajectoryInfo = trajectoryInfos.get(0); - double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(); - double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(); - Log.d(TAG, "size:" + trajectoryInfos.size()); - Log.d(TAG, "trajectoryInfos:" + adasTrajectoryInfo.getLat()+":"+adasTrajectoryInfo.getLon()); - Log.d(TAG, "location:" + lat+":"+lon); +// double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(); +// double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(); + StringBuilder builder = new StringBuilder(); + builder.append("{"); + builder.append(System.currentTimeMillis()).append(";"); + builder.append(mLocation.getLongitude()).append(";"); + builder.append(mLocation.getLatitude()).append(";"); + builder.append(mLocation.getAltitude()).append(";"); + builder.append(mLocation.getBearing()).append(";"); + builder.append(mLocation.getSpeed()).append(";"); +// ADASTrajectoryInfo adasTrajectoryInfo = trajectoryInfos.get(0); +// long temp = SystemClock.currentThreadTimeMillis(); +// Log.d(TAG, "temp:"+temp+" size:" + trajectoryInfos.size()); +// Log.d(TAG, "trajectoryInfos:" + adasTrajectoryInfo.getLat()+":"+adasTrajectoryInfo.getLon()); +// Log.d(TAG, "temp:"+temp+" location:" + lat+":"+lon); List mogoLatLngs = new ArrayList<>(); for (ADASTrajectoryInfo a : trajectoryInfos) { +// Log.d(TAG, "temp:"+temp+" trajectoryInfos:" + a.getLat()+":"+a.getLon()); + builder.append(a.getLon()).append(","); + builder.append(a.getLat()).append(","); mogoLatLngs.add(new MogoLatLng(a.getLat(), a.getLon())); } if (STATUS_AUTOPILOT == 1) { RouteOverlayDrawer.getInstance(mContext).drawTrajectoryList(mogoLatLngs); } + builder.append("}"); + Log.d(TAG,builder.toString()); } @Override @@ -108,4 +135,9 @@ public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener, public void onAutopilotSNRequest() { } + + @Override + public void onLocationChanged(@Nullable MogoLocation location) { + mLocation = location; + } } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java index f1044fe84c..b3145020ed 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java @@ -3,6 +3,7 @@ package com.mogo.module.service.routeoverlay; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Color; import android.util.Log; import com.mogo.commons.debug.DebugConfig; @@ -48,7 +49,6 @@ public class RouteOverlayDrawer { mogoOverlayManager = MogoApisHandler.getInstance().getApis().getMapServiceApi().getOverlayManager(mContext); endingBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_route_ending); - } public static RouteOverlayDrawer getInstance(Context context) { @@ -112,6 +112,8 @@ public class RouteOverlayDrawer { public void drawTrajectoryList(List routeList) { // clearMogoRouteOverlay(); + long drawstart = System.currentTimeMillis(); + mPolylinePointList.clear(); if (routeList != null) { for (MogoLatLng latLng : routeList) { @@ -119,7 +121,17 @@ public class RouteOverlayDrawer { } mPolylineColors.clear(); // mPolylineColors.addAll(ColorUtils.gradientAlpha_("#FF2AAFFD", "#7b2965ED", "#002965ED", mPolylinePointList.size())); - mPolylineColors.addAll(ColorUtils.gradientAlpha("#FF2AAFFD", "#002965ED", mPolylinePointList.size())); + long start = System.currentTimeMillis(); + List list = new ArrayList<>(); +// list = ColorUtils.gradientAlpha("#FF2AAFFD", "#002965ED", mPolylinePointList.size()); + int[] startColor = ColorUtils.hexToArgb("#FF2AAFFD"); + int[] endColor = ColorUtils.hexToArgb("#002965ED"); + list.add(Color.argb(startColor[0],startColor[1],startColor[2],startColor[3])); + list.add(Color.argb(endColor[0],endColor[1],endColor[2],endColor[3])); + long end = System.currentTimeMillis(); + Log.d("MogoRouteOverlayManager","get color cost : "+ (end-start)); + + mPolylineColors.addAll(list); // 线条粗细,渐变,渐变色值 mPolylineOptions.width(12).useGradient(true).colorValues(mPolylineColors); if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()){ @@ -127,8 +139,32 @@ public class RouteOverlayDrawer { mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions); }else { mPolylineOptions.points(mPolylinePointList); - mMoGoPolyline.setOption(mPolylineOptions); +// mMoGoPolyline.setOption(mPolylineOptions); } } + long drawend = System.currentTimeMillis(); + Log.d("MogoRouteOverlayManager","drawTrajectoryList cost : "+ (drawend-drawstart)); + } + + public void initdraw() { + mPolylinePointList.clear(); + MogoLatLng latLng = new MogoLatLng(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()); + mPolylinePointList.add(latLng); + mPolylinePointList.add(latLng); + mPolylineColors.clear(); + long start = System.currentTimeMillis(); + List list = new ArrayList<>(); + list = ColorUtils.gradientAlpha("#FF2AAFFD", "#002965ED", mPolylinePointList.size()); + + mPolylineColors.addAll(list); + // 线条粗细,渐变,渐变色值 + mPolylineOptions.width(12).useGradient(true).colorValues(mPolylineColors); + if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()){ + mPolylineOptions.points(mPolylinePointList); + mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions); + }else { + mPolylineOptions.points(mPolylinePointList); + mMoGoPolyline.setOption(mPolylineOptions); + } } }