| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Color; |
| | | import android.os.Bundle; |
| | | |
| | | 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.esri.arcgisruntime.ArcGISRuntimeEnvironment; |
| | | import com.esri.arcgisruntime.arcgisservices.ArcGISMapServiceInfo; |
| | | import com.esri.arcgisruntime.concurrent.ListenableFuture; |
| | | import com.esri.arcgisruntime.data.ServiceFeatureTable; |
| | | import com.esri.arcgisruntime.geometry.Point; |
| | | import com.esri.arcgisruntime.geometry.PointCollection; |
| | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | | import java.util.concurrent.ExecutionException; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.LinkedBlockingDeque; |
| | | import java.util.concurrent.ScheduledExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.app; |
| | | import safeluck.drive.evaluation.arcgis.MapSingleTapListener; |
| | | 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; |
| | |
| | | * All Rights Saved! Chongqing AnYun Tech co. LTD |
| | | */ |
| | | public class JiaXiaoFragment extends SupportFragment { |
| | | |
| | | private static final String TAG = JiaXiaoFragment.class.getSimpleName(); |
| | | |
| | | |
| | | |
| | | private Gson gson = new Gson(); |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | |
| | | synchronized (JiaXiaoFragment.class){ |
| | | String json = (String)obj; |
| | | Log.i(TAG,String.format("当前线程号%d,json=%s",Thread.currentThread().getId(),json)); |
| | | RTKInfoBean rtkInfoBean = gson.fromJson(json,RTKInfoBean.class); |
| | | Log.i(TAG,String.format("CThreadPoolExecutor,当前线程号%d,Coord_x=%f,Coord_y=%f", |
| | | Thread.currentThread().getId(),rtkInfoBean.getCoord_x(),rtkInfoBean |
| | | .getCoord_y())); |
| | | yaw = rtkInfoBean.getHeading(); |
| | | startX = rtkInfoBean.getCoord_y(); |
| | | startY = rtkInfoBean.getCoord_x(); |
| | | addGraphicLayer(yaw,startX,startY); |
| | | } |
| | | |
| | | |
| | | } |
| | | }; |
| | | |
| | | public static SupportFragment newInstance(){ |
| | | return new JiaXiaoFragment(); |
| | | } |
| | | private static final String TAG = JiaXiaoFragment.class.getSimpleName(); |
| | | |
| | | |
| | | private MapView mMapView ; |
| | | private static final int MSG_CAR = 100; |
| | |
| | | |
| | | View view = inflater.inflate(R.layout.layout_arc_gis,container,false); |
| | | mMapView = view.findViewById(R.id.mapView); |
| | | Log.i(TAG,String.format("当前线程号%d,json=%s",Thread.currentThread().getId(),"onCreateView")); |
| | | setupMap(); |
| | | addTrailheadsLayer(); |
| | | // addImageLayer(); |
| | | addGraphicLayer(0,startX,startY); |
| | | |
| | | mHandler.sendEmptyMessageDelayed(MSG_CAR,1000); |
| | | // mHandler.sendEmptyMessageDelayed(MSG_CAR,1000); |
| | | |
| | | // drawPolygon(); |
| | | |
| | | return view; |
| | | } |
| | | private SublayerList mSublayersList; |
| | |
| | | } |
| | | private void addTrailheadsLayer() { |
| | | |
| | | |
| | | //一定不能少了最后的 / |
| | | |
| | | String url = "http://192.168.0.47:6080/arcgis/rest/services/%E5%9C%9F%E4%B8%BB%E8%80%83%E5%9C%BA/MapServer/"; |
| | | // String url = "http://192.168.0.47:6080/arcgis/rest/services/test/MapServer/"; |
| | | // String url = "http://192.168.0.47:6080/arcgis/rest/services/Testmap_3/MapServer/"; |
| | | ArcGISMapImageLayer arcGISMapImageLayer = new ArcGISMapImageLayer(url); |
| | | arcGISMapImageLayer.loadAsync(); |
| | | arcGISMapImageLayer.addLoadStatusChangedListener(loadStatusChangedEvent -> { |
| | |
| | | |
| | | Log.i(TAG,"ServiceFeatureTables size = "+tables.size()); |
| | | for (int i = tables.size()-1; i >= 0; i--) { |
| | | // for (int i =0; i < tables.size(); i++) { |
| | | ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(url+String.valueOf(i)); |
| | | |
| | | FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable); |
| | |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | final ListenableFuture<Boolean> viewPointSetFuture = mMapView.setViewpointRotationAsync(90); |
| | | viewPointSetFuture.addDoneListener(() -> { |
| | | try{ |
| | | boolean completed = viewPointSetFuture.get(); |
| | | if (completed){ |
| | | Log.i(TAG,"Rotation completed successfully"); |
| | | } |
| | | }catch (InterruptedException e){ |
| | | Log.i(TAG,"Rotation Interrupted"); |
| | | }catch (ExecutionException e){ |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | mMapView.setOnTouchListener(new MapSingleTapListener(getContext(),mMapView)); |
| | | |
| | | |
| | | } |
| | |
| | | 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); |
| | | PointCollection points = new PointCollection(SpatialReference.create(4544)); |
| | | String carFilePath = ExamPlatformData.getInstance().getCarModelPath(); |
| | | if (TextUtils.isEmpty(carFilePath)){ |
| | | Toast.makeText(_mActivity, "车辆模型文件不存在", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } |
| | | CThreadPoolExecutor.runInBackground(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | StringBuffer buffer= FileUtil.readAssetTxtFile(app.getAppContext(),"giscar.json"); |
| | | Log.i(TAG,"giscar="+buffer.toString()); |
| | | GisCarModel gisCarModel= new Gson().fromJson(buffer.toString(),GisCarModel.class); |
| | | // List<safeluck.drive.evaluation.bean.Point> carNew=Utils.getCarPoint(0,45,new safeluck.drive.evaluation.bean.Point(-8633.77199999988,14471.793700000271)); |
| | | byte[] fileContentBytes=FileUtil.readFile(carFilePath); |
| | | String buffer= new String(fileContentBytes); |
| | | // Log.i(TAG,"giscar="+buffer); |
| | | GisCarModel gisCarModel= new Gson().fromJson(buffer,GisCarModel.class); |
| | | List<safeluck.drive.evaluation.bean.Point> carNew=Utils.getCarPoint(0,yaw,new safeluck.drive.evaluation.bean.Point(x,y)); |
| | | List<Integer> bodys =gisCarModel.getBody(); |
| | | for (int i = 0; i <bodys.size(); i++) { |
| | |
| | | |
| | | drawPoint(new Point(x,y)); |
| | | |
| | | if (mMapView != null){ |
| | | mMapView.setViewpointCenterAsync(new Point(x,y)); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | if (mMapView != null) { |
| | | mMapView.dispose(); |
| | | } |
| | | CEventCenter.onBindEvent(false,icEventListener, Constant.BIND_RTK_INFO_MAP); |
| | | super.onDetach(); |
| | | } |
| | | |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTK_INFO_MAP); |
| | | } |
| | | } |