|
@@ -11,11 +11,13 @@ import com.skyversation.poiaddr.util.RequestUtils;
|
|
|
import com.skyversation.poiaddr.util.SerializationUtils;
|
|
|
import com.skyversation.poiaddr.util.fileTools.ReadFileData;
|
|
|
import com.skyversation.poiaddr.util.geotools.GeoJsonIntersector;
|
|
|
+import com.skyversation.poiaddr.util.geotools.GeoJsonPointInRegion;
|
|
|
import com.skyversation.poiaddr.util.status.AddressLevel;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.locationtech.jts.geom.Coordinate;
|
|
|
import org.locationtech.jts.geom.GeometryFactory;
|
|
|
import org.locationtech.jts.geom.Point;
|
|
|
+import org.locationtech.jts.io.ParseException;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -112,7 +114,7 @@ public class PoiAddressController {
|
|
|
@RequestParam(name = "matchingLevel", required = false) Integer matchingLevel,
|
|
|
@RequestParam(name = "regionalJudgment", required = false) MultipartFile regionalJudgment,
|
|
|
@RequestParam(name = "outFileType", required = false) String outFileType,
|
|
|
- @RequestParam(name = "outputFileName", required = false) String outputFileName) throws IOException {
|
|
|
+ @RequestParam(name = "outputFileName", required = false) String outputFileName) throws IOException, ParseException {
|
|
|
// 参数合法性判断
|
|
|
if ((file != null && !file.isEmpty()) && (addrColNames != null && !addrColNames.isEmpty())) {
|
|
|
outputFileName += UUID.randomUUID();
|
|
@@ -163,6 +165,11 @@ public class PoiAddressController {
|
|
|
// 封装解析文件的参数
|
|
|
// TODO 文件数据解析
|
|
|
List<FileDataDto> fileDataDtoList = ReadFileData.ReadMultipartFile(file);
|
|
|
+ List<FileDataDto> regionalDataList = new ArrayList<>();
|
|
|
+ if (regionalJudgment != null && !regionalJudgment.isEmpty()) {
|
|
|
+// 解析geojson文件得到区域
|
|
|
+ regionalDataList = ReadFileData.ReadMultipartFile(regionalJudgment);
|
|
|
+ }
|
|
|
// TODO 补充FileDataDto中的搜索条件参数
|
|
|
for (FileDataDto fileDataDto : fileDataDtoList) {
|
|
|
// 搜索等级
|
|
@@ -172,27 +179,25 @@ public class PoiAddressController {
|
|
|
Map<String, Object> properties = fileDataDto.getProperties();
|
|
|
try {
|
|
|
if (properties != null && properties.get(addr1Key) != null && addr1Key != null && properties.get(addr1Key).toString().length() > 2 && ExcelReaderUtils.isOtherDistrictThanQingpu(properties.get(addr1Key).toString())) {
|
|
|
- String address = "上海市青浦区" + properties.getOrDefault(addr1Key, "").toString().replace("青浦区", "").replace(
|
|
|
- "青浦", "").replace("上海市", "").replace("上海", "").replaceAll("-", "");
|
|
|
+ String address = "上海市青浦区" + AddressQueryEngine.addressReplaceAll(properties.getOrDefault(addr1Key, "").toString());
|
|
|
fileDataDto.setAddr1(address);
|
|
|
}
|
|
|
- if (addr2Key != null && !addr2Key.isEmpty() && ExcelReaderUtils.isOtherDistrictThanQingpu(addr2Key)) {
|
|
|
- String address = "上海市青浦区" + properties.getOrDefault(addr2Key.trim(), "").toString().replace("青浦区", "").replace(
|
|
|
- "青浦", "").replace("上海市", "").replace("上海", "").replace("/弄", "").replace("/号", "").replace("弄", "").replace("/幢", "").replace("/室", " ").replace("(号楼) ", " ");
|
|
|
+ if (properties != null && properties.get(addr1Key) != null && addr2Key != null && properties.get(addr2Key).toString().length() > 2 && ExcelReaderUtils.isOtherDistrictThanQingpu(properties.get(addr2Key).toString())) {
|
|
|
+ String address = "上海市青浦区" + AddressQueryEngine.addressReplaceAll(properties.getOrDefault(addr2Key, "").toString());
|
|
|
fileDataDto.setAddr2(address);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
System.err.println(e);
|
|
|
}
|
|
|
// 判断是否有参考经纬度字段
|
|
|
- if (latKey != null && !latKey.isEmpty() && lonKey != null && !lonKey.isEmpty() && properties.get(latKey) != null && properties.get(lonKey) != null) {
|
|
|
+ if (properties != null && latKey != null && !latKey.isEmpty() && lonKey != null && !lonKey.isEmpty() && properties.get(latKey) != null && properties.get(lonKey) != null) {
|
|
|
String latStr = properties.get(latKey).toString();
|
|
|
String lonStr = properties.get(lonKey).toString();
|
|
|
fileDataDto.setLat(Double.valueOf(latStr));
|
|
|
fileDataDto.setLon(Double.valueOf(lonStr));
|
|
|
- } else if (!latLonKey.isEmpty() && !SplitStr.isEmpty()) {
|
|
|
+ } else if (!latLonKey.isEmpty()) {
|
|
|
String[] latLonKeys = latLonKey.split(SplitStr);
|
|
|
- if (properties.get(latLonKeys[0]) != null && properties.get(latLonKeys[1]) != null) {
|
|
|
+ if (properties != null && properties.get(latLonKeys[0]) != null && properties.get(latLonKeys[1]) != null) {
|
|
|
String latStr = properties.get(latLonKeys[0]).toString();
|
|
|
String lonStr = properties.get(latLonKeys[1]).toString();
|
|
|
fileDataDto.setLat(Double.valueOf(latStr));
|
|
@@ -303,9 +308,17 @@ public class PoiAddressController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // TODO 区域判断
|
|
|
- if (regionalJudgment != null && !regionalJudgment.isEmpty()) {
|
|
|
+ // TODO 区域判断(得到经纬度后,要判断得到的点是否在传入的geojson面内)
|
|
|
+ if (regionalDataList != null && regionalDataList.size() > 0) {
|
|
|
// 解析geojson文件得到区域
|
|
|
+ boolean isArea= false;
|
|
|
+ for(FileDataDto regionlItem: regionalDataList){
|
|
|
+ if(GeoJsonPointInRegion.isPointInGeoJsonRegion(regionlItem.getGeometry().toString(),fileDataDto.getLat(),fileDataDto.getLon())){
|
|
|
+ isArea = true;
|
|
|
+ break;
|
|
|
+ };
|
|
|
+ }
|
|
|
+ fileDataDto.getProperties().put("是否在区域内",isArea ? "是" : "否");
|
|
|
}
|
|
|
dataList.add(fileDataDto.getProperties());
|
|
|
}
|