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/territory/utils/CoordinateSystemUtil.java |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/dji/sample/territory/utils/CoordinateSystemUtil.java b/src/main/java/com/dji/sample/territory/utils/CoordinateSystemUtil.java
index eff1297..6235a3b 100644
--- a/src/main/java/com/dji/sample/territory/utils/CoordinateSystemUtil.java
+++ b/src/main/java/com/dji/sample/territory/utils/CoordinateSystemUtil.java
@@ -3,6 +3,7 @@
 import org.geotools.geometry.jts.JTS;
 import org.geotools.referencing.CRS;
 import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.io.ParseException;
 import org.locationtech.jts.io.WKTReader;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.crs.CRSAuthorityFactory;
@@ -14,6 +15,12 @@
 
 
 public class CoordinateSystemUtil {
+    public static void main(String[] args) {
+        String wtk= "MULTIPOLYGON(((3.94836025714E7 3176072.7897, 3.94835938931E7 3176063.7288, 3.94835894481E7 3176067.1154, 3.94835981264E7 3176075.7938, 3.94836026103E7 3176085.7288, 3.94836089215E7 3176099.7123, 3.94836159065E7 3176121.5139, 3.94836178114E7 3176140.9873, 3.94836181917E7 3176148.7199, 3.94836214775E7 3176146.8663, 3.94836254582E7 3176144.37, 3.94836237382E7 3176137.8123, 3.94836165415E7 3176107.3321, 3.9483608468E7 3176087.3696, 3.94836025714E7 3176072.7897)))";
+        String se=wtk.replaceAll(",\\["," ").replaceAll("]","").replaceAll("\\[","");
+        System.out.println(se);
+        System.out.println(poylonCGCStoWGS(se));
+    }
     public static Geometry pointCGCStoWGS(Double lot, Double lat) {
         String wkt = "POINT (" + lot + " " + lat + ")";
         Geometry source = createGeometry(wkt, 4527);
@@ -60,12 +67,16 @@
             Geometry geometry = reader.read(wkt);
             geometry.setSRID(srid);
             return geometry;
+        } catch (ParseException e) {
+            System.out.println("WKT解析错误: " + e.getMessage());
+            e.printStackTrace();
         } catch (Exception e) {
             e.printStackTrace();
         }
         return null;
     }
 
+
     public static Geometry coordinateTransform(Geometry sourceGeometry, int targetSrid) {
         if (sourceGeometry == null || sourceGeometry.getSRID() == 0 || targetSrid == 0) {
             return null;

--
Gitblit v1.9.3