|
|
|
@ -8,6 +8,7 @@ import com.hisense.hiatmp.server_api.mapper.OperatorMapper; |
|
|
|
import com.hisense.hiatmp.server_api.model.BisRoadVO; |
|
|
|
import com.hisense.hiatmp.server_api.model.BisRoadVO; |
|
|
|
import com.hisense.hiatmp.server_api.service.HighDangerService; |
|
|
|
import com.hisense.hiatmp.server_api.service.HighDangerService; |
|
|
|
import com.hisense.hiatmp.model.dmr.Point; |
|
|
|
import com.hisense.hiatmp.model.dmr.Point; |
|
|
|
|
|
|
|
import com.hisense.hiatmp.server_api.utils.CoordinateUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@ -155,21 +157,26 @@ public class HighDangerController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取全部道路
|
|
|
|
// 获取全部道路
|
|
|
|
@GetMapping("/getAllSection") |
|
|
|
/*@GetMapping("/getAllSection") |
|
|
|
public ServerResponse<?> getAllRoad(){ |
|
|
|
public ServerResponse<?> getAllRoad(){ |
|
|
|
|
|
|
|
|
|
|
|
List<SectionVO> allSection = highDangerMapper.getAllSection(); |
|
|
|
List<SectionVO> allSection = highDangerMapper.getAllSection(); |
|
|
|
|
|
|
|
|
|
|
|
return ServerResponse.ok(allSection); |
|
|
|
return ServerResponse.ok(allSection); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
// 获取最近道路
|
|
|
|
// 获取最近道路
|
|
|
|
@PostMapping("/getNearRoadInfo") |
|
|
|
@PostMapping("/getNearRoadInfo") |
|
|
|
public ServerResponse<?> getNearRoad(@RequestBody Point point, |
|
|
|
public ServerResponse<?> getNearRoad(@RequestBody Point point, |
|
|
|
@RequestParam(defaultValue = "1") Long pageNum, |
|
|
|
@RequestParam(defaultValue = "1") Long pageNum, |
|
|
|
@RequestParam(defaultValue = "10") Long pageSize){ |
|
|
|
@RequestParam(defaultValue = "10") Long pageSize){ |
|
|
|
|
|
|
|
//获取三公里内的坐标
|
|
|
|
|
|
|
|
double[] rectangle = CoordinateUtils.getRectangleCoordinates(point.getY(),point.getX(),3); |
|
|
|
// 获取全部路段数据
|
|
|
|
// 获取全部路段数据
|
|
|
|
List<SectionVO> allRoadInfo = highDangerMapper.getAllSection(); |
|
|
|
BigDecimal d = new BigDecimal(point.getX()).setScale(1,BigDecimal.ROUND_DOWN); |
|
|
|
|
|
|
|
SectionVO sectionVO = new SectionVO(); |
|
|
|
|
|
|
|
sectionVO.setPosition(String.valueOf(d)); |
|
|
|
|
|
|
|
List<SectionVO> allRoadInfo = highDangerMapper.getAllSection(sectionVO); |
|
|
|
HashMap<String, Map<Double, String>> combinedMap = new HashMap<>(); |
|
|
|
HashMap<String, Map<Double, String>> combinedMap = new HashMap<>(); |
|
|
|
HashMap<String, Map<Double, String>> pointMapSection = new HashMap<>(); |
|
|
|
HashMap<String, Map<Double, String>> pointMapSection = new HashMap<>(); |
|
|
|
HashMap<String, Map<Double, String>> pointMapCrossing = new HashMap<>(); |
|
|
|
HashMap<String, Map<Double, String>> pointMapCrossing = new HashMap<>(); |
|
|
|
@ -179,50 +186,60 @@ public class HighDangerController { |
|
|
|
for(SectionVO dto : allRoadInfo){ |
|
|
|
for(SectionVO dto : allRoadInfo){ |
|
|
|
Map<Double,String> map = new HashMap<>(); |
|
|
|
Map<Double,String> map = new HashMap<>(); |
|
|
|
// 临时存储最短距离
|
|
|
|
// 临时存储最短距离
|
|
|
|
Double minDistance = null; |
|
|
|
//Double minDistance = null;
|
|
|
|
if(dto.getPosition() == null){ |
|
|
|
if(dto.getPosition() == null){ |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 将单条路段的坐标点依次取出进行对比
|
|
|
|
// 将单条路段的坐标点依次取出进行对比
|
|
|
|
String[] split = dto.getPosition().split(","); |
|
|
|
String[] split = dto.getPosition().split(","); |
|
|
|
for(int i = 0; i < split.length; i += 2){ |
|
|
|
float x = Float.parseFloat(split[0]); |
|
|
|
float x = Float.parseFloat(split[i]); |
|
|
|
float y = Float.parseFloat(split[1]); |
|
|
|
float y = Float.parseFloat(split[i + 1]); |
|
|
|
if (!(x >= rectangle[0] && x <= rectangle[2] && y >= rectangle[1] && y <= rectangle[3])){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//for(int i = 0; i < split.length; i += 2){
|
|
|
|
|
|
|
|
//float x = Float.parseFloat(split[i]);
|
|
|
|
|
|
|
|
//float y = Float.parseFloat(split[i + 1]);
|
|
|
|
Dpoint.setX(x); |
|
|
|
Dpoint.setX(x); |
|
|
|
Dpoint.setY(y); |
|
|
|
Dpoint.setY(y); |
|
|
|
// 计算两点间的距离
|
|
|
|
// 计算两点间的距离
|
|
|
|
Double pointDistance = highDangerService.getPointDistance(Dpoint, point); |
|
|
|
Double pointDistance = highDangerService.getPointDistance(Dpoint, point); |
|
|
|
// 最短距离为空,初次存入第一个值
|
|
|
|
// 最短距离为空,初次存入第一个值
|
|
|
|
if(minDistance == null){ |
|
|
|
/*if(minDistance == null){ |
|
|
|
minDistance = pointDistance; |
|
|
|
minDistance = pointDistance; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
if(pointDistance < minDistance){ |
|
|
|
if(pointDistance < minDistance){ |
|
|
|
minDistance = pointDistance; |
|
|
|
minDistance = pointDistance; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
//}
|
|
|
|
map.put(minDistance, dto.getPosition()); |
|
|
|
map.put(pointDistance, dto.getPosition()); |
|
|
|
// 将路段和最短路线
|
|
|
|
// 将路段和最短路线
|
|
|
|
pointMapSection.put(dto.getSectionName(), map); |
|
|
|
pointMapSection.put(dto.getSectionName(), map); |
|
|
|
minDistance = null; |
|
|
|
//minDistance = null;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取所有路口信息
|
|
|
|
// 获取所有路口信息
|
|
|
|
List<CrossingDTO> allCrossing = highDangerMapper.getAllCrossing(); |
|
|
|
CrossingDTO crossingDTO = new CrossingDTO(); |
|
|
|
|
|
|
|
crossingDTO.setLonMin(rectangle[0]); |
|
|
|
|
|
|
|
crossingDTO.setLatMin(rectangle[1]); |
|
|
|
|
|
|
|
crossingDTO.setLonMax(rectangle[2]); |
|
|
|
|
|
|
|
crossingDTO.setLatMax(rectangle[3]); |
|
|
|
|
|
|
|
List<CrossingDTO> allCrossing = highDangerMapper.getAllCrossing(crossingDTO); |
|
|
|
// 遍历集合,将所有坐标点与当前坐标比较
|
|
|
|
// 遍历集合,将所有坐标点与当前坐标比较
|
|
|
|
for(CrossingDTO cross : allCrossing){ |
|
|
|
for(CrossingDTO cross : allCrossing){ |
|
|
|
Map<Double,String> map = new HashMap<>(); |
|
|
|
Map<Double,String> map = new HashMap<>(); |
|
|
|
float x = cross.getLongitude(); |
|
|
|
float x = cross.getLongitude(); |
|
|
|
float y = cross.getLatitude(); |
|
|
|
float y = cross.getLatitude(); |
|
|
|
|
|
|
|
/*if (!(x >= rectangle[0] && x <= rectangle[2] && y >= rectangle[1] && y <= rectangle[3])){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
}*/ |
|
|
|
Dpoint.setX(x); |
|
|
|
Dpoint.setX(x); |
|
|
|
Dpoint.setY(y); |
|
|
|
Dpoint.setY(y); |
|
|
|
// 计算两点间的距离
|
|
|
|
// 计算两点间的距离
|
|
|
|
Double pointDistance = highDangerService.getPointDistance(Dpoint, point); |
|
|
|
Double pointDistance = highDangerService.getPointDistance(Dpoint, point); |
|
|
|
map.put(pointDistance, String.valueOf(cross.getLongitude() + "," + cross.getLatitude())); |
|
|
|
map.put(pointDistance, cross.getLongitude() + "," + cross.getLatitude()); |
|
|
|
pointMapCrossing.put(cross.getCrossingName(), map); |
|
|
|
pointMapCrossing.put(cross.getCrossingName(), map); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -235,11 +252,14 @@ public class HighDangerController { |
|
|
|
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
|
|
|
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
|
|
|
|
|
|
|
|
|
|
|
// 将路段根据计算的值进行排序
|
|
|
|
// 将路段根据计算的值进行排序
|
|
|
|
LinkedHashMap<String, Map<Double, String>> collect = highDangerService.sortMapByValue(combinedMap).entrySet().stream() |
|
|
|
|
|
|
|
|
|
|
|
LinkedHashMap<String, Map<Double, String>> collect = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
if (null != combinedMap) { |
|
|
|
|
|
|
|
collect = highDangerService.sortMapByValue(combinedMap).entrySet().stream() |
|
|
|
.skip((pageNum - 1) * pageSize) |
|
|
|
.skip((pageNum - 1) * pageSize) |
|
|
|
.limit(pageSize) |
|
|
|
.limit(pageSize) |
|
|
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); |
|
|
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); |
|
|
|
|
|
|
|
} |
|
|
|
return ServerResponse.ok(collect); |
|
|
|
return ServerResponse.ok(collect); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|