| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.moral.api.pojo.dto.uav.UAVResultListDTO; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private HistorySecondUavMapper historySecondUavMapper; |
| | | |
| | | @Override |
| | | public UAVResultListDTO getUavMore(Map<String, Object> params) { |
| | | UAVResultListDTO uavResultListDTO = new UAVResultListDTO(); |
| | | String uvasize = params.get("uvasize").toString(); |
| | | int size = Integer.parseInt(uvasize); |
| | | //纬度 |
| | | ArrayList<Double> flyLatList = new ArrayList<>(); |
| | | //经度 |
| | | ArrayList<Double> flyLonList = new ArrayList<>(); |
| | | String type = params.get("type").toString(); |
| | | params.put("type","$."+type); |
| | | List<UAVGetBD> historySecondUavs = historySecondUavMapper.reListDetail(params); |
| | | if (ObjectUtils.isEmpty(historySecondUavs)){ |
| | | return null; |
| | | } |
| | | ArrayList<UAVGetBD> rsBDList = new ArrayList<>(); |
| | | for (UAVGetBD historySecondUav : historySecondUavs) { |
| | | UAVGetBD uavGetBD = new UAVGetBD(); |
| | | //WGS84 转 百度坐标 |
| | | double[] doubles = transformWGS84ToBD09(historySecondUav.getFlyLon(), historySecondUav.getFlyLat()); |
| | | uavGetBD.setFlyLon(doubles[0]); |
| | | uavGetBD.setFlyLat(doubles[1]); |
| | | uavGetBD.setNum(historySecondUav.getNum()); |
| | | rsBDList.add(uavGetBD); |
| | | flyLatList.add(doubles[1]); |
| | | flyLonList.add(doubles[0]); |
| | | } |
| | | //获取最大最小的经纬度 |
| | | Double maxLat = Collections.max(flyLatList); |
| | | Double maxLon = Collections.max(flyLonList); |
| | | Double minLat = Collections.min(flyLatList); |
| | | Double minLon = Collections.min(flyLonList); |
| | | double distance1 = getDistance(maxLon, minLat, maxLon, maxLat); |
| | | //计算经度的距离 |
| | | double distance2 = getDistance(maxLon, minLat, minLon, minLat); |
| | | ArrayList<UAVGteForDTO> list = new ArrayList<>(); |
| | | String[] youshang = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, size); |
| | | //右下2 |
| | | String[] youxia = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(youshang[0]), Double.parseDouble(youshang[1]), size); |
| | | //左下2 |
| | | String[] zuoxia = calLocationByDistanceAndLocationAndDirection(180, minLon, maxLat, size); |
| | | for (int i = 0; i <distance2 ; i+=size) { |
| | | UAVGteForDTO dto1 = new UAVGteForDTO(); |
| | | String[] strings2 = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, i); |
| | | String[] strings3 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youshang[0].toString()), Double.parseDouble(youshang[1].toString()), i); |
| | | String[] strings4 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youxia[0].toString()), Double.parseDouble(youxia[1].toString()), i); |
| | | String[] strings5 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(zuoxia[0].toString()), Double.parseDouble(zuoxia[1].toString()), i); |
| | | dto1.setLeftTop(strings2); |
| | | dto1.setRightTop(strings3); |
| | | dto1.setRightBottom(strings4); |
| | | dto1.setLeftBottom(strings5); |
| | | list.add(dto1); |
| | | for (int j = 0; j < distance1; j+=size) { |
| | | UAVGteForDTO dto2 = new UAVGteForDTO(); |
| | | String[] strings6 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings2[0].toString()), Double.parseDouble(strings2[1].toString()), j); |
| | | String[] strings7 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings3[0].toString()), Double.parseDouble(strings3[1].toString()), j); |
| | | String[] strings8 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings4[0].toString()), Double.parseDouble(strings4[1].toString()), j); |
| | | String[] strings9 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings5[0].toString()), Double.parseDouble(strings5[1].toString()), j); |
| | | dto2.setLeftTop(strings6); |
| | | dto2.setRightTop(strings7); |
| | | dto2.setRightBottom(strings8); |
| | | dto2.setLeftBottom(strings9); |
| | | if (j!=0){ |
| | | list.add(dto2); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | @Override |
| | | public List<UAVResultDTO> getUav(Map<String, Object> params) { |
| | | |
| | | String uvasize = params.get("uvasize").toString(); |