Commit 8753c057 by Luosp

增加热力图功能

parent 429f6c96
......@@ -55,9 +55,9 @@ public class MainActivity extends AppCompatActivity {
.setDefaultArcGisCompass()//设置默认罗盘
// .setOpenNavi()//开启导航
// .setOpenSearch()//开启搜索
// .setOpenHotPots()//开启热力图
// .setOpenCluster()//开启聚合
.setOpenDraw()//开启绘制
// .setOpenHotPots()//开启热力图
// .setOpenDraw()//开启绘制
.createArcGisFounder();//创建ArcGisFounder地图实例
IArcGisZoomOption iArcGisZoomOption = arcGisFounder.arcGisZoomOption();
......@@ -151,5 +151,27 @@ public class MainActivity extends AppCompatActivity {
// + "\n补充信息:" + locationModel.getExtraInfo()
// , Toast.LENGTH_LONG).show());
// IArcGisHotPotsOption iArcGisHotPotsOption = arcGisFounder.arcGisHotPotsOption();
//
// List<PointModel> pointList = new ArrayList<>();
// pointList.add(new PointModel(113.935576,22.995918));
// pointList.add(new PointModel(113.959722,23.000176));
// pointList.add(new PointModel(113.97582,22.949069));
// pointList.add(new PointModel(113.952823,22.916051));
// pointList.add(new PointModel(114.019513,22.951198));
// iArcGisHotPotsOption.setHotPotsPonitData(pointList);
// IArcGisDrawOption iArcGisDrawOption = arcGisFounder.arcGisDrawOption();
//
// List<PointModel> pointList = new ArrayList<>();
// pointList.add(new PointModel(113.935576,22.995918));
// pointList.add(new PointModel(113.959722,23.000176));
// pointList.add(new PointModel(113.97582,22.949069));
// pointList.add(new PointModel(113.952823,22.916051));
// pointList.add(new PointModel(114.019513,22.951198));
// iArcGisDrawOption.setDrawPointData("CIRCLE",pointList);
}
}
......@@ -54,6 +54,7 @@ android {
}
dependencies {
//导航
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
......@@ -62,12 +63,12 @@ dependencies {
api 'com.esri.arcgisruntime:arcgis-android:100.6.0'
//权限
implementation 'com.yanzhenjie:permission:2.0.3'
//日志
//日志
implementation 'com.jakewharton.timber:timber:4.5.1'
//工具类
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.mapzen.android:lost:2.1.2'
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
}
apply from: '../mvn_push.gradle'
......@@ -9,7 +9,7 @@ package cn.com.founder.arcgislib.constants;
*/
public class Constants {
/*****************************************互联网*********************************************/
/*****************************************互联网*********************************************
//互联网-地图
private static String baseUrl = "http://47.92.225.109:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//互联网-Geo
......@@ -18,54 +18,74 @@ public class Constants {
private static String searchUrl = "http://47.92.226.24:8051/selectPoiDataList";
//互联网-导航
private static String naviUrl = "minedata.cn/lbsservice/navi/";
//二标四实-单位
private static String dwUrl = "http://68.174.69.46:8051/selectVdwjx";
//二标四实-房屋
private static String fwUrl = "http://68.174.69.46:8051/selectVfwjx";
//二标四实-地址
private static String dzUrl = "http://68.174.69.46:8051/selectVdzjx";
//二标四实-单位
private static String dwUrl = "http://68.174.69.46:8051/selectVdwjx";
//二标四实-房屋
private static String fwUrl = "http://68.174.69.46:8051/selectVfwjx";
//二标四实-地址
private static String dzUrl = "http://68.174.69.46:8051/selectVdzjx";
//华为网关鉴权服务-accessToken(导航时调用)
private static String apiGUrl = "https://68.26.19.197:8343/v1/apigw/oauth2/token";
//华为网关鉴权服务-userToken(导航时调用)
private static String apiGLoginUrl = "http://68.26.19.197:8380/dcuc/api/checklogin.action";
//热力图
private static String hotMapUrl = "http://47.92.225.109:6080/arcgis/rest/services/gp/rltModel/GPServer/hotPotServer";
/**********************************************************************************************
// private static String hotMapUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot";
/**********************************************************************************************/
/*****************************************用户网***********************************************
//如果使用公安局的映射,导航907和958行代码需要修改坐标系
//用户网-地图
private static String baseUrl = "http://192.168.2.56:19076/arcgis/rest/services/founder/dg20191120/MapServer";
//用户网-导航
private static String naviUrl = "http://192.168.2.56:19085/PPmap/LBSservice";
//公安网-Geo
private static String baseGeoUrl = "http://192.168.2.56:19087/esBzdzTestQuery";
//用户网-搜索
private static String searchUrl = "http://192.168.2.56:19084/selectPoiDataList";
//二标四实-单位
private static String dwUrl = "http://192.168.2.56:19084/selectVdwjx";
//二标四实-房屋
private static String fwUrl = "http://192.168.2.56:19084/selectVfwjx";
//二标四实-地址
private static String dzUrl = "http://192.168.2.56:19084/selectVdzjx";
/**********************************************************************************************/
/*****************************************用户网***********************************************/
//如果使用公安局的映射,导航907和958行代码需要修改坐标系
//用户网-地图
private static String baseUrl = "http://192.168.2.56:19076/arcgis/rest/services/founder/dg20191120/MapServer";
//用户网-导航
private static String naviUrl = "http://192.168.2.56:19085/PPmap/LBSservice";
//公安网-Geo
private static String baseGeoUrl = "http://192.168.2.56:19087/esBzdzTestQuery";
//用户网-搜索
private static String searchUrl = "http://192.168.2.56:19084/selectPoiDataList";
//二标四实-单位
private static String dwUrl = "http://192.168.2.56:19084/selectVdwjx";
//二标四实-房屋
private static String fwUrl = "http://192.168.2.56:19084/selectVfwjx";
//二标四实-地址
private static String dzUrl = "http://192.168.2.56:19084/selectVdzjx";
//华为网关鉴权服务-accessToken(导航时调用)
private static String apiGUrl = "https://68.26.19.197:8343/v1/apigw/oauth2/token";
//华为网关鉴权服务-userToken(导航时调用)
private static String apiGLoginUrl = "http://68.26.19.197:8380/dcuc/api/checklogin.action";
//热力图
private static String hotMapUrl = "http://192.168.2.56:19088/arcgis/rest/services/gp/rltModel/GPServer/hotPotServer";
/**********************************************************************************************
/*****************************************公安网***********************************************
//公安网-地图
private static String baseUrl = "http://68.174.69.45:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//公安网-Geo
private static String baseGeoUrl = "http://68.174.25.107:8090/esBzdzTestQuery";
//公安网-搜索
private static String searchUrl = "http://68.174.69.46:8051/selectPoiDataList";
//公安网-导航
private static String naviUrl = "http://68.26.19.197:8380/PPmap/LBSservice";
//公安网-地图
private static String baseUrl = "http://68.174.69.45:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//公安网-Geo
private static String baseGeoUrl = "http://68.174.25.107:8090/esBzdzTestQuery";
//公安网-搜索
private static String searchUrl = "http://68.174.69.46:8051/selectPoiDataList";
//公安网-导航
// private static String naviUrl = "http://68.26.19.197:8380/PPmap/LBSservice";
private static String naviUrl = "68.26.19.197:8380/PPmap/LBSservice2/";
//二标四实-单位
private static String dwUrl = "http://68.174.69.46:8051/selectVdwjx";
//二标四实-房屋
private static String fwUrl = "http://68.174.69.46:8051/selectVfwjx";
//二标四实-地址
private static String dzUrl = "http://68.174.69.46:8051/selectVdzjx";
//华为网关鉴权服务-accessToken(导航时调用)
private static String apiGUrl = "https://68.26.19.197:8343/v1/apigw/oauth2/token";
//华为网关鉴权服务-userToken(导航时调用)
private static String apiGLoginUrl = "http://68.26.19.197:8380/dcuc/api/checklogin.action";
//热力图
private static String hotMapUrl = "http://68.174.69.45:6081/arcgis/rest/services/gp/rltModel/GPServer/hotPotServer";
/**********************************************************************************************/
/**********************************************************************************************/
// argis证书
private static String baseRunTime = "runtimelite,1000,rud9526010123,none,XXMFA0PL4S0MC2EN0175";
......@@ -73,9 +93,11 @@ public class Constants {
private static String baseTianDiTuKey = "39edeab91620fe3c5a1b282228ef6e46";
//天地图Geo
private static String baseTianDiTuGeoUrl = "http://api.tianditu.gov.cn/geocoder";
//测试热力图
private static String hotPotsUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot";
//华为鉴权
private static String baseHuaweiAuthA = "445281199401182770";
private static String baseHuaweiAuthP = "JWY123@cjh";
private static String baseHuaweiAuthAppKey = "2a1c50f40af443a4b58d1375e87a4810";
private static String baseHuaweiAuthAppSecret = "1321cbbf9f3947108aee3f44ea007485";
//arcGis证书
public static final String BASE_MAP_RUNTIME = baseRunTime;
//服务器Url
......@@ -91,7 +113,7 @@ public class Constants {
//导航
public static final String BASE_NAVI_URL = naviUrl;
//热力图
public static final String BASE_HOT_POTS_URL = hotPotsUrl;
public static final String BASE_HOT_POTS_URL = hotMapUrl;
//二标四实-房屋
public static final String BASE_FW_URL = fwUrl;
......@@ -100,4 +122,15 @@ public class Constants {
//二标四实-单位
public static final String BASE_DW_URL = dwUrl;
//华为网关鉴权服务-accessToken
public static final String BASE_APIG_URL = apiGUrl;
//华为鉴权
public static final String BASE_HUA_WEI_AUTHA = baseHuaweiAuthA;
public static final String BASE_HUA_WEI_AUTHP = baseHuaweiAuthP;
public static final String BASE_HUA_WEI_AUTH_APPKEY = baseHuaweiAuthAppKey;
public static final String BASE_HUA_WEI_AUTH_APP_SECRET = baseHuaweiAuthAppSecret;
//华为网关鉴权服务-userToken
public static final String BASE_APIG_LOGIN_URL = apiGLoginUrl;
}
package cn.com.founder.arcgislib.draw;
import java.util.List;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.draw.option.IArcGisDrawOption;
import cn.com.founder.arcgislib.model.PointModel;
import cn.com.founder.arcgislib.view.ArcGisDrawView;
/**
......@@ -38,4 +41,18 @@ public class ArcGisDraw implements IArcGisDrawOption {
mArcGisDrawView.setDrawImage(drawImage);
return this;
}
/**
* @param canvaType 绘制类型:
* "LINE" 线
* "POLYGON" 多边形
* "ORTHOGON" 矩形
* "CIRCLE" 圆
* @param pointModelList 数据集合点
*/
@Override
public IArcGisDrawOption setDrawPointData(String canvaType, List<PointModel> pointModelList) {
mArcGisDrawView.setDrawPointData(canvaType,pointModelList);
return this;
}
}
package cn.com.founder.arcgislib.draw.option;
import java.util.List;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.model.PointModel;
/**
* Copyright: 方正国际软件有限公司
......@@ -25,4 +28,14 @@ public interface IArcGisDrawOption {
* @param drawImage int(资源ID)-绘制图片
*/
IArcGisDrawOption setDrawImage(int drawImage);
/**
* @param canvaType 绘制类型:
* "LINE" 线
* "POLYGON" 多边形
* "ORTHOGON" 矩形 2的倍数点
* "CIRCLE" 圆 2的倍数点
* @param pointModelList 数据集合点
*/
IArcGisDrawOption setDrawPointData(String canvaType, List<PointModel> pointModelList);
}
package cn.com.founder.arcgislib.hotpots;
import java.util.List;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.hotpots.option.IArcGisHotPotsOption;
import cn.com.founder.arcgislib.model.PointModel;
import cn.com.founder.arcgislib.view.ArcGisHotPotsView;
/**
......@@ -37,4 +40,10 @@ public class ArcGisHotPots implements IArcGisHotPotsOption {
mArcGisHotPots.setHotPotsImage(hotPotsImage);
return this;
}
@Override
public IArcGisHotPotsOption setHotPotsPonitData(List<PointModel> pointList) {
mArcGisHotPots.setHotPotsPointData(pointList);
return this;
}
}
package cn.com.founder.arcgislib.hotpots.option;
import java.util.List;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.model.PointModel;
/**
* Copyright: 方正国际软件有限公司
......@@ -25,4 +28,9 @@ public interface IArcGisHotPotsOption {
* @param hotPotsImage int(资源ID)-热力图图片
*/
IArcGisHotPotsOption setHotPotsImage(int hotPotsImage);
/**
* @param pointList 点集合
*/
IArcGisHotPotsOption setHotPotsPonitData(List<PointModel> pointList);
}
......@@ -19,11 +19,20 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import cn.com.founder.arcgislib.common.Variable;
/**
......@@ -277,4 +286,46 @@ public class ToolUtil {
return null;
}
//获取这个SSLSocketFactory
public static SSLSocketFactory getSSLSocketFactory() {
try {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, getTrustManager(), new SecureRandom());
return sslContext.getSocketFactory();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
//获取TrustManager
private static TrustManager[] getTrustManager() {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
};
return trustAllCerts;
}
//获取HostnameVerifier
public static HostnameVerifier getHostnameVerifier() {
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
};
return hostnameVerifier;
}
}
......@@ -169,7 +169,6 @@ public class ArcGisClusterView extends LinearLayout implements View.OnClickListe
mPointCollection = new PointCollection(SpatialReference.create(4326));
mClusterStyleBuilder = new ClusterStyleBuilder(mContext);
// addFeatureLayer();
}
......@@ -193,6 +192,10 @@ public class ArcGisClusterView extends LinearLayout implements View.OnClickListe
@Override
public void onClick(View view) {
if(clusterLayer == null){
return;
}
if (isClean) {
graphicsOverlay.setVisible(false);
clusterLayer.setGraphicVisible(false);
......
package cn.com.founder.arcgislib.view;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
......@@ -8,13 +9,19 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.mapping.view.MapView;
import java.util.List;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.model.PointModel;
import cn.com.founder.arcgislib.widget.draw.DrawEntity;
import cn.com.founder.arcgislib.widget.draw.DrawLayer;
import cn.com.founder.arcgislib.widget.draw.DrawView;
......@@ -235,6 +242,54 @@ public class ArcGisDrawView extends LinearLayout implements View.OnClickListener
mDrawIv.setImageDrawable(getResources().getDrawable(drawImage));
}
public void setDrawPointData(String canvaType, List<PointModel> pointModelList){
if(TextUtils.isEmpty(canvaType)){
Toast.makeText(mContext, "请设置绘画类型", Toast.LENGTH_LONG).show();
return;
}
boolean isEmpty = pointModelList == null || pointModelList.isEmpty();
if (isEmpty) {
Toast.makeText(mContext, "暂无数据源", Toast.LENGTH_LONG).show();
return;
}
if(canvaType.equals("LINE")){//线
drawType = Variable.DrawType.LINE;
mDrawView.endMeasure();
}else if(canvaType.equals("POLYGON")){//多边形
drawType = Variable.DrawType.POLYGON;
mDrawView.endMeasure();
}else if(canvaType.equals("ORTHOGON")){//矩形
drawType= Variable.DrawType.ORTHOGON;
}else if(canvaType.equals("CIRCLE")){//圆
drawType= Variable.DrawType.CIRCLE;
}
for (PointModel pointModel : pointModelList) {
double x = pointModel.getxPoint();
double y = pointModel.getyPoint();
if(x < 0 || y < 0){
break;
}
Point point = new Point(x, y, SpatialReference.create(4326));
if(drawType==Variable.DrawType.LINE) {
mDrawView.drawPointLine(point);
}else if(drawType==Variable.DrawType.POLYGON){
mDrawView.drawPointPolygon(point);
}else if(drawType == Variable.DrawType.CIRCLE){
mDrawView.drawCircle(point);
}else if(drawType == Variable.DrawType.ORTHOGON){
mDrawView.drawBox(point);
}
}
drawType = null;
DrawEntity draw = mDrawView.endMeasure();
}
@Override
public void onMapSingleTapUp(MotionEvent e) {
......
package cn.com.founder.arcgislib.view;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
......@@ -22,7 +16,9 @@ import androidx.annotation.Nullable;
import com.esri.arcgisruntime.concurrent.Job;
import com.esri.arcgisruntime.concurrent.ListenableFuture;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.layers.ArcGISMapImageLayer;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.tasks.geoprocessing.GeoprocessingJob;
import com.esri.arcgisruntime.tasks.geoprocessing.GeoprocessingParameters;
......@@ -30,17 +26,18 @@ import com.esri.arcgisruntime.tasks.geoprocessing.GeoprocessingResult;
import com.esri.arcgisruntime.tasks.geoprocessing.GeoprocessingString;
import com.esri.arcgisruntime.tasks.geoprocessing.GeoprocessingTask;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.constants.Constants;
import cn.com.founder.arcgislib.utils.ToolUtil;
import cn.com.founder.arcgislib.model.PointModel;
import cn.com.founder.arcgislib.widget.popup.PopupLayout;
/**
......@@ -99,19 +96,6 @@ public class ArcGisHotPotsView extends LinearLayout implements View.OnClickListe
private GeoprocessingJob mGeoprocessingJob;
/**
* {@link SimpleDateFormat}
*/
private SimpleDateFormat mSimpleDateFormatter;
/**
* 最小日期
*/
private Date mMinDate;
/**
* 最大日期
*/
private Date mMaxDate;
/**
* 是否取消
*/
private boolean canceled;
......@@ -120,6 +104,13 @@ public class ArcGisHotPotsView extends LinearLayout implements View.OnClickListe
* 是否清除热力图
*/
private boolean isClean;
/**
* 实际数据源
*/
private List<PointModel> pointList = new ArrayList<>();
private GraphicsOverlay mPointOverlay;
public ArcGisHotPotsView(Context context, ArcGisMapView arcGisMapView){
......@@ -127,21 +118,17 @@ public class ArcGisHotPotsView extends LinearLayout implements View.OnClickListe
this.mContext = context;
this.mArcGisMapView = arcGisMapView;
this.mMapView = arcGisMapView.getMapView();
mSimpleDateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
mPointOverlay = new GraphicsOverlay();
mPointOverlay.setOpacity(0.8f);
mMapView.getGraphicsOverlays().add(mPointOverlay);
// map.setInitialViewpoint(new Viewpoint(
// new Envelope(-13893029.0, 3573174.0, -12038972.0, 5309823.0, SpatialReferences.getWebMercator())));
mGeoprocessingTask = new GeoprocessingTask(Constants.BASE_HOT_POTS_URL);
mGeoprocessingTask.loadAsync();
try {
mMinDate = mSimpleDateFormatter.parse("1998-01-01");
mMaxDate = mSimpleDateFormatter.parse("1998-05-31");
} catch (ParseException e) {
e.printStackTrace();
}
}
private ArcGisHotPotsView(Context context) {
this(context,null,0);
}
......@@ -159,73 +146,46 @@ public class ArcGisHotPotsView extends LinearLayout implements View.OnClickListe
mHotPotsIv.setOnClickListener(this);
}
public void setHotPotsPointData(List<PointModel> pointModelList){
boolean isEmpty = pointModelList == null || pointModelList.isEmpty();
if (isEmpty) {
Toast.makeText(mContext, "暂无数据源", Toast.LENGTH_LONG).show();
return;
}
// pointList = pointModelList;
//
// for (PointModel pointModel : pointModelList) {
// double x = pointModel.getxPoint();
// double y = pointModel.getyPoint();
//
// if(x < 0 || y < 0){
// break;
// }
//
// Point point = new Point(x, y, SpatialReference.create(4326));
// mPointOverlay.getGraphics().add(new Graphic(point));
// }
pointModelList.add(new PointModel(114.26742553710938,23.152313232421875));
pointModelList.add(new PointModel(114.26742553710938,22.646942138671875));
pointModelList.add(new PointModel(113.50799560546875,22.646942138671875));
pointModelList.add(new PointModel(113.50799560546875,23.152313232421875));
pointList = pointModelList;
analyzeHotspots();
}
@Override
public void onClick(View view) {
if(isClean){
mMapView.getMap().getOperationalLayers().clear();
}else{
setPopupLayout();
analyzeHotspots();
}
isClean = !isClean;
}
private void setPopupLayout() {
if (bottomParentView == null) {
bottomParentView = View.inflate(mContext, R.layout.layout_hot_pots_input, null);
initBottomView();
popupLayout = new PopupLayout(mContext, bottomParentView);
popupLayout.setUseRadius(true);
popupLayout.setHeight((int) (ToolUtil.getScreenHeight(mContext) * 0.35), false);
}
popupLayout.show(PopupLayout.POSITION_BOTTOM);
}
private void initBottomView() {
ImageView closeIv = bottomParentView.findViewById(R.id.hotpots_close_iv);
RelativeLayout startRl = bottomParentView.findViewById(R.id.hotpots_start_rl);
startTimeTv = bottomParentView.findViewById(R.id.hotpots_start_time_tv);
RelativeLayout endRl = bottomParentView.findViewById(R.id.hotpots_end_rl);
endTimeTv = bottomParentView.findViewById(R.id.hotpots_end_time_tv);
TextView finishTv = bottomParentView.findViewById(R.id.hotpots_finish_tv);
startTimeTv.setOnClickListener(view -> {
showCalendar(Variable.InputCalendar.START);
});
endTimeTv.setOnClickListener(view -> {
String startStr = startTimeTv.getText().toString().trim();
if (TextUtils.isEmpty(startStr)) {
Animation shakeAnimation = AnimationUtils.loadAnimation(mContext, R.anim.anim_shake);
startRl.startAnimation(shakeAnimation);
return;
}
showCalendar(Variable.InputCalendar.END);
});
closeIv.setOnClickListener(view -> {
popupLayout.dismiss();
});
finishTv.setOnClickListener(view -> {
String startStr = startTimeTv.getText().toString().trim();
String endStr = endTimeTv.getText().toString().trim();
if (TextUtils.isEmpty(startStr)) {
Animation shakeAnimation = AnimationUtils.loadAnimation(mContext, R.anim.anim_shake);
startRl.startAnimation(shakeAnimation);
return;
}
if (TextUtils.isEmpty(endStr)) {
Animation shakeAnimation = AnimationUtils.loadAnimation(mContext, R.anim.anim_shake);
endRl.startAnimation(shakeAnimation);
return;
}
analyzeHotspots(startStr,endStr);
popupLayout.dismiss();
});
}
/**
* @param isShow boolean-是否显示热力图布局
* 默认显示
......@@ -269,62 +229,10 @@ public class ArcGisHotPotsView extends LinearLayout implements View.OnClickListe
}
/**
* Shows a date picker dialog and writes the date chosen to the correct editable text.
*
*/
private void showCalendar(Variable.InputCalendar inputCalendar) {
// create a date set listener
DatePickerDialog.OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
// build the correct date format for the query
StringBuilder date = new StringBuilder()
.append(year)
.append("-")
.append(month + 1)
.append("-")
.append(dayOfMonth);
// set the date to correct text view
if (inputCalendar == Variable.InputCalendar.START) {
startTimeTv.setText(date);
try {
// limit the min date to after from date
mMinDate = mSimpleDateFormatter.parse(date.toString());
} catch (ParseException e) {
e.printStackTrace();
}
} else if (inputCalendar == Variable.InputCalendar.END) {
endTimeTv.setText(date);
try {
// limit the maximum date to before the to date
mMaxDate = mSimpleDateFormatter.parse(date.toString());
} catch (ParseException e) {
e.printStackTrace();
}
}
}
};
// define the date picker dialog
Calendar calendar = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(mContext, onDateSetListener,
calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.getDatePicker().setMinDate(mMinDate.getTime());
datePickerDialog.getDatePicker().setMaxDate(mMaxDate.getTime());
if (inputCalendar == Variable.InputCalendar.START) {
// start from calendar from min date
datePickerDialog.updateDate(1998, 0, 1);
}
datePickerDialog.show();
}
/**
* Runs the geoprocessing job, updating progress while loading. On job done, loads the resulting
* ArcGISMapImageLayer to the map and resets the Viewpoint of the MapView.
*
* @param startTime string which holds a date
* @param endTime string which holds a date
*/
private void analyzeHotspots(final String startTime, final String endTime) {
private void analyzeHotspots() {
// cancel previous job request
if (mGeoprocessingJob != null) {
mGeoprocessingJob.cancel();
......@@ -338,73 +246,169 @@ public class ArcGisHotPotsView extends LinearLayout implements View.OnClickListe
Toast.makeText(mContext, "请稍等...", Toast.LENGTH_LONG).show();
// parameters
final ListenableFuture<GeoprocessingParameters> paramsFuture = mGeoprocessingTask.createDefaultParametersAsync();
paramsFuture.addDoneListener(new Runnable() {
@Override public void run() {
paramsFuture.addDoneListener(() -> {
try {
GeoprocessingParameters geoprocessingParameters = paramsFuture.get();
geoprocessingParameters.setProcessSpatialReference(SpatialReference.create(4326));
// geoprocessingParameters.setOutputSpatialReference(mMapView.getSpatialReference());
geoprocessingParameters.setOutputSpatialReference(SpatialReference.create(4326));
JSONObject jsonObject = new JSONObject();
try {
GeoprocessingParameters geoprocessingParameters = paramsFuture.get();
geoprocessingParameters.setProcessSpatialReference(mMapView.getSpatialReference());
geoprocessingParameters.setOutputSpatialReference(mMapView.getSpatialReference());
StringBuilder queryString = new StringBuilder("(\"DATE\" > date '")
.append(startTime)
.append(" 00:00:00' AND \"DATE\" < date '")
.append(endTime)
.append(" 00:00:00')");
geoprocessingParameters.getInputs().put("Query", new GeoprocessingString(queryString.toString()));
Log.e(TAG, "Query: " + queryString.toString());
// create job
mGeoprocessingJob = mGeoprocessingTask.createJob(geoprocessingParameters);
// start job
mGeoprocessingJob.start();
// create a dialog to show progress of the geoprocessing job
final ProgressDialog progressDialog = new ProgressDialog(mContext);
progressDialog.setTitle("正在加载...");
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(100);
progressDialog.setCancelable(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", (dialog, which) -> {
dialog.dismiss();
// set canceled flag to true
canceled = true;
mGeoprocessingJob.cancel();
});
progressDialog.show();
// update progress
mGeoprocessingJob.addProgressChangedListener(() -> progressDialog.setProgress(mGeoprocessingJob.getProgress()));
mGeoprocessingJob.addJobDoneListener(() -> {
progressDialog.dismiss();
if (mGeoprocessingJob.getStatus() == Job.Status.SUCCEEDED) {
Log.i(TAG, "Job succeeded.");
GeoprocessingResult geoprocessingResult = mGeoprocessingJob.getResult();
final ArcGISMapImageLayer hotspotMapImageLayer = geoprocessingResult.getMapImageLayer();
// add the new layer to the map
mMapView.getMap().getOperationalLayers().add(hotspotMapImageLayer);
hotspotMapImageLayer.addDoneLoadingListener(() -> {
// set the map viewpoint to the MapImageLayer, once loaded
mMapView.setViewpointGeometryAsync(hotspotMapImageLayer.getFullExtent());
});
} else if (canceled) {
Toast.makeText(mContext, "热力图加载取消", Toast.LENGTH_SHORT).show();
Log.i(TAG, "Job cancelled.");
} else {
Log.e(TAG, "Job did not succeed!");
Toast.makeText(mContext, "热力图加载失败!", Toast.LENGTH_LONG).show();
}
});
} catch (InterruptedException | ExecutionException e) {
jsonObject.put("displayFieldName","");
jsonObject.put("geometryType","esriGeometryPoint");
JSONObject spatialObject = new JSONObject();
spatialObject.put("wkid",4326);
spatialObject.put("latestWkid",4326);
jsonObject.put("spatialReference",spatialObject);
JSONArray fieldsArray = new JSONArray();
JSONObject fieldOneObject = new JSONObject();
fieldOneObject.put("name","FID");
fieldOneObject.put("type","esriFieldTypeOID");
fieldOneObject.put("alias","FID");
JSONObject fieldTwoObject = new JSONObject();
fieldTwoObject.put("name","x");
fieldTwoObject.put("type","esriFieldTypeDouble");
fieldTwoObject.put("alias","x");
JSONObject fieldThreeObject = new JSONObject();
fieldThreeObject.put("name","y");
fieldThreeObject.put("type","esriFieldTypeDouble");
fieldThreeObject.put("alias","y");
fieldsArray.put(fieldOneObject);
fieldsArray.put(fieldTwoObject);
fieldsArray.put(fieldThreeObject);
jsonObject.put("fields",fieldsArray);
JSONArray featuresArray = new JSONArray();
for(PointModel pointModel : pointList){
JSONObject featuresChildObject = new JSONObject();
JSONObject geometryObject = new JSONObject();
JSONObject spatialReferenceObject = new JSONObject();
spatialReferenceObject.put("wkid",4326);
geometryObject.put("spatialReference",spatialReferenceObject);
geometryObject.put("x",pointModel.getxPoint());
geometryObject.put("y",pointModel.getyPoint());
featuresChildObject.put("geometry",geometryObject);
JSONObject symbolObject = new JSONObject();
symbolObject.put("type","esriSMS");
JSONArray symbolColorArray = new JSONArray();
symbolColorArray.put(255);
symbolColorArray.put(0);
symbolColorArray.put(0);
symbolColorArray.put(255);
symbolObject.put("color",symbolColorArray);
symbolObject.put("angle",0);
symbolObject.put("xoffset",0);
symbolObject.put("yoffset",0);
symbolObject.put("size",12);
symbolObject.put("style","esriSMSCircle");
JSONObject outlineObject = new JSONObject();
outlineObject.put("type","esriSLS");
JSONArray outlineColorArray = new JSONArray();
outlineColorArray.put(255);
outlineColorArray.put(255);
outlineColorArray.put(255);
outlineColorArray.put(255);
outlineObject.put("color", outlineColorArray);
outlineObject.put("width",2);
outlineObject.put("style","esriSLSSolid");
symbolObject.put("outline",outlineObject);
featuresChildObject.put("symbol",symbolObject);
featuresChildObject.put("attributes",new JSONObject());
featuresChildObject.put("popupTemplate","");
featuresArray.put(featuresChildObject);
}
jsonObject.put("features",featuresArray);
jsonObject.put("exceededTransferLimit",false);
} catch (JSONException e) {
e.printStackTrace();
}
geoprocessingParameters.getInputs().put("InputFeatures", new GeoprocessingString(jsonObject.toString()));
// Log.e(TAG, "InputFeatures=: " + jsonObject.toString());
// create job
mGeoprocessingJob = mGeoprocessingTask.createJob(geoprocessingParameters);
// start job
mGeoprocessingJob.start();
// create a dialog to show progress of the geoprocessing job
final ProgressDialog progressDialog = new ProgressDialog(mContext);
progressDialog.setTitle("正在加载...");
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(100);
progressDialog.setCancelable(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", (dialog, which) -> {
dialog.dismiss();
// set canceled flag to true
canceled = true;
mGeoprocessingJob.cancel();
});
progressDialog.show();
// update progress
mGeoprocessingJob.addProgressChangedListener(() -> progressDialog.setProgress(mGeoprocessingJob.getProgress()));
// mGeoprocessingJob.addJobChangedListener(() -> {
//
// Log.e("hotPotsID",mGeoprocessingJob.getServerJobId()+"");
//
// for(Job.Message message : mGeoprocessingJob.getMessages()){
// Log.e("***********","***********");
// Log.e("hotPotsM----",message.getMessage());
// Log.e("###########","###########");
// }
//
// });
mGeoprocessingJob.addJobDoneListener(() -> {
progressDialog.dismiss();
if (mGeoprocessingJob.getStatus() == Job.Status.SUCCEEDED) {
Log.i(TAG, "Job succeeded.");
GeoprocessingResult geoprocessingResult = mGeoprocessingJob.getResult();
final ArcGISMapImageLayer hotspotMapImageLayer = geoprocessingResult.getMapImageLayer();
hotspotMapImageLayer.setOpacity(0.6f);
// add the new layer to the map
mMapView.getMap().getOperationalLayers().add(hotspotMapImageLayer);
hotspotMapImageLayer.addDoneLoadingListener(() -> {
// set the map viewpoint to the MapImageLayer, once loaded
mMapView.setViewpointGeometryAsync(hotspotMapImageLayer.getFullExtent());
});
} else if (canceled) {
Toast.makeText(mContext, "热力图加载取消", Toast.LENGTH_SHORT).show();
Log.i(TAG, "Job cancelled.");
} else {
Log.e(TAG, "Job did not succeed!");
Toast.makeText(mContext, "热力图加载失败!", Toast.LENGTH_LONG).show();
}
});
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
});
}
......
......@@ -2,10 +2,13 @@ package cn.com.founder.arcgislib.view;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
......@@ -21,6 +24,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
......@@ -33,9 +37,11 @@ import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.google.gson.JsonObject;
import com.minedata.minenavi.MineNaviMain;
import com.minedata.minenavi.common.GeoPoint;
import com.minedata.minenavi.common.JamPath;
import com.minedata.minenavi.common.OkHttp3Utils;
import com.minedata.minenavi.navi.GidCamera;
import com.minedata.minenavi.navi.GidDFM;
import com.minedata.minenavi.navi.GidEvent;
......@@ -53,10 +59,12 @@ import com.minedata.minenavi.route.RoutePlanOption;
import com.minedata.minenavi.search.common.FileSource;
import com.minedata.minenavi.tts.TTSProvider;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
......@@ -67,12 +75,21 @@ import cn.com.founder.arcgislib.search.listener.ISearchSelectedListener;
import cn.com.founder.arcgislib.utils.DensityUtil;
import cn.com.founder.arcgislib.utils.FormatUtil;
import cn.com.founder.arcgislib.utils.GpsUtil;
import cn.com.founder.arcgislib.utils.GsonUtil;
import cn.com.founder.arcgislib.utils.ToolUtil;
import cn.com.founder.arcgislib.widget.navi.NaviBigMagBand;
import cn.com.founder.arcgislib.widget.navi.NaviBottomBand;
import cn.com.founder.arcgislib.widget.navi.NaviIndicatorBand;
import cn.com.founder.arcgislib.widget.navi.NaviSABand;
import cn.com.founder.arcgislib.widget.popup.PopupLayout;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.ConnectionPool;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* Copyright: 方正国际软件有限公司
......@@ -179,6 +196,13 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
private NaviSABand naviSABand;
private boolean isHasSearchView;
private OkHttpClient okHttpClient;
/**
* 加载框
*/
protected ProgressDialog myDialog;
public ArcGisNaviView(Context context, ArcGisMapView arcGisMapView, ArcGisLocationView locationView, ArcGisSearchView searchView) {
this(context);
this.mContext = context;
......@@ -197,9 +221,9 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
this.arcGisSearchView.setSearchSelectedListener(this);
mPointCollection = new PointCollection(SpatialReference.create(4326));
initRoute();
// initApig();
// initRoute(null,null);
}
......@@ -221,14 +245,157 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
mNaviIv.setOnClickListener(this);
}
private void initRoute() {
protected void showDialog() {
try {
if (myDialog != null && myDialog.isShowing()) {
myDialog.dismiss();
}
myDialog = new ProgressDialog(mContext);
myDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
myDialog.setMessage("正在加载...");
myDialog.setIndeterminate(false);
myDialog.setCancelable(false);
myDialog.show();
} catch (Exception e) {
}
}
/**
* 关闭
*/
protected void disDialog() {
try {
if (myDialog != null && myDialog.isShowing()) {
myDialog.dismiss();
}
myDialog = null;
} catch (Exception e) {
}
}
/**
* 华为网关鉴权
*/
private void initApig() {
showDialog();
if (okHttpClient == null) {
synchronized (OkHttp3Utils.class) {
if (okHttpClient == null) {
okHttpClient = (new OkHttpClient.Builder()).connectTimeout(10L, TimeUnit.SECONDS).
writeTimeout(10L, TimeUnit.SECONDS).readTimeout(10L, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(5, 1L, TimeUnit.SECONDS))
.sslSocketFactory(ToolUtil.getSSLSocketFactory())
.hostnameVerifier(ToolUtil.getHostnameVerifier()).build();
}
}
}
RequestBody formBodyBuilder = new okhttp3.FormBody.Builder().add("grant_type", "client_credentials")
.add("client_id", Constants.BASE_HUA_WEI_AUTH_APPKEY)
.add("client_secret", Constants.BASE_HUA_WEI_AUTH_APP_SECRET)
.build();
Log.e("0000000", formBodyBuilder.toString());
Request formBodyRequest = (new okhttp3.Request.Builder()).url(Constants.BASE_APIG_URL).post(formBodyBuilder).build();
Call call = okHttpClient.newCall(formBodyRequest);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
disDialog();
Log.e("Fail", "e=" + e.toString());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
if (response.body() != null) {
String responseStr = response.body().string();
Log.e("responseStr1", responseStr);
JsonObject jsonObject = GsonUtil.gsonToBean(responseStr, JsonObject.class);
String appToken = jsonObject.get("access_token").getAsString();
RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("account", Constants.BASE_HUA_WEI_AUTHA)
.addFormDataPart("password", Constants.BASE_HUA_WEI_AUTHP).build();
Request formDataRequest = (new okhttp3.Request.Builder()).url(Constants.BASE_APIG_LOGIN_URL).addHeader("Authorization", "Bearer " + appToken).post(requestBody).build();
Log.e("1111111", formDataRequest.toString());
Call loginCall = okHttpClient.newCall(formDataRequest);
loginCall.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
disDialog();
Log.e("Fail", "e=" + e.toString());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
disDialog();
if (response.isSuccessful()) {
if (response.body() != null) {
String responseStr = response.body().string();
Log.e("responseStr2", responseStr);
JsonObject jsonObject = GsonUtil.gsonToBean(responseStr, JsonObject.class);
int status = jsonObject.get("statusCode").getAsInt();
if (status == 200) {
JsonObject resultObject = jsonObject.get("result").getAsJsonObject();
if (resultObject != null) {
if (resultObject.has("userToken")) {
JsonObject userTokenObject = resultObject.get("userToken").getAsJsonObject();
if (userTokenObject != null) {
String userToken = userTokenObject.get("token").getAsString();
Message message = new Message();
message.obj = appToken + "," + userToken;
mHandler.sendMessage(message);
}
}
}
}
}
}
}
});
}
}
}
});
}
@SuppressLint("HandlerLeak")
Handler mHandler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
String dataStr = (String) msg.obj;
if (!TextUtils.isEmpty(dataStr)) {
String appToken = dataStr.split(",")[0];
String userToken = dataStr.split(",")[1];
Log.e("appToken", appToken);
Log.e("userToken", userToken);
initRoute(appToken, userToken);
} else {
Toast.makeText(mContext, "导航初始化失败,请重新启动", Toast.LENGTH_LONG).show();
}
}
};
private void initRoute(String appToken, String userToken) {
//互联网是GCJ-02,内网是WGS-84:内网不用转,在互联网上测试时转换时先将自己的地图点(WGS-84,ArcGis(4326))转换成GCJ-02,获取到路网数据以后,再将GCJ-02转换成WGS-84坐标
if (mineNaviRoute == null) {
MineNaviMain.getInstance().setNaviURL(Constants.BASE_NAVI_URL);
/**
* 设置华为token
*/
// MineNaviMain.getInstance().setHuaweicloudToken();
// MineNaviMain.getInstance().setHuaweicloudToken(appToken, userToken);
/**
* 获取路径
*/
......@@ -260,12 +427,12 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
* 设置算路成功失败回调
*/
mineNaviRoute.setRoutePlanListener(i -> {
Toast.makeText(mContext, "i="+i, Toast.LENGTH_LONG).show();
Toast.makeText(mContext, "i=" + i, Toast.LENGTH_LONG).show();
if (i == MineNaviRoute.ErrorCode.success || i == MineNaviRoute.ErrorCode.successAndLimit) {
routeInfoList.clear();
Toast.makeText(mContext, "路线规划完毕", Toast.LENGTH_LONG).show();
arcGisSearchView.disDialog();
if(popupLayout != null){
if (popupLayout != null) {
popupLayout.dismiss();
}
createNaviBt();
......@@ -770,9 +937,10 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
/**
* 自定义点开始导航
*
* @param startPoint 起点
* @param endPoint 终点
* new PointModel(113.6242709,22.8810121,"新丽佳百货"),new PointModel(113.6351135,22.8874085,"大自然花场")
* @param endPoint 终点
* new PointModel(113.6242709,22.8810121,"新丽佳百货"),new PointModel(113.6351135,22.8874085,"大自然花场")
*/
public void setCustomPointNavi(PointModel startPoint, PointModel endPoint) {
if (startPoint == null) {
......@@ -893,8 +1061,8 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
arcGisLocationView.setSearchLocation(startSearchModel.getX(), startSearchModel.getY(), Variable.SearchType.START_ADDRESS_SEARCH);
arcGisLocationView.setSearchLocation(endSearchModel.getX(), endSearchModel.getY(), Variable.SearchType.END_ADDRESS_SEARCH);
Log.e("startPoint",startSearchModel.getX()+","+ startSearchModel.getY() + "," + startSearchModel.getPoiname());
Log.e("endPoint",endSearchModel.getX()+","+ endSearchModel.getY() + "," + endSearchModel.getPoiname());
Log.e("startPoint", startSearchModel.getX() + "," + startSearchModel.getY() + "," + startSearchModel.getPoiname());
Log.e("endPoint", endSearchModel.getX() + "," + endSearchModel.getY() + "," + endSearchModel.getPoiname());
PlanPoint startPoint = new PlanPoint();
startPoint.name = startSearchModel.getPoiname();
double[] startPointArr = GpsUtil.toGCJ02Point(startSearchModel.getY(), startSearchModel.getX());
......
......@@ -109,10 +109,10 @@ public class DrawLayer {
}
private SpatialReference getSpatialReference() {
if(spatialReference==null){
return mapView.getSpatialReference();
}
return spatialReference;
// if(spatialReference==null){
// return mapView.getSpatialReference();
// }
return SpatialReference.create(4326);
}
protected Object drawByScreenPoint(android.graphics.Point point){
......@@ -199,6 +199,16 @@ public class DrawLayer {
}
}
public void drawBox( Point point) {
circlePointList.add(point);
drawPoint(point);
if(circlePointList.size()==2){
drawBox(circlePointList.get(0),circlePointList.get(1));
circlePointList.clear();
removeGraphics(pointGraphicList);
}
}
public void drawBox(Point point1,Point point2) {
PolygonBuilder polygonGeometry = new PolygonBuilder(getSpatialReference());
polygonGeometry.addPoint(point1);
......@@ -217,6 +227,16 @@ public class DrawLayer {
removeGraphics(pointGraphicList);
}
}
public void drawCircle(Point point) {
circlePointList.add(point);
drawPoint(point);
if(circlePointList.size()==2){
drawCircle(circlePointList.get(0),circlePointList.get(1));
circlePointList.clear();
removeGraphics(pointGraphicList);
}
}
public void drawCircle(Point point1,Point point2) {
double radius = 0;
double x = (point2.getX() - point1.getX());
......
......@@ -124,8 +124,27 @@ public class DrawView extends DrawLayer{
PolygonBuilder polygon=(PolygonBuilder)super.drawByGisPoint(point);
showArea(polygon);
}
}
public void drawPointLine(Point point){
if(drawType==null) {
super.startLine();
drawType=Variable.DrawType.LINE;
}
PolylineBuilder line=(PolylineBuilder)super.drawByGisPoint(point);
showLength(line,point);
}
public void drawPointPolygon(Point point){
if(drawType==null) {
super.startPolygon();
drawType=Variable.DrawType.POLYGON;
}
PolygonBuilder polygon=(PolygonBuilder)super.drawByGisPoint(point);
showArea(polygon);
}
private void drawScreenPoint(android.graphics.Point screenPoint){
Point point=super.screenXYtoPpoint(screenPoint.x,screenPoint.y);
if( drawType==Variable.DrawType.LINE){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment