| | |
| | | if (ObjectUtils.isEmpty(historySecondUavs)){ |
| | | return new ResultMessage(ResponseCodeEnum.TARGET_IS_NULL,"null"); |
| | | } |
| | | |
| | | int ik=1; |
| | | for (HistorySecondUav historySecondUav : historySecondUavs) { |
| | | String value = historySecondUav.getValue(); |
| | | Map map1 = JSON.parseObject(value, Map.class); |
| | | flyLatList.add(Double.parseDouble(map1.get("flylat").toString())); |
| | | flyLonList.add(Double.parseDouble(map1.get("flylon").toString())); |
| | | historySecondUav.setId(ik++); |
| | | |
| | | } |
| | | Double maxLat = Collections.max(flyLatList); |
| | |
| | | } |
| | | } |
| | | } |
| | | ArrayList<Integer> list2 = new ArrayList<>(); |
| | | ArrayList<UAVResultDTO> uavResultDTOS1 = new ArrayList<>(); |
| | | for (UAVGteForDTO uavGteForDTO : list) { |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | ArrayList<String[]> doubleArrayList = new ArrayList<>(); |
| | | doubleArrayList.add(uavGteForDTO.getLeftTop()); |
| | | doubleArrayList.add(uavGteForDTO.getLeftBottom()); |
| | | doubleArrayList.add(uavGteForDTO.getRightTop()); |
| | | doubleArrayList.add(uavGteForDTO.getRightBottom()); |
| | | UAVResultDTO result = getResults(doubleArrayList); |
| | | for (int i = 0; i < historySecondUavs.size(); i++) { |
| | | HistorySecondUav historySecondUav = historySecondUavs.get(i); |
| | | String value = historySecondUav.getValue(); |
| | | Map map1 = JSON.parseObject(value, Map.class); |
| | | String flylat = map1.get("flylat").toString(); |
| | | String flylon = map1.get("flylon").toString(); |
| | | //判断点是否在区域内 |
| | | boolean flag = isInPolygon(flylon,flylat,doubleArrayList); |
| | | if (flag){ |
| | | list2.add(list2.size()+1); |
| | | list1.add(historySecondUav.getValue()); |
| | | historySecondUavs.remove(i); |
| | | } |
| | | } |
| | | uavResultDTOS1.add(result); |
| | | } |
| | | if (!ObjectUtils.isEmpty(uavResultDTOS1)){ |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS1); |
| | | |
| | | } |
| | | |
| | | |
| | | HashMap<String,List<String>> rsMap = new HashMap<>(); |
| | | List<String> stringList = new ArrayList<>(); |
| | | for (UAVGteForDTO uavGteForDTO : list) { |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | ArrayList<String[]> doubleArrayList = new ArrayList<>(); |
| | |
| | | doubleArrayList.add(uavGteForDTO.getLeftBottom()); |
| | | doubleArrayList.add(uavGteForDTO.getRightTop()); |
| | | doubleArrayList.add(uavGteForDTO.getRightBottom()); |
| | | String[] leftTops = uavGteForDTO.getLeftTop(); |
| | | String[] rightBottoms = uavGteForDTO.getRightBottom(); |
| | | Double x1 = Double.parseDouble(leftTops[0]); |
| | | Double x2 = Double.parseDouble(rightBottoms[0]); |
| | | Double y1 = Double.parseDouble(leftTops[1]); |
| | | Double y2 = Double.parseDouble(rightBottoms[1]); |
| | | //获取区域对象 |
| | | for (int i = 0; i < historySecondUavs.size(); i++) { |
| | | HistorySecondUav historySecondUav = historySecondUavs.get(i); |
| | |
| | | String flylat = map1.get("flylat").toString(); |
| | | String flylon = map1.get("flylon").toString(); |
| | | //判断点是否在区域内 |
| | | boolean flag = isInPolygon(flylon,flylat,doubleArrayList); |
| | | boolean flag = isInPolygon(flylon,flylat,x1,x2,y1,y2); |
| | | if (flag){ |
| | | list1.add(historySecondUav.getValue()); |
| | | historySecondUavs.remove(i); |
| | | String time = DateUtils.dateToDateString(historySecondUav.getTime()); |
| | | //historySecondUavs.remove(i); |
| | | if(!stringList.contains(time)){ |
| | | list1.add(historySecondUav.getValue()); |
| | | stringList.add(time); |
| | | } |
| | | } |
| | | } |
| | | //获取中心点坐标 |
| | | String result = getResult(doubleArrayList); |
| | | rsMap.put(result,list1); |
| | | } |
| | | // for (HistorySecondUav historySecondUav : historySecondUavs) { |
| | | // String value = historySecondUav.getValue(); |
| | | // Map map1 = JSON.parseObject(value, Map.class); |
| | | // String flylat = map1.get("flylat").toString(); |
| | | // String flylon = map1.get("flylon").toString(); |
| | | // //判断点是否在区域内 |
| | | // boolean flag = isInPolygon(flylon,flylat,doubleArrayList); |
| | | // if (flag){ |
| | | // historySecondUavs.remove(historySecondUav); |
| | | // list1.add(historySecondUav.getValue()); |
| | | // } |
| | | // } |
| | | // //获取中心点坐标 |
| | | // String result = getResult(doubleArrayList); |
| | | // rsMap.put(result,list1); |
| | | // } |
| | | } |
| | | |
| | | //计算区域类所有因子的平均数 |
| | | ArrayList<UAVResultDTO> uavResultDTOS = new ArrayList<>(); |
| | |
| | | double p_x =Double.parseDouble(X); |
| | | double p_y =Double.parseDouble(Y); |
| | | Point2D.Double point = new Point2D.Double(p_x, p_y); |
| | | |
| | | List<Point2D.Double> pointList= new ArrayList<Point2D.Double>(); |
| | | |
| | | for (String[] strings : doubleArrayList) { |
| | | double polygonPoint_x=Double.parseDouble(strings[0]); |
| | | double polygonPoint_y=Double.parseDouble(strings[1]); |
| | |
| | | |
| | | } |
| | | |
| | | public boolean isInPolygon(String X,String Y,double x1,double x2,double y1,double y2){ |
| | | boolean result = false; |
| | | double x =Double.parseDouble(X); |
| | | double y =Double.parseDouble(Y); |
| | | if(x >= Math.min(x1, x2) && x <= Math.max(x1, x2) ){ |
| | | if(y >= Math.min(y1, y2) && y <= Math.max(y1, y2)){ |
| | | result = true; |
| | | } |
| | | } |
| | | return result; |
| | | |
| | | } |
| | | |
| | | } |