代码提交
This commit is contained in:
parent
4bf1cd70df
commit
c1d1789057
|
|
@ -0,0 +1,152 @@
|
|||
package com.bonus.waterdesign.controller.utils;
|
||||
|
||||
public class CoordinateTransformUtils {
|
||||
|
||||
private static final double PI = 3.1415926535897932384626;
|
||||
private static final double A = 6378245.0;
|
||||
private static final double EE = 0.00669342162296594323;
|
||||
|
||||
/**
|
||||
* WGS84转GCJ02(火星坐标系)
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @return [经度, 纬度]
|
||||
*/
|
||||
public static double[] wgs84ToGcj02(double lng, double lat) {
|
||||
if (outOfChina(lng, lat)) {
|
||||
return new double[]{lng, lat};
|
||||
}
|
||||
double dLat = transformLat(lng - 105.0, lat - 35.0);
|
||||
double dLng = transformLng(lng - 105.0, lat - 35.0);
|
||||
double radLat = lat / 180.0 * 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) * PI);
|
||||
dLng = (dLng * 180.0) / (A / sqrtMagic * Math.cos(radLat) * PI);
|
||||
double mgLat = lat + dLat;
|
||||
double mgLng = lng + dLng;
|
||||
return new double[]{mgLng, mgLat};
|
||||
}
|
||||
|
||||
/**
|
||||
* GCJ02转WGS84
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @return [经度, 纬度]
|
||||
*/
|
||||
public static double[] gcj02ToWgs84(double lng, double lat) {
|
||||
double[] gcj = wgs84ToGcj02(lng, lat);
|
||||
return new double[]{lng * 2 - gcj[0], lat * 2 - gcj[1]};
|
||||
}
|
||||
|
||||
/**
|
||||
* GCJ02转BD09
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @return [经度, 纬度]
|
||||
*/
|
||||
// public static double[] gcj02ToBd09(double lng, double lat) {
|
||||
// double z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * PI);
|
||||
// double theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * PI);
|
||||
// double bdLng = z * Math.cos(theta) + 0.0065;
|
||||
// double bdLat = z * Math.sin(theta) + 0.006;
|
||||
// return new double[]{bdLng, bdLat};
|
||||
// }
|
||||
|
||||
public static double[] gcj02ToBd09(double lng, double lat) {
|
||||
double x = lng, y = lat;
|
||||
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * PI * 3000.0 / 180.0);
|
||||
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * PI * 3000.0 / 180.0);
|
||||
double bdLng = z * Math.cos(theta) + 0.0065;
|
||||
double bdLat = z * Math.sin(theta) + 0.006;
|
||||
return new double[]{bdLng, bdLat};
|
||||
}
|
||||
|
||||
/**
|
||||
* BD09转GCJ02
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @return [经度, 纬度]
|
||||
*/
|
||||
/* public static double[] bd09ToGcj02(double lng, double lat) {
|
||||
double x = lng - 0.0065;
|
||||
double y = lat - 0.006;
|
||||
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * PI);
|
||||
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * PI);
|
||||
double ggLng = z * Math.cos(theta);
|
||||
double ggLat = z * Math.sin(theta);
|
||||
return new double[]{ggLng, ggLat};
|
||||
}*/
|
||||
|
||||
public static double[] bd09ToGcj02(double lng, double lat) {
|
||||
double x = lng - 0.0065, y = lat - 0.006;
|
||||
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * PI * 3000.0 / 180.0);
|
||||
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * PI * 3000.0 / 180.0);
|
||||
double ggLng = z * Math.cos(theta);
|
||||
double ggLat = z * Math.sin(theta);
|
||||
return new double[]{ggLng, ggLat};
|
||||
}
|
||||
|
||||
/**
|
||||
* WGS84转BD09
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @return [经度, 纬度]
|
||||
*/
|
||||
public static double[] wgs84ToBd09(double lng, double lat) {
|
||||
double[] gcj = wgs84ToGcj02(lng, lat);
|
||||
return gcj02ToBd09(gcj[0], gcj[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* BD09转WGS84
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @return [经度, 纬度]
|
||||
*/
|
||||
public static double[] bd09ToWgs84(double lng, double lat) {
|
||||
double[] gcj = bd09ToGcj02(lng, lat);
|
||||
return gcj02ToWgs84(gcj[0], gcj[1]);
|
||||
}
|
||||
|
||||
private static boolean outOfChina(double lng, double lat) {
|
||||
if (lng < 72.004 || lng > 137.8347) {
|
||||
return true;
|
||||
}
|
||||
return lat < 0.8293 || lat > 55.8271;
|
||||
}
|
||||
|
||||
private static double transformLat(double lng, double lat) {
|
||||
double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
|
||||
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
|
||||
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static double transformLng(double lng, double lat) {
|
||||
double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
|
||||
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
|
||||
ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 测试代码
|
||||
double lng = 116.404;
|
||||
double lat = 39.915;
|
||||
|
||||
System.out.println("原始WGS84坐标: " + lng + ", " + lat);
|
||||
|
||||
double[] gcj = wgs84ToGcj02(lng, lat);
|
||||
System.out.println("转换为GCJ02: " + gcj[0] + ", " + gcj[1]);
|
||||
|
||||
double[] bd = gcj02ToBd09(gcj[0], gcj[1]);
|
||||
System.out.println("转换为BD09: " + bd[0] + ", " + bd[1]);
|
||||
|
||||
double[] wgs = bd09ToWgs84(bd[0], bd[1]);
|
||||
System.out.println("转回WGS84: " + wgs[0] + ", " + wgs[1]);
|
||||
}
|
||||
}
|
||||
|
|
@ -40,13 +40,14 @@ public class ModelController extends BaseController {
|
|||
@GetMapping("/listSelect")
|
||||
public AjaxResult listSelect(ProjectVo model) {
|
||||
List<ProjectVo> list = modelService.list(model);
|
||||
List<ProjectVo> list1 = new ArrayList<>();
|
||||
for (ProjectVo projectVo : list) {
|
||||
if (projectVo.getNodelevel().equals(projectVo.getNodeCount().toString())) {
|
||||
list1.add(projectVo);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(list1);
|
||||
// System.out.println("list:"+list);
|
||||
// List<ProjectVo> list1 = new ArrayList<>();
|
||||
// for (ProjectVo projectVo : list) {
|
||||
// if (projectVo.getNodelevel().equals(projectVo.getNodeCount().toString())) {
|
||||
// list1.add(projectVo);
|
||||
// }
|
||||
// }
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,6 +73,15 @@ public class ModelController extends BaseController {
|
|||
return AjaxResult.success(list);
|
||||
|
||||
}
|
||||
@PostMapping("/openViews")
|
||||
public AjaxResult openViews(@RequestBody PeojectNodes node) throws FactoryException, TransformException {
|
||||
//获取所有的节点信息
|
||||
List<CadData> list = modelService.openViews(node);
|
||||
//返回list信息给前台
|
||||
return AjaxResult.success(list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/openAllView")
|
||||
public AjaxResult openAllView(@RequestBody PeojectNodes node) throws FactoryException, TransformException {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.bonus.common.utils.poi.ExcelUtil;
|
|||
import com.bonus.waterdesign.domain.Project;
|
||||
import com.bonus.waterdesign.domain.ProjectSelect;
|
||||
import com.bonus.waterdesign.domain.ProjectUser;
|
||||
import com.bonus.waterdesign.domain.SelectDto;
|
||||
import com.bonus.waterdesign.service.ProjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
|
@ -47,6 +48,15 @@ public class ProjectController extends BaseController {
|
|||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目类型下拉框
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('project:type')")
|
||||
@GetMapping("/proTypeSelect")
|
||||
public AjaxResult proTypeSelect() {
|
||||
List<SelectDto> list = projectService.proTypeSelect();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
/**
|
||||
* 获取项目下拉框
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.bonus.waterdesign.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2025/11/6 - 9:51
|
||||
*/
|
||||
@Data
|
||||
public class SelectDto {
|
||||
private String id;
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -22,4 +22,6 @@ public interface ModelMapper {
|
|||
List<CadData> openView(PeojectNodes node);
|
||||
|
||||
List<CadData> openAllView(@Param("ids") List<String> ids);
|
||||
|
||||
List<String> getNodes(String projectId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.bonus.waterdesign.mapper;
|
||||
|
||||
|
||||
import com.bonus.waterdesign.domain.CadData;
|
||||
import com.bonus.waterdesign.domain.Project;
|
||||
import com.bonus.waterdesign.domain.ProjectSelect;
|
||||
import com.bonus.waterdesign.domain.ProjectUser;
|
||||
import com.bonus.waterdesign.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -92,4 +89,6 @@ public interface ProjectMapper
|
|||
void insertCadData(CadData data);
|
||||
|
||||
List<ProjectSelect> selectProjectList1(ProjectSelect projectSelect);
|
||||
|
||||
List<SelectDto> proTypeSelect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@ public interface ModelService {
|
|||
boolean update(PeojectNodes node);
|
||||
|
||||
List<CadData> openView(PeojectNodes node) throws FactoryException, TransformException;
|
||||
List<CadData> openViews(PeojectNodes node) throws FactoryException, TransformException;
|
||||
List<CadData> openAllView(PeojectNodes node) throws FactoryException, TransformException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.bonus.waterdesign.service;
|
||||
|
||||
|
||||
import com.bonus.waterdesign.domain.CadData;
|
||||
import com.bonus.waterdesign.domain.Project;
|
||||
import com.bonus.waterdesign.domain.ProjectSelect;
|
||||
import com.bonus.waterdesign.domain.ProjectUser;
|
||||
import com.bonus.waterdesign.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -92,4 +89,6 @@ public interface ProjectService
|
|||
void insertCadData(List<CadData> cadData);
|
||||
|
||||
List<ProjectSelect> selectProjectList1(ProjectSelect projectSelect);
|
||||
|
||||
List<SelectDto> proTypeSelect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
|||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.common.utils.StringUtils;
|
||||
import com.bonus.waterdesign.controller.utils.CoordinateTransformUtils;
|
||||
import com.bonus.waterdesign.domain.*;
|
||||
import com.bonus.waterdesign.mapper.ModelMapper;
|
||||
import com.bonus.waterdesign.mapper.ProjectMapper;
|
||||
|
|
@ -178,8 +179,15 @@ public class ModelServiceImpl implements ModelService {
|
|||
cadDatum.setGeometryWGS84(jsonObject.toString());
|
||||
|
||||
// 2. WGS84经纬度 → 百度BD09坐标(高精度)
|
||||
double[] startBd09 = wgs84ToBd09WithPrecision(startWgs84.x, startWgs84.y);
|
||||
double[] endBd09 = wgs84ToBd09WithPrecision(endWgs84.x, endWgs84.y);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(startWgs84.x, startWgs84.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] startBd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
double[] gcj021 = CoordinateTransformUtils.wgs84ToGcj02(endWgs84.x, endWgs84.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] endBd09 = CoordinateTransformUtils.gcj02ToBd09(gcj021[0], gcj021[1]);
|
||||
|
||||
// 更新为百度BD09坐标,保留高精度
|
||||
startArray.set(0, formatCoordinate(startBd09[0]));
|
||||
|
|
@ -208,7 +216,11 @@ public class ModelServiceImpl implements ModelService {
|
|||
// 假设 transform 和 wgs84ToBd09WithPrecision 已定义
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 start 数组
|
||||
startArray.set(0, formatCoordinate(bd09[0]));
|
||||
|
|
@ -221,7 +233,10 @@ public class ModelServiceImpl implements ModelService {
|
|||
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 end 数组
|
||||
endArray.set(0, formatCoordinate(bd09[0]));
|
||||
|
|
@ -235,8 +250,10 @@ public class ModelServiceImpl implements ModelService {
|
|||
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
// 更新 end 数组
|
||||
arcArray.set(0, formatCoordinate(bd09[0]));
|
||||
arcArray.set(1, formatCoordinate(bd09[1]));
|
||||
|
|
@ -248,7 +265,10 @@ public class ModelServiceImpl implements ModelService {
|
|||
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 end 数组
|
||||
arcArray.set(0, formatCoordinate(bd09[0]));
|
||||
|
|
@ -261,7 +281,10 @@ public class ModelServiceImpl implements ModelService {
|
|||
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] bd09 = wgs84ToBd09WithPrecision(wgs84Coord.x, wgs84Coord.y);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 end 数组
|
||||
arcArray.set(0, formatCoordinate(bd09[0]));
|
||||
|
|
@ -287,7 +310,11 @@ public class ModelServiceImpl implements ModelService {
|
|||
cadDatum.setGeometryWGS84(jsonObject.toString());
|
||||
|
||||
// WGS84 → BD09(高精度)
|
||||
double[] centerBd09 = wgs84ToBd09WithPrecision(centerWgs84.x, centerWgs84.y);
|
||||
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(centerWgs84.x, centerWgs84.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] centerBd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
centerArray.set(0, formatCoordinate(centerBd09[0]));
|
||||
centerArray.set(1, formatCoordinate(centerBd09[1]));
|
||||
|
|
@ -301,6 +328,191 @@ public class ModelServiceImpl implements ModelService {
|
|||
}
|
||||
|
||||
|
||||
public List<CadData> openViews(PeojectNodes node) {
|
||||
List<String> ids = modelMapper.getNodes(node.getProjectId());
|
||||
List<CadData> cadData = new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
node.setId(id);
|
||||
cadData.addAll(modelMapper.openView(node)) ;
|
||||
}
|
||||
try {
|
||||
CRSFactory crsFactory = new CRSFactory();
|
||||
CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
|
||||
|
||||
// 定义坐标系:CGCS2000 3-degree GK zone 20 → WGS84
|
||||
CoordinateReferenceSystem cgcs2000Zone20 = crsFactory.createFromName("EPSG:4498");
|
||||
CoordinateReferenceSystem wgs84 = crsFactory.createFromName("EPSG:4326");
|
||||
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");
|
||||
|
||||
// 获取投影坐标并加上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(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());
|
||||
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(startWgs84.x, startWgs84.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] startBd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
double[] gcj021 = CoordinateTransformUtils.wgs84ToGcj02(endWgs84.x, endWgs84.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] endBd09 = CoordinateTransformUtils.gcj02ToBd09(gcj021[0], gcj021[1]);
|
||||
|
||||
// 更新为百度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("segments");
|
||||
|
||||
// === 深拷贝 points 数组,用于 WGS84 转换 ===
|
||||
JSONArray pointsArrayWGS84 = JSON.parseArray(JSON.toJSONString(pointsArray));
|
||||
|
||||
// === 1. 处理 BD09 坐标:修改原始 pointsArray,并生成 BD09 的 geometry ===
|
||||
for (int i = 0; i < pointsArray.size(); i++) {
|
||||
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);
|
||||
|
||||
// 假设 transform 和 wgs84ToBd09WithPrecision 已定义
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 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);
|
||||
|
||||
ProjCoordinate wgs84Coord = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(x, y), wgs84Coord);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 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[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 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[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 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[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(wgs84Coord.x, wgs84Coord.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] bd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
// 更新 end 数组
|
||||
arcArray.set(0, formatCoordinate(bd09[0]));
|
||||
arcArray.set(1, formatCoordinate(bd09[1]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// 此时 jsonObject 的 points 已变成 BD09 坐标
|
||||
cadDatum.setGeometry(jsonObject.toString()); // 存储 BD09
|
||||
}
|
||||
|
||||
if (jsonObject.get("type").equals("CIRCLE")) {
|
||||
JSONArray centerArray = jsonObject.getJSONArray("center");
|
||||
double centerX = centerArray.getDouble(0) + 20000000;
|
||||
double centerY = centerArray.getDouble(1);
|
||||
|
||||
// 投影坐标 → WGS84
|
||||
ProjCoordinate centerWgs84 = new ProjCoordinate();
|
||||
transform.transform(new ProjCoordinate(centerX, centerY), centerWgs84);
|
||||
double[] gcj02 = CoordinateTransformUtils.wgs84ToGcj02(centerWgs84.x, centerWgs84.y);
|
||||
|
||||
// GCJ02转BD09
|
||||
double[] centerBd09 = CoordinateTransformUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||
|
||||
centerArray.set(0, formatCoordinate(centerBd09[0]));
|
||||
centerArray.set(1, formatCoordinate(centerBd09[1]));
|
||||
cadDatum.setGeometry(jsonObject.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("坐标转换错误", e);
|
||||
}
|
||||
return cadData;
|
||||
}
|
||||
|
||||
// 高精度 WGS84转百度BD09坐标
|
||||
private static double[] wgs84ToBd09WithPrecision(double wgsLon, double wgsLat) {
|
||||
// WGS84 → GCJ02(高精度)
|
||||
|
|
|
|||
|
|
@ -172,4 +172,9 @@ public class ProjectServiceImpl implements ProjectService {
|
|||
List<ProjectSelect> projectList = projectMapper.selectProjectList1(projectSelect);
|
||||
return projectList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectDto> proTypeSelect() {
|
||||
return projectMapper.proTypeSelect();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,4 +181,12 @@
|
|||
#{projectId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getNodes" resultType="java.lang.String">
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
project_node
|
||||
WHERE
|
||||
project_id = #{projectId} and del_flag = 0 and node_count = level
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
SELECT
|
||||
tp.id,
|
||||
tp.pro_name,
|
||||
tp.pro_type,
|
||||
sdd.dict_label as pro_type,
|
||||
tp.unit_name,
|
||||
tp.user_name,
|
||||
tp.pro_location,
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
FROM
|
||||
tb_project tp
|
||||
LEFT JOIN sys_level_config sc ON sc.config_id = tp.LEVEL
|
||||
left join sys_dict_data sdd ON sdd.dict_value = tp.pro_type and sdd.dict_type = 'pro_type'
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
</sql>
|
||||
|
|
@ -108,6 +109,16 @@
|
|||
AND tp.id = #{id}
|
||||
</if>
|
||||
</select>
|
||||
<select id="proTypeSelect" resultType="com.bonus.waterdesign.domain.SelectDto">
|
||||
SELECT
|
||||
tp.dict_label as name,
|
||||
tp.dict_value as id
|
||||
FROM
|
||||
sys_dict_data tp
|
||||
WHERE
|
||||
tp.dict_type = 'pro_type'
|
||||
and status = '0'
|
||||
</select>
|
||||
|
||||
<update id="updateProject" parameterType="Project">
|
||||
update tb_project
|
||||
|
|
|
|||
Loading…
Reference in New Issue