1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package safeluck.drive.evaluation.routecollect;
 
import android.util.Log;
 
import com.anyun.exam.lib.AYSdk;
 
import safeluck.drive.evaluation.fragment.TrainFragment;
import safeluck.drive.evaluation.routecollect.bean.RoadCrossInfo;
import safeluck.drive.evaluation.routecollect.bean.RoadInfo;
import safeluck.drive.evaluation.routecollect.impl.RouteModel;
 
/**
 * DriveJudge
 * Created by lzw on 2020/9/16. 10:08:18
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class RouteCollectController implements ILoadListener {
 
    ICollectView iCollectView;
    RouteModel routeModel;
 
    private static final String TAG = "RouteModel";
    private boolean isStartRoadListener = false;
 
    private RouteCollectController() {
        routeModel = new RouteModel();
    }
public static RouteCollectController getInstance(){
        return new RouteCollectController();
}
    /**
     *  Topic=[bind_rtk_info_map],message={"utc":"20200917081227.40","qf":3,"coord_x":0.974,"coord_x_dir":"N","coord_y":-0.191,"coord_y_dir":"E","heading":315.0,"pitch":0.0,"roll":0.0,"sat_num":14,"latitude":31.174458016666667,"longitude":121.38786518333333,"altitude":58.9666,"speed":1.72591488,"track_ture":315.0}
     * @param collectView
     */
    public  void setRouteCollectController(ICollectView collectView){
        this.iCollectView = collectView;
 
        routeModel.setLoadListener(this);
    }
 
 
    public void startCollect() {
        if (iCollectView != null){
            iCollectView.beginCollectView();
        }
        if (routeModel != null){
            routeModel.startCollect();
        }
    }
 
    public void endCollect(){
        if (routeModel != null){
            routeModel.endCollect();
        }
    }
 
    @Override
    public void finishCollectItem(CollectPointResult collectPointResult) {
        if (iCollectView != null){
            iCollectView.endCollectView();
            iCollectView.routeItem(collectPointResult);
        }
    }
 
    @Override
    public void roadInfo(RoadInfo roadInfo) {
        if (iCollectView != null){
            iCollectView.roadinfo(roadInfo);
        }
    }
 
 
 
    @Override
    public void roadCrossInfo(RoadCrossInfo roadCrossInfo) {
        if (iCollectView != null){
            iCollectView.roadcrossInfo(roadCrossInfo);
        }
    }
 
    public void startRoadListener() {
        if (!isStartRoadListener){
            isStartRoadListener = true;
            if (routeModel != null){
                routeModel.startRoadListener();
            }
        }else{
            Log.i(TAG,"已经监听过了,不再监听");
        }
 
    }
 
    public void endRoadListener(){
        if (routeModel != null){
            routeModel.endRoadListener();
        }
    }
}