From 2db1aa88e8ab53096a936163d686b90d8e056a99 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 21 Aug 2024 23:18:33 +0800
Subject: [PATCH] 国土对接返回信息加密
---
src/main/java/com/dji/sample/patches/utils/FormatConversionUtil.java | 43 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/dji/sample/patches/utils/FormatConversionUtil.java b/src/main/java/com/dji/sample/patches/utils/FormatConversionUtil.java
index 6d66005..288d711 100644
--- a/src/main/java/com/dji/sample/patches/utils/FormatConversionUtil.java
+++ b/src/main/java/com/dji/sample/patches/utils/FormatConversionUtil.java
@@ -1,8 +1,25 @@
package com.dji.sample.patches.utils;
-import java.util.List;
+import com.dji.sample.patches.model.entity.LotInfo;
+import org.geotools.geometry.jts.JTSFactoryFinder;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static com.dji.sample.patches.utils.GeoToolsUtil.getCentro;
+import static com.dji.sample.patches.utils.GeoToolsUtil.getExtremePoints;
public class FormatConversionUtil {
+ static String str = "";
+ //优化Polygon格式
public static String[] formatConversion(List<String> s) {
String str = s.toString().trim();
String ses = str.substring(1, str.length() - 2);
@@ -12,7 +29,7 @@
String[] arr1 = see.split("],");
return arr1;
}
-
+ //优化Polygon格式
public static String modifySpacesAndCommas(String str) {
StringBuilder modified = new StringBuilder();
for (char c : str.toCharArray()) {
@@ -26,4 +43,26 @@
}
return modified.toString();
}
+ //获取Polygon的中心点,X轴和Y轴
+ public static String getCentros(List<LotInfo> list) {
+ List<Coordinate> centros = new ArrayList<>();
+ list.forEach(patche -> {
+ String wkt = patche.getDkfw();
+ // 解析WKT字符串为多边形
+ WKTReader wktReader = new WKTReader(JTSFactoryFinder.getGeometryFactory());
+ Geometry polygon = null;
+ try {
+ polygon = wktReader.read(wkt);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+
+ // 开始封装中心点坐标
+ Coordinate coordinateCentro = getCentro(polygon);
+ centros.add(coordinateCentro);
+ str = coordinateCentro.toString();
+ });
+ return str;
+ }
+
}
--
Gitblit v1.9.3