lizhanwei
2020-06-08 413d11a504be1d79ece09e3007a0acb057cddcf0
增加ArcGis runtime for android sdk,完成车辆模型及地图绘制
6个文件已修改
5个文件已添加
703 ■■■■■ 已修改文件
app/build.gradle 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/AndroidManifest.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/giscar.json 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/app.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/CarModel.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/GisCarModel.java 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java 364 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/util/Utils.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_arc_gis.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/app_settings.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
build.gradle 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/build.gradle
@@ -77,6 +77,9 @@
    implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofit_version"
    implementation "com.google.zxing:core:$rootProject.qrcode_version"
    implementation "com.squareup.picasso:picasso:2.5.2"
    // *** ADD ***
    implementation 'com.esri.arcgisruntime:arcgis-android:100.8.0'
}
repositories {
    mavenCentral()
app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="android.uid.system"
    android:sharedUserId="android.uid.system"
    package="safeluck.drive.evaluation">
    <uses-permission android:name="android.permission.CAMERA" />
@@ -9,6 +9,8 @@
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.REBOOT"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
app/src/main/assets/giscar.json
New file
@@ -0,0 +1,35 @@
{
  "axial": [0, 25],
  "body": [0, 1, 2, 3, 4, 5, 6, 7, 25, 26, 27, 28,29,30,31,32],
  "left_front_tire": [8, 9],
  "left_rear_tire": [10, 11],
  "main_ant": [-9151.5063, 13030.5118],
  "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,
    -9150.1005859,13032.423100000247000,-9150.8535156,13032.752900000662000,-9151.1162109,13032.073200000450000,-9150.5683594,13031.804300000891000,
    -9151.5400391,13030.519500000402000,-9151.9570313,13030.962400000542000,-9152.3496094,13030.609099999070000,-9151.8574219,13030.100199999288000,
    -9151.0009766,13032.559200000018000,-9152.1943359,13030.980799999088000,-9151.9980469,13031.044099999592000,-9151.8066406,13031.161399999633000,-9151.2636719,13031.880100000650000,
    -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,
    -9150.1621094,13031.346100000665000,-9149.5800781,13031.784299999475000,
    -9151.2343750,13029.761800000444000,-9151.0019531,13030.236099999398000,
    -9150.9208984,13030.012800000608000,-9149.7265625,13031.590900000185000,-9150.3085938,13031.153000000864000,-9150.8496094,13030.435100000352000,-9150.9160156,13030.213700000197000
  ],
  "right_front_tire": [33, 34],
  "right_rear_tire": [35, 36],
  "left_front_glass":[12,13,14,15],
  "left_rear_glass":[16,17,18,19],
  "left_center_glass":[20,21,22,23,24],
  "right_front_glass":[37,38],
  "right_rear_glass":[39,40],
  "right_center_glass":[41,42,43,44,45]
}
app/src/main/java/safeluck/drive/evaluation/app.java
@@ -98,7 +98,7 @@
            //考试状态 ,一些初始状态,app一些状态应该先初始化一下
            initData();
            QbSdk.initX5Environment(this,cb);
//            QbSdk.initX5Environment(this,cb);
        }
