package safeluck.drive.evaluation.routecollect.impl; import android.util.Log; import com.anyun.exam.lib.IRemoteInterface; import org.json.JSONException; import org.json.JSONObject; import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.routecollect.CollectPointResult; import safeluck.drive.evaluation.routecollect.ILoadListener; import safeluck.drive.evaluation.routecollect.IRouteCollectInterface; import safeluck.drive.evaluation.util.Utils; /** * DriveJudge * Created by lzw on 2020/9/16. 10:38:39 * 邮箱:632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class RouteModel implements IRouteCollectInterface{ ILoadListener iLoadListener; private static final String TAG = "RouteModel"; private ICEventListener icEventListener= new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { //,"coord_x":0.974,"coord_x_dir":"N","coord_y":-0.191,"c if (msgCode==Constant.RTK_INFO){ if (iLoadListener != null){ CollectPointResult collectPointResult = new CollectPointResult(); try { JSONObject jsonObject = new JSONObject((String)obj); double x = jsonObject.getDouble("coord_x"); double y = jsonObject.getDouble("coord_y"); Log.i(TAG,String.format("采集到的点【x=%f,y=%f]",x,y)); collectPointResult.setX(Utils.getdouble(x,4)); collectPointResult.setY(Utils.getdouble(y,4)); iLoadListener.finishCollectItem(collectPointResult); } catch (JSONException e) { e.printStackTrace(); } } } if (msgCode == Constant.ENTER_OR_EXIT_ROAD_ID){ Log.i(TAG,"道路消息"+(String)obj); } if (msgCode == Constant.ENTER_OR_EXIT_ROADCROSS_ID){ Log.i(TAG,"路口消息"+(String)obj); } } }; @Override public void startCollect(ILoadListener listener) { iLoadListener = listener; //调用AYSdk 方法启动采点 //set IRouteRemotePointCallback //如果采用application的callback ,可能需要注册一个CEventLisntener CEventCenter.onBindEvent(true,icEventListener, Constant.BIND_RTK_INFO_MAP); } /** * 停止采点 */ @Override public void endCollect() { //如果采用application的callback ,可能需要反注册一个CEventLisntener 解绑 CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_RTK_INFO_MAP); iLoadListener = null; } }