diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/WeltDataBean.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/WeltDataBean.kt new file mode 100644 index 0000000000..c0f6809f37 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/WeltDataBean.kt @@ -0,0 +1,10 @@ +package com.mogo.och.sweeper.bean + +data class WeltDataBean( + var locLon: Double,//经度 + var locLat: Double,//纬度 + var weltDistance: Double,//贴边距离 + var cleanMode: Int,//清扫模式 + var cleanDirection: Int,//清扫方向 + var cleanIntensity: Int,//作业强度 +) \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/CleaningModeStateCallback.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ICleaningModeStateCallback.java similarity index 87% rename from OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/CleaningModeStateCallback.java rename to OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ICleaningModeStateCallback.java index b1ec2c6867..df0ed8bc1d 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/CleaningModeStateCallback.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ICleaningModeStateCallback.java @@ -7,6 +7,6 @@ import chassis.ChassisStatesOuterClass; /** * 上装状态回调 */ -public interface CleaningModeStateCallback { +public interface ICleaningModeStateCallback { void cleaningModeState(OperateStateEnum cleaningModeState, ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState,boolean isSelectPureSweepMode); } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IWeltMapSwitchToSmallCallback.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IWeltMapSwitchToSmallCallback.kt new file mode 100644 index 0000000000..1b3e66bfe7 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IWeltMapSwitchToSmallCallback.kt @@ -0,0 +1,5 @@ +package com.mogo.och.sweeper.callback + +interface IWeltMapSwitchToSmallCallback { + fun onWeltMapSwitchToSmall() +} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java index a92ebe344d..1ca537c04e 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java @@ -24,10 +24,15 @@ import com.mogo.map.marker.IMogoMarkerManager; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.VisualAngleMode; import com.mogo.och.common.module.map.AmapNaviToDestinationModel; +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; import com.mogo.och.sweeper.R; -import com.mogo.och.sweeper.view.SweeperCurrentTaskInfoView; +import com.mogo.och.sweeper.bean.WeltDataBean; +import com.mogo.och.sweeper.callback.IWeltMapSwitchToSmallCallback; import com.mogo.och.sweeper.view.SweeperTrafficDataView; -import com.mogo.och.sweeper.view.SweeperWorkModeView; +import com.mogo.och.sweeper.view.WeltSmallMapView; + +import java.util.ArrayList; +import java.util.List; import androidx.annotation.NonNull; import androidx.constraintlayout.widget.Group; @@ -41,7 +46,7 @@ import androidx.fragment.app.FragmentTransaction; * @author tongchenfei */ public abstract class BaseSweeperTabFragment> extends MvpFragment implements IMogoMapListener, - View.OnClickListener { + View.OnClickListener, IWeltMapSwitchToSmallCallback { private static final String TAG = "BaseSweeperTabFragment"; //地图放大缩小 @@ -65,8 +70,15 @@ public abstract class BaseSweeperTabFragment weltDataBean = new ArrayList<>(); + weltDataBean.add(new WeltDataBean(116.38851540542558, 39.97419244219622, -10, 1, 1, 1)); + weltDataBean.add(new WeltDataBean(116.38777443467706, 39.96694323029558, 8, 1, 1, 1)); + weltDataBean.add(new WeltDataBean(116.39311478161825, 39.967085313029074, 16, 1, 1, 1)); + weltDataBean.add(new WeltDataBean(116.40963237692603, 39.975055860562826, 30, 1, 1, 1)); + weltDataBean.add(new WeltDataBean(116.41146331146084, 39.97513910337909, -9999.0, 1, 1, 1)); + weltDataBean.add(new WeltDataBean(116.40748849300006, 39.96752223478818, -10000.0, 1, 1, 1)); + weltDataBean.add(new WeltDataBean(116.42670283855335, 39.97526250389533, 1000, 1, 1, 1)); + mMapWeltView.setWeltData(weltDataBean); + mMapWeltView.drawablePolyline(); + } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt index 235f0074f5..06aa396ffa 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt @@ -4,7 +4,6 @@ import android.os.Bundle import android.view.View import androidx.recyclerview.widget.LinearLayoutManager import chassis.ChassisStatesOuterClass -import com.elegant.utils.UiThreadHandler import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.och.sweeper.R import com.mogo.och.sweeper.bean.SubInfo @@ -24,7 +23,7 @@ import kotlinx.android.synthetic.main.sweeper_no_data_common_view.* /** * 清扫车主界面 */ -class SweeperFragment : BaseSweeperTabFragment(), MenuPopWindow.OnMenuItemOnClickListener { +class SweeperFragment : BaseSweeperTabFragment(), MenuPopWindow.OnMenuItemOnClickListener{ private var mAdapter: TaskListAdapter? = null private var mCurrentSubPosition: Int = 0 //子任务下标 private var mMainMutableList: MutableList? = null diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/WeltMapOverViewFragment.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/WeltMapOverViewFragment.kt new file mode 100644 index 0000000000..1d78438404 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/WeltMapOverViewFragment.kt @@ -0,0 +1,94 @@ +package com.mogo.och.sweeper.fragment + +import android.os.Bundle +import com.mogo.commons.mvp.BaseFragment +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil +import com.mogo.och.sweeper.R +import com.mogo.och.sweeper.bean.WeltDataBean +import com.mogo.och.sweeper.callback.IWeltMapSwitchToSmallCallback +import kotlinx.android.synthetic.main.fragment_welt_map_overview.* +import kotlinx.android.synthetic.main.sweeper_welt_map_overview.* + +class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitchToSmallCallback?) : BaseFragment() { + override fun getLayoutId(): Int = R.layout.fragment_welt_map_overview + override fun getTagName(): String { + return "WeltMapOverViewFragment" + } + + override fun initViews() { + + } + + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + weltMapOverView.onCreateView(savedInstanceState) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setWeltData() + setLegendData() + sweeperSwitchToSmall.setOnClickListener { + mIWeltMapSwitchToSmallCallBack?.onWeltMapSwitchToSmall() + } + } + + companion object { + @JvmStatic + fun newInstance(mIWeltMapSwitchToSmallCallBack: IWeltMapSwitchToSmallCallback): WeltMapOverViewFragment { + val args = Bundle() + val fragment = WeltMapOverViewFragment(mIWeltMapSwitchToSmallCallBack) + fragment.arguments = args + return fragment + } + } + + override fun onPause() { + super.onPause() + weltMapOverView.onPause() + } + + override fun onResume() { + super.onResume() + weltMapOverView.onResume() + } + + override fun onDestroy() { + super.onDestroy() + weltMapOverView.onDestroy() + } + + /** + * mock 贴边假数据 + */ + private fun setWeltData() { + val weltDataBean: MutableList = ArrayList() + weltDataBean.add(WeltDataBean(116.38851540542558, 39.97419244219622, -10.0, 1, 1, 1)) + weltDataBean.add(WeltDataBean(116.38777443467706, 39.96694323029558, 8.0, 1, 1, 1)) + weltDataBean.add(WeltDataBean(116.39311478161825, 39.967085313029074, 16.0, 1, 1, 1)) + weltDataBean.add(WeltDataBean(116.40963237692603, 39.975055860562826, 30.0, 1, 1, 1)) + weltDataBean.add(WeltDataBean(116.41146331146084, 39.97513910337909, -9999.0, 1, 1, 1)) + weltDataBean.add(WeltDataBean(116.40748849300006, 39.96752223478818, -10000.0, 1, 1, 1)) + weltDataBean.add(WeltDataBean(116.42670283855335, 39.97526250389533, 1000.0, 1, 1, 1)) + weltMapOverView.setWeltData(weltDataBean) + weltMapOverView.drawablePolyline() + weltMapOverView.addStartAndEndMarker( + CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, 116.38851540542558, 39.97419244219622), + CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj( + context, 116.42670283855335, 39.97526250389533 + ) + ) + } + + /** + * 设置图例数据 + */ + private fun setLegendData() { + sweeperLegend1.setData(R.drawable.sweeper_legend1, "a<10") + sweeperLegend2.setData(R.drawable.sweeper_legend2, "0≤a<10") + sweeperLegend3.setData(R.drawable.sweeper_legend3, "10≤a<20") + sweeperLegend4.setData(R.drawable.sweeper_legend4, "a≥20") + sweeperLegend5.setData(R.drawable.sweeper_legend5, "非贴边") + sweeperLegend6.setData(R.drawable.sweeper_legend6, "未经过") + } +} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java index 844fe8733d..36508c47a5 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java @@ -292,6 +292,7 @@ public class SweeperPresenter extends Presenter @Override public void onSweeperFutianTaskIndexData(@NonNull RoboSweeperTaskIndexOuterClass.RoboSweeperTaskIndex roboSweeperTaskIndex) { + } /** diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java index e8620e25f9..934cc029de 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java @@ -30,10 +30,9 @@ import androidx.annotation.Nullable; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener; -import com.mogo.eagle.core.utilcode.util.ThreadUtils; import com.mogo.eagle.core.utilcode.util.ToastUtils; import com.mogo.och.sweeper.R; -import com.mogo.och.sweeper.callback.CleaningModeStateCallback; +import com.mogo.och.sweeper.callback.ICleaningModeStateCallback; import com.mogo.och.sweeper.constant.OperateStateEnum; import com.mogo.och.sweeper.util.SweeperFutianCmdUtil; import com.mogo.och.sweeper.view.NoTouchConstraintLayout; @@ -121,7 +120,7 @@ public class SweeperOperatePanelView extends LinearLayout { }; private boolean isSelectPureSweepMode = false;//用于标注是否选中纯扫 - private CleaningModeStateCallback cleaningModeStateCallback; + private ICleaningModeStateCallback cleaningModeStateCallback; private OperateStateEnum operateStateEnum = OperateStateEnum.SYNCING_STATUS; @@ -724,7 +723,7 @@ public class SweeperOperatePanelView extends LinearLayout { } public void setSweeperFutianCleanSystemState(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState, - CleaningModeStateCallback cleaningModeStateCallback) { + ICleaningModeStateCallback cleaningModeStateCallback) { this.cleaningModeStateCallback = cleaningModeStateCallback; // 有命令正在执行 if (mCurrentCmdRequestCallback != null) { diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt index 17f5fae813..1004555886 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import android.widget.PopupWindow import chassis.ChassisStatesOuterClass import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.callback.CleaningModeStateCallback +import com.mogo.och.sweeper.callback.ICleaningModeStateCallback import com.mogo.och.sweeper.constant.OperateStateEnum import com.mogo.och.sweeper.ui.SweeperOperatePanelView @@ -35,7 +35,7 @@ class SweeperOperatePanelPopWindow : PopupWindow{ */ fun setCleanSystemState( cleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates?, - cleaningModeStateCallback: CleaningModeStateCallback + cleaningModeStateCallback: ICleaningModeStateCallback ) { mOperatePanelView?.setSweeperFutianCleanSystemState(cleanSystemState, cleaningModeStateCallback) } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/LegendItemView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/LegendItemView.kt new file mode 100644 index 0000000000..9a6e360b14 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/LegendItemView.kt @@ -0,0 +1,32 @@ +package com.mogo.och.sweeper.view + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.mogo.och.sweeper.R +import kotlinx.android.synthetic.main.sweeper_item_legend.view.* + +/** + * 任务路线全览图图例 + */ +class LegendItemView:LinearLayout { + constructor(context: Context) : super(context) {} + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { + initView(context) + } + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {} + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {} + + private fun initView(context: Context) { + LayoutInflater.from(context).inflate(R.layout.sweeper_item_legend, this) + } + + /** + * 设置数据 + */ + fun setData(resId:Int,text:String){ + sweeperLegendIcon.setImageResource(resId) + sweeperLegendText.text = text + } +} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt index e1dfbf38c1..565ec75a99 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt @@ -10,7 +10,7 @@ import com.elegant.utils.UiThreadHandler import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.callback.CleaningModeStateCallback +import com.mogo.och.sweeper.callback.ICleaningModeStateCallback import com.mogo.och.sweeper.constant.OperateStateEnum import com.mogo.och.sweeper.constant.SubTaskTypeEnum import com.mogo.och.sweeper.ui.popwindow.SweeperOperatePanelPopWindow @@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.sweeper_work_mode.view.* /** * 清扫车模式信息展示 */ -class SweeperWorkModeView : ConstraintLayout, CleaningModeStateCallback { +class SweeperWorkModeView : ConstraintLayout, ICleaningModeStateCallback { private var isSelectPureSweepMode: Boolean = false private val TAG = "SweeperWorkModeView" diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt new file mode 100644 index 0000000000..749767df93 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt @@ -0,0 +1,212 @@ +package com.mogo.och.sweeper.view + +import android.content.Context +import android.graphics.Color +import android.os.Bundle +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.ImageView +import androidx.constraintlayout.widget.ConstraintLayout +import com.amap.api.maps.AMap +import com.amap.api.maps.CameraUpdateFactory +import com.amap.api.maps.model.* +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil +import com.mogo.och.sweeper.R +import com.mogo.och.sweeper.bean.WeltDataBean +import kotlinx.android.synthetic.main.sweeper_welt_map_overview.view.* + +/** + * 作业任务全览图 + */ +class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { + private var mWeltData: MutableList = mutableListOf() //任务数据集合 + private var mCoordinatesLatLng: MutableList = mutableListOf() //任务坐标点 + private var mCarMarker: Marker? = null + private var mAMap: AMap? = null + private var mPolyline: Polyline? = null + private var colorList: MutableList = mutableListOf() + private val mLineMarkers: MutableList = mutableListOf() + //清扫车任务地图 + private val TAG = "WeltMapOverView" + constructor(context: Context) : super(context) {} + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { + initView(context) + } + + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {} + + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {} + + private fun initView(context: Context) { + LayoutInflater.from(context).inflate(R.layout.sweeper_welt_map_overview, this) + initAMapView() + // 注册定位监听 + CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) + setLegendData() + } + private fun initAMapView() { + mAMap = sweeperTextureMapView.map + // 地图文字标注 + mAMap?.showMapText(true) + //显示3D建筑物 + mAMap?.showBuildings(true) + // 设置导航地图模式,aMap是地图控制器对象。 + mAMap?.mapType = AMap.MAP_TYPE_NIGHT + // 关闭显示实时路况图层,aMap是地图控制器对象。 + mAMap?.isTrafficEnabled = false + // 设置 锚点 图标 + mCarMarker = mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.sweeper_car_small)) + .anchor(0.5f, 0.5f) + ) + // 设置地图的样式 + val uiSettings = mAMap?.uiSettings + uiSettings?.isZoomControlsEnabled = false // 地图缩放级别的交换按钮 + uiSettings?.setAllGesturesEnabled(false) // 所有手势 + uiSettings?.isMyLocationButtonEnabled = false // 显示默认的定位按钮 + uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可 + mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener { + CallerLogger.d(SceneConstant.M_SWEEPER + TAG, "WeltView---onMapLoaded") + // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 + mAMap?.isTrafficEnabled = false + mAMap?.showBuildings(true) + }) + } + + /** + * 添加画线颜色值 + */ + private fun addRouteColorList() { + for (i in mWeltData.indices) { + if (mWeltData[i].weltDistance == -9999.0) {//未经过 + colorList.add(Color.parseColor("#3BA1CC")) + } else if (mWeltData[i].weltDistance == -10000.0) {//非贴边 + colorList.add(Color.parseColor("#236299")) + } else if (mWeltData[i].weltDistance < 0) { + colorList.add(Color.parseColor("#C22101")) + } else if (mWeltData[i].weltDistance >= 0 && mWeltData[i].weltDistance < 10) { + colorList.add(Color.parseColor("#4DFFA4")) + } else if (mWeltData[i].weltDistance >= 10 && mWeltData[i].weltDistance < 20) { + colorList.add(Color.parseColor("#FFDD4D")) + } else if (mWeltData[i].weltDistance >= 20) { + colorList.add(Color.parseColor("#FF912B")) + } + } + } + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + mogoLocation?.let { gnssInfo -> + val currentLatLng = LatLng(gnssInfo.latitude, gnssInfo.longitude) + //更新车辆位置 + mCarMarker?.rotateAngle = (360 - gnssInfo.heading).toFloat() + mCarMarker?.position = currentLatLng + mCarMarker?.setToTop() + //圈定地图显示范围 + val boundsBuilder = LatLngBounds.Builder() + if (mCoordinatesLatLng.size > 0) { + //存放经纬度 + for (i in mCoordinatesLatLng.indices) { + boundsBuilder.include(mCoordinatesLatLng[i]) + } + boundsBuilder.include(currentLatLng) + mAMap?.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)) + } + } + } + /** + * 根据贴边数据绘制任务路线 + */ + fun drawablePolyline() { + mPolyline?.remove() + if (mAMap != null) { + addRouteColorList() + if (mWeltData.size >= 2 && mCoordinatesLatLng.size > 2) { + //设置线段纹理 + val polylineOptions = PolylineOptions() + polylineOptions.addAll(mCoordinatesLatLng) + polylineOptions.width(14f) //线段宽度 + polylineOptions.isUseTexture = false + polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapSquare) + polylineOptions.colorValues(colorList) + // 绘制线 + mPolyline = mAMap?.addPolyline(polylineOptions) + } + } + } + + /** + * 添加起点和终点的marker + */ + fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) { + val startMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.start_maker_icon))) + startMarker?.position = startPoint + mLineMarkers.add(startMarker) + val endMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.end_maker_icon))) + endMarker?.position = endPoint + mLineMarkers.add(endMarker) + } + + /** + * 清除maker + */ + private fun clearMarkers() { + for (i in mLineMarkers.indices) { + mLineMarkers[i]?.isVisible = false + mLineMarkers[i]?.remove() + } + mLineMarkers.clear() + } + + /** + * 清除任务路线 + */ + fun clearPolyline() { + mPolyline?.remove() + } + + /** + * 设置贴边数据 + */ + fun setWeltData(weltData: MutableList) { + this.mWeltData = weltData + for (i in mWeltData.indices) { + mCoordinatesLatLng.add(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, mWeltData[i].locLon, mWeltData[i].locLat)) + } + } + /** + * 设置图例数据 + */ + private fun setLegendData() { + sweeperLegend1.setData(R.drawable.sweeper_legend1, "a<10") + sweeperLegend2.setData(R.drawable.sweeper_legend2, "0≤a<10") + sweeperLegend3.setData(R.drawable.sweeper_legend3, "10≤a<20") + sweeperLegend4.setData(R.drawable.sweeper_legend4, "a≥20") + sweeperLegend5.setData(R.drawable.sweeper_legend5, "非贴边") + sweeperLegend6.setData(R.drawable.sweeper_legend6, "未经过") + } + + fun onCreateView(savedInstanceState: Bundle?) { + sweeperTextureMapView.onCreate(savedInstanceState) + } + + fun onResume() { + sweeperTextureMapView.onResume() + } + + fun onPause() { + sweeperTextureMapView.onPause() + } + + fun onDestroy() { + sweeperTextureMapView.onDestroy() + } + + fun getSweeperSwitchToSmall(): ImageView { + return sweeperSwitchToSmall + } +} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt new file mode 100644 index 0000000000..0f0829095e --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt @@ -0,0 +1,208 @@ +package com.mogo.och.sweeper.view + +import android.content.Context +import android.graphics.Color +import android.os.Bundle +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.amap.api.maps.AMap +import com.amap.api.maps.CameraUpdateFactory +import com.amap.api.maps.model.* +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil +import com.mogo.och.sweeper.R +import com.mogo.och.sweeper.bean.WeltDataBean +import kotlinx.android.synthetic.main.sweeper_welt_small_map_view.view.* + +/** + * 作业任务小地图 + */ +class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { + private var mWeltData: MutableList = mutableListOf() //任务数据集合 + private var mCoordinatesLatLng: MutableList = mutableListOf() //任务坐标点 + private var mCarMarker: Marker? = null + private var mAMap: AMap? = null + private var mPolyline: Polyline? = null + private var colorList: MutableList = mutableListOf() + private val mLineMarkers: MutableList = mutableListOf() + + //清扫车任务地图 + private val TAG = "WeltMapView" + + constructor(context: Context) : super(context) {} + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { + initView(context) + } + + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {} + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {} + + private fun initView(context: Context) { + LayoutInflater.from(context).inflate(R.layout.sweeper_welt_small_map_view, this) + initAMapView() + // 注册定位监听 + CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) + } + + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + mogoLocation?.let { + val currentLatLng = LatLng(it.latitude, it.longitude) + drawCarMarker(mogoLocation) + //圈定地图显示范围 + val boundsBuilder = LatLngBounds.Builder() + if (mCoordinatesLatLng.size > 0) { + //存放经纬度 + for (i in mCoordinatesLatLng.indices) { + boundsBuilder.include(mCoordinatesLatLng[i]) + } + } + boundsBuilder.include(currentLatLng) + mAMap!!.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)) + } + } + + /** + * 绘制自车 + * + * @param location + */ + private fun drawCarMarker(location: MogoLocation?) { + if (location == null) return + val currentLatLng = LatLng(location.latitude, location.longitude) + //更新车辆位置 + if (mCarMarker != null) { + mCarMarker!!.rotateAngle = (360 - location.heading).toFloat() + mCarMarker!!.position = currentLatLng + mCarMarker!!.setToTop() + } + } + + private fun initAMapView() { + mAMap = sweeperSmallTextureMapView?.map + // 地图文字标注 + mAMap?.showMapText(true) + // 设置导航地图模式,aMap是地图控制器对象。 + mAMap?.mapType = AMap.MAP_TYPE_NIGHT + // 关闭显示实时路况图层,aMap是地图控制器对象。 + mAMap?.isTrafficEnabled = false + // 设置 锚点 图标 + mCarMarker = mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.sweeper_car_small)) + .anchor(0.5f, 0.5f) + ) + // 设置地图的样式 + val uiSettings = mAMap?.uiSettings + uiSettings?.isZoomControlsEnabled = false // 地图缩放级别的交换按钮 + uiSettings?.setAllGesturesEnabled(false) // 所有手势 + uiSettings?.isMyLocationButtonEnabled = false // 显示默认的定位按钮 + uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可 + mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener { + d(SceneConstant.M_SWEEPER + TAG, "WeltView---onMapLoaded") + //mAMap?.setPointToCenter(mAMapNaviView?.width?.div(2) ?: 0, mAMapNaviView?.height?.div(2) ?: 0) + }) + } + + /** + * 添加画线颜色值 + */ + private fun addRouteColorList() { + for (i in mWeltData.indices) { + if (mWeltData[i].weltDistance == -9999.0) {//未经过 + colorList.add(Color.parseColor("#3BA1CC")) + } else if (mWeltData[i].weltDistance == -10000.0) {//非贴边 + colorList.add(Color.parseColor("#236299")) + } else if (mWeltData[i].weltDistance < 0) { + colorList.add(Color.parseColor("#C22101")) + } else if (mWeltData[i].weltDistance >= 0 && mWeltData[i].weltDistance < 10) { + colorList.add(Color.parseColor("#4DFFA4")) + } else if (mWeltData[i].weltDistance >= 10 && mWeltData[i].weltDistance < 20) { + colorList.add(Color.parseColor("#FFDD4D")) + } else if (mWeltData[i].weltDistance >= 20) { + colorList.add(Color.parseColor("#FF912B")) + } + } + } + + /** + * 根据贴边数据绘制任务路线 + */ + fun drawablePolyline() { + mPolyline?.remove() + if (mAMap != null) { + addRouteColorList() + if (mWeltData.size >= 2 && mCoordinatesLatLng.size > 2) { + val polylineOptions = PolylineOptions() + polylineOptions.addAll(mCoordinatesLatLng) + polylineOptions.width(14f) //线段宽度 + polylineOptions.isUseTexture = false + polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapSquare) + polylineOptions.colorValues(colorList) + // 绘制线 + mPolyline = mAMap?.addPolyline(polylineOptions) + addStartAndEndMarker(mCoordinatesLatLng[0], mCoordinatesLatLng[mCoordinatesLatLng.size - 1]) + } + } + } + + /** + * 添加起点和终点的marker + */ + private fun addStartAndEndMarker(startPoint: LatLng, endPoint: LatLng) { + val startMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.start_maker_icon))) + startMarker?.position = startPoint + mLineMarkers.add(startMarker) + val endMarker = mAMap?.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.end_maker_icon))) + endMarker?.position = endPoint + mLineMarkers.add(endMarker) + } + + /** + * 清除数据 + */ + private fun clearMarkers() { + for (i in mLineMarkers.indices) { + mLineMarkers[i]?.isVisible = false + mLineMarkers[i]?.remove() + } + mLineMarkers.clear() + } + + /** + * 清除任务路线 + */ + fun clearPolyline() { + mPolyline?.remove() + } + + /** + * 设置贴边数据 + */ + fun setWeltData(weltData: MutableList) { + this.mWeltData = weltData + for (i in mWeltData.indices) { + mCoordinatesLatLng.add(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, mWeltData[i].locLon, mWeltData[i].locLat)) + } + } + + fun onCreateView(savedInstanceState: Bundle?) { + sweeperSmallTextureMapView?.onCreate(savedInstanceState) + } + + fun onResume() { + sweeperSmallTextureMapView?.onResume() + } + + fun onPause() { + sweeperSmallTextureMapView?.onPause() + } + + fun onDestroy() { + sweeperSmallTextureMapView?.onDestroy() + } +} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/end_maker_icon.png b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/end_maker_icon.png new file mode 100644 index 0000000000..438ee2136a Binary files /dev/null and b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/end_maker_icon.png differ diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/start_maker_icon.png b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/start_maker_icon.png index 9eca61e199..ba3747994c 100644 Binary files a/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/start_maker_icon.png and b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/start_maker_icon.png differ diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_car_small.png b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_car_small.png new file mode 100644 index 0000000000..c3762f55bb Binary files /dev/null and b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_car_small.png differ diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_full_screen_icon.png b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_full_screen_icon.png new file mode 100644 index 0000000000..f39894922d Binary files /dev/null and b/OCH/mogo-och-sweeper/src/main/res/drawable-xhdpi/sweeper_full_screen_icon.png differ diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend1.xml b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend1.xml new file mode 100644 index 0000000000..3698943bc9 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend1.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend2.xml b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend2.xml new file mode 100644 index 0000000000..d521b0a45d --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend3.xml b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend3.xml new file mode 100644 index 0000000000..59edb172fa --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend3.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend4.xml b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend4.xml new file mode 100644 index 0000000000..2a4efb7072 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend4.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend5.xml b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend5.xml new file mode 100644 index 0000000000..c3ac48e545 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend5.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend6.xml b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend6.xml new file mode 100644 index 0000000000..a8b8ac1b06 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/drawable/sweeper_legend6.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/layout/fragment_welt_map_overview.xml b/OCH/mogo-och-sweeper/src/main/res/layout/fragment_welt_map_overview.xml new file mode 100644 index 0000000000..e5655ea229 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/res/layout/fragment_welt_map_overview.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml b/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml index 9fd699603b..17bf4d63a9 100644 --- a/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml +++ b/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml @@ -2,15 +2,15 @@ + android:layout_marginTop="@dimen/dp_72"> + android:layout_height="match_parent" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_goneMarginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call" /> + + + + + + + android:background="@drawable/sweeper_setting_btn_bg" /> + android:layout_marginBottom="@dimen/module_mogo_och_margin_bottom" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintRight_toRightOf="parent" /> + + android:layout_marginTop="@dimen/dp_26" + android:src="@drawable/sweeper_close_navi_icon" + android:visibility="gone" + app:layout_constraintStart_toStartOf="@+id/module_mogo_och_navi_panel_container" + app:layout_constraintTop_toTopOf="@+id/module_mogo_och_navi_panel_container" /> + + +