[Taxi-d 280 Taxi-p 130] bus 乘客屏增加小地图估计擦除功能
This commit is contained in:
@@ -13,4 +13,5 @@ import mogo.telematics.pad.MessagePad;
|
||||
public interface IBusPassengerAutopilotPlanningCallback {
|
||||
void routeResult(List<LatLng> models);
|
||||
void routePlanningToNextStationChanged(long meters, long timeInSecond);
|
||||
void setLineMarker(List<LatLng> models);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class BusPassengerConst {
|
||||
|
||||
// 轮询line
|
||||
const val LOOP_LINE_2S = 2 * 1000L
|
||||
const val LOOP_LINE_1S = 1 * 1000L
|
||||
const val LOOP_DELAY = 100L
|
||||
|
||||
// 无状态
|
||||
|
||||
@@ -349,13 +349,23 @@ public class BusPassengerModel {
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onAutopilotRotting = "
|
||||
+ GsonUtil.jsonFromObject(routeList));
|
||||
List<MessagePad.Location> mRoutePoints = routeList.getWayPointsList();
|
||||
if (null != routeList && mRoutePoints.size() > 0){
|
||||
updateRoutePoints(mRoutePoints);
|
||||
List<MessagePad.Location> routePoints = routeList.getWayPointsList();
|
||||
if (null != routePoints && routePoints.size() > 0){
|
||||
updateRoutePoints(routePoints);
|
||||
startRemainRouteInfo();
|
||||
setRouteLineMarker();
|
||||
startToRouteAndWipe();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void updateRoutePoints(List<MessagePad.Location> routePoints){
|
||||
mRoutePoints.clear();
|
||||
List<LatLng> latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjListCommon(mContext,routePoints);
|
||||
mRoutePoints.addAll(latLngModels);
|
||||
}
|
||||
|
||||
public void dynamicCalculateRouteInfo() {
|
||||
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
|
||||
@@ -376,20 +386,46 @@ public class BusPassengerModel {
|
||||
|
||||
}
|
||||
|
||||
public void updateRoutePoints(List<MessagePad.Location> routePoints) {
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routeResult(
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext
|
||||
, routePoints));
|
||||
}
|
||||
|
||||
//转换成高德坐标系
|
||||
mRoutePoints.clear();
|
||||
mRoutePoints.addAll(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routePoints));
|
||||
public void startRemainRouteInfo() {
|
||||
//开启实时计算剩余距离,剩余时间,预计时间
|
||||
startOrStopCalculateRouteInfo(true);
|
||||
}
|
||||
|
||||
public void startToRouteAndWipe() {
|
||||
startOrStopRouteAndWipe(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时轨迹擦除
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopRouteAndWipe(boolean isStart){
|
||||
if (isStart){
|
||||
BusPassengerModelLoopManager.getInstance().startOrStopRouteAndWipe();
|
||||
}else {
|
||||
BusPassengerModelLoopManager.getInstance().stopOrStopRouteAndWipe();
|
||||
}
|
||||
}
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mRoutePoints != null && mRoutePoints.size() > 0){
|
||||
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routeResult(lastPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置小地图路径的起终点marker
|
||||
*/
|
||||
public void setRouteLineMarker(){
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.setLineMarker(mRoutePoints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始轮询计算剩余里程和时间
|
||||
* @param isStart
|
||||
|
||||
@@ -13,6 +13,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_DELAY;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_LINE_2S;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.LOOP_LINE_1S;
|
||||
|
||||
/**
|
||||
* Created on 2021/11/22
|
||||
@@ -34,6 +35,28 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
private Disposable mHeartbeatDisposable; //心跳轮询
|
||||
private Disposable mRouteWipeDisposable; //轨迹擦除
|
||||
|
||||
public void startOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null && !mRouteWipeDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startOrStopRouteWipe()");
|
||||
mRouteWipeDisposable = Observable.interval(LOOP_DELAY,
|
||||
LOOP_LINE_1S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> BusPassengerModel.getInstance().loopRouteAndWipe());
|
||||
}
|
||||
|
||||
public void stopOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopOrStopRouteWipe()");
|
||||
mRouteWipeDisposable.dispose();
|
||||
mRouteWipeDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void startQueryDriverLineLoop() {
|
||||
if (mHeartbeatDisposable != null && !mHeartbeatDisposable.isDisposed()) {
|
||||
|
||||
@@ -144,4 +144,9 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
public void routePlanningToNextStationChanged(long meters, long timeInSecond) {
|
||||
runOnUIThread(() -> mView.updateRoutePlanningToNextStation(meters, timeInSecond));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker(List<LatLng> models) {
|
||||
runOnUIThread(() -> mView.setLineMarker(models));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,23 +208,18 @@ public class BusPassengerMapDirectionView
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
clearPolyline();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
// 设置开始结束Marker位置
|
||||
|
||||
LatLng startLatLng = mCoordinatesLatLng.get(0);
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mStartMarker.setVisible(true);
|
||||
mEndMarker.setVisible(true);
|
||||
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
@@ -263,6 +258,27 @@ public class BusPassengerMapDirectionView
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
// 设置开始结束Marker位置
|
||||
|
||||
LatLng startLatLng = mCoordinatesLatLng.get(0);
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mStartMarker.setVisible(true);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCoordinatesLatLng(){
|
||||
mCoordinatesLatLng.clear();
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.elegant.utils.UiThreadHandler;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.adapter.BusPassengerLineStationsAdapter;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
|
||||
@@ -148,6 +148,22 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void setLineMarker(List<LatLng> latLngList){
|
||||
if (latLngList.size() > 0) {
|
||||
if (mMapDirectionView != null) {
|
||||
mMapDirectionView.setCoordinatesLatLng(latLngList);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.setLineMarker();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制
|
||||
*
|
||||
|
||||
@@ -15,4 +15,9 @@ public interface IBusPassengerMapDirectionView {
|
||||
* 清除路径线
|
||||
*/
|
||||
void clearPolyline();
|
||||
|
||||
/**
|
||||
* 设置路径中起终点marker
|
||||
*/
|
||||
void setLineMarker();
|
||||
}
|
||||
|
||||
@@ -25,182 +25,6 @@ public class BPRouteDataTestUtils {
|
||||
" ]\n" +
|
||||
"}";
|
||||
|
||||
//13号路口西-汇源果汁
|
||||
// static String jsonStr = "{\"models\":[{\n" +
|
||||
// "\t\t\"lat\": 40.19927810144466,\n" +
|
||||
// "\t\t\"lon\": 116.73527259387767\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19927836356079,\n" +
|
||||
// "\t\t\"lon\": 116.73513114732762\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19927759500293,\n" +
|
||||
// "\t\t\"lon\": 116.73497660879111\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.199264819842284,\n" +
|
||||
// "\t\t\"lon\": 116.73480063747202\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1992510141554,\n" +
|
||||
// "\t\t\"lon\": 116.73463922037767\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.199245872804,\n" +
|
||||
// "\t\t\"lon\": 116.73445960685193\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19924673374912,\n" +
|
||||
// "\t\t\"lon\": 116.73427704009703\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19924747108264,\n" +
|
||||
// "\t\t\"lon\": 116.7340707102972\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19924828745573,\n" +
|
||||
// "\t\t\"lon\": 116.73385916927226\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19924941093133,\n" +
|
||||
// "\t\t\"lon\": 116.73364048294795\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19924939253381,\n" +
|
||||
// "\t\t\"lon\": 116.73340837408566\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19924949105934,\n" +
|
||||
// "\t\t\"lon\": 116.73317368725336\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19925040039033,\n" +
|
||||
// "\t\t\"lon\": 116.73296532811216\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1992515355653,\n" +
|
||||
// "\t\t\"lon\": 116.73277787366743\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1992512720328,\n" +
|
||||
// "\t\t\"lon\": 116.73263377253741\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.199205174954606,\n" +
|
||||
// "\t\t\"lon\": 116.73249773114644\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1991015743076,\n" +
|
||||
// "\t\t\"lon\": 116.7324219601283\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.198971862686285,\n" +
|
||||
// "\t\t\"lon\": 116.73239393296355\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19883883071582,\n" +
|
||||
// "\t\t\"lon\": 116.73237676435652\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19870171355796,\n" +
|
||||
// "\t\t\"lon\": 116.73236052150362\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1985491853193,\n" +
|
||||
// "\t\t\"lon\": 116.73234157857011\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1983890047355,\n" +
|
||||
// "\t\t\"lon\": 116.73232167996464\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1982209877466,\n" +
|
||||
// "\t\t\"lon\": 116.73230101645792\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.198037574138326,\n" +
|
||||
// "\t\t\"lon\": 116.73227735486083\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19787327856243,\n" +
|
||||
// "\t\t\"lon\": 116.73225676816314\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19771917207499,\n" +
|
||||
// "\t\t\"lon\": 116.73223814728027\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.197548305175935,\n" +
|
||||
// "\t\t\"lon\": 116.73221624705808\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19739568979691,\n" +
|
||||
// "\t\t\"lon\": 116.73219618210774\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19724703821575,\n" +
|
||||
// "\t\t\"lon\": 116.73217598293311\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1970956560885,\n" +
|
||||
// "\t\t\"lon\": 116.73215773721505\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19697703483188,\n" +
|
||||
// "\t\t\"lon\": 116.73214337172284\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19687000725696,\n" +
|
||||
// "\t\t\"lon\": 116.73210037067965\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.196833449601726,\n" +
|
||||
// "\t\t\"lon\": 116.73196646708011\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19685833847804,\n" +
|
||||
// "\t\t\"lon\": 116.73181315361103\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.196889170203264,\n" +
|
||||
// "\t\t\"lon\": 116.73164355747393\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19692242860347,\n" +
|
||||
// "\t\t\"lon\": 116.7314555399657\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19696431701069,\n" +
|
||||
// "\t\t\"lon\": 116.7312261834129\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19700025925464,\n" +
|
||||
// "\t\t\"lon\": 116.73102774016093\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19703414798773,\n" +
|
||||
// "\t\t\"lon\": 116.73084270562073\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19707287604138,\n" +
|
||||
// "\t\t\"lon\": 116.73062835248406\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19710951629977,\n" +
|
||||
// "\t\t\"lon\": 116.73041744082339\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19714593807105,\n" +
|
||||
// "\t\t\"lon\": 116.73021414314803\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.197183297026285,\n" +
|
||||
// "\t\t\"lon\": 116.7300057066447\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.1972247359487,\n" +
|
||||
// "\t\t\"lon\": 116.7297751515664\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19726518822745,\n" +
|
||||
// "\t\t\"lon\": 116.72954958923812\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19730538240706,\n" +
|
||||
// "\t\t\"lon\": 116.72932440756041\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19734272112662,\n" +
|
||||
// "\t\t\"lon\": 116.72911631453036\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.197379191549075,\n" +
|
||||
// "\t\t\"lon\": 116.72890982812105\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.197417565369314,\n" +
|
||||
// "\t\t\"lon\": 116.72869447869044\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19746052080799,\n" +
|
||||
// "\t\t\"lon\": 116.72845641541247\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19750040582118,\n" +
|
||||
// "\t\t\"lon\": 116.72823569991117\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19753999704064,\n" +
|
||||
// "\t\t\"lon\": 116.72801998373052\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19757796882569,\n" +
|
||||
// "\t\t\"lon\": 116.72781280504363\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.197617062364586,\n" +
|
||||
// "\t\t\"lon\": 116.72759949431683\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19765391602761,\n" +
|
||||
// "\t\t\"lon\": 116.72739776789756\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19768973009218,\n" +
|
||||
// "\t\t\"lon\": 116.72719980764646\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.197726191028785,\n" +
|
||||
// "\t\t\"lon\": 116.72699719861669\n" +
|
||||
// "\t}, {\n" +
|
||||
// "\t\t\"lat\": 40.19776233489642,\n" +
|
||||
// "\t\t\"lon\": 116.72679516155276\n" +
|
||||
// "\t}]}\n";
|
||||
public static void converToRouteData(){
|
||||
List<MessagePad.Location> list = new ArrayList<>();
|
||||
|
||||
@@ -215,6 +39,9 @@ public class BPRouteDataTestUtils {
|
||||
list.add(builder.build());
|
||||
}
|
||||
BusPassengerModel.getInstance().updateRoutePoints(list);
|
||||
BusPassengerModel.getInstance().startRemainRouteInfo();
|
||||
BusPassengerModel.getInstance().setRouteLineMarker();
|
||||
BusPassengerModel.getInstance().startToRouteAndWipe();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TaxiPassengerModelLoopManager {
|
||||
|
||||
private Disposable mInAndWaitServiceDisposable; //进行中、待服务订单列表轮询
|
||||
private Disposable mQueryOrderRemainingDisposable; //心跳轮询
|
||||
private Disposable mRouteWipeDisposable; //心跳轮询
|
||||
private Disposable mRouteWipeDisposable; //轨迹擦除
|
||||
|
||||
public void startOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null && !mRouteWipeDisposable.isDisposed()) {
|
||||
|
||||
Reference in New Issue
Block a user