From 99b82ceeb6cb9814c26b195233d4b9322a8ba84e Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 21 Apr 2021 16:57:10 +0800 Subject: [PATCH] add tileId in uploadData --- gradle.properties | 14 +- .../amap/uicontroller/AMapUIController.java | 5 + .../mogo/map/impl/custom/AMapViewWrapper.java | 53 +++-- .../com/mogo/map/impl/custom/AMapWrapper.java | 33 ++- .../custom/uicontroller/AMapUIController.java | 6 + .../uicontroller/IMogoMapUIController.java | 9 + .../com/mogo/map/MogoMapUIController.java | 194 +++++++++--------- .../SnapshotLocationController.java | 2 + .../service/location/MogoRTKLocation.java | 79 +++---- .../service/impl/adas/AdasObjectUtils.java | 49 +++-- .../com/mogo/service/impl/v2x/V2XManager.java | 6 +- 11 files changed, 240 insertions(+), 210 deletions(-) diff --git a/gradle.properties b/gradle.properties index c263dde2c6..c12c099553 100644 --- a/gradle.properties +++ b/gradle.properties @@ -155,19 +155,19 @@ LOGLIB_VERSION = 1.0.4 ######## MogoAiCloudSDK Version # 网络请求 -MOGO_NETWORK_VERSION=1.0.71 +MOGO_NETWORK_VERSION=1.0.74 # 鉴权 -MOGO_PASSPORT_VERSION=1.0.71 +MOGO_PASSPORT_VERSION=1.0.74 # 常链接 -MOGO_SOCKET_VERSION=1.0.71 +MOGO_SOCKET_VERSION=1.0.74 # 数据采集 -MOGO_REALTIME_VERSION=1.0.71 +MOGO_REALTIME_VERSION=1.0.74 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.0.71 +MOGO_TANLU_VERSION=1.0.74 # 直播推流 -MOGO_LIVE_VERSION=1.0.71 +MOGO_LIVE_VERSION=1.0.74 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.0.71 +MOGO_TRAFFICLIVE_VERSION=1.0.74 ######## Foundation MogoAiCloud Module # mogoAiCloud apk services diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java index d8f81123fa..5061ea4b39 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java @@ -298,4 +298,9 @@ public class AMapUIController implements IMogoMapUIController { mClient.changeBearing( bearing ); } } + + @Override + public long getTileId(double lon, double lat) { + return 0; + } } 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 ebe2ac1cbd..b3c6c20f0e 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 @@ -9,7 +9,6 @@ import android.location.Location; import android.os.Bundle; import android.os.Trace; import android.text.TextUtils; -import android.util.ArrayMap; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -17,7 +16,6 @@ import android.view.ViewGroup; import android.view.animation.Interpolator; import android.widget.TextView; -import com.autonavi.nge.map.LonLat; import com.mogo.commons.debug.DebugConfig; import com.mogo.map.IMogoMap; import com.mogo.map.IMogoMapView; @@ -38,7 +36,6 @@ import com.mogo.map.uicontroller.MapControlResult; import com.mogo.utils.TipToast; import com.mogo.utils.UiThreadHandler; import com.mogo.utils.logger.Logger; -import com.mogo.utils.network.utils.GsonUtil; import com.zhidaoauto.map.sdk.open.MapAutoApi; import com.zhidaoauto.map.sdk.open.abs.MapStatusListener; import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener; @@ -57,7 +54,6 @@ 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; -import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions; import com.zhidaoauto.map.sdk.open.query.LonLatPoint; import com.zhidaoauto.map.sdk.open.tools.MapTools; import com.zhidaoauto.map.sdk.open.view.MapAutoView; @@ -67,10 +63,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.json.JSONObject; -import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.concurrent.ConcurrentHashMap; public class AMapViewWrapper implements IMogoMapView, @@ -729,6 +723,11 @@ public class AMapViewWrapper implements IMogoMapView, } } + @Override + public long getTileId(double lon, double lat) { + return getMap().getUIController().getTileId(lon,lat); + } + @Override public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) { Location sysLocation = new Location(location.getProvider()); @@ -796,13 +795,13 @@ public class AMapViewWrapper implements IMogoMapView, String speedVal = String.valueOf(speedIntVal); String infoResName = ResIdCache.getVal(speedVal); int offset = 20; - if ( !mMapView.getMapAutoViewHelper().getLockMode() ) { + if (!mMapView.getMapAutoViewHelper().getLockMode()) { offset = 30; } - if ( offset != mLastYOffset ) { + if (offset != mLastYOffset) { mLastYOffset = offset; } - mSelfMarker.setInfoWindowOffset( 0, offset ); + mSelfMarker.setInfoWindowOffset(0, offset); if (TextUtils.isEmpty(infoResName)) { if (mSpeedView == null) { mSpeedView = new TextView(mMapView.getContext()); @@ -958,7 +957,7 @@ public class AMapViewWrapper implements IMogoMapView, /** * 切换到车头朝上 */ - private void change2CarUp(){ + private void change2CarUp() { mMapView.getMapAutoViewHelper().setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_UP_CAR); } @@ -1029,9 +1028,9 @@ public class AMapViewWrapper implements IMogoMapView, bean.setAcceleration(acceleration); bean.setAlt(alt); bean.setSystemTime(systemTime); - bean.setSatelliteTime( satelliteTime ); + bean.setSatelliteTime(satelliteTime); bean.setReceiverDataTime(receiverDataTime); - bean.setAdasSatelliteTime( adasSatelliteTime ); + bean.setAdasSatelliteTime(adasSatelliteTime); bean.setLon(lon); bean.setGnss_speed(((float) speed)); bean.setLat(lat); @@ -1063,24 +1062,24 @@ public class AMapViewWrapper implements IMogoMapView, /** * 带缓存的道路匹配算法 - * + *

