From c719838525c874e1527b6ee137a163f044ba4a80 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Thu, 11 Jul 2024 20:42:26 +0800
Subject: [PATCH] 新增喊话模块,更新shp文件入库,对图片返回做去重处理
---
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java | 45 ++++++++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java b/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
index db86543..157abb7 100644
--- a/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
+++ b/src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
@@ -49,25 +49,19 @@
List<LotInfo> list = new ArrayList<>();
File file1 = MultipartFileTOFileUtil.multipartFile2File(file, patchesConfigPojo.getUnzip());
List<ShpDTO> shpData = ShapeFileUtil.shpToGeoJson(file1);
- String s=null;
- for (int i = 0; i < shpData.size(); i++) {
- String[] arr1 = FormatConversionUtil.formatConversion(Collections.singletonList(s));
+ for (ShpDTO shpDatum : shpData) {
LotInfo lotInfo = new LotInfo();
- String temp = arr1[i].trim();
- temp = FormatConversionUtil.modifySpacesAndCommas(temp);
- json = head + temp;
String uuid = UUID.randomUUID().toString();
String bsm = uuid.replaceAll("-", "");
lotInfo.setBsm(bsm);
lotInfo.setWorkspaceId(workspaceId);
- lotInfo.setDkfw(json);
- lotInfo.setDkbh("dkbh" + i);
+ lotInfo.setDkfw(poylonCGCStoWGS(convertToWKT(shpDatum.getDKFW())));
+ lotInfo.setDkbh(shpDatum.getDKBH());
+ lotInfo.setXzb(shpDatum.getXZB());
+ lotInfo.setYzb(shpDatum.getYZB());
+ lotInfo.setXzqdm(shpDatum.getXZQDM());
+ lotInfo.setXmc(DistrictCodeUtils.codeToName(lotInfo.getXzqdm()));
list.add(lotInfo);
- String strs = getCentros(list);
- String end = strs.replaceAll("\\(", "").replaceAll(", NaN\\)", "");
- String[] points = end.split(",");
- lotInfo.setXzb(Double.valueOf(points[0]));
- lotInfo.setYzb(Double.valueOf(points[1]));
shpToDataSourceMapper.insert(lotInfo);
}
List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, airportLat, airportLon);
@@ -126,6 +120,31 @@
public List<LotInfo> getNoPlan(){
return shpToDataSourceMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getIsPlan,0));
}
+ public static String convertToWKT(String coordinates) {
+ // Remove outermost square brackets and split by comma
+ String cleanedCoordinates = coordinates.substring(4, coordinates.length() - 4);
+ String[] polygons = cleanedCoordinates.split("\\]\\],\\[\\[");
+ StringBuilder wkt = new StringBuilder("MULTIPOLYGON(");
+
+ for (String polygon : polygons) {
+ wkt.append("((");
+ String[] points = polygon.split("\\],\\[");
+ for (String point : points) {
+ String[] coords = point.split(",");
+ double x = Double.parseDouble(coords[0]);
+ double y = Double.parseDouble(coords[1]);
+ wkt.append(x).append(" ").append(y).append(", ");
+ }
+ // Remove the last comma and space
+ wkt.setLength(wkt.length() - 2);
+ wkt.append(")), ");
+ }
+ // Remove the last comma and space, and close the polygon
+ wkt.setLength(wkt.length() - 2);
+ wkt.append(")");
+
+ return wkt.toString();
+ }
}
--
Gitblit v1.9.3