|
@@ -3,6 +3,7 @@ package com.skyversation.poiaddr.controller;
|
|
|
import com.skyversation.poiaddr.entity.FileDataDto;
|
|
|
import com.skyversation.poiaddr.entity.PoiAddress;
|
|
|
import com.skyversation.poiaddr.service.PoiAddressService;
|
|
|
+import com.skyversation.poiaddr.util.ExcelReaderUtils;
|
|
|
import com.skyversation.poiaddr.util.RequestUtils;
|
|
|
import com.skyversation.poiaddr.util.fileTools.ReadFileData;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -139,22 +140,22 @@ public class PoiAddressController {
|
|
|
}
|
|
|
// 封装解析文件的参数
|
|
|
// TODO 文件数据解析
|
|
|
- assert file != null;
|
|
|
List<FileDataDto> fileDataDtoList = ReadFileData.ReadMultipartFile(file);
|
|
|
// TODO 补充FileDataDto中的搜索条件参数
|
|
|
for (FileDataDto fileDataDto : fileDataDtoList) {
|
|
|
// 搜索等级
|
|
|
fileDataDto.setMatchingLevel(matchingLevel);
|
|
|
-// set地名地址搜索字段
|
|
|
+// TODO 数据过滤
|
|
|
+// set地名地址搜索字段
|
|
|
Map<String, Object> properties = fileDataDto.getProperties();
|
|
|
- if (addr1Key != null && !addr1Key.isEmpty()) {
|
|
|
+ if (addr1Key != null && !addr1Key.isEmpty() && ExcelReaderUtils.isOtherDistrictThanQingpu(addr1Key)) {
|
|
|
String address = "上海市青浦区" + properties.getOrDefault(addr1Key, "").toString().replace("青浦区", "").replace(
|
|
|
- "青浦", "").replace("上海市","").replace("上海","").replace("/弄","").replace("/号","").replace("弄","").replace("/幢","").replace("/室"," ").replace("(号楼) "," ");
|
|
|
+ "青浦", "").replace("上海市", "").replace("上海", "").replace("/弄", "").replace("/号", "").replace("弄", "").replace("/幢", "").replace("/室", " ").replace("(号楼) ", " ");
|
|
|
fileDataDto.setAddr1(address);
|
|
|
}
|
|
|
- if (addr2Key != null && !addr2Key.isEmpty()) {
|
|
|
+ if (addr2Key != null && !addr2Key.isEmpty() && ExcelReaderUtils.isOtherDistrictThanQingpu(addr2Key)) {
|
|
|
String address = "上海市青浦区" + properties.getOrDefault(addr2Key, "").toString().replace("青浦区", "").replace(
|
|
|
- "青浦", "").replace("上海市","").replace("上海","").replace("/弄","").replace("/号","").replace("弄","").replace("/幢","").replace("/室"," ").replace("(号楼) "," ");
|
|
|
+ "青浦", "").replace("上海市", "").replace("上海", "").replace("/弄", "").replace("/号", "").replace("弄", "").replace("/幢", "").replace("/室", " ").replace("(号楼) ", " ");
|
|
|
fileDataDto.setAddr2(address);
|
|
|
}
|
|
|
// 判断是否有参考经纬度字段
|
|
@@ -181,34 +182,34 @@ public class PoiAddressController {
|
|
|
selectOptions.add("GCJ02");
|
|
|
selectOptions.add("BD09");
|
|
|
selectOptions.add("SH2000");
|
|
|
- if(inCoordinate != null && !inCoordinate.isEmpty()){
|
|
|
+ if (inCoordinate != null && !inCoordinate.isEmpty()) {
|
|
|
if (!selectOptions.contains(inCoordinate)) {
|
|
|
return "请传入正确的坐标系名称!可选坐标系名称:WGS84,GCJ02,BD09,SH2000";
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
inCoordinate = "WGS84";
|
|
|
}
|
|
|
- for(FileDataDto fileDataDto:fileDataDtoList){
|
|
|
- if(fileDataDto.getLat() != null && fileDataDto.getLon() != null){
|
|
|
- double[] lonLat = com.skyversation.poiaddr.util.Coordinate.transformationCoordinateByCoordinate(fileDataDto.getLat(),fileDataDto.getLon(),inCoordinate,outCoordinate);
|
|
|
+ for (FileDataDto fileDataDto : fileDataDtoList) {
|
|
|
+ if (fileDataDto.getLat() != null && fileDataDto.getLon() != null) {
|
|
|
+ double[] lonLat = com.skyversation.poiaddr.util.Coordinate.transformationCoordinateByCoordinate(fileDataDto.getLat(), fileDataDto.getLon(), inCoordinate, outCoordinate);
|
|
|
fileDataDto.setLat(lonLat[1]);
|
|
|
fileDataDto.setLon(lonLat[0]);
|
|
|
}
|
|
|
// TODO 距离计算
|
|
|
- if(matchingDistance != null){
|
|
|
- if(fileDataDto.getResultLat() != null && fileDataDto.getResultLon() != null && fileDataDto.getLat() != null && fileDataDto.getLon() != null){
|
|
|
- double distance = com.skyversation.poiaddr.util.Coordinate.calculateDistance(fileDataDto.getResultLat(),fileDataDto.getResultLon(),fileDataDto.getLat(),fileDataDto.getLon());
|
|
|
+ if (matchingDistance != null) {
|
|
|
+ if (fileDataDto.getResultLat() != null && fileDataDto.getResultLon() != null && fileDataDto.getLat() != null && fileDataDto.getLon() != null) {
|
|
|
+ double distance = com.skyversation.poiaddr.util.Coordinate.calculateDistance(fileDataDto.getResultLat(), fileDataDto.getResultLon(), fileDataDto.getLat(), fileDataDto.getLon());
|
|
|
fileDataDto.setMatchingDistance(distance);
|
|
|
double matchingDistanceDb = Double.parseDouble(matchingDistance.toString());
|
|
|
- if(distance < matchingDistanceDb){
|
|
|
+ if (distance < matchingDistanceDb) {
|
|
|
fileDataDto.setLtMatchingDistance("是");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
fileDataDto.setLtMatchingDistance("否");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// TODO 区域判断
|
|
|
- if(regionalJudgment != null && !regionalJudgment.isEmpty()){
|
|
|
+ if (regionalJudgment != null && !regionalJudgment.isEmpty()) {
|
|
|
// 解析geojson文件得到区域
|
|
|
|
|
|
}
|