@@ -150,7 +150,6 @@
    @Override
    public void callBackMsg(final int cmd, String json) {
        String strConent = String.format("收到命令[%d],Json内容为%s", cmd, json);
        Log.i(TAG,strConent);
        if (strConent.equalsIgnoreCase(lastStr)){
        }else{
app/src/main/java/safeluck/drive/evaluation/bean/CarModel.java
New file
@@ -0,0 +1,43 @@
package safeluck.drive.evaluation.bean;
/**
 * @ProjectName: DriveJudge
 * @Package: safeluck.drive.evaluation.bean
 * @ClassName: CarModel
 * @Description: java类作用描述
 * @Author: 李占伟
 * @CreateDate: 2020-06-03 15:22
 * @UpdateUser: 更新者
 * @UpdateDate: 2020-06-03 15:22
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class CarModel {
    private double distance;
    private double angle;
    public CarModel(double distance, double angle) {
        this.distance = distance;
        this.angle = angle;
    }
    public CarModel() {
    }
    public double getDistance() {
        return distance;
    }
    public void setDistance(double distance) {
        this.distance = distance;
    }
    public double getAngle() {
        return angle;
    }
    public void setAngle(double angle) {
        this.angle = angle;
    }
}
app/src/main/java/safeluck/drive/evaluation/bean/GisCarModel.java
New file
@@ -0,0 +1,146 @@
package safeluck.drive.evaluation.bean;
import java.util.List;
/**
 * @ProjectName: DriveJudge
 * @Package: safeluck.drive.evaluation.bean
 * @ClassName: GisCarModel
 * @Description: java类作用描述
 * @Author: 李占伟
 * @CreateDate: 2020-06-03 16:56
 * @UpdateUser: 更新者
 * @UpdateDate: 2020-06-03 16:56
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class GisCarModel {
    private List<Integer> axial;
    private List<Integer> body;
    private List<Integer> left_front_tire;
    private List<Integer> left_rear_tire;
    private List<Double> main_ant;
    private List<Double> point;
    private List<Integer> right_front_tire;
    private List<Integer> right_rear_tire;
    private List<Integer> left_front_glass;
    private List<Integer> left_rear_glass;
    private List<Integer> left_center_glass;
    private List<Integer> right_front_glass;
    private List<Integer> right_rear_glass;
    private List<Integer> right_center_glass;
    public List<Integer> getAxial() {
        return axial;
    }
    public void setAxial(List<Integer> axial) {
        this.axial = axial;
    }
    public List<Integer> getBody() {
        return body;
    }
    public void setBody(List<Integer> body) {
        this.body = body;
    }
    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<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<Double> getMain_ant() {
        return main_ant;
    }
    public void setMain_ant(List<Double> main_ant) {
        this.main_ant = main_ant;
    }
    public List<Double> getPoint() {
        return point;
    }
    public void setPoint(List<Double> point) {
        this.point = point;
    }
    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_front_glass() {
        return left_front_glass;
    }
    public void setLeft_front_glass(List<Integer> left_front_glass) {
        this.left_front_glass = left_front_glass;
    }
    public List<Integer> getLeft_rear_glass() {
        return left_rear_glass;
    }
    public void setLeft_rear_glass(List<Integer> left_rear_glass) {
        this.left_rear_glass = left_rear_glass;
    }
    public List<Integer> getLeft_center_glass() {
        return left_center_glass;
    }
    public void setLeft_center_glass(List<Integer> left_center_glass) {
        this.left_center_glass = left_center_glass;
    }
    public List<Integer> getRight_front_glass() {
        return right_front_glass;
    }
    public void setRight_front_glass(List<Integer> right_front_glass) {
        this.right_front_glass = right_front_glass;
    }
    public List<Integer> getRight_rear_glass() {
        return right_rear_glass;
    }
    public void setRight_rear_glass(List<Integer> right_rear_glass) {
        this.right_rear_glass = right_rear_glass;
    }
    public List<Integer> getRight_center_glass() {
        return right_center_glass;
    }
    public void setRight_center_glass(List<Integer> right_center_glass) {
        this.right_center_glass = right_center_glass;
    }
}
app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java
@@ -1,16 +1,66 @@
package safeluck.drive.evaluation.fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.arcgisservices.ArcGISMapServiceInfo;
import com.esri.arcgisruntime.data.ServiceFeatureTable;
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.geometry.SpatialReferences;
import com.esri.arcgisruntime.layers.ArcGISMapImageLayer;
import com.esri.arcgisruntime.layers.ArcGISMapImageSublayer;
import com.esri.arcgisruntime.layers.ArcGISSublayer;
import com.esri.arcgisruntime.layers.ArcGISTiledLayer;
import com.esri.arcgisruntime.layers.ArcGISVectorTiledLayer;
import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.layers.MobileBasemapLayer;
import com.esri.arcgisruntime.layers.SublayerList;
import com.esri.arcgisruntime.loadable.LoadStatus;
import com.esri.arcgisruntime.loadable.LoadStatusChangedEvent;
import com.esri.arcgisruntime.loadable.LoadStatusChangedListener;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.Viewpoint;
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.portal.Portal;
import com.esri.arcgisruntime.portal.PortalItem;
import com.esri.arcgisruntime.symbology.LineSymbol;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.util.ListenableList;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.bean.GisCarModel;
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.util.Utils;
/**驾校信息UI
 * MyApplication2
@@ -22,13 +72,325 @@
    public static SupportFragment newInstance(){
        return new JiaXiaoFragment();
    }
    private static final String TAG = JiaXiaoFragment.class.getSimpleName();
    private MapView mMapView ;
    GraphicsOverlay mGraphicsOverlay;
    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_jiaxiao_info,container,false);
        View view = inflater.inflate(R.layout.layout_arc_gis,container,false);
        mMapView = view.findViewById(R.id.mapView);
        setupMap();
        addTrailheadsLayer();
//        addImageLayer();
        addGraphicLayer();
//        drawPolygon();
        return view;
    }
    private SublayerList mSublayersList;
    private void setupMap() {
        if (mMapView != null) {
            ArcGISMap map = new ArcGISMap();
            mMapView.setMap(map);
            mGraphicsOverlay= new GraphicsOverlay();
            mMapView.getGraphicsOverlays().add(mGraphicsOverlay);
        }
    }
    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/";
        ArcGISMapImageLayer arcGISMapImageLayer = new ArcGISMapImageLayer(url);
        arcGISMapImageLayer.loadAsync();
        arcGISMapImageLayer.addLoadStatusChangedListener(loadStatusChangedEvent -> {
            if (loadStatusChangedEvent.getNewLoadStatus() == LoadStatus.LOADED){
                SublayerList tables = arcGISMapImageLayer.getSublayers();
                Log.i(TAG,"ServiceFeatureTables size = "+tables.size());
                for (int i = tables.size()-1; i >= 0; i--) {
        ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(url+String.valueOf(i));
        FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);
        ArcGISMap map = mMapView.getMap();
        map.getOperationalLayers().add(featureLayer);
    }
            }
        });
    }
    private void addGraphicLayer(){
        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));
        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));
                List<safeluck.drive.evaluation.bean.Point> carNew=Utils.getCarPoint(0,45,new safeluck.drive.evaluation.bean.Point(-8647.003,14590.7213));
                List<Integer> bodys =gisCarModel.getBody();
                for (int i = 0; i <bodys.size(); i++) {
                    Log.i(TAG,String.format("车身点位置:%d",bodys.get(i)));
                    Log.i(TAG,"新坐标"+carNew.get(bodys.get(i)).getX()+" Y="+carNew.get(bodys.get(i)).getY());
                    points.add(carNew.get(bodys.get(i)).getX(),carNew.get(bodys.get(i)).getY());
                }
                CThreadPoolExecutor.runOnMainThread(new Runnable() {
                    @Override
                    public void run() {
                        Polygon polygon = new Polygon(points);
                        Graphic graphic = new Graphic(polygon,simpleFillSymbol);
                        mGraphicsOverlay.getGraphics().clear();
                        mGraphicsOverlay.getGraphics().add(graphic);
                        drawrightCenterGls(gisCarModel,carNew);
                        drawPoint(new Point(-8647.003,14590.7213));
                    }
                });
            }
        });
    }
    private void drawPoint(Point point) {
        SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.WHITE, 5);
        Graphic graphic = new Graphic(point, simpleMarkerSymbol);
        mGraphicsOverlay.getGraphics().add(graphic);
    }
    private void drawrightCenterGls(GisCarModel gisCarModel, List<safeluck.drive.evaluation.bean.Point> carNew) {
        SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLACK, 0.5f);
        SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,0,0,0), lineSymbol);
        PointCollection points = new PointCollection(SpatialReference.create(4544));
        drawGlses(carNew, simpleFillSymbol, points, gisCarModel.getRight_center_glass());
        drawGlses(carNew, simpleFillSymbol, points, gisCarModel.getLeft_center_glass());
        List<Integer> frontCLs = new ArrayList<>();
        frontCLs.addAll(gisCarModel.getLeft_front_glass());
        frontCLs.addAll(gisCarModel.getRight_front_glass());
        drawGlses(carNew, simpleFillSymbol, points, frontCLs);
        frontCLs.clear();
        frontCLs.addAll(gisCarModel.getLeft_rear_glass());
        frontCLs.addAll(gisCarModel.getRight_rear_glass());
        drawGlses(carNew, simpleFillSymbol, points, frontCLs);
    }
    private void drawGlses(List<safeluck.drive.evaluation.bean.Point> carNew, SimpleFillSymbol simpleFillSymbol, PointCollection points, List<Integer> left_center_glass) {
        List<Integer> leftCenterGls = left_center_glass;
        points.clear();
        for (int i = 0; i < leftCenterGls.size(); i++) {
            int pos = leftCenterGls.get(i);
            points.add(carNew.get(pos).getX(), carNew.get(pos).getY());
        }
        Polygon polygon1 = new Polygon(points);
        Graphic graphic1 = new Graphic(polygon1, simpleFillSymbol);
        mGraphicsOverlay.getGraphics().add(graphic1);
    }
    /**
     * 绘制面
     */
    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);
            }
        });
    }
