From 91bb7b8a153546114e67847fd77423b1a63f1669 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期一, 22 二月 2021 13:33:28 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge --- app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt | 8 app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentMMPK.java | 601 +++++++++++++++ app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java | 595 ++++++++++++++ app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentVTPK.java | 590 ++++++++++++++ app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpGisCarRespBean.java | 538 +++++++++++++ app/src/main/res/layout/layout_arc_gis.xml | 50 app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpCarRespBean.java | 4 7 files changed, 2,354 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java index 4fda76a..feabb12 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java @@ -1,7 +1,12 @@ package safeluck.drive.evaluation.fragment; import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PointF; import android.os.Bundle; import android.os.Environment; @@ -11,6 +16,8 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; +import android.view.SurfaceHolder; +import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; @@ -26,21 +33,32 @@ import com.esri.arcgisruntime.geometry.SpatialReference; import com.esri.arcgisruntime.layers.ArcGISMapImageLayer; import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.loadable.LoadStatus; import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.MobileMapPackage; import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; import com.esri.arcgisruntime.mapping.view.Graphic; import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.MapScaleChangedEvent; +import com.esri.arcgisruntime.mapping.view.MapScaleChangedListener; import com.esri.arcgisruntime.mapping.view.MapView; import com.esri.arcgisruntime.symbology.SimpleFillSymbol; import com.esri.arcgisruntime.symbology.SimpleLineSymbol; import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol; import com.google.gson.Gson; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.File; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.Constant; @@ -51,6 +69,7 @@ import safeluck.drive.evaluation.bean.GisCarModel; import safeluck.drive.evaluation.bean.MapInfoHead; import safeluck.drive.evaluation.bean.RTKInfoBean; +import safeluck.drive.evaluation.bean.RealTimeCarPos; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.util.CThreadPoolExecutor; @@ -69,6 +88,7 @@ private static final int ENTER = 1;//杩涘叆 绉戜簩鏌愪釜椤圭洰鍦板浘 private LinkedBlockingQueue queue = new LinkedBlockingQueue(100); + private LinkedBlockingQueue queue1 = new LinkedBlockingQueue(100); private ExecutorService consumer = Executors.newSingleThreadExecutor(); private ExecutorService producer = Executors.newSingleThreadExecutor(); SimpleLineSymbol lineSymbolGls = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLACK, 0.5f); @@ -102,18 +122,25 @@ ExamStatus examStatus = (ExamStatus)obj; if (examStatus.getMap_id()>-1){ if (examStatus.getEnter()==ENTER){ - MyLog.i(TAG,String.format("杩涘叆[%d] map",examStatus.getMap_id())); double scale = mMapView.getMapScale(); - mMapView.setViewpointScaleAsync(scale * 0.2*0.2); + MyLog.i(TAG,String.format("杩涘叆[%d] map,scale=%f",examStatus.getMap_id(),scale)); + mMapView.setViewpointScaleAsync(scale * 0.2); + + + }else{ - MyLog.i(TAG,String.format("閫�鍑篬%d] map",examStatus.getMap_id())); double scale = mMapView.getMapScale(); - mMapView.setViewpointScaleAsync(scale * 5*5); + MyLog.i(TAG,String.format("閫�鍑篬%d] map,scale=%f",examStatus.getMap_id(),scale)); + + mMapView.setViewpointScaleAsync(scale * 5); + } } } } }; + private SurfaceView mSurfaceView; + private SurfaceHolder holder; public static SupportFragment newInstance(String s){ ArcGisMapFragment jiaXiaoFragment = new ArcGisMapFragment(); @@ -140,13 +167,19 @@ List<safeluck.drive.evaluation.bean.Point> newCarPoints = (List<safeluck.drive.evaluation.bean.Point>) msg.obj; Log.i(TAG,"handle message newcarPoints.size="+newCarPoints.size()); drawGlses(newCarPoints,gisCarModel); - + drawRightPart(); break; } } }; PointCollection mPointCollection = new PointCollection(SpatialReference.create(4544)); + private Bitmap bmp2 = null; + private Paint paint = new Paint(); + + private Canvas canvas3 = null; + private int screen_width = 0, screen_height = 0,display_width=0; + private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -154,7 +187,67 @@ View view = inflater.inflate(R.layout.layout_arc_gis,container,false); mMapView = view.findViewById(R.id.mapView); + mMapView.addMapScaleChangedListener(new MapScaleChangedListener() { + @Override + public void mapScaleChanged(MapScaleChangedEvent mapScaleChangedEvent) { + Log.i(TAG,"mapscaleChangelistenre"); + } + }); view.findViewById(R.id.btn_change_map).setOnClickListener(this); + mSurfaceView = view.findViewById(R.id.surfaceview_arcgis); + + holder = mSurfaceView.getHolder(); + display_width = getResources().getDisplayMetrics().widthPixels; + holder.addCallback(new SurfaceHolder.Callback() { + @Override + public void surfaceCreated(SurfaceHolder surfaceHolder) { + Canvas canvas = surfaceHolder.lockCanvas(); + + if (canvas != null) { +// Log.d(TAG, "W = " + canvas.getWidth() + " H = " + canvas.getHeight()); + screen_width = canvas.getWidth(); + screen_height = canvas.getHeight(); + Log.d(TAG, "W = " + screen_width+ " H = " + screen_height ); + surfaceHolder.unlockCanvasAndPost(canvas); + + bmp2 = Bitmap.createBitmap(screen_width, screen_height, Bitmap.Config.ARGB_8888); + canvas3 = new Canvas(bmp2); + canvas3.drawColor(Color.WHITE); + + Log.d(TAG, "displaywidth W = " + display_width + "BMP H = " + bmp2.getHeight()); + + + paint.setTextSize(30); + paint.setColor(Color.BLACK); + paint.setStrokeWidth(1.5f); + paint.setAntiAlias(true); + paint.setStyle(Paint.Style.STROKE); + + holder.lockCanvas(); + + + if (canvas != null){ + + + canvas.drawBitmap(bmp2,0, 0, paint); + holder.unlockCanvasAndPost(canvas); + } + } + } + + @Override + public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) { + + } + + @Override + public void surfaceDestroyed(SurfaceHolder surfaceHolder) { + + } + }); + + + Log.i(TAG,String.format("褰撳墠绾跨▼鍙�%d,json=%s",Thread.currentThread().getId(),"onCreateView")); url = getArguments().getString("arcgis_url"); CThreadPoolExecutor.runInBackground(()->{ @@ -164,11 +257,35 @@ }); consumer.execute(new CalRunnable()); + scheduledExecutorService.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { +// Log.i(TAG,"1s鍒�"); + if (lastcount==count){ +// Log.i(TAG,"宸茬粡娌″湪鍙戞秷鎭簡"); + leftDistance = 0.0; + rightDistance = 0.0; + } + lastcount = count; + } + },1000,1000, TimeUnit.MILLISECONDS); setupMap(); addTrailheadsLayer(); +// url = Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator+_mActivity.getPackageName()+"/shoufei0220.mmpk"; +// Log.i(TAG,"url ========="+url); +// final MobileMapPackage mobileMapPackage = new MobileMapPackage(url); +// mobileMapPackage.loadAsync(); +// mobileMapPackage.addDoneLoadingListener(()->{ +// LoadStatus loadStatus = mobileMapPackage.getLoadStatus(); +// if (loadStatus==LoadStatus.LOADED){ +// List<ArcGISMap> mainArcGisMapL = mobileMapPackage.getMaps(); +// ArcGISMap mainArcGismapMMPK = mainArcGisMapL.get(0); +// mMapView.setMap(mainArcGismapMMPK); +// } +// }); return view; } @@ -199,22 +316,126 @@ break; } } - + private String osdHeading = null; + private String osdRtkSpeed = null; + private List<Integer> body = new ArrayList<>(); + private List<Integer> tire = new ArrayList<>(); + int line = 0; + double car[][] = {{8.278, 1.467}, {7.2780000000000009, 1.467}, {7.2780000000000009, -1.533}, {8.278, -1.533} + , {9.278, -1.5330000000000004}, {9.277999999999999, 1.467000000000001}}; class CalRunnable implements Runnable{ - + private String json; + private int cmd; @Override public void run() { while (flag){ + MessageRemoteService messageRemoteService = (MessageRemoteService) queue1.peek(); + if (messageRemoteService == null){ + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + messageRemoteService = (MessageRemoteService) queue1.poll(); + if (messageRemoteService != null) { + this.cmd = messageRemoteService.msgCode; + this.json = messageRemoteService.json; + MyLog.i(TAG, json); + + RealTimeCarPos timeCarPos = gson.fromJson((String) json, RealTimeCarPos.class); + List<Double> points = timeCarPos.getPoint(); + switch (timeCarPos.getMove()) { + case 0: + osdMoveDirect = "鍋滆溅"; + break; + case 1: + osdMoveDirect = "鍓嶈繘"; + break; + case -1: + osdMoveDirect = "鍚庨��"; + break; + } + osdHeading = "鏂瑰悜瑙�" + String.valueOf(timeCarPos.getHeading()); + + BigDecimal bd = new BigDecimal(timeCarPos.getSpeed()); + bd = bd.setScale(3, BigDecimal.ROUND_HALF_UP); + osdRtkSpeed = "閫熷害:" + bd; + + + line = 0; + + + + + car = new double[points.size() / 2][2]; + + for (int i = 0; i < points.size(); i++) { + if ((i % 2) == 0) { + car[line][0] = points.get(i); + } else { + double value = points.get(i); + car[line][1] = value; + line++; + } + + } + + List<Double> mainAnt = timeCarPos.getMain_ant(); + List<Integer> tire1 = timeCarPos.getLeft_front_tire(); + List<Integer> tire2 = timeCarPos.getRight_front_tire(); + List<Integer> tire3 = timeCarPos.getLeft_rear_tire(); + List<Integer> tire4 = timeCarPos.getRight_rear_tire(); + + body = timeCarPos.getBody(); + + tire = new ArrayList<>(); + + double yaw = timeCarPos.getHeading(); + + tire.add(tire1.get(0)); + tire.add(tire2.get(0)); + tire.add(tire3.get(0)); + tire.add(tire4.get(0)); + + + } + + + + + + + + + + + +// rtkInfoBean = (RTKInfoBean)queue.peek(); +// if (rtkInfoBean ==null){ +// try { +// Thread.sleep(100); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } rtkInfoBean = (RTKInfoBean)queue.poll(); if (rtkInfoBean != null){ Log.i(TAG,String.format("鍙栧嚭涓�涓紝queue.size=%d,rtkinfo=%s,绾跨▼鍙�=%d",queue.size(),rtkInfoBean.toString(),Thread.currentThread().getId())); yaw = rtkInfoBean.getHeading(); startX = rtkInfoBean.getCoord_y(); startY = rtkInfoBean.getCoord_x(); + osdHeading="鏂瑰悜瑙�"+String.valueOf(rtkInfoBean.getHeading()); + + + + if (mMapView != null){ + mMapView.setViewpointRotationAsync(rtkInfoBean.getHeading()); + } addGraphicLayer(yaw,startX,startY); @@ -225,14 +446,277 @@ } } + float base_x = 300; + float base_y = 20; + long scale_x,scale_y; + double min_x=0.0,min_y = 0; + private String osdMoveDirect = null; + private void drawRightPart() { + paint.setStyle(Paint.Style.FILL_AND_STROKE); + + canvas3.drawColor(Color.YELLOW); + + + +if (gisCarModel != null){ + PointF mainPoint = new PointF(startX, startY); + + + + for (int i = 0; i < car.length; i++) { + PointF oldPoint = new PointF(car[i][0], car[i][1]); + PointF newPoint = rotatePoint(oldPoint, mainPoint, yaw ); + car[i][0] = newPoint.getX(); + car[i][1] = newPoint.getY(); + + car[i][0] = car[i][0] - mainPoint.getX(); + car[i][1] = car[i][1] - mainPoint.getY(); + car[i][1] = -car[i][1]; + } + +} + + + + // 鎸囧崡閽� ++++++++++++++++++++++++++++++++++++++++++++++++++++ + float compassOX = bmp2.getWidth() - 60, compassOY = 60; + Log.i(TAG,"draw widht="+(bmp2.getWidth() - 60)); + float compass1X = compassOX + 7, compass1Y = compassOY; + float compass2X = compassOX, compass2Y = compassOY + 30; + float compass3X = compassOX - 7, compass3Y = compassOY; + + float compass4X = compassOX + 7, compass4Y = compassOY; + float compass5X = compassOX, compass5Y = compassOY - 30; + float compass6X = compassOX - 7, compass6Y = compassOY; + + PointF compassO = new PointF(compassOX, compassOY); + PointF compass1 = new PointF(compass1X, compass1Y); + PointF compass2 = new PointF(compass2X, compass2Y); + PointF compass3 = new PointF(compass3X, compass3Y); + PointF compass4 = new PointF(compass4X, compass4Y); + PointF compass5 = new PointF(compass5X, compass5Y); + PointF compass6 = new PointF(compass6X, compass6Y); + + compass1 = rotatePoint(compass1, compassO, yaw); + compass2 = rotatePoint(compass2, compassO, yaw); + compass3 = rotatePoint(compass3, compassO, yaw); + compass4 = rotatePoint(compass4, compassO, yaw); + compass5 = rotatePoint(compass5, compassO, yaw); + compass6 = rotatePoint(compass6, compassO, yaw); + + paint.setStyle(Paint.Style.STROKE); + paint.setColor(Color.RED); + + canvas3.drawCircle((float)compassO.getX(), (float)compassO.getY(), 20, paint); + canvas3.drawCircle((float)compassO.getX(), (float)compassO.getY(), 40, paint); + + paint.setStyle(Paint.Style.FILL_AND_STROKE); + paint.setColor(Color.BLUE); + Path compassN = new Path(); + + compassN.moveTo((float)compassO.getX(), (float)compassO.getY()); + compassN.lineTo((float)compass1.getX(), (float)compass1.getY()); + compassN.lineTo((float)compass2.getX(), (float)compass2.getY()); + compassN.lineTo((float)compass3.getX(), (float)compass3.getY()); + compassN.close(); + canvas3.drawPath(compassN, paint); + + paint.setColor(Color.RED); + Path compassS = new Path(); + compassS.moveTo((float)compassO.getX(), (float)compassO.getY()); + compassS.lineTo((float)compass4.getX(), (float)compass4.getY()); + compassS.lineTo((float)compass5.getX(), (float)compass5.getY()); + compassS.lineTo((float)compass6.getX(), (float)compass6.getY()); + compassS.close(); + canvas3.drawPath(compassS, paint); + // 鎸囧崡閽� ------------------------------------------- + + + if (osdHeading != null) { + Path pathText = new Path(); + pathText.moveTo(10, 30); + pathText.lineTo(700, 30); + canvas3.drawTextOnPath(osdHeading, pathText, 0, 0, paint);//閫嗘椂閽堢敓鎴� + } + + + if (osdRtkSpeed != null) { + Path pathText = new Path(); + pathText.moveTo(10, 70); + pathText.lineTo(700, 70); + canvas3.drawTextOnPath(osdRtkSpeed, pathText, 0, 0, paint);//閫嗘椂閽堢敓鎴� + } + base_x = 170; + base_y = 350; + + scale_x=scale_y = 27; + + paint.setStyle(Paint.Style.FILL_AND_STROKE); + paint.setColor(Color.BLUE); +// canvas2.drawCircle((float) (base_x + (mainAnt.get(0) - min_x) * scale_x), (float) (base_y + (mainAnt.get(1) - min_y) * scale_y), 2, paint); + canvas3.drawCircle((float) base_x, (float) base_y, 2, paint); + + if (gisCarModel != null){ + paint.setColor(Color.RED); + Log.i(TAG,String.format("scalex=%d,scaley=%d,car[0][0]=%f,base_x=%f,base_y=%f",scale_x,scale_y,car[tire.get(0)][0],base_x,base_y)); + canvas3.drawCircle((float) (base_x + (car[tire.get(0)][0]) * scale_x), (float) (base_y + (car[tire.get(0)][1]) * scale_y), 2.5f, paint); + canvas3.drawCircle((float) (base_x + (car[tire.get(1)][0]) * scale_x), (float) (base_y + (car[tire.get(1)][1]) * scale_y), 2.5f, paint); + canvas3.drawCircle((float) (base_x + (car[tire.get(2)][0]) * scale_x), (float) (base_y + (car[tire.get(2)][1]) * scale_y), 2.5f, paint); + canvas3.drawCircle((float) (base_x + (car[tire.get(3)][0]) * scale_x), (float) (base_y + (car[tire.get(3)][1]) * scale_y), 2.5f, paint); + Path pathCanvs3 = new Path(); + pathCanvs3.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y)); + for (int i = 1; i < body.size(); i++){ +// Log.d(TAG, "for 寰幆 DrawMap to X = " + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); + Log.i(TAG,String.format("car[%d][0]=%f,to X =%f,car[%d][1]=%f,to Y=%f",i,car[body.get(i)][0], + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x),i,car[body.get(i)][1],(float) (base_y + (car[body.get(i)][1] - min_y) * scale_y))); + pathCanvs3.lineTo((float) (base_x + (car[body.get(i)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); + } + paint.setStyle(Paint.Style.STROKE); + paint.setColor(Color.BLACK); + pathCanvs3.close(); + canvas3.drawPath(pathCanvs3,paint); + } + + Paint mPaint = new Paint(); + mPaint.setTextSize(20); + mPaint.setStyle(Paint.Style.FILL_AND_STROKE); + osdMoveDirect="9.4345"; + if (osdMoveDirect != null) { + Path pathText = new Path(); + pathText.moveTo(base_x-110, base_y-35); + pathText.lineTo(base_x-20, base_y-35); + if (leftDistance == 0.0){ + + canvas3.drawTextOnPath("...", pathText, 0, 0, mPaint);//閫嗘椂閽堢敓鎴� + }else{ + + canvas3.drawTextOnPath(String.valueOf(leftDistance), pathText, 0, 0, mPaint);//閫嗘椂閽堢敓鎴� + } + } + if (osdMoveDirect != null) { + Path pathText = new Path(); + pathText.moveTo(base_x+30, base_y-35); + pathText.lineTo(base_x+110, base_y-35); + if (rightDistance == 0.0){ + + canvas3.drawTextOnPath("...", pathText, 0, 0, mPaint);//閫嗘椂閽堢敓鎴� + }else{ + canvas3.drawTextOnPath(String.valueOf(rightDistance), pathText, 0, 0, mPaint);//閫嗘椂閽堢敓鎴� + } + + } + paint.setColor(Color.RED); + canvas3.drawLine(base_x-120,base_y-200,base_x-120,base_y+200,paint); + canvas3.drawLine(base_x+120,base_y-200,base_x+120,base_y+200,paint); + + DrawArrows(canvas3,Color.GREEN,15f,base_x-20,base_y-30,base_x-120,base_y-30);//宸﹁竟绠ご锛堝乏杈硅窛 + DrawArrows(canvas3,Color.GREEN,15f,base_x+20,base_y-30,base_x+120,base_y-30);//鍙宠竟绠ご锛堣竟璺� + + + // 鎻愪氦鐢诲竷 + Canvas canvas = holder.lockCanvas(); + if (canvas != null){ + + + canvas.drawBitmap(bmp2,0, 0, paint); + holder.unlockCanvasAndPost(canvas); + } + } + void DrawArrows(Canvas canvas, int color, float arrowSize, float x1, + float y1, float x2, float y2) { + paint.setAntiAlias(true); + paint.setStyle(Paint.Style.STROKE); + paint.setColor(color); + + // 鐢荤洿绾� + canvas.drawLine(x1, y1, x2, y2, paint); + + // 绠ご涓殑绗竴鏉$嚎鐨勮捣鐐� + int x3 = 0; + int y3 = 0; + + // 绠ご涓殑绗簩鏉$嚎鐨勮捣鐐� + int x4 = 0; + int y4 = 0; + + double awrad = Math.atan(3.5 / 8); + double[] arrXY_1 = rotateVec(x2 - x1, y2 - y1, awrad, arrowSize); + double[] arrXY_2 = rotateVec(x2 - x1, y2 - y1, -awrad, arrowSize); + + // 绗竴绔偣 + Double X3 = Double.valueOf(x2 - arrXY_1[0]); + x3 = X3.intValue(); + Double Y3 = Double.valueOf(y2 - arrXY_1[1]); + y3 = Y3.intValue(); + + // 绗簩绔偣 + Double X4 = Double.valueOf(x2 - arrXY_2[0]); + x4 = X4.intValue(); + Double Y4 = Double.valueOf(y2 - arrXY_2[1]); + y4 = Y4.intValue(); + + Path arrowsPath = new Path(); + arrowsPath.moveTo(x2, y2); + arrowsPath.lineTo(x3, y3); + arrowsPath.lineTo(x4, y4); + arrowsPath.close(); + canvas.drawLine(x3, y3, x2, y2, paint); + canvas.drawLine(x4, y4, x2, y2, paint); + } + private double[] rotateVec(float px, float py, double ang, double arrowSize) { + double mathstr[] = new double[2]; + double vx = px * Math.cos(ang) - py * Math.sin(ang); + double vy = px * Math.sin(ang) + py * Math.cos(ang); + double d = Math.sqrt(vx * vx + vy * vy); + vx = vx / d * arrowSize; + vy = vy / d * arrowSize; + mathstr[0] = vx; + mathstr[1] = vy; + return mathstr; + } + + public PointF rotatePoint(PointF oldPoint, PointF centre, double degree) { + PointF newPoint = new PointF(0, 0); + + newPoint.setX( (oldPoint.getX()-centre.getX())*Math.cos(Math.toRadians(degree)) - (oldPoint.getY()-centre.getY())*Math.sin(Math.toRadians(degree)) + centre.getX() ); + newPoint.setY ( (oldPoint.getX()-centre.getX())*Math.sin(Math.toRadians(degree)) + (oldPoint.getY()-centre.getY())*Math.cos(Math.toRadians(degree)) + centre.getY() ); + + return newPoint; + } + + class PointF { + double x; + double y; + + public PointF(double x, double y) { + this.x = x; + this.y = y; + } + + double getX() { + return x; + } + + double getY() { + return y; + } + + void setX(double x) { + this.x = x; + } + + void setY(double y) { + this.y = y; + } + } private void setupMap() { if (mMapView != null) { @@ -249,7 +733,7 @@ // create an empty map instance ArcGISMap map = new ArcGISMap(); Log.i(TAG,String.format("map.getMiniScale=%f",map.getMinScale())); - map.setMinScale(1000.0); + map.setMinScale(400.0); // add map image layer as operational layer map.getOperationalLayers().add(mapImageLayer); mMapView.setMap(map); @@ -313,8 +797,9 @@ } private void readGisCar() { - String carFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+_mActivity.getPackageName()+"/lianfang_giscar.json"; + String carFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+_mActivity.getPackageName()+"/gisvehiclemodel.json"; if (TextUtils.isEmpty(carFilePath)){ + Toast.makeText(_mActivity, "杞﹁締妯″瀷鏂囦欢涓嶅瓨鍦�", Toast.LENGTH_SHORT).show(); MyLog.i (TAG, "GISCar杞﹁締妯″瀷鏂囦欢涓嶅瓨鍦�"); return ; } @@ -322,6 +807,42 @@ if (fileContentBytes !=null&&fileContentBytes.length>0){ String buffer= new String(fileContentBytes); gisCarModel = new Gson().fromJson(buffer, GisCarModel.class); + + + +// line = 0; +// +// +// List<Double> points = gisCarModel.getPoint(); +// +// car = new double[points.size() / 2][2]; +// +// for (int i = 0; i < points.size(); i++) { +// if ((i % 2) == 0) { +// car[line][0] = points.get(i); +// } else { +// double value = points.get(i); +// car[line][1] = value; +// line++; +// } +// +// } +// +// +// List<Integer> tire1 = gisCarModel.getLeft_front_tire(); +// List<Integer> tire2 = gisCarModel.getRight_front_tire(); +// List<Integer> tire3 = gisCarModel.getLeft_rear_tire(); +// List<Integer> tire4 = gisCarModel.getRight_rear_tire(); +// +// body = gisCarModel.getBody(); +// +// tire = new ArrayList<>(); +// +// +// tire.add(tire1.get(0)); +// tire.add(tire2.get(0)); +// tire.add(tire3.get(0)); +// tire.add(tire4.get(0)); }else{ return; } @@ -345,6 +866,7 @@ if(gisCarModel== null){ return; } + long beginTime = System.currentTimeMillis(); @@ -566,6 +1088,8 @@ queue.clear(); CEventCenter.onBindEvent(false,icEventListener, Constant.BIND_RTK_INFO_MAP); CEventCenter.onBindEvent(false,icEventListener1, Constant.BIND_EXAM_STATUS_TOPIC); + CEventCenter.onBindEvent(false, speedListener, Constant.BIND_RTK_SPEED_TOPIC); + CEventCenter.onBindEvent(false, icEventListenerCar, Constant.REAL_TIME_POS_CAR_TOPIC); } @@ -575,6 +1099,59 @@ super.onAttach(context); CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTK_INFO_MAP); CEventCenter.onBindEvent(true,icEventListener1,Constant.BIND_EXAM_STATUS_TOPIC); + CEventCenter.onBindEvent(true, speedListener, Constant.BIND_RTK_SPEED_TOPIC); + CEventCenter.onBindEvent(true, icEventListenerCar, Constant.REAL_TIME_POS_CAR_TOPIC); } + private long count =0; + private long lastcount =0; + private double gpsSpeed = 0; + private double leftDistance = 0; + private double rightDistance = 0; + private ICEventListener speedListener = new ICEventListener() { + @Override + public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { + if (msgCode == Constant.RTK_INFO){ + gpsSpeed = (double)obj; + } + if (msgCode == Constant.LEFT_RIGHT_DISTANCE){ + String str = (String)obj; + count++; + + try { + JSONObject jsonObject = new JSONObject(str); + leftDistance = Utils.getdouble(jsonObject.getDouble("left"),3); + rightDistance = Utils.getdouble(jsonObject.getDouble("right"),3); + + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + }; + class MessageRemoteService{ + public int msgCode; + public String json; + + public MessageRemoteService(int msgCode, Object obj) { + this.json = (String) obj; + this.msgCode = msgCode; + } + } + + private ICEventListener icEventListenerCar = new ICEventListener() { + @Override + public void onCEvent(String topic, final int msgCode, int resultCode, final Object obj) { + + + producer.execute(new Runnable() { + @Override + public void run() { + queue1.offer(new MessageRemoteService(msgCode,obj)); + } + }); + + + } + }; } diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentMMPK.java b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentMMPK.java new file mode 100644 index 0000000..29744f1 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentMMPK.java @@ -0,0 +1,601 @@ +package safeluck.drive.evaluation.fragment; + +import android.content.Context; +import android.graphics.Color; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.anyun.basecommonlib.MyLog; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.PointCollection; +import com.esri.arcgisruntime.geometry.Polygon; +import com.esri.arcgisruntime.geometry.Polyline; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISMapImageLayer; +import com.esri.arcgisruntime.layers.ArcGISVectorTiledLayer; +import com.esri.arcgisruntime.loadable.LoadStatus; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.MobileMapPackage; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.SimpleFillSymbol; +import com.esri.arcgisruntime.symbology.SimpleLineSymbol; +import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol; +import com.google.gson.Gson; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; + +import me.yokeyword.fragmentation.SupportFragment; +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.exam_status.ExamStatus; +import safeluck.drive.evaluation.R; +import safeluck.drive.evaluation.bean.ExamPlatformData; +import safeluck.drive.evaluation.bean.GisCarModel; +import safeluck.drive.evaluation.bean.RTKInfoBean; +import safeluck.drive.evaluation.cEventCenter.CEventCenter; +import safeluck.drive.evaluation.cEventCenter.ICEventListener; +import safeluck.drive.evaluation.util.CThreadPoolExecutor; +import safeluck.drive.evaluation.util.FileUtil; +import safeluck.drive.evaluation.util.Utils; + +/**椹炬牎淇℃伅UI + * MyApplication2 + * Created by lzw on 2019/3/20. 11:22:39 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class ArcGisMapFragmentMMPK extends SupportFragment implements View.OnClickListener { + + private static final String TAG = ArcGisMapFragmentMMPK.class.getSimpleName(); + private static final int ENTER = 1;//杩涘叆 绉戜簩鏌愪釜椤圭洰鍦板浘 + + private LinkedBlockingQueue queue = new LinkedBlockingQueue(100); + private ExecutorService consumer = Executors.newSingleThreadExecutor(); + private ExecutorService producer = Executors.newSingleThreadExecutor(); + SimpleLineSymbol lineSymbolGls = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLACK, 0.5f); + + + PointCollection points = new PointCollection(SpatialReference.create(4544)); + private Gson gson = new Gson(); + private ICEventListener icEventListener = new ICEventListener() { + @Override + public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { + + + + + producer.execute(()->{ + String json = (String)obj; + Log.i(TAG,String.format("褰撳墠绾跨▼鍙�%d,json=%s",Thread.currentThread().getId(),json)); + RTKInfoBean rtkInfoBean = gson.fromJson(json,RTKInfoBean.class); + queue.offer(rtkInfoBean); + }); + +// MyLog.i(TAG,"澶勭悊瀹�11.鏃堕棿="+Utils.formatTimeYYMMDDHHmmSSSSS(System.currentTimeMillis())); + + + } + }; + private ICEventListener icEventListener1 = new ICEventListener() { + @Override + public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { + if (msgCode==13){ + ExamStatus examStatus = (ExamStatus)obj; + if (examStatus.getMap_id()>-1){ + if (examStatus.getEnter()==ENTER){ + MyLog.i(TAG,String.format("杩涘叆[%d] map",examStatus.getMap_id())); + double scale = mMapView.getMapScale(); + mMapView.setViewpointScaleAsync(scale * 0.2*0.2); + }else{ + MyLog.i(TAG,String.format("閫�鍑篬%d] map",examStatus.getMap_id())); + double scale = mMapView.getMapScale(); + mMapView.setViewpointScaleAsync(scale * 5*5); + } + } + } + } + }; + + public static SupportFragment newInstance(String s){ + ArcGisMapFragmentMMPK jiaXiaoFragment = new ArcGisMapFragmentMMPK(); + Bundle bundle = new Bundle(); + bundle.putString("arcgis_url",s); + jiaXiaoFragment.setArguments(bundle); + return jiaXiaoFragment; + } + + + private MapView mMapView ; + private static final int MSG_CAR = 100; + double yaw = 0; + + GraphicsOverlay mGraphicsOverlay; + GraphicsOverlay mGraphicsOverlay_body; + private double startY = 428882,startX = 3291858; + private Handler mHandler = new Handler(){ + @Override + public void handleMessage(Message msg) { + switch (msg.what){ + case MSG_CAR: + + List<safeluck.drive.evaluation.bean.Point> newCarPoints = (List<safeluck.drive.evaluation.bean.Point>) msg.obj; + Log.i(TAG,"handle message newcarPoints.size="+newCarPoints.size()); + drawGlses(newCarPoints,gisCarModel); + + break; + } + } + }; + + PointCollection mPointCollection = new PointCollection(SpatialReference.create(4544)); + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + + + View view = inflater.inflate(R.layout.layout_arc_gis,container,false); + mMapView = view.findViewById(R.id.mapView); + view.findViewById(R.id.btn_change_map).setOnClickListener(this); + Log.i(TAG,String.format("褰撳墠绾跨▼鍙�%d,json=%s",Thread.currentThread().getId(),"onCreateView")); + url = getArguments().getString("arcgis_url"); + CThreadPoolExecutor.runInBackground(()->{ + + readGisCar(); + + + }); + consumer.execute(new CalRunnable()); + + setupMap(); + + +// addTrailheadsLayer(); + + + + url = Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator+_mActivity.getPackageName()+"/shoufei0220.mmpk"; + Log.i(TAG,"url ========="+url); + final MobileMapPackage mobileMapPackage = new MobileMapPackage(url); + mobileMapPackage.loadAsync(); + mobileMapPackage.addDoneLoadingListener(()->{ + LoadStatus loadStatus = mobileMapPackage.getLoadStatus(); + if (loadStatus==LoadStatus.LOADED){ + List<ArcGISMap> mainArcGisMapL = mobileMapPackage.getMaps(); + ArcGISMap mainArcGismapMMPK = mainArcGisMapL.get(0); + mMapView.setMap(mainArcGismapMMPK); + } + }); + + return view; + } + + + + RTKInfoBean rtkInfoBean; + boolean flag = true; + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.btn_change_map: + if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){ + RoadDriveMapFragmentab jiaXiaoFragment = findFragment(RoadDriveMapFragmentab.class); + if (jiaXiaoFragment == null) { + jiaXiaoFragment = (RoadDriveMapFragmentab) RoadDriveMapFragmentab.newInstance(); + } + startWithPop(jiaXiaoFragment); + }else{ + MapFragment jiaXiaoFragment = findFragment(MapFragment.class); + if (jiaXiaoFragment == null) { + jiaXiaoFragment = (MapFragment) MapFragment.newInstance(); + } + startWithPop(jiaXiaoFragment); + } + + + break; + } + } + + class CalRunnable implements Runnable{ + + @Override + public void run() { + while (flag){ + + + rtkInfoBean = (RTKInfoBean)queue.poll(); + if (rtkInfoBean != null){ + Log.i(TAG,String.format("鍙栧嚭涓�涓紝queue.size=%d,rtkinfo=%s,绾跨▼鍙�=%d",queue.size(),rtkInfoBean.toString(),Thread.currentThread().getId())); + yaw = rtkInfoBean.getHeading(); + startX = rtkInfoBean.getCoord_y(); + startY = rtkInfoBean.getCoord_x(); + + if (mMapView != null){ + mMapView.setViewpointRotationAsync(rtkInfoBean.getHeading()); + } + addGraphicLayer(yaw,startX,startY); + + + + } + + } + + } + } + + + + + + + + + private void setupMap() { + if (mMapView != null) { + + + mGraphicsOverlay = addGraphicsOverlay(mMapView); + + } + } +String url ; + private void addTrailheadsLayer() { + if (!TextUtils.isEmpty(url)){ + Log.i(TAG,"map_url="+url); + final ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(url); + // create an empty map instance + ArcGISMap map = new ArcGISMap(); + Log.i(TAG,String.format("map.getMiniScale=%f",map.getMinScale())); + map.setMinScale(1000.0); + // add map image layer as operational layer + map.getOperationalLayers().add(mapImageLayer); + mMapView.setMap(map); + }else{ + Toast.makeText(_mActivity, "url涓虹┖", Toast.LENGTH_SHORT).show(); + } + + + + } + + + + GisCarModel gisCarModel; + boolean once =true; + private void addGraphicLayer(double yaw,double x,double y){ + Log.i(TAG,"addgraphicLayer寮�濮�"); + long time = System.currentTimeMillis(); + + + + if (gisCarModel != null){ + + + long qudianTime = System.currentTimeMillis(); + List<safeluck.drive.evaluation.bean.Point> carNew =Utils.getCarPoint(0,yaw,new safeluck.drive.evaluation.bean.Point(x,y),gisCarModel); + Log.i(TAG,String.format("鍙栧埌鐐硅�楁椂=%d姣,绾跨▼鍙�=%d",System.currentTimeMillis()-qudianTime,Thread.currentThread().getId())); + if (carNew == null) return; + if (once){ + Message message = Message.obtain(); + message.what = MSG_CAR; + + message.obj = carNew; + mHandler.sendMessage(message); + + } + + + + + + + } + + + long period= System.currentTimeMillis()-time; + Log.i(TAG,"鎵цaddGraphicLayer鏂规硶锛岃�楁椂="+period); + + + + } + + private GraphicsOverlay addGraphicsOverlay(MapView mapView){ + //create the graphics overlay + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + mGraphicsOverlay_body = new GraphicsOverlay(); + //add the overlay to the map view + mapView.getGraphicsOverlays().add(mGraphicsOverlay_body); + mapView.getGraphicsOverlays().add(graphicsOverlay); + return graphicsOverlay; + } + private void readGisCar() { + + String carFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+_mActivity.getPackageName()+"/gisvehiclemodel.json"; + if (TextUtils.isEmpty(carFilePath)){ + MyLog.i (TAG, "GISCar杞﹁締妯″瀷鏂囦欢涓嶅瓨鍦�"); + Toast.makeText(_mActivity, "杞﹁締妯″瀷鏂囦欢涓嶅瓨鍦�", Toast.LENGTH_SHORT).show(); + return ; + } + byte[] fileContentBytes= FileUtil.readFile(carFilePath); + if (fileContentBytes !=null&&fileContentBytes.length>0){ + String buffer= new String(fileContentBytes); + gisCarModel = new Gson().fromJson(buffer, GisCarModel.class); + }else{ + return; + } + + + } + + + + PointCollection points1 = new PointCollection(SpatialReference.create(4544)); + PointCollection points2 = new PointCollection(SpatialReference.create(4544)); + PointCollection points3 = new PointCollection(SpatialReference.create(4544)); + PointCollection points4 = new PointCollection(SpatialReference.create(4544)); + SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.rgb(232,0,0), 0.5f); + SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,232,0,0), lineSymbol); + + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.WHITE, 5); + SimpleFillSymbol simpleFillSymbolGls = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,0,0,0), lineSymbolGls); + private void drawGlses(List<safeluck.drive.evaluation.bean.Point> carNew, GisCarModel gisCarModel) { + + if(gisCarModel== null){ + return; + } + long beginTime = System.currentTimeMillis(); + + +/**==============================car body=========================================*/ + + List<Integer> bodys =gisCarModel.getBody(); + points.clear(); + for (int i = 0; i <bodys.size(); i++) { + points.add(carNew.get(bodys.get(i)).getX(),carNew.get(bodys.get(i)).getY()); + } + + Polygon polygon = new Polygon(points); + + Graphic graphic = new Graphic(polygon,simpleFillSymbol); + + + + /**===============================car body end========================================*/ + + +/**==============================鐢诲ぉ绾�=========================================*/ + + +// Graphic graphicAnt = new Graphic(new Point(startX,startY), simpleMarkerSymbol); + + /**==============================鐢诲ぉ绾跨粨鏉� END=========================================*/ + + + + List<Integer> leftCenterGls = gisCarModel.getLeft_center_glass(); + points1.clear(); + for (int i = 0; i < leftCenterGls.size(); i++) { + int pos = leftCenterGls.get(i); + points1.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + List<Integer> rightCenterGls = gisCarModel.getRight_center_glass(); + points2.clear(); + for (int i = 0; i < rightCenterGls.size(); i++) { + int pos = rightCenterGls.get(i); + points2.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + + + List<Integer> frontCLs = new ArrayList<>(); + frontCLs.addAll(gisCarModel.getLeft_front_glass()); + frontCLs.addAll(gisCarModel.getRight_front_glass()); + + + points3.clear(); + for (int i = 0; i < frontCLs.size(); i++) { + int pos = frontCLs.get(i); + points3.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + frontCLs.clear(); + frontCLs.addAll(gisCarModel.getLeft_rear_glass()); + frontCLs.addAll(gisCarModel.getRight_rear_glass()); + points4.clear(); + for (int i = 0; i < frontCLs.size(); i++) { + int pos = frontCLs.get(i); + points4.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + Polygon polygon1 = new Polygon(points1); + Polygon polygon2 = new Polygon(points2); + Polygon polygon3 = new Polygon(points3); + Polygon polygon4 = new Polygon(points4); + + + //create graphics + + Graphic buoyGraphic1 = new Graphic(polygon1, simpleFillSymbolGls); + Graphic buoyGraphic2 = new Graphic(polygon2, simpleFillSymbolGls); + Graphic buoyGraphic3 = new Graphic(polygon3, simpleFillSymbolGls); + Graphic buoyGraphic4 = new Graphic(polygon4, simpleFillSymbolGls); + //add the graphics to the graphics overlay + /**==============================娓呴櫎GraphicsOverlay涓婃墍鏈塯raphic=========================================*/ + long clearTime = System.currentTimeMillis(); + + + mGraphicsOverlay.getGraphics().clear(); + Log.i(TAG,"clear鏂规硶鏃堕棿+"+(System.currentTimeMillis()-clearTime)); + /**==============================娓呴櫎GraphicsOverlay涓婃墍鏈塯raphic END=========================================*/ + + mGraphicsOverlay.getGraphics().add(buoyGraphic1); + mGraphicsOverlay.getGraphics().add(buoyGraphic2); + mGraphicsOverlay.getGraphics().add(buoyGraphic3); + mGraphicsOverlay.getGraphics().add(buoyGraphic4); + mGraphicsOverlay_body.getGraphics().clear(); + mGraphicsOverlay_body.getGraphics().add(graphic); +// mGraphicsOverlay.getGraphics().add(graphicAnt); + Log.i(TAG,"GraphicsOverLay add graphic瀹屾垚"+(System.currentTimeMillis()-beginTime)); + if (mMapView != null){ + mMapView.setViewpointCenterAsync(new Point(startX,startY)); + + } + + + + + } + + /** + * 缁樺埗闈� + */ + private void drawPolygon() { +// List<Point> points = new ArrayList<>(); +// points.add(new Point(21.21,21.32, SpatialReference.create("4544"))); +// PointCollection pointCollection = new PointCollection(points); + + mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + + mGraphicsOverlay.getGraphics().clear(); + Point point = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()))); + mPointCollection.add(point); + + Polygon polygon = new Polygon(mPointCollection); + + if (mPointCollection.size() == 1) { + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10); + Graphic pointGraphic = new Graphic(point, simpleMarkerSymbol); + mGraphicsOverlay.getGraphics().add(pointGraphic); + } + + SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.GREEN, 3.0f); + SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.parseColor("#33e97676"), lineSymbol); + Graphic graphic = new Graphic(polygon, simpleFillSymbol); + mGraphicsOverlay.getGraphics().add(graphic); + + return super.onSingleTapConfirmed(e); + } + }); + } + + /** + * 缁樺埗鐐� + */ + private void drawPoint() { + mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + Point clickPoint = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()))); + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 20); + Graphic graphic = new Graphic(clickPoint, simpleMarkerSymbol); + //娓呴櫎涓婁竴涓偣 + mGraphicsOverlay.getGraphics().clear(); + mGraphicsOverlay.getGraphics().add(graphic); + + //浣跨敤娓叉煋鍣� + // Graphic graphic1 = new Graphic(clickPoint); + // SimpleRenderer simpleRenderer = new SimpleRenderer(simpleMarkerSymbol); + // mGraphicsOverlay.setRenderer(simpleRenderer); + // mGraphicsOverlay.getGraphics().clear(); + // mGraphicsOverlay.getGraphics().add(graphic1); + + return super.onSingleTapConfirmed(e); + } + }); + } + + /** + * 缁樺埗绾� + */ + private void drawPolyline() { + mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + Point point = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()))); + mPointCollection.add(point); + + Polyline polyline = new Polyline(mPointCollection); + + //鐐� + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10); + Graphic pointGraphic = new Graphic(point, simpleMarkerSymbol); + mGraphicsOverlay.getGraphics().add(pointGraphic); + + //绾� + SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.parseColor("#FC8145"), 3); + Graphic graphic = new Graphic(polyline, simpleLineSymbol); + mGraphicsOverlay.getGraphics().add(graphic); + + return super.onSingleTapConfirmed(e); + } + }); + } + + + + @Override + public void onPause() { + if (mMapView != null) { + mMapView.pause(); + } + super.onPause(); + } + + @Override + public void onResume() { + super.onResume(); + if (mMapView != null) { + mMapView.resume(); + } + } + + @Override + public void onDetach() { + super.onDetach(); + if (mMapView != null) { + mMapView.dispose(); + } + Log.i(TAG,"娓呯┖闃熷垪"); + flag = false; + producer.shutdown(); + consumer .shutdown(); + queue.clear(); + CEventCenter.onBindEvent(false,icEventListener, Constant.BIND_RTK_INFO_MAP); + CEventCenter.onBindEvent(false,icEventListener1, Constant.BIND_EXAM_STATUS_TOPIC); + + + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTK_INFO_MAP); + CEventCenter.onBindEvent(true,icEventListener1,Constant.BIND_EXAM_STATUS_TOPIC); + } + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentVTPK.java b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentVTPK.java new file mode 100644 index 0000000..7e7d37c --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragmentVTPK.java @@ -0,0 +1,590 @@ +package safeluck.drive.evaluation.fragment; + +import android.content.Context; +import android.graphics.Color; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.anyun.basecommonlib.MyLog; +import com.esri.arcgisruntime.data.TileCache; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.PointCollection; +import com.esri.arcgisruntime.geometry.Polygon; +import com.esri.arcgisruntime.geometry.Polyline; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISMapImageLayer; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.layers.ArcGISVectorTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.SimpleFillSymbol; +import com.esri.arcgisruntime.symbology.SimpleLineSymbol; +import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol; +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; + +import me.yokeyword.fragmentation.SupportFragment; +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.exam_status.ExamStatus; +import safeluck.drive.evaluation.R; +import safeluck.drive.evaluation.bean.ExamPlatformData; +import safeluck.drive.evaluation.bean.GisCarModel; +import safeluck.drive.evaluation.bean.RTKInfoBean; +import safeluck.drive.evaluation.cEventCenter.CEventCenter; +import safeluck.drive.evaluation.cEventCenter.ICEventListener; +import safeluck.drive.evaluation.util.CThreadPoolExecutor; +import safeluck.drive.evaluation.util.FileUtil; +import safeluck.drive.evaluation.util.Utils; + +/**椹炬牎淇℃伅UI + * MyApplication2 + * Created by lzw on 2019/3/20. 11:22:39 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class ArcGisMapFragmentVTPK extends SupportFragment implements View.OnClickListener { + + private static final String TAG = ArcGisMapFragmentVTPK.class.getSimpleName(); + private static final int ENTER = 1;//杩涘叆 绉戜簩鏌愪釜椤圭洰鍦板浘 + + private LinkedBlockingQueue queue = new LinkedBlockingQueue(100); + private ExecutorService consumer = Executors.newSingleThreadExecutor(); + private ExecutorService producer = Executors.newSingleThreadExecutor(); + SimpleLineSymbol lineSymbolGls = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLACK, 0.5f); + + + PointCollection points = new PointCollection(SpatialReference.create(4544)); + private Gson gson = new Gson(); + private ICEventListener icEventListener = new ICEventListener() { + @Override + public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { + + + + + producer.execute(()->{ + String json = (String)obj; + Log.i(TAG,String.format("褰撳墠绾跨▼鍙�%d,json=%s",Thread.currentThread().getId(),json)); + RTKInfoBean rtkInfoBean = gson.fromJson(json,RTKInfoBean.class); + queue.offer(rtkInfoBean); + }); + +// MyLog.i(TAG,"澶勭悊瀹�11.鏃堕棿="+Utils.formatTimeYYMMDDHHmmSSSSS(System.currentTimeMillis())); + + + } + }; + private ICEventListener icEventListener1 = new ICEventListener() { + @Override + public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { + if (msgCode==13){ + ExamStatus examStatus = (ExamStatus)obj; + if (examStatus.getMap_id()>-1){ + if (examStatus.getEnter()==ENTER){ + MyLog.i(TAG,String.format("杩涘叆[%d] map",examStatus.getMap_id())); + double scale = mMapView.getMapScale(); + mMapView.setViewpointScaleAsync(scale * 0.2*0.2); + }else{ + MyLog.i(TAG,String.format("閫�鍑篬%d] map",examStatus.getMap_id())); + double scale = mMapView.getMapScale(); + mMapView.setViewpointScaleAsync(scale * 5*5); + } + } + } + } + }; + + public static SupportFragment newInstance(String s){ + ArcGisMapFragmentVTPK jiaXiaoFragment = new ArcGisMapFragmentVTPK(); + Bundle bundle = new Bundle(); + bundle.putString("arcgis_url",s); + jiaXiaoFragment.setArguments(bundle); + return jiaXiaoFragment; + } + + + private MapView mMapView ; + private static final int MSG_CAR = 100; + double yaw = 0; + + GraphicsOverlay mGraphicsOverlay; + GraphicsOverlay mGraphicsOverlay_body; + private double startY = 428882,startX = 3291858; + private Handler mHandler = new Handler(){ + @Override + public void handleMessage(Message msg) { + switch (msg.what){ + case MSG_CAR: + + List<safeluck.drive.evaluation.bean.Point> newCarPoints = (List<safeluck.drive.evaluation.bean.Point>) msg.obj; + Log.i(TAG,"handle message newcarPoints.size="+newCarPoints.size()); + drawGlses(newCarPoints,gisCarModel); + + break; + } + } + }; + + PointCollection mPointCollection = new PointCollection(SpatialReference.create(4544)); + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + + + View view = inflater.inflate(R.layout.layout_arc_gis,container,false); + mMapView = view.findViewById(R.id.mapView); + view.findViewById(R.id.btn_change_map).setOnClickListener(this); + Log.i(TAG,String.format("褰撳墠绾跨▼鍙�%d,json=%s",Thread.currentThread().getId(),"onCreateView")); + url = getArguments().getString("arcgis_url"); + CThreadPoolExecutor.runInBackground(()->{ + + readGisCar(); + + + }); + consumer.execute(new CalRunnable()); + + setupMap(); + + +// addTrailheadsLayer(); + + + + url = Environment.getExternalStorageDirectory().getAbsolutePath()+"/ArcGISTileVectorMine.vtpk"; + Log.i(TAG,"url ========="+url); + ArcGISVectorTiledLayer arcGISTiledLayer = new ArcGISVectorTiledLayer (url); + Basemap basemap = new Basemap(arcGISTiledLayer); + ArcGISMap arcGISMap = new ArcGISMap(basemap); + mMapView.setMap(arcGISMap); + + return view; + } + + + + RTKInfoBean rtkInfoBean; + boolean flag = true; + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.btn_change_map: + if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){ + RoadDriveMapFragmentab jiaXiaoFragment = findFragment(RoadDriveMapFragmentab.class); + if (jiaXiaoFragment == null) { + jiaXiaoFragment = (RoadDriveMapFragmentab) RoadDriveMapFragmentab.newInstance(); + } + startWithPop(jiaXiaoFragment); + }else{ + MapFragment jiaXiaoFragment = findFragment(MapFragment.class); + if (jiaXiaoFragment == null) { + jiaXiaoFragment = (MapFragment) MapFragment.newInstance(); + } + startWithPop(jiaXiaoFragment); + } + + + break; + } + } + + class CalRunnable implements Runnable{ + + @Override + public void run() { + while (flag){ + + + rtkInfoBean = (RTKInfoBean)queue.poll(); + if (rtkInfoBean != null){ + Log.i(TAG,String.format("鍙栧嚭涓�涓紝queue.size=%d,rtkinfo=%s,绾跨▼鍙�=%d",queue.size(),rtkInfoBean.toString(),Thread.currentThread().getId())); + yaw = rtkInfoBean.getHeading(); + startX = rtkInfoBean.getCoord_y(); + startY = rtkInfoBean.getCoord_x(); + + + addGraphicLayer(yaw,startX,startY); + + + + } + + } + + } + } + + + + + + + + + private void setupMap() { + if (mMapView != null) { + + + mGraphicsOverlay = addGraphicsOverlay(mMapView); + + } + } +String url ; + private void addTrailheadsLayer() { + if (!TextUtils.isEmpty(url)){ + Log.i(TAG,"map_url="+url); + final ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(url); + // create an empty map instance + ArcGISMap map = new ArcGISMap(); + Log.i(TAG,String.format("map.getMiniScale=%f",map.getMinScale())); + map.setMinScale(1000.0); + // add map image layer as operational layer + map.getOperationalLayers().add(mapImageLayer); + mMapView.setMap(map); + }else{ + Toast.makeText(_mActivity, "url涓虹┖", Toast.LENGTH_SHORT).show(); + } + + + + } + + + + GisCarModel gisCarModel; + boolean once =true; + private void addGraphicLayer(double yaw,double x,double y){ + Log.i(TAG,"addgraphicLayer寮�濮�"); + long time = System.currentTimeMillis(); + + + + if (gisCarModel != null){ + + + long qudianTime = System.currentTimeMillis(); + List<safeluck.drive.evaluation.bean.Point> carNew =Utils.getCarPoint(0,yaw,new safeluck.drive.evaluation.bean.Point(x,y),gisCarModel); + Log.i(TAG,String.format("鍙栧埌鐐硅�楁椂=%d姣,绾跨▼鍙�=%d",System.currentTimeMillis()-qudianTime,Thread.currentThread().getId())); + if (carNew == null) return; + if (once){ + Message message = Message.obtain(); + message.what = MSG_CAR; + + message.obj = carNew; + mHandler.sendMessage(message); + + } + + + + + + + } + + + long period= System.currentTimeMillis()-time; + Log.i(TAG,"鎵цaddGraphicLayer鏂规硶锛岃�楁椂="+period); + + + + } + + private GraphicsOverlay addGraphicsOverlay(MapView mapView){ + //create the graphics overlay + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + mGraphicsOverlay_body = new GraphicsOverlay(); + //add the overlay to the map view + mapView.getGraphicsOverlays().add(mGraphicsOverlay_body); + mapView.getGraphicsOverlays().add(graphicsOverlay); + return graphicsOverlay; + } + private void readGisCar() { + + String carFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+_mActivity.getPackageName()+"/giscar.json"; + if (TextUtils.isEmpty(carFilePath)){ + MyLog.i (TAG, "GISCar杞﹁締妯″瀷鏂囦欢涓嶅瓨鍦�"); + return ; + } + byte[] fileContentBytes= FileUtil.readFile(carFilePath); + if (fileContentBytes !=null&&fileContentBytes.length>0){ + String buffer= new String(fileContentBytes); + gisCarModel = new Gson().fromJson(buffer, GisCarModel.class); + }else{ + return; + } + + + } + + + + PointCollection points1 = new PointCollection(SpatialReference.create(4544)); + PointCollection points2 = new PointCollection(SpatialReference.create(4544)); + PointCollection points3 = new PointCollection(SpatialReference.create(4544)); + PointCollection points4 = new PointCollection(SpatialReference.create(4544)); + SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.rgb(232,0,0), 0.5f); + SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,232,0,0), lineSymbol); + + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.WHITE, 5); + SimpleFillSymbol simpleFillSymbolGls = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,0,0,0), lineSymbolGls); + private void drawGlses(List<safeluck.drive.evaluation.bean.Point> carNew, GisCarModel gisCarModel) { + + if(gisCarModel== null){ + return; + } + long beginTime = System.currentTimeMillis(); + + +/**==============================car body=========================================*/ + + List<Integer> bodys =gisCarModel.getBody(); + points.clear(); + for (int i = 0; i <bodys.size(); i++) { + points.add(carNew.get(bodys.get(i)).getX(),carNew.get(bodys.get(i)).getY()); + } + + Polygon polygon = new Polygon(points); + + Graphic graphic = new Graphic(polygon,simpleFillSymbol); + + + + /**===============================car body end========================================*/ + + +/**==============================鐢诲ぉ绾�=========================================*/ + + +// Graphic graphicAnt = new Graphic(new Point(startX,startY), simpleMarkerSymbol); + + /**==============================鐢诲ぉ绾跨粨鏉� END=========================================*/ + + + + List<Integer> leftCenterGls = gisCarModel.getLeft_center_glass(); + points1.clear(); + for (int i = 0; i < leftCenterGls.size(); i++) { + int pos = leftCenterGls.get(i); + points1.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + List<Integer> rightCenterGls = gisCarModel.getRight_center_glass(); + points2.clear(); + for (int i = 0; i < leftCenterGls.size(); i++) { + int pos = rightCenterGls.get(i); + points2.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + + + List<Integer> frontCLs = new ArrayList<>(); + frontCLs.addAll(gisCarModel.getLeft_front_glass()); + frontCLs.addAll(gisCarModel.getRight_front_glass()); + + + points3.clear(); + for (int i = 0; i < frontCLs.size(); i++) { + int pos = frontCLs.get(i); + points3.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + frontCLs.clear(); + frontCLs.addAll(gisCarModel.getLeft_rear_glass()); + frontCLs.addAll(gisCarModel.getRight_rear_glass()); + points4.clear(); + for (int i = 0; i < frontCLs.size(); i++) { + int pos = frontCLs.get(i); + points4.add(carNew.get(pos).getX(), carNew.get(pos).getY()); + + } + Polygon polygon1 = new Polygon(points1); + Polygon polygon2 = new Polygon(points2); + Polygon polygon3 = new Polygon(points3); + Polygon polygon4 = new Polygon(points4); + + + //create graphics + + Graphic buoyGraphic1 = new Graphic(polygon1, simpleFillSymbolGls); + Graphic buoyGraphic2 = new Graphic(polygon2, simpleFillSymbolGls); + Graphic buoyGraphic3 = new Graphic(polygon3, simpleFillSymbolGls); + Graphic buoyGraphic4 = new Graphic(polygon4, simpleFillSymbolGls); + //add the graphics to the graphics overlay + /**==============================娓呴櫎GraphicsOverlay涓婃墍鏈塯raphic=========================================*/ + long clearTime = System.currentTimeMillis(); + + + mGraphicsOverlay.getGraphics().clear(); + Log.i(TAG,"clear鏂规硶鏃堕棿+"+(System.currentTimeMillis()-clearTime)); + /**==============================娓呴櫎GraphicsOverlay涓婃墍鏈塯raphic END=========================================*/ + + mGraphicsOverlay.getGraphics().add(buoyGraphic1); + mGraphicsOverlay.getGraphics().add(buoyGraphic2); + mGraphicsOverlay.getGraphics().add(buoyGraphic3); + mGraphicsOverlay.getGraphics().add(buoyGraphic4); + mGraphicsOverlay_body.getGraphics().clear(); + mGraphicsOverlay_body.getGraphics().add(graphic); +// mGraphicsOverlay.getGraphics().add(graphicAnt); + Log.i(TAG,"GraphicsOverLay add graphic瀹屾垚"+(System.currentTimeMillis()-beginTime)); +// if (mMapView != null){ +// mMapView.setViewpointCenterAsync(new Point(startX,startY)); +// } + + + + + } + + /** + * 缁樺埗闈� + */ + private void drawPolygon() { +// List<Point> points = new ArrayList<>(); +// points.add(new Point(21.21,21.32, SpatialReference.create("4544"))); +// PointCollection pointCollection = new PointCollection(points); + + mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + + mGraphicsOverlay.getGraphics().clear(); + Point point = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()))); + mPointCollection.add(point); + + Polygon polygon = new Polygon(mPointCollection); + + if (mPointCollection.size() == 1) { + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10); + Graphic pointGraphic = new Graphic(point, simpleMarkerSymbol); + mGraphicsOverlay.getGraphics().add(pointGraphic); + } + + SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.GREEN, 3.0f); + SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.parseColor("#33e97676"), lineSymbol); + Graphic graphic = new Graphic(polygon, simpleFillSymbol); + mGraphicsOverlay.getGraphics().add(graphic); + + return super.onSingleTapConfirmed(e); + } + }); + } + + /** + * 缁樺埗鐐� + */ + private void drawPoint() { + mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + Point clickPoint = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()))); + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 20); + Graphic graphic = new Graphic(clickPoint, simpleMarkerSymbol); + //娓呴櫎涓婁竴涓偣 + mGraphicsOverlay.getGraphics().clear(); + mGraphicsOverlay.getGraphics().add(graphic); + + //浣跨敤娓叉煋鍣� + // Graphic graphic1 = new Graphic(clickPoint); + // SimpleRenderer simpleRenderer = new SimpleRenderer(simpleMarkerSymbol); + // mGraphicsOverlay.setRenderer(simpleRenderer); + // mGraphicsOverlay.getGraphics().clear(); + // mGraphicsOverlay.getGraphics().add(graphic1); + + return super.onSingleTapConfirmed(e); + } + }); + } + + /** + * 缁樺埗绾� + */ + private void drawPolyline() { + mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + Point point = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()))); + mPointCollection.add(point); + + Polyline polyline = new Polyline(mPointCollection); + + //鐐� + SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10); + Graphic pointGraphic = new Graphic(point, simpleMarkerSymbol); + mGraphicsOverlay.getGraphics().add(pointGraphic); + + //绾� + SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.parseColor("#FC8145"), 3); + Graphic graphic = new Graphic(polyline, simpleLineSymbol); + mGraphicsOverlay.getGraphics().add(graphic); + + return super.onSingleTapConfirmed(e); + } + }); + } + + + + @Override + public void onPause() { + if (mMapView != null) { + mMapView.pause(); + } + super.onPause(); + } + + @Override + public void onResume() { + super.onResume(); + if (mMapView != null) { + mMapView.resume(); + } + } + + @Override + public void onDetach() { + super.onDetach(); + if (mMapView != null) { + mMapView.dispose(); + } + Log.i(TAG,"娓呯┖闃熷垪"); + flag = false; + producer.shutdown(); + consumer .shutdown(); + queue.clear(); + CEventCenter.onBindEvent(false,icEventListener, Constant.BIND_RTK_INFO_MAP); + CEventCenter.onBindEvent(false,icEventListener1, Constant.BIND_EXAM_STATUS_TOPIC); + + + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTK_INFO_MAP); + CEventCenter.onBindEvent(true,icEventListener1,Constant.BIND_EXAM_STATUS_TOPIC); + } + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpCarRespBean.java b/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpCarRespBean.java index 90c2ac0..a4334b9 100644 --- a/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpCarRespBean.java +++ b/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpCarRespBean.java @@ -3,6 +3,7 @@ import java.util.List; public class HttpCarRespBean { + /** * result : true * data : {"server":"gps.safeluck.com","port":"3301","gps_monitor_url":"https%3A%2F%2Ftrainsim.aaej.cn%2F%23%2Fvisitor%2Fmonitor%3Fdevice_id%3D0314200100000004%26area_type%3Dcar","map_json":{"left_front_tire":[9,10],"main_ant":[428984.9367,3291974.6021],"type":"car","body":[0,1,2,3,4,5,6,7,8,13,14,15,16,17,18,19,20,21],"ground_height":229.8357,"version":"0.1","point":[428984.1653,3291977.6796,428983.7684,3291977.5547,428983.498,3291977.0243,428983.5552,3291976.6508,428983.8355,3291975.483,428984.0438,3291974.7034,428984.1558,3291974.1226,428984.5245,3291973.295,428984.8693,3291973.2598,428983.5944,3291976.6639,428983.769,3291976.6702,428984.203,3291974.1338,428984.342,3291974.1803,428985.23,3291973.3175,428985.6473,3291973.4636,428985.8995,3291973.6719,428985.8234,3291974.5267,428985.6107,3291975.3336,428985.4377,3291976.0995,428985.1876,3291977.0475,428984.9813,3291977.5092,428984.5666,3291977.7383,428985.1356,3291977.0333,428984.9657,3291976.9994,428985.785,3291974.5007,428985.6423,3291974.4559],"axial":[0,13],"ant_pitch":0.081,"ant_height":231.2434,"right_front_tire":[22,23],"right_rear_tire":[24,25],"name":"娑櫟浜ら�氶┚鏍�","left_rear_tire":[11,12]},"version":"0.1","pzh":"璞獷8000娴�"} @@ -237,4 +238,7 @@ } } } + + + } diff --git a/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpGisCarRespBean.java b/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpGisCarRespBean.java new file mode 100644 index 0000000..19b5631 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/httpmodule/HttpGisCarRespBean.java @@ -0,0 +1,538 @@ +package safeluck.drive.evaluation.httpmodule; + +import java.util.List; + +public class HttpGisCarRespBean { + /** + * result : true + * data : {"server":"gps.safeluck.com","port":"3301","gps_monitor_url":"https%3A%2F%2Ftrainsim.aaej.cn%2F%23%2Fvisitor%2Fmonitor%3Fdevice_id%3D0314200100000003%26area_type%3Dcar","map_json":{"left_front_tire":[12,13],"main_ant":[642214.3436,3270761.9102],"right_rear_glass":[58,59,60,61],"body":[0,1,2,3,4,5,6,7,8,9,10,11,32,33,34,35,36,37,38,39,40,41,42,43],"ground_height":331.6199,"type":"car","version":"1.0","point":[642216.5511,3270759.543,642216.7239,3270759.7759,642216.8133,3270759.8769,642216.859,3270760.3094,642216.7995,3270760.4553,642216.5513,3270760.7819,642216.242,3270761.0874,642215.5468,3270761.8527,642214.7732,3270762.7061,642214.483,3270762.97,642214.1131,3270763.2124,642213.7448,3270763.0632,642216.5364,3270760.7594,642216.4056,3270760.6352,642214.763,3270762.684,642214.6482,3270762.5763,642216.0948,3270760.559,642216.2863,3270760.9176,642215.5665,3270761.3672,642215.3224,3270761.075,642215.8444,3270760.2702,642216.0948,3270760.559,642216.1878,3270761.022,642214.5299,3270762.782,642214.7092,3270762.266,642215.5793,3270761.43,642213.9578,3270762.621,642214.4689,3270762.846,642214.6577,3270762.255,642214.3621,3270762.0998,642214.242,3270762.0047,642214.3621,3270762.0098,642213.4524,3270762.8314,642213.2324,3270762.5872,642213.0537,3270762.2115,642213.3048,3270761.7942,642213.5453,3270761.5047,642214.2823,3270760.7212,642215.0634,3270759.9012,642215.346,3270759.5816,642215.6092,3270759.3543,642215.7336,3270759.2982,642216.2033,3270759.2972,642216.3468,3270759.4079,642215.3611,3270759.6032,642215.4909,3270759.7158,642213.5608,3270761.519,642213.6874,3270761.6509,642213.4249,3270761.767,642215.0934,3270759.996,642214.7549,3270760.717,642213.9469,3270761.587,642215.0584,3270760.8537,642214.8047,3270760.7012,642215.1958,3270759.8877,642215.6907,3270760.1429,642215.8444,3270760.2702,642216.0948,3270760.559,642214.1323,3270761.8943,642213.9566,3270761.6397,642213.3781,3270761.8166,642213.5721,3270762.2307,642214.3621,3270762.0998],"ant_pitch":0.602,"axial":[0,32],"ant_height":333.0715,"left_rear_glass":[26,27,28,29],"right_front_tire":[44,45],"right_rear_tire":[46,47],"right_front_glass":[52,53,54,55],"name":"棣栭椹炬牎鑱旇姵杞︽ā鍨�","left_rear_tire":[14,15],"left_front_glass":[16,17,18,19],"left_center_glass":[22,23,24,25],"right_center_glass":[48,49,50,51]},"version":"1.0","pzh":"璞獷2000娴�"} + */ + + private boolean result; + private DataBean data; + + public boolean isResult() { + return result; + } + + public void setResult(boolean result) { + this.result = result; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public static class DataBean { + /** + * server : gps.safeluck.com + * port : 3301 + * gps_monitor_url : https%3A%2F%2Ftrainsim.aaej.cn%2F%23%2Fvisitor%2Fmonitor%3Fdevice_id%3D0314200100000003%26area_type%3Dcar + * map_json : {"left_front_tire":[12,13],"main_ant":[642214.3436,3270761.9102],"right_rear_glass":[58,59,60,61],"body":[0,1,2,3,4,5,6,7,8,9,10,11,32,33,34,35,36,37,38,39,40,41,42,43],"ground_height":331.6199,"type":"car","version":"1.0","point":[642216.5511,3270759.543,642216.7239,3270759.7759,642216.8133,3270759.8769,642216.859,3270760.3094,642216.7995,3270760.4553,642216.5513,3270760.7819,642216.242,3270761.0874,642215.5468,3270761.8527,642214.7732,3270762.7061,642214.483,3270762.97,642214.1131,3270763.2124,642213.7448,3270763.0632,642216.5364,3270760.7594,642216.4056,3270760.6352,642214.763,3270762.684,642214.6482,3270762.5763,642216.0948,3270760.559,642216.2863,3270760.9176,642215.5665,3270761.3672,642215.3224,3270761.075,642215.8444,3270760.2702,642216.0948,3270760.559,642216.1878,3270761.022,642214.5299,3270762.782,642214.7092,3270762.266,642215.5793,3270761.43,642213.9578,3270762.621,642214.4689,3270762.846,642214.6577,3270762.255,642214.3621,3270762.0998,642214.242,3270762.0047,642214.3621,3270762.0098,642213.4524,3270762.8314,642213.2324,3270762.5872,642213.0537,3270762.2115,642213.3048,3270761.7942,642213.5453,3270761.5047,642214.2823,3270760.7212,642215.0634,3270759.9012,642215.346,3270759.5816,642215.6092,3270759.3543,642215.7336,3270759.2982,642216.2033,3270759.2972,642216.3468,3270759.4079,642215.3611,3270759.6032,642215.4909,3270759.7158,642213.5608,3270761.519,642213.6874,3270761.6509,642213.4249,3270761.767,642215.0934,3270759.996,642214.7549,3270760.717,642213.9469,3270761.587,642215.0584,3270760.8537,642214.8047,3270760.7012,642215.1958,3270759.8877,642215.6907,3270760.1429,642215.8444,3270760.2702,642216.0948,3270760.559,642214.1323,3270761.8943,642213.9566,3270761.6397,642213.3781,3270761.8166,642213.5721,3270762.2307,642214.3621,3270762.0998],"ant_pitch":0.602,"axial":[0,32],"ant_height":333.0715,"left_rear_glass":[26,27,28,29],"right_front_tire":[44,45],"right_rear_tire":[46,47],"right_front_glass":[52,53,54,55],"name":"棣栭椹炬牎鑱旇姵杞︽ā鍨�","left_rear_tire":[14,15],"left_front_glass":[16,17,18,19],"left_center_glass":[22,23,24,25],"right_center_glass":[48,49,50,51]} + * version : 1.0 + * pzh : 璞獷2000娴� + */ + + private String server; + private String port; + private String gps_monitor_url; + private MapJsonBean map_json; + private String version; + private String pzh; + + public String getServer() { + return server; + } + + public void setServer(String server) { + this.server = server; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getGps_monitor_url() { + return gps_monitor_url; + } + + public void setGps_monitor_url(String gps_monitor_url) { + this.gps_monitor_url = gps_monitor_url; + } + + public MapJsonBean getMap_json() { + return map_json; + } + + public void setMap_json(MapJsonBean map_json) { + this.map_json = map_json; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPzh() { + return pzh; + } + + public void setPzh(String pzh) { + this.pzh = pzh; + } + + public static class MapJsonBean { + /** + * left_front_tire : [12,13] + * main_ant : [642214.3436,3270761.9102] + * right_rear_glass : [58,59,60,61] + * body : [0,1,2,3,4,5,6,7,8,9,10,11,32,33,34,35,36,37,38,39,40,41,42,43] + * ground_height : 331.6199 + * type : car + * version : 1.0 + * point : [642216.5511,3270759.543,642216.7239,3270759.7759,642216.8133,3270759.8769,642216.859,3270760.3094,642216.7995,3270760.4553,642216.5513,3270760.7819,642216.242,3270761.0874,642215.5468,3270761.8527,642214.7732,3270762.7061,642214.483,3270762.97,642214.1131,3270763.2124,642213.7448,3270763.0632,642216.5364,3270760.7594,642216.4056,3270760.6352,642214.763,3270762.684,642214.6482,3270762.5763,642216.0948,3270760.559,642216.2863,3270760.9176,642215.5665,3270761.3672,642215.3224,3270761.075,642215.8444,3270760.2702,642216.0948,3270760.559,642216.1878,3270761.022,642214.5299,3270762.782,642214.7092,3270762.266,642215.5793,3270761.43,642213.9578,3270762.621,642214.4689,3270762.846,642214.6577,3270762.255,642214.3621,3270762.0998,642214.242,3270762.0047,642214.3621,3270762.0098,642213.4524,3270762.8314,642213.2324,3270762.5872,642213.0537,3270762.2115,642213.3048,3270761.7942,642213.5453,3270761.5047,642214.2823,3270760.7212,642215.0634,3270759.9012,642215.346,3270759.5816,642215.6092,3270759.3543,642215.7336,3270759.2982,642216.2033,3270759.2972,642216.3468,3270759.4079,642215.3611,3270759.6032,642215.4909,3270759.7158,642213.5608,3270761.519,642213.6874,3270761.6509,642213.4249,3270761.767,642215.0934,3270759.996,642214.7549,3270760.717,642213.9469,3270761.587,642215.0584,3270760.8537,642214.8047,3270760.7012,642215.1958,3270759.8877,642215.6907,3270760.1429,642215.8444,3270760.2702,642216.0948,3270760.559,642214.1323,3270761.8943,642213.9566,3270761.6397,642213.3781,3270761.8166,642213.5721,3270762.2307,642214.3621,3270762.0998] + * ant_pitch : 0.602 + * axial : [0,32] + * ant_height : 333.0715 + * left_rear_glass : [26,27,28,29] + * right_front_tire : [44,45] + * right_rear_tire : [46,47] + * right_front_glass : [52,53,54,55] + * name : 棣栭椹炬牎鑱旇姵杞︽ā鍨� + * left_rear_tire : [14,15] + * left_front_glass : [16,17,18,19] + * left_center_glass : [22,23,24,25] + * right_center_glass : [48,49,50,51] + */ + + private double ground_height; + private String type; + private String version; + private double ant_pitch; + private double ant_height; + private String name; + private List<Double> left_front_tire; + private List<Double> main_ant; + private List<Double> right_rear_glass; + private List<Double> body; + private List<Double> point; + private List<Double> axial; + private List<Double> left_rear_glass; + private List<Double> right_front_tire; + private List<Double> right_rear_tire; + private List<Double> right_front_glass; + private List<Double> left_rear_tire; + private List<Double> left_front_glass; + private List<Double> left_center_glass; + private List<Double> right_center_glass; + + public double getGround_height() { + return ground_height; + } + + public void setGround_height(double ground_height) { + this.ground_height = ground_height; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public double getAnt_pitch() { + return ant_pitch; + } + + public void setAnt_pitch(double ant_pitch) { + this.ant_pitch = ant_pitch; + } + + public double getAnt_height() { + return ant_height; + } + + public void setAnt_height(double ant_height) { + this.ant_height = ant_height; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List<Double> getLeft_front_tire() { + return left_front_tire; + } + + public void setLeft_front_tire(List<Double> left_front_tire) { + this.left_front_tire = left_front_tire; + } + + public List<Double> getMain_ant() { + return main_ant; + } + + public void setMain_ant(List<Double> main_ant) { + this.main_ant = main_ant; + } + + public List<Double> getRight_rear_glass() { + return right_rear_glass; + } + + public void setRight_rear_glass(List<Double> right_rear_glass) { + this.right_rear_glass = right_rear_glass; + } + + public List<Double> getBody() { + return body; + } + + public void setBody(List<Double> body) { + this.body = body; + } + + public List<Double> getPoint() { + return point; + } + + public void setPoint(List<Double> point) { + this.point = point; + } + + public List<Double> getAxial() { + return axial; + } + + public void setAxial(List<Double> axial) { + this.axial = axial; + } + + public List<Double> getLeft_rear_glass() { + return left_rear_glass; + } + + public void setLeft_rear_glass(List<Double> left_rear_glass) { + this.left_rear_glass = left_rear_glass; + } + + public List<Double> getRight_front_tire() { + return right_front_tire; + } + + public void setRight_front_tire(List<Double> right_front_tire) { + this.right_front_tire = right_front_tire; + } + + public List<Double> getRight_rear_tire() { + return right_rear_tire; + } + + public void setRight_rear_tire(List<Double> right_rear_tire) { + this.right_rear_tire = right_rear_tire; + } + + public List<Double> getRight_front_glass() { + return right_front_glass; + } + + public void setRight_front_glass(List<Double> right_front_glass) { + this.right_front_glass = right_front_glass; + } + + public List<Double> getLeft_rear_tire() { + return left_rear_tire; + } + + public void setLeft_rear_tire(List<Double> left_rear_tire) { + this.left_rear_tire = left_rear_tire; + } + + public List<Double> getLeft_front_glass() { + return left_front_glass; + } + + public void setLeft_front_glass(List<Double> left_front_glass) { + this.left_front_glass = left_front_glass; + } + + public List<Double> getLeft_center_glass() { + return left_center_glass; + } + + public void setLeft_center_glass(List<Double> left_center_glass) { + this.left_center_glass = left_center_glass; + } + + public List<Double> getRight_center_glass() { + return right_center_glass; + } + + public void setRight_center_glass(List<Double> right_center_glass) { + this.right_center_glass = right_center_glass; + } + } + } +// /** +// * result : true +// * data : {"server":"gps.safeluck.com","port":"3301","gps_monitor_url":"https%3A%2F%2Ftrainsim.aaej.cn%2F%23%2Fvisitor%2Fmonitor%3Fdevice_id%3D0314200100000004%26area_type%3Dcar","map_json":{"left_front_tire":[9,10],"main_ant":[428984.9367,3291974.6021],"type":"car","body":[0,1,2,3,4,5,6,7,8,13,14,15,16,17,18,19,20,21],"ground_height":229.8357,"version":"0.1","point":[428984.1653,3291977.6796,428983.7684,3291977.5547,428983.498,3291977.0243,428983.5552,3291976.6508,428983.8355,3291975.483,428984.0438,3291974.7034,428984.1558,3291974.1226,428984.5245,3291973.295,428984.8693,3291973.2598,428983.5944,3291976.6639,428983.769,3291976.6702,428984.203,3291974.1338,428984.342,3291974.1803,428985.23,3291973.3175,428985.6473,3291973.4636,428985.8995,3291973.6719,428985.8234,3291974.5267,428985.6107,3291975.3336,428985.4377,3291976.0995,428985.1876,3291977.0475,428984.9813,3291977.5092,428984.5666,3291977.7383,428985.1356,3291977.0333,428984.9657,3291976.9994,428985.785,3291974.5007,428985.6423,3291974.4559],"axial":[0,13],"ant_pitch":0.081,"ant_height":231.2434,"right_front_tire":[22,23],"right_rear_tire":[24,25],"name":"娑櫟浜ら�氶┚鏍�","left_rear_tire":[11,12]},"version":"0.1","pzh":"璞獷8000娴�"} +// */ +// +// +// private boolean result; +// private DataBean data; +// +// public boolean isResult() { +// return result; +// } +// +// public void setResult(boolean result) { +// this.result = result; +// } +// +// public DataBean getData() { +// return data; +// } +// +// public void setData(DataBean data) { +// this.data = data; +// } +// +// public static class DataBean { +// /** +// * server : gps.safeluck.com +// * port : 3301 +// * map_json : {"axial":[0,12],"left_front_tire":[8,9],"main_ant":[-9151.5063,13030.5118],"right_front_tire":[20,21],"right_rear_tire":[22,23],"name":"绉戜簩鍦鸿�冭溅妯″瀷","left_rear_tire":[10,11],"type":"car","body":[0,1,2,3,4,5,6,7,12,13,14,15,16,17,18,19],"point":[-9149.6063,13033.0768,-9149.9978,13033.3124,-9150.3258,13033.3485,-9150.8341,13032.8985,-9151.7318,13031.6639,-9152.3573,13030.83,-9152.5214,13030.5639,-9152.602,13030.3105,-9150.8053,13032.8843,-9150.6537,13032.7602,-9152.3352,13030.8124,-9152.221,13030.7008,-9152.092,13029.7892,-9151.4638,13029.4333,-9151.2111,13029.568,-9150.9808,13029.8341,-9150.3546,13030.6796,-9149.458,13031.8642,-9149.1611,13032.4276,-9149.2827,13032.7653,-9149.4842,13031.8708,-9149.6176,13031.9937,-9151.0011,13029.8717,-9151.1367,13029.9878]} +// * pzh : 璞獷8000娴� +// */ +// +// private String server; +// private String port; +// private String version; +// +// public String getGps_monitor_url() { +// return gps_monitor_url; +// } +// +// public void setGps_monitor_url(String gps_monitor_url) { +// this.gps_monitor_url = gps_monitor_url; +// } +// +// private String gps_monitor_url; +// private MapJsonBean map_json; +// private String pzh; +// +// public String getServer() { +// return server; +// } +// +// public String getVersion() { +// return version; +// } +// +// public void setVersion(String version) { +// this.version = version; +// } +// +// +// +// public void setServer(String server) { +// this.server = server; +// } +// +// public String getPort() { +// return port; +// } +// +// public void setPort(String port) { +// this.port = port; +// } +// +// public MapJsonBean getMap_json() { +// return map_json; +// } +// +// public void setMap_json(MapJsonBean map_json) { +// this.map_json = map_json; +// } +// +// public String getPzh() { +// return pzh; +// } +// +// public void setPzh(String pzh) { +// this.pzh = pzh; +// } +// +// public static class MapJsonBean { +// /** +// * axial : [0,12] +// * left_front_tire : [8,9] +// * main_ant : [-9151.5063,13030.5118] +// * right_front_tire : [20,21] +// * right_rear_tire : [22,23] +// * name : 绉戜簩鍦鸿�冭溅妯″瀷 +// * left_rear_tire : [10,11] +// * type : car +// * body : [0,1,2,3,4,5,6,7,12,13,14,15,16,17,18,19] +// * point : [-9149.6063,13033.0768,-9149.9978,13033.3124,-9150.3258,13033.3485,-9150.8341,13032.8985,-9151.7318,13031.6639,-9152.3573,13030.83,-9152.5214,13030.5639,-9152.602,13030.3105,-9150.8053,13032.8843,-9150.6537,13032.7602,-9152.3352,13030.8124,-9152.221,13030.7008,-9152.092,13029.7892,-9151.4638,13029.4333,-9151.2111,13029.568,-9150.9808,13029.8341,-9150.3546,13030.6796,-9149.458,13031.8642,-9149.1611,13032.4276,-9149.2827,13032.7653,-9149.4842,13031.8708,-9149.6176,13031.9937,-9151.0011,13029.8717,-9151.1367,13029.9878] +// */ +// +// private String name; +// private String type; +// private List<Integer> axial; +// private List<Integer> left_front_tire; +// private List<Double> main_ant; +// private List<Integer> right_front_tire; +// private List<Integer> right_rear_tire; +// private List<Integer> left_rear_tire; +// private List<Integer> body; +// private List<Double> point; +// +// private double ground_height; +// private String version; +// private double ant_pitch; +// private double ant_height; +// +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } +// +// public String getType() { +// return type; +// } +// +// public void setType(String type) { +// this.type = type; +// } +// +// public List<Integer> getAxial() { +// return axial; +// } +// +// +// public double getGround_height() { +// return ground_height; +// } +// +// public void setGround_height(double ground_height) { +// this.ground_height = ground_height; +// } +// +// public String getVersion() { +// return version; +// } +// +// public void setVersion(String version) { +// this.version = version; +// } +// +// public double getAnt_pitch() { +// return ant_pitch; +// } +// +// public void setAnt_pitch(double ant_pitch) { +// this.ant_pitch = ant_pitch; +// } +// +// public double getAnt_height() { +// return ant_height; +// } +// +// public void setAnt_height(double ant_height) { +// this.ant_height = ant_height; +// } +// public void setAxial(List<Integer> axial) { +// this.axial = axial; +// } +// +// public List<Integer> getLeft_front_tire() { +// return left_front_tire; +// } +// +// public void setLeft_front_tire(List<Integer> left_front_tire) { +// this.left_front_tire = left_front_tire; +// } +// +// public List<Double> getMain_ant() { +// return main_ant; +// } +// +// public void setMain_ant(List<Double> main_ant) { +// this.main_ant = main_ant; +// } +// +// public List<Integer> getRight_front_tire() { +// return right_front_tire; +// } +// +// public void setRight_front_tire(List<Integer> right_front_tire) { +// this.right_front_tire = right_front_tire; +// } +// +// public List<Integer> getRight_rear_tire() { +// return right_rear_tire; +// } +// +// public void setRight_rear_tire(List<Integer> right_rear_tire) { +// this.right_rear_tire = right_rear_tire; +// } +// +// public List<Integer> getLeft_rear_tire() { +// return left_rear_tire; +// } +// +// public void setLeft_rear_tire(List<Integer> left_rear_tire) { +// this.left_rear_tire = left_rear_tire; +// } +// +// public List<Integer> getBody() { +// return body; +// } +// +// public void setBody(List<Integer> body) { +// this.body = body; +// } +// +// public List<Double> getPoint() { +// return point; +// } +// +// public void setPoint(List<Double> point) { +// this.point = point; +// } +// } +// } + + + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt b/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt index d3e5108..85633f0 100644 --- a/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt +++ b/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt @@ -24,10 +24,7 @@ import safeluck.drive.evaluation.app import safeluck.drive.evaluation.bean.* import safeluck.drive.evaluation.bean.SimulateNightBean.QuestionBean -import safeluck.drive.evaluation.httpmodule.HttpCarRespBean -import safeluck.drive.evaluation.httpmodule.HttpRequetBean -import safeluck.drive.evaluation.httpmodule.HttpRoadMapRsp -import safeluck.drive.evaluation.httpmodule.HttpYardRsp +import safeluck.drive.evaluation.httpmodule.* import safeluck.drive.evaluation.httpmodule.RetrofitCreator.Companion.getRestService import safeluck.drive.evaluation.platformMessage.PlatFormConstant import java.io.File @@ -326,6 +323,7 @@ else ->{ mapInfoHead.type = BaseDataUIBean.TYPE_.car val car = gson.fromJson<HttpCarRespBean>(str,HttpCarRespBean::class.java) + val gcar = gson.fromJson<HttpGisCarRespBean>(str, HttpGisCarRespBean::class.java) // car.isResult = false if (car.isResult){ if (car.data !=null){ @@ -337,8 +335,10 @@ // Log.i(TAG, "瑙f瀽涔嬪悗鐨勮溅妯″瀷=$str") CThreadPoolExecutor.runInBackground(Runnable{ str = gson.toJson(car.data.map_json) + var giscarStr = gson.toJson(gcar.data.map_json) MyLog.i(PlatFormConstant.HTTPTAG,"杞﹁締妯″瀷淇濆瓨鎴愬姛") FileUtil.writeTxtFileToSD(app.getAppContext(),fileName,str,"") + FileUtil.writeTxtFileToSD(app.getAppContext(),"gis"+fileName,giscarStr,"") sendVehicleInfo() }) diff --git a/app/src/main/res/layout/layout_arc_gis.xml b/app/src/main/res/layout/layout_arc_gis.xml index 58a2d20..b393920 100644 --- a/app/src/main/res/layout/layout_arc_gis.xml +++ b/app/src/main/res/layout/layout_arc_gis.xml @@ -1,22 +1,34 @@ <?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/activity_main" - android:layout_width="match_parent" - android:layout_height="match_parent" - > +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" + android:orientation="horizontal" + android:layout_width="match_parent"> + <FrameLayout + android:id="@+id/activity_main" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="3" + > - <com.esri.arcgisruntime.mapping.view.MapView - android:id="@+id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" > - </com.esri.arcgisruntime.mapping.view.MapView> - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="bottom|left" - android:id="@+id/btn_change_map" - android:background="@drawable/btn_state_save" + <com.esri.arcgisruntime.mapping.view.MapView + android:id="@+id/mapView" + android:layout_width="match_parent" + android:layout_height="match_parent" + > + </com.esri.arcgisruntime.mapping.view.MapView> + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|left" + android:id="@+id/btn_change_map" + android:background="@drawable/btn_state_save" - android:text="鍒囨崲鍦板浘"/> -</FrameLayout> \ No newline at end of file + android:text="鍒囨崲鍦板浘"/> + + </FrameLayout> + <SurfaceView + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:id="@+id/surfaceview_arcgis"/> +</LinearLayout> -- Gitblit v1.8.0