From 4bf1cd70df5f014f3363568b9a81ee81d6ed6d29 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 4 Nov 2025 16:44:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- water-design-const/pom.xml | 1 - .../controller/utils/DxfClient.java | 6 +- .../com/bonus/waterdesign/domain/CadData.java | 1 + .../service/impl/ModelServiceImpl.java | 387 +++++++++++++++--- 4 files changed, 328 insertions(+), 67 deletions(-) diff --git a/water-design-const/pom.xml b/water-design-const/pom.xml index fef4475..cf9a8f7 100644 --- a/water-design-const/pom.xml +++ b/water-design-const/pom.xml @@ -88,7 +88,6 @@ proj4j 1.1.3 - org.geotools gt-referencing diff --git a/water-design-const/src/main/java/com/bonus/waterdesign/controller/utils/DxfClient.java b/water-design-const/src/main/java/com/bonus/waterdesign/controller/utils/DxfClient.java index 056b642..8a9f212 100644 --- a/water-design-const/src/main/java/com/bonus/waterdesign/controller/utils/DxfClient.java +++ b/water-design-const/src/main/java/com/bonus/waterdesign/controller/utils/DxfClient.java @@ -14,8 +14,10 @@ import java.util.UUID; public class DxfClient { - private static final String GET_LAYERS_URL = "http://192.168.0.14:21010/get_layers"; - private static final String EXTRACT_LAYERS_URL = "http://192.168.0.14:21010/extract_layers"; +/* private static final String GET_LAYERS_URL = "http://192.168.0.14:21010/get_layers"; + private static final String EXTRACT_LAYERS_URL = "http://192.168.0.14:21010/extract_layers";*/ + private static final String GET_LAYERS_URL = "http://192.168.0.37:8008/get_layers"; + private static final String EXTRACT_LAYERS_URL = "http://192.168.0.37:8008/extract_layers"; public static void main(String[] args) throws IOException { //获取图层函数代码 diff --git a/water-design-const/src/main/java/com/bonus/waterdesign/domain/CadData.java b/water-design-const/src/main/java/com/bonus/waterdesign/domain/CadData.java index 70bc3d9..308d46b 100644 --- a/water-design-const/src/main/java/com/bonus/waterdesign/domain/CadData.java +++ b/water-design-const/src/main/java/com/bonus/waterdesign/domain/CadData.java @@ -45,6 +45,7 @@ public class CadData { * 完整 geometry JSON(备份原始结构) */ private String geometry; + private String geometryWGS84; private LocalDateTime createdAt; } diff --git a/water-design-const/src/main/java/com/bonus/waterdesign/service/impl/ModelServiceImpl.java b/water-design-const/src/main/java/com/bonus/waterdesign/service/impl/ModelServiceImpl.java index 6b7995a..6072b32 100644 --- a/water-design-const/src/main/java/com/bonus/waterdesign/service/impl/ModelServiceImpl.java +++ b/water-design-const/src/main/java/com/bonus/waterdesign/service/impl/ModelServiceImpl.java @@ -10,11 +10,10 @@ import com.bonus.waterdesign.mapper.ProjectMapper; import com.bonus.waterdesign.service.ModelService; import lombok.extern.slf4j.Slf4j; import org.locationtech.proj4j.*; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.operation.TransformException; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; /** @@ -125,7 +124,7 @@ public class ModelServiceImpl implements ModelService { @Override public boolean add(PeojectNodes node) { //id给我随机生成32为的字符串 - node.setId(java.util.UUID.randomUUID().toString()); + node.setId(UUID.randomUUID().toString()); return modelMapper.insert(node) > 0; } @@ -146,98 +145,302 @@ public class ModelServiceImpl implements ModelService { CRSFactory crsFactory = new CRSFactory(); CoordinateTransformFactory ctFactory = new CoordinateTransformFactory(); - // 定义坐标系(CGCS2000 GK Zone 20 → WGS84) - CoordinateReferenceSystem gkZone20 = crsFactory.createFromParameters("EPSG:4498", - "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs"); + // 定义坐标系:CGCS2000 3-degree GK zone 20 → WGS84 + CoordinateReferenceSystem cgcs2000Zone20 = crsFactory.createFromName("EPSG:4498"); CoordinateReferenceSystem wgs84 = crsFactory.createFromName("EPSG:4326"); - - CoordinateTransform transform = ctFactory.createTransform(gkZone20, wgs84); + CoordinateTransform transform = ctFactory.createTransform(cgcs2000Zone20, wgs84); for (CadData cadDatum : cadData) { String geometry = cadDatum.getGeometry(); JSONObject jsonObject = JSON.parseObject(geometry); + if (jsonObject.get("type").equals("LINE")) { JSONArray startArray = jsonObject.getJSONArray("start"); JSONArray endArray = jsonObject.getJSONArray("end"); - // 获取第一个元素(X坐标) - double x = startArray.getDouble(0); - // 获取第二个元素(Y坐标) - double y = startArray.getDouble(1); - // 获取第一个元素(X坐标) - double x1 = endArray.getDouble(0); - // 获取第二个元素(Y坐标) - double y1 = endArray.getDouble(1); - // 原始坐标 - ProjCoordinate startGk = new ProjCoordinate(x, y); - ProjCoordinate endGk = new ProjCoordinate(x1, y1); + // 获取投影坐标并加上20带号 + double startX = startArray.getDouble(0) + 20000000; + double startY = startArray.getDouble(1); + double endX = endArray.getDouble(0) + 20000000; + double endY = endArray.getDouble(1); - // 转换 + // 1. 投影坐标 → WGS84经纬度(高精度) ProjCoordinate startWgs84 = new ProjCoordinate(); ProjCoordinate endWgs84 = new ProjCoordinate(); - transform.transform(startGk, startWgs84); - transform.transform(endGk, endWgs84); + transform.transform(new ProjCoordinate(startX, startY), startWgs84); + transform.transform(new ProjCoordinate(endX, endY), endWgs84); + startArray.set(0, startWgs84.x); startArray.set(1, startWgs84.y); endArray.set(0, endWgs84.x); endArray.set(1, endWgs84.y); + cadDatum.setGeometryWGS84(jsonObject.toString()); + + // 2. WGS84经纬度 → 百度BD09坐标(高精度) + double[] startBd09 = wgs84ToBd09WithPrecision(startWgs84.x, startWgs84.y); + double[] endBd09 = wgs84ToBd09WithPrecision(endWgs84.x, endWgs84.y); + + // 更新为百度BD09坐标,保留高精度 + startArray.set(0, formatCoordinate(startBd09[0])); + startArray.set(1, formatCoordinate(startBd09[1])); + endArray.set(0, formatCoordinate(endBd09[0])); + endArray.set(1, formatCoordinate(endBd09[1])); + cadDatum.setGeometry(jsonObject.toString()); } + if (jsonObject.get("type").equals("LWPOLYLINE")) { - JSONArray pointsArray = jsonObject.getJSONArray("points"); + JSONArray pointsArray = jsonObject.getJSONArray("segments"); + + // === 深拷贝 points 数组,用于 WGS84 转换 === + JSONArray pointsArrayWGS84 = JSON.parseArray(JSON.toJSONString(pointsArray)); + + // === 1. 处理 BD09 坐标:修改原始 pointsArray,并生成 BD09 的 geometry === for (int i = 0; i < pointsArray.size(); i++) { - JSONArray point = pointsArray.getJSONArray(i); - double x = point.getDouble(0); - double y = point.getDouble(1); + JSONObject point = pointsArray.getJSONObject(i); + if (point.get("type").equals("line")) { + if (point.containsKey("start")) { + JSONArray startArray = point.getJSONArray("start"); + double x = startArray.getDoubleValue(0) + 20000000; + double y = startArray.getDoubleValue(1); - // 原始坐标 - ProjCoordinate pointstGk = new ProjCoordinate(x, y); + // 假设 transform 和 wgs84ToBd09WithPrecision 已定义 + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y); - // 转换 - ProjCoordinate pointstGkWgs84 = new ProjCoordinate(); - transform.transform(pointstGk, pointstGkWgs84); + // 更新 start 数组 + startArray.set(0, formatCoordinate(bd09[0])); + startArray.set(1, formatCoordinate(bd09[1])); + } + if (point.containsKey("end")) { + JSONArray endArray = point.getJSONArray("end"); + double x = endArray.getDoubleValue(0) + 20000000; + double y = endArray.getDoubleValue(1); - point.set(0, pointstGkWgs84.x); - point.set(1, pointstGkWgs84.y); + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y); + + // 更新 end 数组 + endArray.set(0, formatCoordinate(bd09[0])); + endArray.set(1, formatCoordinate(bd09[1])); + } + } else if (point.get("type").equals("arc")) { + if (point.containsKey("center")) { + JSONArray arcArray = point.getJSONArray("center"); + double x = arcArray.getDoubleValue(0) + 20000000; + double y = arcArray.getDoubleValue(1); + + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y); + + // 更新 end 数组 + arcArray.set(0, formatCoordinate(bd09[0])); + arcArray.set(1, formatCoordinate(bd09[1])); + } + if (point.containsKey("end_point")) { + JSONArray arcArray = point.getJSONArray("end_point"); + double x = arcArray.getDoubleValue(0) + 20000000; + double y = arcArray.getDoubleValue(1); + + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y); + + // 更新 end 数组 + arcArray.set(0, formatCoordinate(bd09[0])); + arcArray.set(1, formatCoordinate(bd09[1])); + } + if (point.containsKey("start_point")) { + JSONArray arcArray = point.getJSONArray("start_point"); + double x = arcArray.getDoubleValue(0) + 20000000; + double y = arcArray.getDoubleValue(1); + + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y); + + // 更新 end 数组 + arcArray.set(0, formatCoordinate(bd09[0])); + arcArray.set(1, formatCoordinate(bd09[1])); + } + + } } - cadDatum.setGeometry(jsonObject.toString()); + // 此时 jsonObject 的 points 已变成 BD09 坐标 + cadDatum.setGeometry(jsonObject.toString()); // 存储 BD09 } + if (jsonObject.get("type").equals("CIRCLE")) { JSONArray centerArray = jsonObject.getJSONArray("center"); - // 获取第一个元素(X坐标) - double x = centerArray.getDouble(0); - // 获取第二个元素(Y坐标) - double y = centerArray.getDouble(1); - // 原始坐标 - ProjCoordinate startGk = new ProjCoordinate(x, y); - ProjCoordinate startWgs84 = new ProjCoordinate(); - transform.transform(startGk, startWgs84); - centerArray.set(0, startWgs84.x); - centerArray.set(1, startWgs84.y); + double centerX = centerArray.getDouble(0) + 20000000; + double centerY = centerArray.getDouble(1); + + // 投影坐标 → WGS84 + ProjCoordinate centerWgs84 = new ProjCoordinate(); + transform.transform(new ProjCoordinate(centerX, centerY), centerWgs84); + centerArray.set(0, centerWgs84.x); + centerArray.set(1, centerWgs84.y); + cadDatum.setGeometryWGS84(jsonObject.toString()); + + // WGS84 → BD09(高精度) + double[] centerBd09 = wgs84ToBd09WithPrecision(centerWgs84.x, centerWgs84.y); + + centerArray.set(0, formatCoordinate(centerBd09[0])); + centerArray.set(1, formatCoordinate(centerBd09[1])); cadDatum.setGeometry(jsonObject.toString()); } - } } catch (Exception e) { - e.printStackTrace(); + log.error("坐标转换错误", e); } return cadData; } + + // 高精度 WGS84转百度BD09坐标 + private static double[] wgs84ToBd09WithPrecision(double wgsLon, double wgsLat) { + // WGS84 → GCJ02(高精度) + double[] gcj02 = wgs84ToGcj02WithPrecision(wgsLon, wgsLat); + // GCJ02 → BD09(高精度) + return gcj02ToBd09WithPrecision(gcj02[0], gcj02[1]); + } + + // 高精度 WGS84转火星坐标系GCJ02 + private static double[] wgs84ToGcj02WithPrecision(double wgsLon, double wgsLat) { + if (outOfChina(wgsLon, wgsLat)) { + return new double[]{wgsLon, wgsLat}; + } + + // 使用 BigDecimal 进行高精度计算 + BigDecimal lon = BigDecimal.valueOf(wgsLon); + BigDecimal lat = BigDecimal.valueOf(wgsLat); + + double[] delta = deltaWithPrecision(lon.doubleValue(), lat.doubleValue()); + return new double[]{ + lon.add(BigDecimal.valueOf(delta[0])).doubleValue(), + lat.add(BigDecimal.valueOf(delta[1])).doubleValue() + }; + } + + // 高精度 火星坐标系GCJ02转百度BD09 + private static double[] gcj02ToBd09WithPrecision(double gcjLon, double gcjLat) { + BigDecimal x = BigDecimal.valueOf(gcjLon); + BigDecimal y = BigDecimal.valueOf(gcjLat); + BigDecimal pi = BigDecimal.valueOf(Math.PI); + + // 计算 z = sqrt(x² + y²) + 0.00002 * sin(y * π) + BigDecimal xSquared = x.multiply(x); + BigDecimal ySquared = y.multiply(y); + BigDecimal sumSquared = xSquared.add(ySquared); + BigDecimal z = BigDecimal.valueOf(Math.sqrt(sumSquared.doubleValue())) + .add(BigDecimal.valueOf(0.00002) + .multiply(BigDecimal.valueOf(Math.sin(y.multiply(pi).doubleValue())))); + + // 计算 theta = atan2(y, x) + 0.000003 * cos(x * π) + BigDecimal theta = BigDecimal.valueOf(Math.atan2(y.doubleValue(), x.doubleValue())) + .add(BigDecimal.valueOf(0.000003) + .multiply(BigDecimal.valueOf(Math.cos(x.multiply(pi).doubleValue())))); + + // 计算百度坐标 + double bdLon = z.multiply(BigDecimal.valueOf(Math.cos(theta.doubleValue()))) + .add(BigDecimal.valueOf(0.0065)).doubleValue(); + double bdLat = z.multiply(BigDecimal.valueOf(Math.sin(theta.doubleValue()))) + .add(BigDecimal.valueOf(0.006)).doubleValue(); + + return new double[]{bdLon, bdLat}; + } + + // 高精度计算WGS84到GCJ02的偏移量 + private static double[] deltaWithPrecision(double wgsLon, double wgsLat) { + BigDecimal lon = BigDecimal.valueOf(wgsLon); + BigDecimal lat = BigDecimal.valueOf(wgsLat); + + double a = 6378245.0; + double ee = 0.00669342162296594323; + + double dLat = transformLatWithPrecision(lon.doubleValue() - 105.0, lat.doubleValue() - 35.0); + double dLon = transformLonWithPrecision(lon.doubleValue() - 105.0, lat.doubleValue() - 35.0); + + double radLat = lat.doubleValue() / 180.0 * Math.PI; + double magic = Math.sin(radLat); + magic = 1 - ee * magic * magic; + double sqrtMagic = Math.sqrt(magic); + + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * Math.PI); + dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * Math.PI); + + return new double[]{dLon, dLat}; + } + + // 高精度纬度转换 + private static double transformLatWithPrecision(double x, double y) { + BigDecimal bdX = BigDecimal.valueOf(x); + BigDecimal bdY = BigDecimal.valueOf(y); + BigDecimal pi = BigDecimal.valueOf(Math.PI); + + double ret = -100.0 + 2.0 * bdX.doubleValue() + 3.0 * bdY.doubleValue() + + 0.2 * bdY.doubleValue() * bdY.doubleValue() + + 0.1 * bdX.doubleValue() * bdY.doubleValue() + + 0.2 * Math.sqrt(Math.abs(bdX.doubleValue())); + + ret += (20.0 * Math.sin(6.0 * bdX.doubleValue() * Math.PI) + + 20.0 * Math.sin(2.0 * bdX.doubleValue() * Math.PI)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(bdY.doubleValue() * Math.PI) + + 40.0 * Math.sin(bdY.doubleValue() / 3.0 * Math.PI)) * 2.0 / 3.0; + ret += (160.0 * Math.sin(bdY.doubleValue() / 12.0 * Math.PI) + + 320 * Math.sin(bdY.doubleValue() * Math.PI / 30.0)) * 2.0 / 3.0; + + return ret; + } + + // 高精度经度转换 + private static double transformLonWithPrecision(double x, double y) { + BigDecimal bdX = BigDecimal.valueOf(x); + BigDecimal bdY = BigDecimal.valueOf(y); + + double ret = 300.0 + bdX.doubleValue() + 2.0 * bdY.doubleValue() + + 0.1 * bdX.doubleValue() * bdX.doubleValue() + + 0.1 * bdX.doubleValue() * bdY.doubleValue() + + 0.1 * Math.sqrt(Math.abs(bdX.doubleValue())); + + ret += (20.0 * Math.sin(6.0 * bdX.doubleValue() * Math.PI) + + 20.0 * Math.sin(2.0 * bdX.doubleValue() * Math.PI)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(bdX.doubleValue() * Math.PI) + + 40.0 * Math.sin(bdX.doubleValue() / 3.0 * Math.PI)) * 2.0 / 3.0; + ret += (150.0 * Math.sin(bdX.doubleValue() / 12.0 * Math.PI) + + 300.0 * Math.sin(bdX.doubleValue() / 30.0 * Math.PI)) * 2.0 / 3.0; + + return ret; + } + + // 格式化坐标值,保留足够精度(10位小数) + private double formatCoordinate(double value) { + return Math.round(value * 10000000000.0) / 10000000000.0; // 保留10位小数 + } + + // 判断是否在中国境外(保持不变) + private static boolean outOfChina(double lon, double lat) { + return lon < 72.004 || lon > 137.8347 || lat < 0.8293 || lat > 55.8271; + } + + @Override - public List openAllView(PeojectNodes node) throws FactoryException, TransformException { + public List openAllView(PeojectNodes node) { List cadData = modelMapper.openAllView(node.getIds()); try { CRSFactory crsFactory = new CRSFactory(); CoordinateTransformFactory ctFactory = new CoordinateTransformFactory(); // 定义坐标系(CGCS2000 GK Zone 20 → WGS84) - CoordinateReferenceSystem gkZone20 = crsFactory.createFromParameters("EPSG:4498", - "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs"); + + CoordinateReferenceSystem cgcs2000Zone20 = crsFactory.createFromName("EPSG:4498"); CoordinateReferenceSystem wgs84 = crsFactory.createFromName("EPSG:4326"); - CoordinateTransform transform = ctFactory.createTransform(gkZone20, wgs84); + CoordinateTransform transform = ctFactory.createTransform(cgcs2000Zone20, wgs84); for (CadData cadDatum : cadData) { String geometry = cadDatum.getGeometry(); @@ -246,11 +449,11 @@ public class ModelServiceImpl implements ModelService { JSONArray startArray = jsonObject.getJSONArray("start"); JSONArray endArray = jsonObject.getJSONArray("end"); // 获取第一个元素(X坐标) - double x = startArray.getDouble(0); + double x = startArray.getDouble(0) + 20000000; // 获取第二个元素(Y坐标) double y = startArray.getDouble(1); // 获取第一个元素(X坐标) - double x1 = endArray.getDouble(0); + double x1 = endArray.getDouble(0) + 20000000; // 获取第二个元素(Y坐标) double y1 = endArray.getDouble(1); @@ -271,28 +474,84 @@ public class ModelServiceImpl implements ModelService { cadDatum.setGeometry(jsonObject.toString()); } if (jsonObject.get("type").equals("LWPOLYLINE")) { - JSONArray pointsArray = jsonObject.getJSONArray("points"); + JSONArray pointsArray = jsonObject.getJSONArray("segments"); + + // === 1. 处理 BD09 坐标:修改原始 pointsArray,并生成 BD09 的 geometry === for (int i = 0; i < pointsArray.size(); i++) { - JSONArray point = pointsArray.getJSONArray(i); - double x = point.getDouble(0); - double y = point.getDouble(1); + JSONObject point = pointsArray.getJSONObject(i); + if (point.get("type").equals("line")) { + if (point.containsKey("start")) { + JSONArray startArray = point.getJSONArray("start"); + double x = startArray.getDoubleValue(0) + 20000000; + double y = startArray.getDoubleValue(1); - // 原始坐标 - ProjCoordinate pointstGk = new ProjCoordinate(x, y); + // 假设 transform 和 wgs84ToBd09WithPrecision 已定义 + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); - // 转换 - ProjCoordinate pointstGkWgs84 = new ProjCoordinate(); - transform.transform(pointstGk, pointstGkWgs84); + // 更新 start 数组 + startArray.set(0, wgs84Coord.x); + startArray.set(1, wgs84Coord.y); + } + if (point.containsKey("end")) { + JSONArray endArray = point.getJSONArray("end"); + double x = endArray.getDoubleValue(0) + 20000000; + double y = endArray.getDoubleValue(1); - point.set(0, pointstGkWgs84.x); - point.set(1, pointstGkWgs84.y); + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + + // 更新 end 数组 + endArray.set(0, wgs84Coord.x); + endArray.set(1, wgs84Coord.y); + } + } else if (point.get("type").equals("arc")) { + if (point.containsKey("center")) { + JSONArray arcArray = point.getJSONArray("center"); + double x = arcArray.getDoubleValue(0) + 20000000; + double y = arcArray.getDoubleValue(1); + + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + + // 更新 end 数组 + arcArray.set(0, wgs84Coord.x); + arcArray.set(1, wgs84Coord.y); + } + if (point.containsKey("end_point")) { + JSONArray arcArray = point.getJSONArray("end_point"); + double x = arcArray.getDoubleValue(0) + 20000000; + double y = arcArray.getDoubleValue(1); + + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + + // 更新 end 数组 + arcArray.set(0, wgs84Coord.x); + arcArray.set(1, wgs84Coord.y); + } + if (point.containsKey("start_point")) { + JSONArray arcArray = point.getJSONArray("start_point"); + double x = arcArray.getDoubleValue(0) + 20000000; + double y = arcArray.getDoubleValue(1); + + ProjCoordinate wgs84Coord = new ProjCoordinate(); + transform.transform(new ProjCoordinate(x, y), wgs84Coord); + + // 更新 end 数组 + arcArray.set(0, wgs84Coord.x); + arcArray.set(1, wgs84Coord.y); + } + + } } cadDatum.setGeometry(jsonObject.toString()); } + if (jsonObject.get("type").equals("CIRCLE")) { JSONArray centerArray = jsonObject.getJSONArray("center"); // 获取第一个元素(X坐标) - double x = centerArray.getDouble(0); + double x = centerArray.getDouble(0) + 20000000; // 获取第二个元素(Y坐标) double y = centerArray.getDouble(1); // 原始坐标