private void addImageLayer(){
            String url = "http://192.168.0.47:6080/arcgis/rest/services/%E5%9C%9F%E4%B8%BB%E8%80%83%E5%9C%BA/MobileServer";
    // create a MapImageLayer with dynamically generated map images
    final ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(url);
//    mapImageLayer.loadAsync();
    // Add a listener that is invoked when layer loading has completed.
    mapImageLayer.addDoneLoadingListener(() -> {
        if (mapImageLayer.getLoadStatus() == LoadStatus.LOADED) {
            ArcGISMapServiceInfo mapServiceInfo = mapImageLayer.getMapServiceInfo();
            Log.i(TAG, "addImageLayer: 加载完成。。。");
            // work with map service info here
        }
    });
    // create an empty map instance
    ArcGISMap map = new ArcGISMap();
    // add map image layer as operational layer
    map.getOperationalLayers().add(mapImageLayer);
    // set the map to be displayed in this view
    mMapView.setMap(map);
}
private void addtiledLayer(){
//    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/manager/service.html?name=SampleWorldCities.MapServer";
    // create a MapImageLayer with dynamically generated map images
    final ArcGISTiledLayer arcGISTiledLayer = new ArcGISTiledLayer(url);
    // Add a listener that is invoked when layer loading has completed.
    arcGISTiledLayer.addDoneLoadingListener(() -> {
        if (arcGISTiledLayer.getLoadStatus() == LoadStatus.LOADED) {
            // work with map service info here
            Log.i(TAG,"ArcGISTiledLayer加载完成");
        }
    });
    Basemap basemap = new Basemap(arcGISTiledLayer);
    // create a map with the basemap
    ArcGISMap arcGISMap = new ArcGISMap(basemap);
    // set the map to be displayed in this view
    mMapView.setMap(arcGISMap);
}
private void addVectorTiledLayer(){
    String url = "http://192.168.0.47:6080/arcgis/rest/services/%E5%9C%9F%E4%B8%BB%E8%80%83%E5%9C%BA/MapServer";
    // create a MapImageLayer with dynamically generated map images
    final ArcGISVectorTiledLayer mVectorTiledLayer = new ArcGISVectorTiledLayer(url);
    // Add a listener that is invoked when layer loading has completed.
    mVectorTiledLayer.addDoneLoadingListener(() -> {
        if (mVectorTiledLayer.getLoadStatus() == LoadStatus.LOADED) {
            // work with map service info here
            Log.i(TAG,"ArcGISTiledLayer加载完成");
        }
    });
    Basemap basemap = new Basemap(mVectorTiledLayer);
    // create a map with the basemap
    ArcGISMap arcGISMap = new ArcGISMap(basemap);
    Viewpoint vp = new Viewpoint(47.606726, -122.335564, 72223.819286);
    arcGISMap.setInitialViewpoint(vp);
    // set the map to be displayed in this view
    mMapView.setMap(arcGISMap);
}
    @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() {
        if (mMapView != null) {
            mMapView.dispose();
        }
        super.onDetach();
    }
}
app/src/main/java/safeluck/drive/evaluation/util/Utils.java
@@ -8,6 +8,7 @@
import com.anyun.exam.lib.MyLog;
import com.anyun.exam.lib.util.ByteUtil;
import com.google.gson.Gson;
import com.safeluck.aykj.utils.BytesUtils;
import java.io.File;
@@ -37,7 +38,11 @@
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.bean.CarModel;
import safeluck.drive.evaluation.bean.GisCarModel;
import safeluck.drive.evaluation.bean.Point;
import safeluck.drive.evaluation.httpmodule.GsonConverterFactory;
import static java.lang.Math.cos;
import static java.lang.Math.pow;
@@ -656,4 +661,82 @@
        }
    }
    public static List<CarModel> getCarModelData(Point basePoint, List<Integer> axial, List<Point> car){
        List<CarModel> carModelList = new ArrayList<>();
        double C02= (car.get(0).getX()-basePoint.getX())*(car.get(0).getX()-basePoint.getX()) + (car.get(0).getY()-basePoint.getY())*(car.get(0).getY()-basePoint.getY());
        double c0 = Math.sqrt(C02);
        CarModel carModel = new CarModel();
        carModel.setDistance(c0);
        carModel.setAngle(0.0);
        carModelList.add(carModel);
        for (int i = 1; i < car.size(); ++i) {
            double dis2 = (car.get(i).getX()-basePoint.getX())*(car.get(i).getX()-basePoint.getX()) + (car.get(i).getY()-basePoint.getY())*(car.get(i).getY()-basePoint.getY());
            double dis = Math.sqrt(dis2);
            CarModel c =new CarModel();
            c.setDistance(dis);
            c.setAngle(180 * Math.acos((dis2 + C02 - ((car.get(i).getX()-car.get(0).getX())*(car.get(i).getX()-car.get(0).getX()) +
                    (car.get(i).getY()-car.get(0).getY())*(car.get(i).getY()-car.get(0).getY())))/(2*c0*dis)) / Math.PI);
            if (i > axial.get(1)){
                c.setAngle( 360.0 - c.getAngle());
            }
            carModelList.add(c);
        }
        return carModelList;
    }
    public static List<Point> getCarPoint(double pitch,double yaw,Point point){
        pitch = 0;
        yaw = 45;
        Point main_ant = point;
        List<Point> carNew = new ArrayList<>();
        StringBuffer buffer=FileUtil.readAssetTxtFile(app.getAppContext(),"giscar.json");
        Log.i(TAG,"giscar="+buffer.toString());
        GisCarModel gisCarModel= new Gson().fromJson(buffer.toString(),GisCarModel.class);
        List<Point> pointList = new ArrayList<Point>() ;
        for (int i = 0; i < gisCarModel.getPoint().size(); i++) {
                double x= gisCarModel.getPoint().get(i);
                i++;
                double y= gisCarModel.getPoint().get(i);
                pointList.add(new Point(x,y));
        }
        List<CarModel> carModels = getCarModelData(new Point(-9151.5063, 13030.5118),gisCarModel.getAxial(),pointList);
        if (carModels != null && carModels.size()>0){
            for (int i = 0; i < carModels.size(); ++i) {
                Log.i(TAG,String.format("位置[%d],distance=%f,angle=%f",i,carModels.get(i).getDistance(),carModels.get(i).getAngle()));
                double qrx = carModels.get(i).getDistance() * Math.sin(carModels.get(i).getAngle() * Math.PI / 180);
                double qry = carModels.get(i).getDistance() * Math.cos(carModels.get(i).getAngle() * Math.PI / 180) * Math.cos(pitch * Math.PI / 180);
                double projectDistance = Math.sqrt(Math.pow(qrx, 2) + Math.pow(qry, 2));
                double projectAngle = Math.acos(qry / projectDistance) * 180 / Math.PI;
                if (carModels.get(i).getAngle() > 180) {
                    projectAngle = 360 - projectAngle;
                }
                double X =
                        projectDistance * Math.sin(yaw * Math.PI / 180) * Math.cos(projectAngle * Math.PI / 180) -
                                projectDistance * Math.cos(yaw * Math.PI / 180) * Math.sin(projectAngle * Math.PI / 180) +
                                main_ant.getX();
                double Y =
                        projectDistance * Math.sin(yaw * Math.PI / 180) * Math.sin(projectAngle * Math.PI / 180) +
                                projectDistance * Math.cos(yaw * Math.PI / 180) * Math.cos(projectAngle * Math.PI / 180) +
                                main_ant.getY();
                carNew.add(new Point(X,Y));
            }
        }
        return carNew;
    }
}
app/src/main/res/layout/layout_arc_gis.xml
New file
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
   >
    <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>
</RelativeLayout>
app/src/main/res/values/app_settings.xml
New file
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="arcgis_license_key">YOUR_LICENSE_KEY</string>
</resources>
build.gradle
@@ -7,6 +7,7 @@
        jcenter()
        
    }
    ext{
        roomVersion  ='2.2.1'
        workVersion  ='2.2.0'
@@ -28,6 +29,9 @@
    repositories {
        google()
        jcenter()
        maven {
            url 'https://esri.bintray.com/arcgis'
        }
        
    }
}