|
|
@ -128,7 +128,7 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
zmqApplication.msAreaPointService = this.msAreaPointService; |
|
|
|
zmqApplication.msPreWarnService = this.msPreWarnService; |
|
|
|
zmqApplication.msAlarmSettingsService = this.msAlarmSettingsService; |
|
|
|
zmqApplication.msCameraSettingService=this.msCameraSettingService; |
|
|
|
zmqApplication.msCameraSettingService = this.msCameraSettingService; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -683,6 +683,7 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
|
|
|
|
//todo 新增代码 目标位置信息
|
|
|
|
/** |
|
|
|
* case4 : 点击的目标数据 (只有点击雷达图上的目标时才发送) |
|
|
|
* address : 172.20.0.77 (ZMQ发布地址) |
|
|
|
* port : 5151 |
|
|
|
* topic : NyGuideCamPos |
|
|
@ -809,69 +810,44 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
|
|
|
|
//todo : 联动控制球机
|
|
|
|
log.info("联动控制球机:"); |
|
|
|
List<MsCameraSetting> cameraSettings=null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
|
|
|
|
List<MsCameraSetting> cameraSettings = null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
|
|
|
|
LambdaQueryWrapper<MsCameraSetting> cameraSettingLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
|
|
|
|
//todo : 用于调整球机初始角
|
|
|
|
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息
|
|
|
|
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType, 2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
|
|
|
|
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息 用于调整球机初始角
|
|
|
|
|
|
|
|
cameraSettings = msCameraSettingService.list(cameraSettingLambdaQueryWrapper); |
|
|
|
if (cameraSettings==null|| cameraSettings.isEmpty()){ |
|
|
|
if (cameraSettings == null || cameraSettings.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
log.info("case4 : 遍历相机列表 寻找最近的点的球机去跟踪"); |
|
|
|
log.info("case4 : "+JSON.toJSONString(cameraSettings)); |
|
|
|
|
|
|
|
//todo : 未优化算法(减少相机数量)
|
|
|
|
/* double minDis=GEOUtils.GetDistance(cameraSettings.get(0).getLongitude().doubleValue(),cameraSettings.get(0).getLatitude().doubleValue(), targetLonLat.getLon(), targetLonLat.getLat()); |
|
|
|
int index=0; |
|
|
|
for (int i = 1; i < cameraSettings.size(); i++) { |
|
|
|
MsCameraSetting cameraSetting = cameraSettings.get(i); |
|
|
|
//todo : 1.计算距离 选最近球机 进行跟踪
|
|
|
|
BigDecimal cameraHeight = cameraSetting.getHeight(); |
|
|
|
BigDecimal labelHeight = new BigDecimal(h); |
|
|
|
double heightDiff = cameraHeight.subtract(labelHeight).doubleValue(); |
|
|
|
if (heightDiff < 0) { |
|
|
|
log.info("IP:"+cameraSetting.getIp()+"与目标的高度差:"+heightDiff+"小于0"); |
|
|
|
} else{ |
|
|
|
BigDecimal longitude = cameraSetting.getLongitude();//经度
|
|
|
|
BigDecimal latitude = cameraSetting.getLatitude();//纬度
|
|
|
|
double zDis = GEOUtils.GetDistance(longitude.doubleValue(), latitude.doubleValue(), targetLonLat.getLon(), targetLonLat.getLat()); |
|
|
|
log.info("下标i:"+i+ " 相机IP:"+ cameraSetting.getIp() +" 距离当前相机:"+zDis); |
|
|
|
//todo : 更新距离最小的数据 如果数据是按顺序的 可以判断当数据比前一个数据变大的时候就终止 取前一个数据
|
|
|
|
if (zDis<minDis){ |
|
|
|
minDis=zDis; |
|
|
|
index=i; |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
log.info("case4 : " + JSON.toJSONString(cameraSettings)); |
|
|
|
|
|
|
|
// todo : 优化1.0
|
|
|
|
// 计算距离最近的球机
|
|
|
|
MsCameraSetting msCameraSetting=null;//最近球机信息
|
|
|
|
double nearestDistance=0;//最近距离
|
|
|
|
double heightDiff=0;//最近球机的高度差
|
|
|
|
MsCameraSetting msCameraSetting = null;//最近球机信息
|
|
|
|
double nearestDistance = 0;//最近距离
|
|
|
|
double heightDiff = 0;//最近球机的高度差
|
|
|
|
//Map cameraList=new HashMap();//保存距离目标球机的顺序
|
|
|
|
for (MsCameraSetting cameraSetting : cameraSettings) { |
|
|
|
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
|
|
|
|
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
|
|
|
|
BigDecimal labelHeight = new BigDecimal(h);//目标高度
|
|
|
|
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
|
|
|
|
if (tempHeightDiff<0){ |
|
|
|
log.info("case4 :"+"ip="+cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围"); |
|
|
|
}else { |
|
|
|
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(),cameraSetting.getLatitude().doubleValue(),targetLonLat.getLon(),targetLonLat.getLat()); |
|
|
|
if (tempHeightDiff < 0) { |
|
|
|
log.info("case4 :" + "ip=" + cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围"); |
|
|
|
} else { |
|
|
|
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(), cameraSetting.getLatitude().doubleValue(), targetLonLat.getLon(), targetLonLat.getLat()); |
|
|
|
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
|
|
|
|
if (msCameraSetting==null){ |
|
|
|
msCameraSetting=cameraSetting; |
|
|
|
nearestDistance=temp; |
|
|
|
if (msCameraSetting == null) { |
|
|
|
msCameraSetting = cameraSetting; |
|
|
|
nearestDistance = temp; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
|
|
|
|
if (nearestDistance>temp){ |
|
|
|
msCameraSetting=cameraSetting; |
|
|
|
nearestDistance=temp; |
|
|
|
heightDiff=tempHeightDiff; |
|
|
|
if (nearestDistance > temp) { |
|
|
|
msCameraSetting = cameraSetting; |
|
|
|
nearestDistance = temp; |
|
|
|
heightDiff = tempHeightDiff; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -881,30 +857,17 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
double heightDiff= msCameraSetting.getHeight().subtract(BigDecimal.valueOf(h)).doubleValue(); |
|
|
|
*/ //判断两点的距离是否超过有效距离,超过则丢掉
|
|
|
|
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) { |
|
|
|
log.info("case4 :"+"超过跟踪的最大距离"+redisUtil.hget("alarm_settings", "inOutEffectDistance").toString()); |
|
|
|
log.info("case4 :" + "超过跟踪的最大距离" + redisUtil.hget("alarm_settings", "inOutEffectDistance").toString()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//MsCameraSetting msCameraSetting = cameraSettings.get(index);
|
|
|
|
log.info("case4 :"+" 相机IP:"+ msCameraSetting.getIp() +" 最短距离nearestDistance:"+nearestDistance); |
|
|
|
log.info("case4 :"+"距离最近的相机:"+JSON.toJSONString(msCameraSetting)); |
|
|
|
|
|
|
|
/* //todo : 计算PTZ
|
|
|
|
//球机高度
|
|
|
|
BigDecimal cameraHeight = msCameraSetting.getHeight(); |
|
|
|
//目标高度
|
|
|
|
BigDecimal labelHeight = new BigDecimal(h); |
|
|
|
//球机与目标的高度差
|
|
|
|
double heightDiff = cameraHeight.subtract(labelHeight).doubleValue(); |
|
|
|
//高度差小于0 则说明目标在球机上方 超过球机照射范围
|
|
|
|
if (heightDiff < 0) { |
|
|
|
log.info("heightDiff < 0 超过球机照射范围"); |
|
|
|
return; |
|
|
|
}*/ |
|
|
|
|
|
|
|
log.info("case4 :" + " 相机IP:" + msCameraSetting.getIp() + " 最短距离nearestDistance:" + nearestDistance); |
|
|
|
log.info("case4 :" + "距离最近的相机:" + JSON.toJSONString(msCameraSetting)); |
|
|
|
|
|
|
|
//todo : 球机也跟踪光电过去(此处可保留 也可删除 因为轨迹数据也会让球机过去)
|
|
|
|
//1.先控制球机照射目标
|
|
|
|
log.info("【尝试使用ptzControllerByLatLonAndDistance】"); |
|
|
|
log.info("case4【尝试使用ptzControllerByLatLonAndDistance】将球机转到目标位置"); |
|
|
|
msCameraSettingService.ptzControllerByLatLon(msCameraSetting.getIp(), |
|
|
|
msCameraSetting.getUser(), |
|
|
|
msCameraSetting.getPassword(), |
|
|
@ -917,64 +880,42 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
targetLonLat.getLon(), |
|
|
|
targetLonLat.getLat(), |
|
|
|
msCameraSetting.getStyle());//style用于区分品牌类型 1:海康 2:宇视
|
|
|
|
log.info("case4 :"+"【参数信息】"); |
|
|
|
log.info("cameraSetting.getUser():"+msCameraSetting.getUser()); |
|
|
|
log.info("cameraSetting.getPassword():"+msCameraSetting.getPassword()); |
|
|
|
log.info("cameraSetting.getMaxElevation():"+msCameraSetting.getMaxElevation()); |
|
|
|
log.info("cameraSetting.getZeroAzimuth():"+msCameraSetting.getZeroAzimuth()); |
|
|
|
log.info("heightDiff:"+heightDiff); |
|
|
|
log.info("cameraSetting.getZoomFactor():"+msCameraSetting.getZoomFactor()); |
|
|
|
log.info("cameraSetting.getLongitude():"+msCameraSetting.getLongitude().doubleValue()); |
|
|
|
log.info("cameraSetting.getLatitude():"+msCameraSetting.getLatitude().doubleValue()); |
|
|
|
log.info("targetLonLat.getLon()"+targetLonLat.getLon()); |
|
|
|
log.info("targetLonLat.getLat()"+targetLonLat.getLat()); |
|
|
|
log.info("case4 :" + "【参数信息】"); |
|
|
|
log.info("cameraSetting.getUser():" + msCameraSetting.getUser()); |
|
|
|
log.info("cameraSetting.getPassword():" + msCameraSetting.getPassword()); |
|
|
|
log.info("cameraSetting.getMaxElevation():" + msCameraSetting.getMaxElevation()); |
|
|
|
log.info("cameraSetting.getZeroAzimuth():" + msCameraSetting.getZeroAzimuth()); |
|
|
|
log.info("heightDiff:" + heightDiff); |
|
|
|
log.info("cameraSetting.getZoomFactor():" + msCameraSetting.getZoomFactor()); |
|
|
|
log.info("cameraSetting.getLongitude():" + msCameraSetting.getLongitude().doubleValue()); |
|
|
|
log.info("cameraSetting.getLatitude():" + msCameraSetting.getLatitude().doubleValue()); |
|
|
|
log.info("targetLonLat.getLon()" + targetLonLat.getLon()); |
|
|
|
log.info("targetLonLat.getLat()" + targetLonLat.getLat()); |
|
|
|
|
|
|
|
//todo : 2.水平跟踪目标 目标详细信息再redis中 当雷达开启目标跟踪后 将发case3数据 订阅case3数据后 将目标详细数据缓存到redis中
|
|
|
|
log.info("------case4将球机转到目标位置-------"); |
|
|
|
//由于只能接收到方位角和距离 并且轨迹不断更新 所以只能将方位角和距离进行
|
|
|
|
//由于经纬度不断变化 暂时不使用经纬度进行定位
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");//保留两位小数
|
|
|
|
String longitude = decimalFormat.format(targetLonLat.getLon()); |
|
|
|
String latitude = decimalFormat.format(targetLonLat.getLat()); |
|
|
|
|
|
|
|
//获取轨迹信息
|
|
|
|
//String redisKey = "tracks"+"_"+longitude+"_"+latitude;
|
|
|
|
int redisAzimuth=(int)azimuth; |
|
|
|
String redisKey = "tracks:"+redisAzimuth; |
|
|
|
log.info("case4 :"+"longitude:"+longitude+" "+"latitude"+latitude+"azimuth"+redisAzimuth); |
|
|
|
|
|
|
|
|
|
|
|
// todo : 1.通过船速和航向控制球机转动(不采用)
|
|
|
|
/* float targetSpeed = Float.parseFloat(redisUtil.hget(redisKey, "targetSpeed").toString());//航速
|
|
|
|
float targetCourse =Float.parseFloat(redisUtil.hget(redisKey, "targetCourse").toString());//航向
|
|
|
|
int redisAzimuth = (int) azimuth; |
|
|
|
int redisDis = (((int) distance + 999) / 1000) * 1000; |
|
|
|
String redisKey = "tracks:" + redisAzimuth + "_" + redisDis; |
|
|
|
log.info("case4 :" + "longitude:" + longitude + " " + "latitude" + latitude + "azimuth" + redisAzimuth + redisDis); |
|
|
|
log.info("case4 :" + "redisKey = " + redisKey); |
|
|
|
|
|
|
|
log.info("targetCourse 航向:"+String.valueOf(targetSpeed)); |
|
|
|
log.info("targetSpeed 航速:"+String.valueOf(targetCourse)); |
|
|
|
|
|
|
|
double ySpend = Math.cos(Math.toRadians(targetCourse))*targetSpeed; //正数 上 负数 下
|
|
|
|
log.info("ySpend 方向:"+String.valueOf(ySpend)); |
|
|
|
|
|
|
|
String instruct="stop"; |
|
|
|
//todo : 待优化
|
|
|
|
if (ySpend>=0){ //160 下 330 上
|
|
|
|
instruct="right";//(-1, 0, 0)
|
|
|
|
}else { |
|
|
|
instruct="left";//(1, 0, 0)
|
|
|
|
} |
|
|
|
|
|
|
|
//todo : 速度的计算 根据航速和航向
|
|
|
|
float speed= (float) (targetSpeed * msCameraSetting.getLeftAngle()); |
|
|
|
log.info("相机水平转动速度:"+String.valueOf(speed)+"方向:"+instruct); |
|
|
|
|
|
|
|
msCameraSettingService.ptzControl(msCameraSetting.getIp(), msCameraSetting.getUser(), msCameraSetting.getPassword(),instruct,speed); |
|
|
|
*/ |
|
|
|
|
|
|
|
//todo : 2.通过不断更新的船经纬度信息控制球机转动
|
|
|
|
/* redisUtil.hget(redisKey,"targetLon"); |
|
|
|
redisUtil.hget(redisKey,"targetLat");*/ |
|
|
|
int trackId = (int) redisUtil.hget(redisKey, "trackId");//根据方位角 找到 轨迹Id
|
|
|
|
redisUtil.hset("trackingTargetId", String.valueOf(trackId),msCameraSetting.getIp());//将该轨迹 和 定位该轨迹的球机 保存到跟踪队列中
|
|
|
|
log.info("正在跟踪的trackId:"+trackId); |
|
|
|
int trackId = Integer.valueOf(redisUtil.hget(redisKey, "trackId").toString());//根据方位角 找到 轨迹Id
|
|
|
|
redisUtil.hset("trackingTargetId", String.valueOf(trackId), msCameraSetting.getIp());//将该轨迹 和 定位该轨迹的球机 保存到跟踪队列中
|
|
|
|
log.info("正在跟踪的trackId:" + trackId); |
|
|
|
|
|
|
|
//todo : 根据trackId更新的数据转动球机
|
|
|
|
//todo : case4 当前轨迹数据是正在跟踪点时 调动球机跟踪
|
|
|
|
|
|
|
|
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
@ -986,8 +927,10 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
}; |
|
|
|
new Thread(nyGuideCamPosThread).start(); |
|
|
|
|
|
|
|
|
|
|
|
//todo : 新增代码 球机联动
|
|
|
|
/** |
|
|
|
* case3 : 船轨迹数据 (开启目标跟踪使能后 持续发送) |
|
|
|
* address : 172.20.0.77 (ZMQ发布地址) |
|
|
|
* port : 5151 |
|
|
|
* topic : RadarTrack(todo : 暂时写死 后续通过配置文件配置) |
|
|
@ -997,13 +940,13 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
public void dealWithData(byte[] data) throws ParseException { |
|
|
|
log.info(Thread.currentThread().getName() + "接收到数据:" + new String(data)); |
|
|
|
JSONObject jsonObject = JSON.parseObject(new String(data)); |
|
|
|
log.info("case3 :"+"1.RadarTrack数据:" + jsonObject.toString()); |
|
|
|
log.info("case3 :" + "1.RadarTrack数据:" + jsonObject.toString()); |
|
|
|
|
|
|
|
String radarTarcksJsonString = (String) jsonObject.get("radarTracks"); |
|
|
|
List<RadarTrackModel> radarTrackModels = JSONObject.parseArray(radarTarcksJsonString, RadarTrackModel.class); |
|
|
|
log.info(JSON.toJSONString(radarTrackModels)); |
|
|
|
RadarTrackModel radarTrackModel = radarTrackModels.get(0); |
|
|
|
log.info("case3 :"+JSON.toJSONString(radarTrackModel)); |
|
|
|
log.info("case3 :" + JSON.toJSONString(radarTrackModel)); |
|
|
|
|
|
|
|
//将经纬度作为key去定位
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
|
|
@ -1011,107 +954,105 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
String latitude = decimalFormat.format(radarTrackModel.getLatitude()); |
|
|
|
String azimuth = decimalFormat.format(radarTrackModel.getAzimuth()); |
|
|
|
|
|
|
|
log.info("longitude:"+longitude+"latitude:"+latitude+"azimuth:"+azimuth); |
|
|
|
log.info("longitude:" + longitude + "latitude:" + latitude + "azimuth:" + azimuth); |
|
|
|
|
|
|
|
//将每个目标轨迹信息进行缓存
|
|
|
|
//String redisKey = "tracks"+"_"+longitude+"_"+latitude;//经纬度来进行缓存
|
|
|
|
float redisAzimuth=Float.parseFloat(azimuth); |
|
|
|
float redisAzimuth = Float.parseFloat(azimuth); |
|
|
|
int redisDis = ((radarTrackModel.getDis() + 999) / 1000) * 1000; |
|
|
|
|
|
|
|
String redisKey = "tracks:"+(int)redisAzimuth;//方位角进行缓存
|
|
|
|
String redisKey = "tracks:" + (int) redisAzimuth + "_" + redisDis;//方位角进行缓存
|
|
|
|
//String redisKey = "tracks";//方位角进行缓存
|
|
|
|
|
|
|
|
//todo : 将雷达轨迹数据持续进行缓存 后续根据当用户点击雷达图的目标时 持续跟踪最新的该目标信息(存在的问题 : 雷达数据不更新)
|
|
|
|
log.info("redisKey:"+redisKey); |
|
|
|
log.info("redisKey:" + redisKey); |
|
|
|
|
|
|
|
//缓存 Azimuth =》 船信息
|
|
|
|
redisUtil.hset(redisKey,"targetLon",radarTrackModel.getLongitude()); |
|
|
|
redisUtil.hset(redisKey,"targetLat",radarTrackModel.getLatitude()); |
|
|
|
redisUtil.hset(redisKey,"targetDis",radarTrackModel.getDis()); |
|
|
|
redisUtil.hset(redisKey,"targetAzimuth",radarTrackModel.getAzimuth()); |
|
|
|
redisUtil.hset(redisKey,"targetCourse",radarTrackModel.getCourse()); |
|
|
|
redisUtil.hset(redisKey,"targetSpeed",radarTrackModel.getSpeed()); |
|
|
|
redisUtil.hset(redisKey,"trackId",radarTrackModel.getTrackId()); |
|
|
|
redisUtil.hset(redisKey, "targetLon", radarTrackModel.getLongitude()); |
|
|
|
redisUtil.hset(redisKey, "targetLat", radarTrackModel.getLatitude()); |
|
|
|
redisUtil.hset(redisKey, "targetDis", radarTrackModel.getDis()); |
|
|
|
redisUtil.hset(redisKey, "targetAzimuth", radarTrackModel.getAzimuth()); |
|
|
|
redisUtil.hset(redisKey, "targetCourse", radarTrackModel.getCourse()); |
|
|
|
redisUtil.hset(redisKey, "targetSpeed", radarTrackModel.getSpeed()); |
|
|
|
redisUtil.hset(redisKey, "trackId", radarTrackModel.getTrackId()); |
|
|
|
|
|
|
|
|
|
|
|
//缓存 TrackId =》 船信息 (todo:如果雷达case 4数据可以多发一个trackId 就无需多缓存azimuth)
|
|
|
|
String trackIdKey = "trackIds:"+radarTrackModel.getTrackId(); |
|
|
|
redisUtil.hset(trackIdKey,"targetLon",radarTrackModel.getLongitude()); |
|
|
|
redisUtil.hset(trackIdKey,"targetLat",radarTrackModel.getLatitude()); |
|
|
|
redisUtil.hset(trackIdKey,"targetDis",radarTrackModel.getDis()); |
|
|
|
redisUtil.hset(trackIdKey,"targetAzimuth",radarTrackModel.getAzimuth()); |
|
|
|
redisUtil.hset(trackIdKey,"targetCourse",radarTrackModel.getCourse()); |
|
|
|
redisUtil.hset(trackIdKey,"targetSpeed",radarTrackModel.getSpeed()); |
|
|
|
redisUtil.hset(trackIdKey,"trackId",radarTrackModel.getTrackId()); |
|
|
|
String trackIdKey = "trackIds:" + radarTrackModel.getTrackId(); |
|
|
|
redisUtil.hset(trackIdKey, "targetLon", radarTrackModel.getLongitude()); |
|
|
|
redisUtil.hset(trackIdKey, "targetLat", radarTrackModel.getLatitude()); |
|
|
|
redisUtil.hset(trackIdKey, "targetDis", radarTrackModel.getDis()); |
|
|
|
redisUtil.hset(trackIdKey, "targetAzimuth", radarTrackModel.getAzimuth()); |
|
|
|
redisUtil.hset(trackIdKey, "targetCourse", radarTrackModel.getCourse()); |
|
|
|
redisUtil.hset(trackIdKey, "targetSpeed", radarTrackModel.getSpeed()); |
|
|
|
redisUtil.hset(trackIdKey, "trackId", radarTrackModel.getTrackId()); |
|
|
|
|
|
|
|
//redis中存在正在跟踪的轨迹目标信息
|
|
|
|
String ip = (String) redisUtil.hget("trackingTargetId", String.valueOf(radarTrackModel.getTrackId()));//获取并判断雷达传过来的轨迹数据 看是否该轨迹在跟踪目标队列中
|
|
|
|
log.info("查询当前轨迹是否处于跟踪状态"+ip); |
|
|
|
if (ip!=null){// 该轨迹处于跟踪状态
|
|
|
|
log.info("查询当前轨迹是否处于跟踪状态" + ip); |
|
|
|
if (ip != null) {// 该轨迹处于跟踪状态
|
|
|
|
|
|
|
|
// todo : 2.0
|
|
|
|
//计算最近球机
|
|
|
|
List<MsCameraSetting> cameraSettings=null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
|
|
|
|
List<MsCameraSetting> cameraSettings = null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
|
|
|
|
LambdaQueryWrapper<MsCameraSetting> cameraSettingLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
|
|
|
|
//todo : 用于调整球机初始角
|
|
|
|
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息
|
|
|
|
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType, 2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
|
|
|
|
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息 用于调整球机初始角
|
|
|
|
|
|
|
|
cameraSettings = msCameraSettingService.list(cameraSettingLambdaQueryWrapper); |
|
|
|
if (cameraSettings==null|| cameraSettings.isEmpty()){ |
|
|
|
if (cameraSettings == null || cameraSettings.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
log.info("遍历相机列表 寻找最近的点的球机去跟踪"); |
|
|
|
log.info(JSON.toJSONString(cameraSettings)); |
|
|
|
|
|
|
|
MsCameraSetting msCameraSetting=null;//最近球机信息
|
|
|
|
double nearestDistance=0;//最近距离
|
|
|
|
double heightDiff=0;//最近球机的高度差
|
|
|
|
MsCameraSetting msCameraSetting = null;//最近球机信息
|
|
|
|
double nearestDistance = 0;//最近距离
|
|
|
|
double heightDiff = 0;//最近球机的高度差
|
|
|
|
double targetHeight = Double.parseDouble(redisUtil.hget("alarm_settings", "targetHeight").toString()); |
|
|
|
//Map cameraList=new HashMap();//保存距离目标球机的顺序
|
|
|
|
for (MsCameraSetting cameraSetting : cameraSettings) { |
|
|
|
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
|
|
|
|
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
|
|
|
|
BigDecimal labelHeight = new BigDecimal(targetHeight);//目标高度
|
|
|
|
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
|
|
|
|
if (tempHeightDiff<0){ |
|
|
|
log.info("case3 :"+"ip="+cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围"); |
|
|
|
}else { |
|
|
|
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(),cameraSetting.getLatitude().doubleValue(),(double) redisUtil.hget("trackIds:"+radarTrackModel.getTrackId(), "targetLon"),(double) redisUtil.hget("trackIds:"+radarTrackModel.getTrackId(), "targetLat")); |
|
|
|
if (tempHeightDiff < 0) { |
|
|
|
log.info("case3 :" + "ip=" + cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围"); |
|
|
|
} else { |
|
|
|
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(), cameraSetting.getLatitude().doubleValue(), (double) redisUtil.hget("trackIds:" + radarTrackModel.getTrackId(), "targetLon"), (double) redisUtil.hget("trackIds:" + radarTrackModel.getTrackId(), "targetLat")); |
|
|
|
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
|
|
|
|
if (msCameraSetting==null){ |
|
|
|
msCameraSetting=cameraSetting; |
|
|
|
nearestDistance=temp; |
|
|
|
if (msCameraSetting == null) { |
|
|
|
msCameraSetting = cameraSetting; |
|
|
|
nearestDistance = temp; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
|
|
|
|
if (nearestDistance>temp){ |
|
|
|
msCameraSetting=cameraSetting; |
|
|
|
nearestDistance=temp; |
|
|
|
heightDiff=tempHeightDiff; |
|
|
|
if (nearestDistance > temp) { |
|
|
|
msCameraSetting = cameraSetting; |
|
|
|
nearestDistance = temp; |
|
|
|
heightDiff = tempHeightDiff; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//判断两点的距离是否超过有效距离,超过则丢掉
|
|
|
|
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) { |
|
|
|
log.info("case3 :"+"超过跟踪的最大距离"+redisUtil.hget("alarm_settings", "inOutEffectDistance").toString()); |
|
|
|
log.info("case3 :" + "超过跟踪的最大距离" + redisUtil.hget("alarm_settings", "inOutEffectDistance").toString()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//MsCameraSetting msCameraSetting = cameraSettings.get(index);
|
|
|
|
log.info("case3 :"+" 相机IP:"+ msCameraSetting.getIp() +" 最短距离nearestDistance:"+nearestDistance); |
|
|
|
log.info("case3 :"+"距离最近的相机:"+JSON.toJSONString(msCameraSetting)); |
|
|
|
log.info("case3 :" + " 相机IP:" + msCameraSetting.getIp() + " 最短距离nearestDistance:" + nearestDistance); |
|
|
|
log.info("case3 :" + "距离最近的相机:" + JSON.toJSONString(msCameraSetting)); |
|
|
|
|
|
|
|
|
|
|
|
//todo : 1.0
|
|
|
|
String trackIdKey2 = "trackIds:"+radarTrackModel.getTrackId();//获取该轨迹对应的最新数据
|
|
|
|
String trackIdKey2 = "trackIds:" + radarTrackModel.getTrackId();//获取该轨迹对应的最新数据
|
|
|
|
double targetLon = (double) redisUtil.hget(trackIdKey2, "targetLon"); |
|
|
|
double targetLat = (double) redisUtil.hget(trackIdKey2, "targetLat"); |
|
|
|
|
|
|
|
//LambdaQueryWrapper<MsCameraSetting> lambdaQueryWrapper = new LambdaQueryWrapper<MsCameraSetting>().eq(MsCameraSetting::getIp, ip);
|
|
|
|
//MsCameraSetting msCameraSetting = msCameraSettingService.getOne(lambdaQueryWrapper);
|
|
|
|
//控制球机照射目标
|
|
|
|
log.info("case3 :"+"【尝试使用ptzControllerByLatLonAndDistance】"); |
|
|
|
log.info("case3 :" + "【尝试使用ptzControllerByLatLonAndDistance】"); |
|
|
|
msCameraSettingService.ptzControllerByLatLon(msCameraSetting.getIp(), |
|
|
|
msCameraSetting.getUser(), |
|
|
|
msCameraSetting.getPassword(), |
|
|
@ -1125,18 +1066,17 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
targetLat, |
|
|
|
msCameraSetting.getStyle());//style用于区分品牌类型 1:海康 2:宇视
|
|
|
|
log.info("【参数信息】"); |
|
|
|
log.info("cameraSetting.getUser():"+msCameraSetting.getUser()); |
|
|
|
log.info("cameraSetting.getPassword():"+msCameraSetting.getPassword()); |
|
|
|
log.info("cameraSetting.getMaxElevation():"+msCameraSetting.getMaxElevation()); |
|
|
|
log.info("cameraSetting.getZeroAzimuth():"+msCameraSetting.getZeroAzimuth()); |
|
|
|
log.info("heightDiff:"+heightDiff); |
|
|
|
log.info("cameraSetting.getZoomFactor():"+msCameraSetting.getZoomFactor()); |
|
|
|
log.info("cameraSetting.getLongitude():"+msCameraSetting.getLongitude().doubleValue()); |
|
|
|
log.info("cameraSetting.getLatitude():"+msCameraSetting.getLatitude().doubleValue()); |
|
|
|
log.info("targetLonLat.getLon()"+targetLon); |
|
|
|
log.info("targetLonLat.getLat()"+targetLat); |
|
|
|
|
|
|
|
log.info("case3 :"+"已控制球机照过去 等待下一次轨迹信息 在进行下次定位"); |
|
|
|
log.info("cameraSetting.getUser():" + msCameraSetting.getUser()); |
|
|
|
log.info("cameraSetting.getPassword():" + msCameraSetting.getPassword()); |
|
|
|
log.info("cameraSetting.getMaxElevation():" + msCameraSetting.getMaxElevation()); |
|
|
|
log.info("cameraSetting.getZeroAzimuth():" + msCameraSetting.getZeroAzimuth()); |
|
|
|
log.info("heightDiff:" + heightDiff); |
|
|
|
log.info("cameraSetting.getZoomFactor():" + msCameraSetting.getZoomFactor()); |
|
|
|
log.info("cameraSetting.getLongitude():" + msCameraSetting.getLongitude().doubleValue()); |
|
|
|
log.info("cameraSetting.getLatitude():" + msCameraSetting.getLatitude().doubleValue()); |
|
|
|
log.info("targetLonLat.getLon()" + targetLon); |
|
|
|
log.info("targetLonLat.getLat()" + targetLat); |
|
|
|
log.info("case3 :" + "已控制球机照过去 等待下一次更新的轨迹信息 在进行下次定位"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1146,133 +1086,6 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws SOAPException, ConnectException { |
|
|
|
float speed=10.45f; |
|
|
|
System.out.println(speed*1000L); |
|
|
|
long result= (long) (speed*1000L); |
|
|
|
System.out.println(result); |
|
|
|
|
|
|
|
|
|
|
|
RadarTrackModel radarTrackModel =new RadarTrackModel(); |
|
|
|
radarTrackModel.setDis(1); |
|
|
|
log.info(JSON.toJSONString(radarTrackModel)); |
|
|
|
|
|
|
|
String a="314.8044"; |
|
|
|
float b= Float.parseFloat(a); |
|
|
|
System.out.println(b); |
|
|
|
|
|
|
|
float azimuth=314.80445f; |
|
|
|
int redisAzimuth=(int)azimuth; |
|
|
|
System.out.println(redisAzimuth); |
|
|
|
|
|
|
|
double targetSpeed=1.0831853; |
|
|
|
double targetCourse=330; |
|
|
|
double degree=Math.toRadians(targetCourse); |
|
|
|
|
|
|
|
double cos=Math.cos(degree); |
|
|
|
double ySpend = Math.cos(targetCourse)*targetSpeed; |
|
|
|
System.out.println(degree); |
|
|
|
System.out.println(cos); |
|
|
|
System.out.println(ySpend); |
|
|
|
System.out.println("--------------------"); |
|
|
|
/* System.out.println(System.getProperty("user.dir") + "\\lib\\hk\\win64\\HCNetSDK.dll"); |
|
|
|
de.onvif.soap.OnvifDevice onvifDevice = new OnvifDevice("192.168.1.71","admin","hk123456"); |
|
|
|
PtzDevices ptzDevices = onvifDevice.getPtz(); |
|
|
|
String token = onvifDevice.getDevices().getProfiles().get(0).getToken();*/ |
|
|
|
// boolean absoluteMoveSupported = ptzDevices.isAbsoluteMoveSupported(token);
|
|
|
|
/* System.out.println(absoluteMoveSupported); |
|
|
|
ptzDevices.absoluteMove(token,0.5f,0.5f,0.5f); |
|
|
|
ptzDevices.relativeMove(token,0,0,0.5f);*/ |
|
|
|
|
|
|
|
/* ptzDevices.absoluteMove(token,0.5f,0f,0f); |
|
|
|
ptzDevices.relativeMove(token,0,0,0.5f); |
|
|
|
ptzDevices.continuousMove(token,0.5f , 0f, 0f); |
|
|
|
//ptzDevices.stopMove(token);
|
|
|
|
PTZStatus status = ptzDevices.getStatus(token);*/ |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("flag",1); |
|
|
|
jsonObject.put("sourceId","AgilTrack_cat010bsz"); |
|
|
|
jsonObject.put("utc",System.currentTimeMillis()); |
|
|
|
|
|
|
|
List<RadarTrackModel> radarTracks=new ArrayList<>(); |
|
|
|
RadarTrackModel radarTrack = new RadarTrackModel(); |
|
|
|
radarTrack.setDis(100); |
|
|
|
radarTrack.setAzimuth(315); |
|
|
|
radarTrack.setRadarId(10); |
|
|
|
radarTrack.setSpeed(10); |
|
|
|
radarTrack.setLatitude(22.180616f); |
|
|
|
radarTrack.setLongitude(113.40126f); |
|
|
|
radarTracks.add(radarTrack); |
|
|
|
jsonObject.put("radarTracks",JSON.toJSONString(radarTracks)); |
|
|
|
String jsonString = JSON.toJSONString(jsonObject); |
|
|
|
|
|
|
|
byte[] data=jsonString.getBytes(); |
|
|
|
|
|
|
|
JSONObject jsonObject2 = JSON.parseObject(new String(data)); |
|
|
|
log.info("1.RadarTrack数据:" + jsonObject2.toString()); |
|
|
|
|
|
|
|
String radarTarcksJsonString = (String) jsonObject2.get("radarTracks"); |
|
|
|
List<RadarTrackModel> radarTrackModels = JSONObject.parseArray(radarTarcksJsonString, RadarTrackModel.class); |
|
|
|
float latitude = radarTrackModels.get(0).getLatitude(); |
|
|
|
float longitude = radarTrackModels.get(0).getLongitude(); |
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
|
|
|
String l = decimalFormat.format(latitude); |
|
|
|
String r = decimalFormat.format(longitude); |
|
|
|
System.out.println(latitude); |
|
|
|
System.out.println(longitude); |
|
|
|
System.out.println(l); |
|
|
|
System.out.println(r); |
|
|
|
System.out.println(radarTrackModels); |
|
|
|
|
|
|
|
float ab=1.0831853f; |
|
|
|
log.info(String.valueOf(ab)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取最近球机 |
|
|
|
* @param cameraSettings 所有球机 |
|
|
|
* @param targetHeight 目标高度 |
|
|
|
* @param targetLon 目标经度 |
|
|
|
* @param targetLat 目标纬度 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public MsCameraSetting getNearestDistanceCamera(List<MsCameraSetting> cameraSettings,double targetHeight,double targetLon,double targetLat){ |
|
|
|
// todo : 优化1.0
|
|
|
|
// 计算距离最近的球机
|
|
|
|
MsCameraSetting msCameraSetting=null;//最近球机信息
|
|
|
|
double nearestDistance=0;//最近距离
|
|
|
|
double heightDiff=0;//最近球机的高度差
|
|
|
|
//Map cameraList=new HashMap();//保存距离目标球机的顺序
|
|
|
|
for (MsCameraSetting cameraSetting : cameraSettings) { |
|
|
|
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
|
|
|
|
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
|
|
|
|
BigDecimal labelHeight = new BigDecimal(targetHeight);//目标高度
|
|
|
|
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
|
|
|
|
if (tempHeightDiff<0){ |
|
|
|
log.info("ip="+cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围"); |
|
|
|
}else { |
|
|
|
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(),cameraSetting.getLatitude().doubleValue(),targetLon,targetLat); |
|
|
|
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
|
|
|
|
if (msCameraSetting==null){ |
|
|
|
msCameraSetting=cameraSetting; |
|
|
|
nearestDistance=temp; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
|
|
|
|
if (nearestDistance>temp){ |
|
|
|
msCameraSetting=cameraSetting; |
|
|
|
nearestDistance=temp; |
|
|
|
heightDiff=tempHeightDiff; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//判断两点的距离是否超过有效距离,超过则丢掉
|
|
|
|
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) { |
|
|
|
log.info("超过跟踪的最大距离"+redisUtil.hget("alarm_settings", "inOutEffectDistance").toString()); |
|
|
|
} |
|
|
|
return msCameraSetting; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 计算围网报警有效区域(围网外5米 + 雷达测角误差±1°造成的距离偏差) |
|
|
@ -1346,7 +1159,7 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
msPreWarn.setKind(WarnType.WARN.getValue()); |
|
|
|
boolean result = msPreWarnService.save(msPreWarn); |
|
|
|
if (result) { |
|
|
|
// 当新增报警信息时,websocket通知前端刷新数据
|
|
|
|
//当新增报警信息时,websocket通知前端刷新数据
|
|
|
|
JSONObject obj = new JSONObject(); |
|
|
|
obj.put("cmd", "new_warn_info");//业务类型
|
|
|
|
obj.put("serialNum", msPreWarn.getEventSerialNum());//时间编号
|
|
|
@ -1416,4 +1229,176 @@ public class MilitaryZMQApplication implements ApplicationRunner { |
|
|
|
return new MsAreaPoint[]{pointMap.get(min1), pointMap.get(min2)}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//测试数据
|
|
|
|
public static void main(String[] args) throws SOAPException, ConnectException { |
|
|
|
float d = 3142f; |
|
|
|
int redisDis = (((int) d + 999) / 1000) * 1000; |
|
|
|
System.out.println(redisDis); |
|
|
|
int dis = 845; |
|
|
|
int count = (int) Math.log10(dis) + 1; |
|
|
|
System.out.println();//判断一个数是几位数
|
|
|
|
|
|
|
|
int num = 5000; |
|
|
|
System.out.println(((num + 999) / 1000) * 1000); |
|
|
|
|
|
|
|
|
|
|
|
float speed = 10.45f; |
|
|
|
System.out.println(speed * 1000L); |
|
|
|
long result = (long) (speed * 1000L); |
|
|
|
System.out.println(result); |
|
|
|
|
|
|
|
|
|
|
|
RadarTrackModel radarTrackModel = new RadarTrackModel(); |
|
|
|
radarTrackModel.setDis(1); |
|
|
|
log.info(JSON.toJSONString(radarTrackModel)); |
|
|
|
|
|
|
|
String a = "314.8044"; |
|
|
|
float b = Float.parseFloat(a); |
|
|
|
System.out.println(b); |
|
|
|
|
|
|
|
float azimuth = 314.80445f; |
|
|
|
int redisAzimuth = (int) azimuth; |
|
|
|
System.out.println(redisAzimuth); |
|
|
|
|
|
|
|
double targetSpeed = 1.0831853; |
|
|
|
double targetCourse = 330; |
|
|
|
double degree = Math.toRadians(targetCourse); |
|
|
|
|
|
|
|
double cos = Math.cos(degree); |
|
|
|
double ySpend = Math.cos(targetCourse) * targetSpeed; |
|
|
|
System.out.println(degree); |
|
|
|
System.out.println(cos); |
|
|
|
System.out.println(ySpend); |
|
|
|
System.out.println("--------------------"); |
|
|
|
/* System.out.println(System.getProperty("user.dir") + "\\lib\\hk\\win64\\HCNetSDK.dll"); |
|
|
|
de.onvif.soap.OnvifDevice onvifDevice = new OnvifDevice("192.168.1.71","admin","hk123456"); |
|
|
|
PtzDevices ptzDevices = onvifDevice.getPtz(); |
|
|
|
String token = onvifDevice.getDevices().getProfiles().get(0).getToken();*/ |
|
|
|
// boolean absoluteMoveSupported = ptzDevices.isAbsoluteMoveSupported(token);
|
|
|
|
/* System.out.println(absoluteMoveSupported); |
|
|
|
ptzDevices.absoluteMove(token,0.5f,0.5f,0.5f); |
|
|
|
ptzDevices.relativeMove(token,0,0,0.5f);*/ |
|
|
|
|
|
|
|
/* ptzDevices.absoluteMove(token,0.5f,0f,0f); |
|
|
|
ptzDevices.relativeMove(token,0,0,0.5f); |
|
|
|
ptzDevices.continuousMove(token,0.5f , 0f, 0f); |
|
|
|
//ptzDevices.stopMove(token);
|
|
|
|
PTZStatus status = ptzDevices.getStatus(token);*/ |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("flag", 1); |
|
|
|
jsonObject.put("sourceId", "AgilTrack_cat010bsz"); |
|
|
|
jsonObject.put("utc", System.currentTimeMillis()); |
|
|
|
|
|
|
|
List<RadarTrackModel> radarTracks = new ArrayList<>(); |
|
|
|
RadarTrackModel radarTrack = new RadarTrackModel(); |
|
|
|
radarTrack.setDis(100); |
|
|
|
radarTrack.setAzimuth(315); |
|
|
|
radarTrack.setRadarId(10); |
|
|
|
radarTrack.setSpeed(10); |
|
|
|
radarTrack.setLatitude(22.180616f); |
|
|
|
radarTrack.setLongitude(113.40126f); |
|
|
|
radarTracks.add(radarTrack); |
|
|
|
jsonObject.put("radarTracks", JSON.toJSONString(radarTracks)); |
|
|
|
String jsonString = JSON.toJSONString(jsonObject); |
|
|
|
|
|
|
|
byte[] data = jsonString.getBytes(); |
|
|
|
|
|
|
|
JSONObject jsonObject2 = JSON.parseObject(new String(data)); |
|
|
|
log.info("1.RadarTrack数据:" + jsonObject2.toString()); |
|
|
|
|
|
|
|
String radarTarcksJsonString = (String) jsonObject2.get("radarTracks"); |
|
|
|
List<RadarTrackModel> radarTrackModels = JSONObject.parseArray(radarTarcksJsonString, RadarTrackModel.class); |
|
|
|
float latitude = radarTrackModels.get(0).getLatitude(); |
|
|
|
float longitude = radarTrackModels.get(0).getLongitude(); |
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
|
|
|
String l = decimalFormat.format(latitude); |
|
|
|
String r = decimalFormat.format(longitude); |
|
|
|
System.out.println(latitude); |
|
|
|
System.out.println(longitude); |
|
|
|
System.out.println(l); |
|
|
|
System.out.println(r); |
|
|
|
System.out.println(radarTrackModels); |
|
|
|
|
|
|
|
float ab = 1.0831853f; |
|
|
|
log.info(String.valueOf(ab)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据船速和航向进行跟踪
|
|
|
|
private void trackingTarget() { |
|
|
|
// todo : 通过船速和航向控制球机转动(不采用)
|
|
|
|
MsCameraSetting msCameraSetting=null; |
|
|
|
|
|
|
|
String redisKey = "";//根据雷达图上目标的距离和方位角找到轨迹数据中对应的目标ID
|
|
|
|
|
|
|
|
float targetSpeed = Float.parseFloat(redisUtil.hget(redisKey, "targetSpeed").toString());//获取跟踪目标的航速
|
|
|
|
float targetCourse = Float.parseFloat(redisUtil.hget(redisKey, "targetCourse").toString());//获取跟踪目标的航向
|
|
|
|
|
|
|
|
log.info("targetCourse 航向:" + String.valueOf(targetSpeed)); |
|
|
|
log.info("targetSpeed 航速:" + String.valueOf(targetCourse)); |
|
|
|
|
|
|
|
//计算水平运动速度
|
|
|
|
double ySpend = Math.cos(Math.toRadians(targetCourse)) * targetSpeed; //正数 上 负数 下
|
|
|
|
log.info("ySpend 方向:" + String.valueOf(ySpend)); |
|
|
|
|
|
|
|
String instruct = "stop"; |
|
|
|
//todo : 待优化
|
|
|
|
if (ySpend >= 0) { //160 下 330 上
|
|
|
|
instruct = "right";//(-1, 0, 0)
|
|
|
|
} else { |
|
|
|
instruct = "left";//(1, 0, 0)
|
|
|
|
} |
|
|
|
|
|
|
|
//todo : 速度的计算 根据航速和航向
|
|
|
|
float speed = (float) (targetSpeed * msCameraSetting.getLeftAngle()); |
|
|
|
log.info("相机水平转动速度:" + String.valueOf(speed) + "方向:" + instruct); |
|
|
|
|
|
|
|
msCameraSettingService.ptzControl(msCameraSetting.getIp(), msCameraSetting.getUser(), msCameraSetting.getPassword(), instruct, speed); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取最近球机 |
|
|
|
* |
|
|
|
* @param cameraSettings 所有球机 |
|
|
|
* @param targetHeight 目标高度 |
|
|
|
* @param targetLon 目标经度 |
|
|
|
* @param targetLat 目标纬度 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public MsCameraSetting getNearestDistanceCamera(List<MsCameraSetting> cameraSettings, double targetHeight, double targetLon, double targetLat) { |
|
|
|
// 计算距离最近的球机
|
|
|
|
MsCameraSetting msCameraSetting = null;//最近球机信息
|
|
|
|
double nearestDistance = 0;//最近距离
|
|
|
|
double heightDiff = 0;//最近球机的高度差
|
|
|
|
//Map cameraList=new HashMap();//保存距离目标球机的顺序
|
|
|
|
for (MsCameraSetting cameraSetting : cameraSettings) { |
|
|
|
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
|
|
|
|
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
|
|
|
|
BigDecimal labelHeight = new BigDecimal(targetHeight);//目标高度
|
|
|
|
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
|
|
|
|
if (tempHeightDiff < 0) { |
|
|
|
log.info("ip=" + cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围"); |
|
|
|
} else { |
|
|
|
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(), cameraSetting.getLatitude().doubleValue(), targetLon, targetLat); |
|
|
|
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
|
|
|
|
if (msCameraSetting == null) { |
|
|
|
msCameraSetting = cameraSetting; |
|
|
|
nearestDistance = temp; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
|
|
|
|
if (nearestDistance > temp) { |
|
|
|
msCameraSetting = cameraSetting; |
|
|
|
nearestDistance = temp; |
|
|
|
heightDiff = tempHeightDiff; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//判断两点的距离是否超过有效距离,超过则丢掉
|
|
|
|
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) { |
|
|
|
log.info("超过跟踪的最大距离" + redisUtil.hget("alarm_settings", "inOutEffectDistance").toString()); |
|
|
|
} |
|
|
|
return msCameraSetting; |
|
|
|
} |
|
|
|
} |
|
|
|