* 使用{@link MapDataApi#INSTANCE#getSinglePointMatchRoad()}这个方法获取道路数据会存在一定耗时,目前是4-10ms,因为请求频繁,为了 * 减小这部分耗时,使用一个ConcurrentHashMap{@link #roadCacheMap}缓存道路数据,此缓存是以目标车id为key,道路数据为value,以此减少 * 道路数据获取次数。 - * + *

* 当出现道路改变的情况,需要重新获取道路数据,采用递归的方式重获道路数据以及添加缓存,为了避免一直获取不到道路数据,一直递归,增加useCache参数跳出递归。 - * + *

* 道路改变的情况主要分为: - * 1. 目标车距离道路中心线距离超过阈值 matchThreshold(取路宽的1/4为阈值); - * 2. 目标车到道路中心线的映射点不在道路上(此判断在{@link PointInterpolatorUtil#mergeToRoad(double, double, List)}),也就是说已经驶出了这条道路 + * 1. 目标车距离道路中心线距离超过阈值 matchThreshold(取路宽的1/4为阈值); + * 2. 目标车到道路中心线的映射点不在道路上(此判断在{@link PointInterpolatorUtil#mergeToRoad(double, double, List)}),也就是说已经驶出了这条道路 * - * @param id 目标车唯一标识 - * @param lon 目标车经度 - * @param lat 目标车纬度 - * @param angle 目标车角度 + * @param id 目标车唯一标识 + * @param lon 目标车经度 + * @param lat 目标车纬度 + * @param angle 目标车角度 * @param isGpsLocation true-使用gps定位数据 - * @param isRTK true-使用rtk数据 - * @param usdCache true-使用道路缓存 false-不使用道路缓存 + * @param isRTK true-使用rtk数据 + * @param usdCache true-使用道路缓存 false-不使用道路缓存 * @return double[]{匹配后经度,匹配后纬度,目标车距离车道中心线距离},若匹配后经纬度值为-1,则没有匹配成功 */ private double[] matchRoad(String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK, boolean usdCache) { @@ -1089,7 +1088,7 @@ public class AMapViewWrapper implements IMogoMapView, RoadCacheWrapper roadCache = roadCacheMap.get(id); double matchThreshold = -1; - if (roadCache == null||roadCache == noCache) { + if (roadCache == null || roadCache == noCache) { SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(((float) wgs[0]), ((float) wgs[1]), ((float) angle), isGpsLocation, isRTK); if (singlePointRoadInfo != null && singlePointRoadInfo.getCoords() != null && !singlePointRoadInfo.getCoords().isEmpty()) { Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId()); @@ -1127,7 +1126,7 @@ public class AMapViewWrapper implements IMogoMapView, matchThreshold = roadCache.getLaneWidth() / 4; double[] matchedPoint = PointInterpolatorUtil.mergeToRoad(wgs[0], wgs[1], roadCache.getRoad()); - if (matchThreshold>0&&matchedPoint[2] > 0 && matchedPoint[2] <= matchThreshold) { + if (matchThreshold > 0 && matchedPoint[2] > 0 && matchedPoint[2] <= matchThreshold) { // 目标车在阈值范围内 roadCacheMap.put(id, roadCache); Log.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms"); @@ -1152,8 +1151,8 @@ public class AMapViewWrapper implements IMogoMapView, } @Override - public String getMarkerInfoResName( String speedVal ) { - return ResIdCache.getVal( speedVal ); + public String getMarkerInfoResName(String speedVal) { + return ResIdCache.getVal(speedVal); } @Override diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapWrapper.java index c8a58396a6..f1e03b51d2 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapWrapper.java @@ -2,7 +2,6 @@ package com.mogo.map.impl.custom; import android.content.Context; import android.graphics.Point; -import android.util.Log; import com.mogo.map.IMogoMap; import com.mogo.map.IMogoUiSettings; @@ -51,13 +50,13 @@ public class AMapWrapper implements IMogoMap { private IMogoUiSettings mUiSettings; public AMapWrapper(MapAutoViewHelper map, MapAutoView mapView, IMogoMapUIController controller) { - Logger.i(TAG, "autoop--AMapWrapper: init"+this); + Logger.i(TAG, "autoop--AMapWrapper: init" + this); this.mAMap = map; sAMap = map; this.mMapView = mapView; mUIcontroller = controller; // 设置实现自定义 info window - MapAutoApi.INSTANCE.setInfoWindowAdapter( new AMapInfoWindowAdapter() ); + MapAutoApi.INSTANCE.setInfoWindowAdapter(new AMapInfoWindowAdapter()); AMapUIController.getInstance().initClient(mUIcontroller); } @@ -83,7 +82,7 @@ public class AMapWrapper implements IMogoMap { @Override public IMogoMarker addMarker(String tag, MogoMarkerOptions options) { - Logger.i(TAG, "autoop-addMarker: " + tag + ",MogoMarkerOptions:" + options + ",AMap:" + (mAMap != null)+",this:"+this); + Logger.i(TAG, "autoop-addMarker: " + tag + ",MogoMarkerOptions:" + options + ",AMap:" + (mAMap != null) + ",this:" + this); if (!checkAMap()) { return null; } @@ -134,7 +133,7 @@ public class AMapWrapper implements IMogoMap { multiPointOverlayOptions.setData(markerOptions); multiPointOverlayOptions.setMarkerIcon(R.drawable.marker_blue); List data = mAMap.addMarkers(multiPointOverlayOptions).getOptions().getData(); - for (int i = 0 ;i< data.size();i++){ + for (int i = 0; i < data.size(); i++) { markers.add(new Marker(data.get(i))); } if (markers == null || markers.isEmpty()) { @@ -168,7 +167,7 @@ public class AMapWrapper implements IMogoMap { @Override public void setPointToCenter(int x, int y) { if (checkAMap()) { - LonLatPoint lonLatPoint = MapTools.INSTANCE.fromScreenLocation(new Point(x,y)); + LonLatPoint lonLatPoint = MapTools.INSTANCE.fromScreenLocation(new Point(x, y)); mAMap.setCenter(lonLatPoint); } } @@ -176,21 +175,21 @@ public class AMapWrapper implements IMogoMap { @Override public void setTouchPoiEnable(boolean touchPoiEnable) { if (checkAMap()) { - mAMap.setTouchPoiEnable( touchPoiEnable ); + mAMap.setTouchPoiEnable(touchPoiEnable); } } @Override public void setTrafficEnable(boolean enable) { if (checkAMap()) { - mAMap.setTraffic( enable ); + mAMap.setTraffic(enable); } } @Override public void showBuildings(boolean enabled) { if (checkAMap()) { - mAMap.showBuildings( enabled ); + mAMap.showBuildings(enabled); } } @@ -204,7 +203,7 @@ public class AMapWrapper implements IMogoMap { @Override public void showMapText(boolean enable) { if (checkAMap()) { - mAMap.showMapText( enable ); + mAMap.showMapText(enable); } } @@ -217,7 +216,7 @@ public class AMapWrapper implements IMogoMap { @Override public float getScalePerPixel() { - if ( checkAMap() ) { + if (checkAMap()) { return mAMap.getScalePerPixel(); } return 0; @@ -247,19 +246,19 @@ public class AMapWrapper implements IMogoMap { @Override public IMogoPolyline addPolyline(MogoPolylineOptions options) { - if ( checkAMap() ) { - PolylineOptions polylineOptions = ObjectUtils.fromMogo( options ); + if (checkAMap()) { + PolylineOptions polylineOptions = ObjectUtils.fromMogo(options); Logger.d(TAG, "addPolyline %s", polylineOptions.toString()); - if ( polylineOptions == null ) { + if (polylineOptions == null) { return null; } Polyline polyline = null; - if (polylineOptions.getLineWidth() > 0){ + if (polylineOptions.getLineWidth() > 0) { polyline = mAMap.drawThickLine(polylineOptions); - }else { + } else { polyline = mAMap.drawLine(polylineOptions); } - return new AMapPolylineWrapper( polyline, options ); + return new AMapPolylineWrapper(polyline, options); } return null; } diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java index 4dc88d87fb..184f7f7ff0 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java @@ -13,6 +13,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.zhidaoauto.map.sdk.open.MapAutoApi; import org.json.JSONObject; @@ -286,6 +287,11 @@ public class AMapUIController implements IMogoMapUIController { } } + @Override + public long getTileId(double lon, double lat) { + return MapAutoApi.INSTANCE.getTileID(lon,lat,13); // 13为默认获取瓦片层级级别 + } + @Override public void setAnchorScale( float x, float y ) { diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index 4f7ee5a167..0634cec1f7 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -237,6 +237,15 @@ public interface IMogoMapUIController { */ void changeBearing( float bearing ); + /** + * 获取瓦片id + * @param lon 经度 + * @param lat 纬度 + * @return 瓦片id + */ + long getTileId(double lon, double lat); + + default void setAnchorScale( float x, float y ) { } 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 9aca5abc2c..d6d009fed0 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 @@ -3,7 +3,6 @@ package com.mogo.map; import android.graphics.Point; import android.graphics.Rect; import android.location.Location; -import android.util.Log; import android.view.View; import android.view.animation.Interpolator; @@ -38,9 +37,9 @@ public class MogoMapUIController implements IMogoMapUIController { } public static MogoMapUIController getInstance() { - if ( sInstance == null ) { - synchronized ( MogoMapUIController.class ) { - if ( sInstance == null ) { + if (sInstance == null) { + synchronized (MogoMapUIController.class) { + if (sInstance == null) { sInstance = new MogoMapUIController(); } } @@ -48,7 +47,7 @@ public class MogoMapUIController implements IMogoMapUIController { return sInstance; } - public void setDelegate( IMogoMapUIController mDelegate ) { + public void setDelegate(IMogoMapUIController mDelegate) { this.mDelegate = mDelegate; } @@ -57,77 +56,77 @@ public class MogoMapUIController implements IMogoMapUIController { } @Override - public void setTrafficEnabled( boolean visible ) { + public void setTrafficEnabled(boolean visible) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.setTrafficEnabled( visible ); + if (mDelegate != null) { + mDelegate.setTrafficEnabled(visible); } } @Override - public MapControlResult changeZoom( boolean zoom ) { + public MapControlResult changeZoom(boolean zoom) { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.changeZoom( zoom ); + if (mDelegate != null) { + return mDelegate.changeZoom(zoom); } return MapControlResult.ERROR; } @Override - public MapControlResult changeZoom( float zoom ) { + public MapControlResult changeZoom(float zoom) { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.changeZoom( zoom ); + if (mDelegate != null) { + return mDelegate.changeZoom(zoom); } return MapControlResult.ERROR; } @Override - public void changeMapMode( EnumMapUI mode ) { + public void changeMapMode(EnumMapUI mode) { initDelegate(); - if ( mDelegate != null ) { - Logger.d( TAG, "set type: %s", mode.name() ); - mDelegate.changeMapMode( mode ); + if (mDelegate != null) { + Logger.d(TAG, "set type: %s", mode.name()); + mDelegate.changeMapMode(mode); } } @Override - public void moveToCenter( MogoLatLng latLng, boolean animate ) { + public void moveToCenter(MogoLatLng latLng, boolean animate) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.moveToCenter( latLng, animate ); + if (mDelegate != null) { + mDelegate.moveToCenter(latLng, animate); } } @Override - public void showMyLocation( boolean visible ) { + public void showMyLocation(boolean visible) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.showMyLocation( visible ); + if (mDelegate != null) { + mDelegate.showMyLocation(visible); } } @Override public void emphasizeMyLocation() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { mDelegate.emphasizeMyLocation(); } } @Override - public void showMyLocation( View view ) { + public void showMyLocation(View view) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.showMyLocation( view ); + if (mDelegate != null) { + mDelegate.showMyLocation(view); } } @Override public void recoverLockMode() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { mDelegate.recoverLockMode(); } } @@ -135,31 +134,31 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public void loseLockMode() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { mDelegate.loseLockMode(); } } @Override - public void setLockZoom( int var1 ) { + public void setLockZoom(int var1) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.setLockZoom( var1 ); + if (mDelegate != null) { + mDelegate.setLockZoom(var1); } } @Override - public void displayOverview( Rect bounds ) { + public void displayOverview(Rect bounds) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.displayOverview( bounds ); + if (mDelegate != null) { + mDelegate.displayOverview(bounds); } } @Override public float getScalePerPixel() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getScalePerPixel(); } return 0; @@ -168,7 +167,7 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public float getZoomLevel() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getZoomLevel(); } return 0; @@ -177,7 +176,7 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getRoadWidth(lon, lat, angle, isGpsLocation, isRTK); } @@ -187,7 +186,7 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public MogoLatLng getCameraNorthEastPosition() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getCameraNorthEastPosition(); } return null; @@ -196,7 +195,7 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public MogoLatLng getCameraSouthWestPosition() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getCameraSouthWestPosition(); } return null; @@ -205,75 +204,75 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public MogoLatLng getWindowCenterLocation() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getWindowCenterLocation(); } return null; } @Override - public void setPointToCenter( double mapCenterX, double mapCenterY ) { + public void setPointToCenter(double mapCenterX, double mapCenterY) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.setPointToCenter( mapCenterX, mapCenterY ); + if (mDelegate != null) { + mDelegate.setPointToCenter(mapCenterX, mapCenterY); } } @Override - public Point getLocationPointInScreen( MogoLatLng latLng ) { + public Point getLocationPointInScreen(MogoLatLng latLng) { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.getLocationPointInScreen( latLng ); + if (mDelegate != null) { + return mDelegate.getLocationPointInScreen(latLng); } return null; } @Override - public MogoLatLng getLocationMogoLatLngInScreen( Point point ) { + public MogoLatLng getLocationMogoLatLngInScreen(Point point) { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.getLocationMogoLatLngInScreen( point ); + if (mDelegate != null) { + return mDelegate.getLocationMogoLatLngInScreen(point); } return null; } @Override - public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator, long duration ) { + public void startJumpAnimation(IMogoMarker marker, float high, Interpolator interpolator, long duration) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.startJumpAnimation( marker, high, interpolator, duration ); + if (mDelegate != null) { + mDelegate.startJumpAnimation(marker, high, interpolator, duration); } } @Override - public void setRenderFps( int fps ) { + public void setRenderFps(int fps) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.setRenderFps( fps ); + if (mDelegate != null) { + mDelegate.setRenderFps(fps); } } @Override - public void showBounds( String tag, MogoLatLng carPosition, List< MogoLatLng > lonLats, Rect bound, boolean lockCarPosition ) { + public void showBounds(String tag, MogoLatLng carPosition, List lonLats, Rect bound, boolean lockCarPosition) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.showBounds( tag, carPosition, lonLats, bound, lockCarPosition ); + if (mDelegate != null) { + mDelegate.showBounds(tag, carPosition, lonLats, bound, lockCarPosition); } } @Override public void forceRender() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { mDelegate.forceRender(); } } @Override - public float calculateLineDistance( MogoLatLng p1, MogoLatLng p2 ) throws Exception { + public float calculateLineDistance(MogoLatLng p1, MogoLatLng p2) throws Exception { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.calculateLineDistance( p1, p2 ); + if (mDelegate != null) { + return mDelegate.calculateLineDistance(p1, p2); } return 0; } @@ -281,67 +280,72 @@ public class MogoMapUIController implements IMogoMapUIController { @Override public EnumMapUI getCurrentUiMode() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getCurrentUiMode(); } return null; } @Override - public void changeMyLocation( Location location ) { + public void changeMyLocation(Location location) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.changeMyLocation( location ); + if (mDelegate != null) { + mDelegate.changeMyLocation(location); } } @Override public boolean isCarLocked() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.isCarLocked(); } return false; } @Override - public void setCarCursorOption( CarCursorOption option ) { + public void setCarCursorOption(CarCursorOption option) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.setCarCursorOption( option ); + if (mDelegate != null) { + mDelegate.setCarCursorOption(option); } } @Override public MapCameraPosition getMapCameraPosition() { initDelegate(); - if ( mDelegate != null ) { + if (mDelegate != null) { return mDelegate.getMapCameraPosition(); } return null; } @Override - public void changeBearing( float bearing ) { + public void changeBearing(float bearing) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.changeBearing( bearing ); + if (mDelegate != null) { + mDelegate.changeBearing(bearing); } } @Override - public void rtkEnable( boolean enable ) { + public long getTileId(double lon, double lat) { + return mDelegate.getTileId(lon, lat); + } + + @Override + public void rtkEnable(boolean enable) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.rtkEnable( enable ); + if (mDelegate != null) { + mDelegate.rtkEnable(enable); } } @Override - public void syncLocation2Map( JSONObject data ) { + public void syncLocation2Map(JSONObject data) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.syncLocation2Map( data ); + if (mDelegate != null) { + mDelegate.syncLocation2Map(data); } } @@ -351,42 +355,42 @@ public class MogoMapUIController implements IMogoMapUIController { } private void initDelegate() { - if ( mDelegate == null ) { + if (mDelegate == null) { mDelegate = MogoMapDelegateFactory.getMapUIControllerDelegate(); } } @Override - public void openVrMode( boolean zoomGestureEnable ) { + public void openVrMode(boolean zoomGestureEnable) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.openVrMode( zoomGestureEnable ); + if (mDelegate != null) { + mDelegate.openVrMode(zoomGestureEnable); } } @Override - public double[] matchRoad( String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) { + public double[] matchRoad(String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK) { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.matchRoad( id, lon, lat, angle, isGpsLocation, isRTK ); + if (mDelegate != null) { + return mDelegate.matchRoad(id, lon, lat, angle, isGpsLocation, isRTK); } return null; } @Override - public String getMarkerInfoResName( String speedVal ) { + public String getMarkerInfoResName(String speedVal) { initDelegate(); - if ( mDelegate != null ) { - return mDelegate.getMarkerInfoResName( speedVal ); + if (mDelegate != null) { + return mDelegate.getMarkerInfoResName(speedVal); } return null; } @Override - public void setMarkerInfoResName( String speedVal, String val ) { + public void setMarkerInfoResName(String speedVal, String val) { initDelegate(); - if ( mDelegate != null ) { - mDelegate.setMarkerInfoResName( speedVal, val ); + if (mDelegate != null) { + mDelegate.setMarkerInfoResName(speedVal, val); } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java index da20e6f206..8ff04c3c59 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java @@ -1,6 +1,7 @@ package com.mogo.module.common.uploadintime; import com.mogo.commons.debug.DebugConfig; +import com.mogo.module.common.MogoApisHandler; import com.mogo.realtime.entity.CloudLocationInfo; import com.mogo.utils.logger.Logger; @@ -98,6 +99,7 @@ class SnapshotLocationController { cloudLocationInfo.setSpeed( speed ); cloudLocationInfo.setSatelliteTime( satelliteTime ); cloudLocationInfo.setSystemTime( systemTime ); + cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon,lat))); mLastLocationInfo = cloudLocationInfo; mMachineCacheList.add( cloudLocationInfo ); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java index dd926dbb11..6fba82182a 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java @@ -8,6 +8,7 @@ import android.location.LocationManager; import android.os.Bundle; import com.mogo.commons.AbsMogoApplication; +import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.uploadintime.SnapshotLocationController; import com.mogo.realtime.entity.CloudLocationInfo; import com.mogo.utils.logger.Logger; @@ -29,77 +30,79 @@ public class MogoRTKLocation { } public void init() { - locationManager = ( LocationManager ) AbsMogoApplication.getApp().getApplicationContext().getSystemService( Context.LOCATION_SERVICE ); - String provider = locationManager.getBestProvider( getCriteria(), true ); - Logger.d( TAG, "init provider : " + provider ); - if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) { + locationManager = (LocationManager) AbsMogoApplication.getApp().getApplicationContext().getSystemService(Context.LOCATION_SERVICE); + String provider = locationManager.getBestProvider(getCriteria(), true); + Logger.d(TAG, "init provider : " + provider); + if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { try { - locationManager.requestLocationUpdates( provider, 0, 0, locationListener ); - Location location = locationManager.getLastKnownLocation( provider ); - if ( location != null ) { - Logger.i( TAG, "location : " + location.toString() ); + locationManager.requestLocationUpdates(provider, 0, 0, locationListener); + Location location = locationManager.getLastKnownLocation(provider); + if (location != null) { + Logger.i(TAG, "location : " + location.toString()); } - } catch ( Exception e ) { + } catch (Exception e) { e.printStackTrace(); - Logger.d( TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage() ); + Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage()); } } else { - Logger.d( TAG, "RTK LocationManager Provider GPS_PROVIDER unable" ); + Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable"); } } private Criteria getCriteria() { Criteria criteria = new Criteria(); - criteria.setAccuracy( Criteria.ACCURACY_FINE ); //高精 - criteria.setAltitudeRequired( false ); - criteria.setBearingRequired( true ); - criteria.setSpeedRequired( true ); - criteria.setPowerRequirement( Criteria.POWER_LOW ); + criteria.setAccuracy(Criteria.ACCURACY_FINE); //高精 + criteria.setAltitudeRequired(false); + criteria.setBearingRequired(true); + criteria.setSpeedRequired(true); + criteria.setPowerRequirement(Criteria.POWER_LOW); return criteria; } private final LocationListener locationListener = new LocationListener() { @Override - public void onLocationChanged( Location location ) { - if ( location != null ) { + public void onLocationChanged(Location location) { + if (location != null) { CloudLocationInfo cloudLocationInfo = new CloudLocationInfo(); - if(location.getLatitude() != 0.0 && location.getLongitude() != 0.0){ - cloudLocationInfo.setAlt( location.getAltitude() ); - cloudLocationInfo.setHeading( location.getBearing() ); - cloudLocationInfo.setLat( location.getLatitude() ); - cloudLocationInfo.setLon( location.getLongitude() ); - cloudLocationInfo.setSpeed( location.getSpeed() ); - cloudLocationInfo.setSatelliteTime( location.getTime() ); - cloudLocationInfo.setSystemTime( System.currentTimeMillis() ); - SnapshotLocationController.getInstance().syncLocationInfo( cloudLocationInfo ); + if (location.getLatitude() != 0.0 && location.getLongitude() != 0.0) { + cloudLocationInfo.setAlt(location.getAltitude()); + cloudLocationInfo.setHeading(location.getBearing()); + cloudLocationInfo.setLat(location.getLatitude()); + cloudLocationInfo.setLon(location.getLongitude()); + cloudLocationInfo.setSpeed(location.getSpeed()); + cloudLocationInfo.setSatelliteTime(location.getTime()); + cloudLocationInfo.setSystemTime(System.currentTimeMillis()); + cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController() + .getTileId(location.getLongitude(), location.getLatitude()))); + SnapshotLocationController.getInstance().syncLocationInfo(cloudLocationInfo); } } else { - Logger.e( TAG, "location == null" ); + Logger.e(TAG, "location == null"); } } @Override - public void onStatusChanged( String provider, int status, Bundle extras ) { - Logger.d( TAG, "onStatusChanged status: " + status ); + public void onStatusChanged(String provider, int status, Bundle extras) { + Logger.d(TAG, "onStatusChanged status: " + status); } @Override - public void onProviderEnabled( String provider ) { - Logger.d( TAG, "onProviderEnabled" ); + public void onProviderEnabled(String provider) { + Logger.d(TAG, "onProviderEnabled"); } @Override - public void onProviderDisabled( String provider ) { - Logger.d( TAG, "onProviderEnabled" ); + public void onProviderDisabled(String provider) { + Logger.d(TAG, "onProviderEnabled"); } }; public void stop() { - Logger.d( TAG, "stop RTK Location" ); - if ( locationManager != null && locationListener != null ) { - locationManager.removeUpdates( locationListener ); + Logger.d(TAG, "stop RTK Location"); + if (locationManager != null && locationListener != null) { + locationManager.removeUpdates(locationListener); } else { - Logger.d( TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null" ); + Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null"); } } } diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java index 8183c0f01f..1836e7e73e 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java @@ -1,8 +1,10 @@ package com.mogo.service.impl.adas; -import com.mogo.cloud.commons.utils.CoordinateUtils; +import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.utils.MortonCode; +import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.realtime.entity.ADASRecognizedResult; +import com.mogo.service.IMogoServiceApis; import com.mogo.service.adas.entity.ADASWarnMessage; import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel; import com.zhidao.support.adas.high.bean.WarnMessageInfo; @@ -10,68 +12,71 @@ import com.zhidao.support.adas.high.bean.WarnMessageInfo; import java.util.ArrayList; import java.util.List; -public + /* * @author congtaowang * @since 2020/10/25 * * 对象转换类 */ -class AdasObjectUtils { +public class AdasObjectUtils { - public static ADASWarnMessage fromAdasObject( WarnMessageInfo info ) { - if ( info == null ) { + public static ADASWarnMessage fromAdasObject(WarnMessageInfo info) { + if (info == null) { return null; } ADASWarnMessage warnMessage = new ADASWarnMessage(); warnMessage.content = info.getContent(); warnMessage.level = info.getLevel(); try { - warnMessage.type = Integer.parseInt( info.getType() ); - } catch ( NumberFormatException e ) { + warnMessage.type = Integer.parseInt(info.getType()); + } catch (NumberFormatException e) { return null; } warnMessage.value = info.getValue(); return warnMessage; } - public static List regroupData(List< AdasAIDLOwnerCarRectModel > datums ) { - if ( datums == null || datums.isEmpty() ) { + public static List regroupData(List datums) { + if (datums == null || datums.isEmpty()) { return null; } - List< ADASRecognizedResult > recognizedListResults = new ArrayList<>(); - for ( AdasAIDLOwnerCarRectModel model : datums ) { - if ( model == null ) { + List recognizedListResults = new ArrayList<>(); + for (AdasAIDLOwnerCarRectModel model : datums) { + if (model == null) { continue; } - ADASRecognizedResult recognizedListResult = fromAdasObject( model ); - if ( recognizedListResult != null ) { - recognizedListResults.add( recognizedListResult ); + ADASRecognizedResult recognizedListResult = fromAdasObject(model); + if (recognizedListResult != null) { + recognizedListResults.add(recognizedListResult); } } return recognizedListResults; } - public static ADASRecognizedResult fromAdasObject( AdasAIDLOwnerCarRectModel model ) { - if ( model == null ) { + public static ADASRecognizedResult fromAdasObject(AdasAIDLOwnerCarRectModel model) { + if (model == null) { return null; } ADASRecognizedResult result = new ADASRecognizedResult(); result.uuid = model.getUuid(); - result.lat = model.getLat(); result.lon = model.getLon(); - result.type = Integer.parseInt( model.getType() ); + result.type = Integer.parseInt(model.getType()); result.heading = model.getHeading(); - result.systemTime = Long.parseLong( model.getSystemTime() ); - result.satelliteTime = Long.parseLong( model.getSatelliteTime() ); + result.systemTime = Long.parseLong(model.getSystemTime()); + result.satelliteTime = Long.parseLong(model.getSatelliteTime()); result.alt = model.getAlt(); result.color = model.getColor(); result.speed = model.getSpeed(); result.carId = model.getCarId(); result.dataAccuracy = model.dataAccuracy; result.distance = model.distance; - result.mortonCode = MortonCode.wrapEncodeMorton( result.lon, result.lat ); + result.mortonCode = MortonCode.wrapEncodeMorton(result.lon, result.lat); + IMogoMapUIController mogoMapUIController = ARouter.getInstance().navigation(IMogoServiceApis.class).getMapServiceApi().getMapUIController(); + if (mogoMapUIController != null) { + result.tileId = String.valueOf(mogoMapUIController.getTileId(result.lon, result.lat)); + } return result; } } diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/v2x/V2XManager.java b/services/mogo-service/src/main/java/com/mogo/service/impl/v2x/V2XManager.java index 7b7c867a67..5b3bcbee05 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/v2x/V2XManager.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/v2x/V2XManager.java @@ -24,7 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList; */ @Route(path = MogoServicePaths.PATH_V2X_FRONT_CRASH_WARNING) public class V2XManager implements IV2XProvider { - private Map> mListeners = new ConcurrentHashMap<>(); + private final Map> mListeners = new ConcurrentHashMap<>(); @Override public void registerIntentListener(String intent, IV2XListener listener) { @@ -50,9 +50,7 @@ public class V2XManager implements IV2XProvider { public void warningChangedForListenerWithDirection(int direction, String command) { List listeners = mListeners.get(command); if (listeners != null && !listeners.isEmpty()) { - Iterator iterator = listeners.iterator(); - while (iterator.hasNext()) { - IV2XListener listener = iterator.next(); + for (IV2XListener listener : listeners) { if (listener != null) { listener.warningChangedWithDirection(direction); }