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) {
......
......@@ -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