diff --git a/foudations/mogo-utils/build.gradle b/foudations/mogo-utils/build.gradle index acb651044b..b189907466 100644 --- a/foudations/mogo-utils/build.gradle +++ b/foudations/mogo-utils/build.gradle @@ -38,6 +38,7 @@ dependencies { annotationProcessor rootProject.ext.dependencies.supportannos annotationProcessor rootProject.ext.dependencies.glidecompiler implementation rootProject.ext.dependencies.androidxappcompat + api 'ch.hsr:geohash:1.4.0' api rootProject.ext.dependencies.mogoaicloudnetwork api rootProject.ext.dependencies.mogoaicloudpassport diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java index 92e1a9844d..4e2757fc78 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java @@ -4,13 +4,14 @@ import android.content.Context; import android.graphics.Color; import android.location.Location; import android.util.AttributeSet; +import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; -import android.view.animation.LinearInterpolator; import android.widget.RelativeLayout; import androidx.annotation.Nullable; +import com.alibaba.android.arouter.thread.CancelableCountDownLatch; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdate; import com.amap.api.maps.CameraUpdateFactory; @@ -24,13 +25,13 @@ 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.cloud.commons.utils.CoordinateUtils; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.debug.DebugConfig; import com.mogo.map.MogoLatLng; import com.mogo.map.navi.IMogoCarLocationChangedListener2; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.view.RoundLayout; -import com.mogo.module.small.map.animation.DirectionRotateAnimation; import com.mogo.module.small.map.utils.MapAssetStyleUtils; import com.mogo.module.small.map.view.ISmallMapDirectionView; import com.mogo.utils.logger.Logger; @@ -38,6 +39,8 @@ import com.mogo.utils.logger.Logger; import java.util.ArrayList; import java.util.List; +import ch.hsr.geohash.GeoHash; + /** * 小地图的方向View * @@ -48,9 +51,7 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLocationChangedListener2, ISmallMapDirectionView { - /** - * 小地图名称 - */ + //小地图名称 public static final String MODULE_NAME = "SmallMap"; private RoundLayout rlSmallMapBorder; @@ -60,13 +61,11 @@ public class SmallMapDirectionView private Marker mStartMarker; private Marker mEndMarker; - private int lastAngle = 0; private int zoomLevel = 13; private List mCoordinatesLatLng = new ArrayList<>(); private List mCoordinatesLatLngCurrent = new ArrayList<>(); private Polyline mPolyline; private CameraUpdate mCameraUpdate; - private DirectionRotateAnimation mRotateAnimation; public SmallMapDirectionView(Context context) { this(context, null); @@ -86,8 +85,6 @@ public class SmallMapDirectionView } private void initView(Context context) { - mRotateAnimation = new DirectionRotateAnimation(context, null); - LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this); mAMapNaviView = AbsMogoApplication.getMapNaviView(); @@ -134,18 +131,6 @@ public class SmallMapDirectionView // 关闭显示实时路况图层,aMap是地图控制器对象。 mAMap.setTrafficEnabled(false); - -// MyLocationStyle myLocationStyle; -// myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。 -// myLocationStyle.interval(1000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。 -// myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE);//连续定位、蓝点不会移动到地图中心点,地图依照设备方向旋转,并且蓝点会跟随设备移动。 -// myLocationStyle.myLocationIcon(BitmapDescriptorFactory -// .fromResource(R.drawable.module_small_map_view_my_location_logo)); -// mAMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style -// mAMap.getUiSettings().setMyLocationButtonEnabled(false);//设置默认定位按钮是否显示,非必需设置。 -// mAMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。 -// mAMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW); - // 设置 锚点 图标 mCarMarker = mAMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo)) @@ -193,24 +178,38 @@ public class SmallMapDirectionView LatLng currentLatLng = new LatLng(latLng.getLatitude(), latLng.getLongitude()); if (mCarMarker != null) { - //mAMap.moveCamera(CameraUpdateFactory.changeBearing(latLng.getBearing())); - -// changeAngle((int) latLng.getBearing()); -// mStartMarker.setRotateAngle(360 - latLng.getBearing()); -// mEndMarker.setRotateAngle(360 - latLng.getBearing()); - mCarMarker.setRotateAngle(360 - latLng.getBearing()); mCarMarker.setPosition(currentLatLng); mCarMarker.setToTop(); } + if (mCoordinatesLatLng.size() > 1) { mCoordinatesLatLngCurrent.clear(); for (LatLng lng : mCoordinatesLatLng) { MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude); mCoordinatesLatLngCurrent.add(mogoLatLng); } - drawablePolyline(mCoordinatesLatLngCurrent); + + // 结束位置 + LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1); + // 与结束位置进行 GeoHash 0-12 +// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7); +// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7); +// Log.d(MODULE_NAME, "currentGeoHash=" + currentGeoHash); +// Log.d(MODULE_NAME, "endGeoHash=" + endGeoHash); + + float calculateDistance = CoordinateUtils.calculateLineDistance( + endLatLng.latitude, endLatLng.longitude, + currentLatLng.latitude, currentLatLng.longitude + ); + + Log.d(MODULE_NAME, "calculateDistance=" + calculateDistance); + if (calculateDistance <= 20) { + clearPolyline(); + } else { + drawablePolyline(mCoordinatesLatLngCurrent); + } } else { //设置希望展示的地图缩放级别 mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel)); @@ -277,28 +276,4 @@ public class SmallMapDirectionView } } - /** - * 修改角度 - * - * @param angle 角度 0 - 359 度旋转,相对于自身中心位置 - */ - public void changeAngle(int angle) { -// int tempAngle = 360 - angle; -// if (tempAngle > 180) { -// tempAngle = -(360 - tempAngle); -// } - - mRotateAnimation.setFromDegrees(lastAngle); - mRotateAnimation.setToDegrees(angle); - - //设置线性插值,可以解决旋转一圈后卡顿问题 - mRotateAnimation.setInterpolator(new LinearInterpolator()); - //设置旋转一圈时间 - mRotateAnimation.setDuration(300); - //控件动画结束时是否保持动画最后的状态 - mRotateAnimation.setFillAfter(true); - startAnimation(mRotateAnimation); - // 刷新最后一次角度 - lastAngle = angle; - } } diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapProvider.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapProvider.java index fafaf538e8..77255728a9 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapProvider.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapProvider.java @@ -9,6 +9,7 @@ import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.map.MogoLatLng; import com.mogo.module.common.MogoApisHandler; import com.mogo.service.MogoServicePaths; +import com.mogo.service.adas.IMogoAdasRouteCallBack; import com.mogo.service.smp.IMogoSmallMapProvider; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; @@ -21,7 +22,7 @@ import java.util.List; * @date 12/10/20 1:34 PM */ @Route(path = MogoServicePaths.PATH_SMALL_MAP) -public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener { +public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener, IMogoAdasRouteCallBack { private final String TAG = "SmallVisionProvider"; private Context mContext; @@ -36,6 +37,7 @@ public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChang mActivity = activity; mContainerId = containerId; SmpServiceManager.init(mActivity); + MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasAutopilotRouteCallBack(this); } @Override @@ -108,4 +110,13 @@ public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChang } } } + + @Override + public void routeResult(List routeList) { + if (routeList != null && routeList.size() > 0) { + drawablePolyline(routeList); + } else { + clearPolyline(); + } + } } diff --git a/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border_north.png b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border_north.png new file mode 100644 index 0000000000..1c4bf333ca Binary files /dev/null and b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border_north.png differ diff --git a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml index 02e8509713..8ad5786c81 100644 --- a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml +++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml @@ -8,10 +8,9 @@ + android:background="@drawable/module_small_map_view_border_north" /> 40px + 550px + 360px - 400px - 400px - - 370px - 370px - - 1620px - 780px - - 0px - 0px - 1920px - 1080px \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml index 62836ac9d0..3620ac47d1 100644 --- a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml @@ -1,18 +1,7 @@ 30px - - 288px - 288px - + 450px 260px - 260px - 1620px - 780px - - 0px - 0px - 1920px - 1080px \ No newline at end of file diff --git a/modules/mogo-module-v2x/build.gradle b/modules/mogo-module-v2x/build.gradle index a299f8db01..9e1de63cc6 100644 --- a/modules/mogo-module-v2x/build.gradle +++ b/modules/mogo-module-v2x/build.gradle @@ -44,7 +44,6 @@ dependencies { // implementation 'com.tencent.liteavsdk:LiteAVSDK_Smart:7.4.9211' implementation rootProject.ext.dependencies.livesdk - implementation 'ch.hsr:geohash:1.4.0' implementation rootProject.ext.dependencies.flexbox implementation rootProject.ext.dependencies.rxandroid implementation rootProject.ext.dependencies.androidxrecyclerview diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java index c1830441d9..396e8bef1d 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java @@ -496,7 +496,7 @@ public class TestOnLineCarUtils { try { InputStream inputStream = V2XUtils.getApp() .getResources() - .openRawResource(R.raw.test_coordinates2); + .openRawResource(R.raw.test_coordinates); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int len = -1; byte[] buffer = new byte[1024]; diff --git a/modules/mogo-module-v2x/src/main/res/raw/test_coordinates.json b/modules/mogo-module-v2x/src/main/res/raw/test_coordinates.json index 23201af00b..ddbe44c4da 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/test_coordinates.json +++ b/modules/mogo-module-v2x/src/main/res/raw/test_coordinates.json @@ -4,51 +4,91 @@ "lat": 39.976655 }, { - "lon": 116.41763, - "lat": 39.978033 + "lon": 116.417636, + "lat": 39.977925 }, { - "lon": 116.417593, - "lat": 39.978772 + "lon": 116.417577, + "lat": 39.97876 }, { - "lon": 116.417464, - "lat": 39.981346 - }, - { - "lon": 116.41741, - "lat": 39.982965 - }, - { - "lon": 116.417132, - "lat": 39.987076 - }, - { - "lon": 116.417217, - "lat": 39.988621 - }, - { - "lon": 116.417217, - "lat": 39.990791 - }, - { - "lon": 116.417325, - "lat": 39.997432 + "lon": 116.417545, + "lat": 39.979578 }, { "lon": 116.417475, - "lat": 39.998583 + "lat": 39.981111 }, { - "lon": 116.417818, - "lat": 40.001377 + "lon": 116.417443, + "lat": 39.981933 }, { - "lon": 116.417668, - "lat": 40.002939 + "lon": 116.4174, + "lat": 39.982718 }, { - "lon": 116.417475, - "lat": 40.003777 + "lon": 116.417341, + "lat": 39.98398 + }, + { + "lon": 116.417293, + "lat": 39.984999 + }, + { + "lon": 116.417266, + "lat": 39.98583 + }, + { + "lon": 116.417228, + "lat": 39.986697 + }, + { + "lon": 116.417169, + "lat": 39.987844 + }, + { + "lon": 116.417164, + "lat": 39.988312 + }, + { + "lon": 116.417164, + "lat": 39.988916 + }, + { + "lon": 116.417164, + "lat": 39.989956 + }, + { + "lon": 116.417185, + "lat": 39.990914 + }, + { + "lon": 116.417175, + "lat": 39.991654 + }, + { + "lon": 116.417148, + "lat": 39.992952 + }, + { + "lon": 116.417159, + "lat": 39.993783 + }, + { + "lon": 116.41718, + "lat": 39.994843 + }, + { + "lon": 116.417191, + "lat": 39.99557 + }, + { + "lon": 116.417234, + "lat": 39.996577 + }, + { + "lon": 116.417362, + "lat": 39.997641 } ] \ No newline at end of file