测试方法与大地坐标系转化
This commit is contained in:
parent
0043bc5bac
commit
99adfdca80
@ -0,0 +1,426 @@
|
||||
package com.example.demo.common.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* 坐标转换工具类,支持大地坐标与空间直角坐标的正算和反算
|
||||
* 支持多种椭球参数(WGS84、CGCS2000等)
|
||||
*
|
||||
* <p>大地坐标(Geodetic Coordinate):由纬度(B)、经度(L)和大地高(H)组成
|
||||
* <p>空间直角坐标(Cartesian Coordinate):由X、Y、Z三个分量组成
|
||||
*
|
||||
* @author 岳佳君 (2025年9月29日 15:02:13)
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class CoordinateConverterUtil {
|
||||
|
||||
/**
|
||||
* 椭球参数接口,定义了椭球的基本参数
|
||||
*/
|
||||
public interface Ellipsoid {
|
||||
/**
|
||||
* 获取椭球长半轴(赤道半径),单位:米
|
||||
* @return 长半轴值
|
||||
*/
|
||||
double getSemiMajorAxis();
|
||||
|
||||
/**
|
||||
* 获取椭球短半轴(极半径),单位:米
|
||||
* @return 短半轴值
|
||||
*/
|
||||
double getSemiMinorAxis();
|
||||
|
||||
/**
|
||||
* 获取第一偏心率平方
|
||||
* @return 第一偏心率平方值
|
||||
*/
|
||||
double getFirstEccentricitySquared();
|
||||
|
||||
/**
|
||||
* 获取第二偏心率平方
|
||||
* @return 第二偏心率平方值
|
||||
*/
|
||||
double getSecondEccentricitySquared();
|
||||
}
|
||||
|
||||
/**
|
||||
* WGS84椭球参数实现
|
||||
* <p>WGS84是GPS系统使用的椭球参数
|
||||
*/
|
||||
public static class WGS84Ellipsoid implements Ellipsoid {
|
||||
// 长半轴,单位:米
|
||||
private static final double SEMI_MAJOR_AXIS = 6378137.0;
|
||||
// 短半轴,单位:米
|
||||
private static final double SEMI_MINOR_AXIS = 6356752.314245179;
|
||||
// 第一偏心率平方
|
||||
private static final double FIRST_ECCENTRICITY_SQUARED = 0.0066943799901413165;
|
||||
// 第二偏心率平方
|
||||
private static final double SECOND_ECCENTRICITY_SQUARED = 0.006739496742276435;
|
||||
|
||||
@Override
|
||||
public double getSemiMajorAxis() {
|
||||
return SEMI_MAJOR_AXIS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSemiMinorAxis() {
|
||||
return SEMI_MINOR_AXIS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFirstEccentricitySquared() {
|
||||
return FIRST_ECCENTRICITY_SQUARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSecondEccentricitySquared() {
|
||||
return SECOND_ECCENTRICITY_SQUARED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CGCS2000椭球参数实现
|
||||
* <p>CGCS2000是中国国家大地坐标系使用的椭球参数
|
||||
*/
|
||||
public static class CGCS2000Ellipsoid implements Ellipsoid {
|
||||
// 长半轴,单位:米
|
||||
private static final double SEMI_MAJOR_AXIS = 6378137.0;
|
||||
// 短半轴,单位:米
|
||||
private static final double SEMI_MINOR_AXIS = 6356752.314140356;
|
||||
// 第一偏心率平方
|
||||
private static final double FIRST_ECCENTRICITY_SQUARED = 0.006694380022903416;
|
||||
// 第二偏心率平方
|
||||
private static final double SECOND_ECCENTRICITY_SQUARED = 0.006739496775481663;
|
||||
|
||||
@Override
|
||||
public double getSemiMajorAxis() {
|
||||
return SEMI_MAJOR_AXIS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSemiMinorAxis() {
|
||||
return SEMI_MINOR_AXIS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFirstEccentricitySquared() {
|
||||
return FIRST_ECCENTRICITY_SQUARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSecondEccentricitySquared() {
|
||||
return SECOND_ECCENTRICITY_SQUARED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大地坐标模型类,包含纬度、经度和大地高
|
||||
*/
|
||||
public static class GeodeticCoordinate {
|
||||
// 纬度,单位:弧度(北半球为正,南半球为负)
|
||||
private final double latitude;
|
||||
// 经度,单位:弧度(东经为正,西经为负)
|
||||
private final double longitude;
|
||||
// 大地高,单位:米
|
||||
private final double height;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param latitude 纬度(弧度)
|
||||
* @param longitude 经度(弧度)
|
||||
* @param height 大地高(米)
|
||||
*/
|
||||
public GeodeticCoordinate(double latitude, double longitude, double height) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取纬度(弧度)
|
||||
* @return 纬度值
|
||||
*/
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取经度(弧度)
|
||||
* @return 经度值
|
||||
*/
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取大地高(米)
|
||||
* @return 大地高值
|
||||
*/
|
||||
public double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// 转换为度格式显示
|
||||
return String.format("GeodeticCoordinate [纬度=%.6f°, 经度=%.6f°, 大地高=%.2fm]",
|
||||
Math.toDegrees(latitude), Math.toDegrees(longitude), height);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 空间直角坐标模型类,包含X、Y、Z三个分量
|
||||
*/
|
||||
public static class CartesianCoordinate {
|
||||
// X坐标,单位:米
|
||||
private final double x;
|
||||
// Y坐标,单位:米
|
||||
private final double y;
|
||||
// Z坐标,单位:米
|
||||
private final double z;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param x X坐标(米)
|
||||
* @param y Y坐标(米)
|
||||
* @param z Z坐标(米)
|
||||
*/
|
||||
public CartesianCoordinate(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取X坐标
|
||||
* @return X坐标值
|
||||
*/
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Y坐标
|
||||
* @return Y坐标值
|
||||
*/
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Z坐标
|
||||
* @return Z坐标值
|
||||
*/
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("CartesianCoordinate [X=%.2fm, Y=%.2fm, Z=%.2fm]", x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
// 默认椭球参数为WGS84
|
||||
private static final Ellipsoid DEFAULT_ELLIPSOID = new WGS84Ellipsoid();
|
||||
// 迭代计算精度,单位:弧度,约等于0.00000057度
|
||||
private static final double ITERATION_PRECISION = 1e-10;
|
||||
// 最大迭代次数
|
||||
private static final int MAX_ITERATIONS = 10;
|
||||
|
||||
/**
|
||||
* 大地坐标正算:将大地坐标转换为空间直角坐标
|
||||
* 使用默认椭球参数(WGS84)
|
||||
*
|
||||
* @param geodetic 大地坐标(纬度、经度单位为弧度)
|
||||
* @return 空间直角坐标
|
||||
*/
|
||||
public static CartesianCoordinate geodeticToCartesian(GeodeticCoordinate geodetic) {
|
||||
return geodeticToCartesian(geodetic, DEFAULT_ELLIPSOID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 大地坐标正算:将大地坐标转换为空间直角坐标
|
||||
*
|
||||
* @param geodetic 大地坐标(纬度、经度单位为弧度)
|
||||
* @param ellipsoid 椭球参数
|
||||
* @return 空间直角坐标
|
||||
*/
|
||||
public static CartesianCoordinate geodeticToCartesian(GeodeticCoordinate geodetic, Ellipsoid ellipsoid) {
|
||||
// 验证输入参数
|
||||
if (geodetic == null) {
|
||||
throw new IllegalArgumentException("大地坐标不能为空");
|
||||
}
|
||||
if (ellipsoid == null) {
|
||||
throw new IllegalArgumentException("椭球参数不能为空");
|
||||
}
|
||||
|
||||
double B = geodetic.getLatitude(); // 纬度(弧度)
|
||||
double L = geodetic.getLongitude(); // 经度(弧度)
|
||||
double H = geodetic.getHeight(); // 大地高(米)
|
||||
|
||||
double a = ellipsoid.getSemiMajorAxis();
|
||||
double e2 = ellipsoid.getFirstEccentricitySquared();
|
||||
|
||||
// 计算卯酉圈曲率半径N
|
||||
double sinB = Math.sin(B);
|
||||
double cosB = Math.cos(B);
|
||||
double cosL = Math.cos(L);
|
||||
double sinL = Math.sin(L);
|
||||
|
||||
double N = a / Math.sqrt(1 - e2 * sinB * sinB);
|
||||
|
||||
// 计算空间直角坐标
|
||||
double X = (N + H) * cosB * cosL;
|
||||
double Y = (N + H) * cosB * sinL;
|
||||
double Z = (N * (1 - e2) + H) * sinB;
|
||||
|
||||
// 保留6位小数精度
|
||||
X = round(X, 6);
|
||||
Y = round(Y, 6);
|
||||
Z = round(Z, 6);
|
||||
|
||||
return new CartesianCoordinate(X, Y, Z);
|
||||
}
|
||||
|
||||
/**
|
||||
* 大地坐标反算:将空间直角坐标转换为大地坐标
|
||||
* 使用默认椭球参数(WGS84)
|
||||
*
|
||||
* @param cartesian 空间直角坐标
|
||||
* @return 大地坐标(纬度、经度单位为弧度)
|
||||
*/
|
||||
public static GeodeticCoordinate cartesianToGeodetic(CartesianCoordinate cartesian) {
|
||||
return cartesianToGeodetic(cartesian, DEFAULT_ELLIPSOID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 大地坐标反算:将空间直角坐标转换为大地坐标
|
||||
*
|
||||
* @param cartesian 空间直角坐标
|
||||
* @param ellipsoid 椭球参数
|
||||
* @return 大地坐标(纬度、经度单位为弧度)
|
||||
*/
|
||||
public static GeodeticCoordinate cartesianToGeodetic(CartesianCoordinate cartesian, Ellipsoid ellipsoid) {
|
||||
// 验证输入参数
|
||||
if (cartesian == null) {
|
||||
throw new IllegalArgumentException("空间直角坐标不能为空");
|
||||
}
|
||||
if (ellipsoid == null) {
|
||||
throw new IllegalArgumentException("椭球参数不能为空");
|
||||
}
|
||||
|
||||
double X = cartesian.getX();
|
||||
double Y = cartesian.getY();
|
||||
double Z = cartesian.getZ();
|
||||
|
||||
double a = ellipsoid.getSemiMajorAxis();
|
||||
double b = ellipsoid.getSemiMinorAxis();
|
||||
double e2 = ellipsoid.getFirstEccentricitySquared();
|
||||
double ePrime2 = ellipsoid.getSecondEccentricitySquared();
|
||||
|
||||
// 计算经度L
|
||||
double L;
|
||||
if (X == 0 && Y == 0) {
|
||||
L = 0; // 位于极点,经度无意义,设为0
|
||||
} else {
|
||||
L = Math.atan2(Y, X); // 计算经度(弧度)
|
||||
}
|
||||
|
||||
// 计算点到地轴的距离r
|
||||
double r = Math.sqrt(X * X + Y * Y);
|
||||
|
||||
// 特殊情况处理:如果r为0,说明在极点
|
||||
if (r == 0) {
|
||||
double B = (Z > 0) ? Math.PI / 2 : -Math.PI / 2; // 北极或南极
|
||||
double H = Math.abs(Z) - b; // 大地高
|
||||
return new GeodeticCoordinate(B, L, H);
|
||||
}
|
||||
|
||||
// 迭代计算纬度B
|
||||
double B = Math.atan2(Z, r * (1 - e2)); // 初始值
|
||||
double previousB;
|
||||
int iterations = 0;
|
||||
|
||||
do {
|
||||
previousB = B;
|
||||
double sinB = Math.sin(B);
|
||||
// 计算卯酉圈曲率半径N
|
||||
double N = a / Math.sqrt(1 - e2 * sinB * sinB);
|
||||
// 迭代计算新的纬度
|
||||
B = Math.atan2(Z + N * e2 * sinB, r);
|
||||
iterations++;
|
||||
} while (Math.abs(B - previousB) > ITERATION_PRECISION && iterations < MAX_ITERATIONS);
|
||||
|
||||
// 计算大地高H
|
||||
double sinB = Math.sin(B);
|
||||
double cosB = Math.cos(B);
|
||||
double N = a / Math.sqrt(1 - e2 * sinB * sinB);
|
||||
double H = (r / cosB) - N;
|
||||
|
||||
// 保留8位小数精度
|
||||
B = round(B, 8);
|
||||
L = round(L, 8);
|
||||
H = round(H, 6);
|
||||
|
||||
return new GeodeticCoordinate(B, L, H);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角度转换:度分秒转弧度
|
||||
*
|
||||
* @param degrees 度
|
||||
* @param minutes 分
|
||||
* @param seconds 秒
|
||||
* @return 转换后的弧度值
|
||||
*/
|
||||
public static double dmsToRadians(int degrees, int minutes, double seconds) {
|
||||
if (degrees < 0 || minutes < 0 || minutes >= 60 || seconds < 0 || seconds >= 60) {
|
||||
throw new IllegalArgumentException("无效的度分秒值");
|
||||
}
|
||||
|
||||
double decimalDegrees = degrees + minutes / 60.0 + seconds / 3600.0;
|
||||
return Math.toRadians(decimalDegrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角度转换:弧度转度分秒表示的字符串
|
||||
*
|
||||
* @param radians 弧度值
|
||||
* @return 度分秒格式的字符串(例如:30°15'22.5")
|
||||
*/
|
||||
public static String radiansToDmsString(double radians) {
|
||||
double degrees = Math.toDegrees(radians);
|
||||
int deg = (int) Math.floor(Math.abs(degrees));
|
||||
double minutes = (Math.abs(degrees) - deg) * 60;
|
||||
int min = (int) Math.floor(minutes);
|
||||
double sec = (minutes - min) * 60;
|
||||
|
||||
// 保留两位小数
|
||||
sec = round(sec, 2);
|
||||
|
||||
// 处理符号
|
||||
String sign = degrees >= 0 ? "" : "-";
|
||||
|
||||
return String.format("%s%d°%d'%f\"", sign, deg, min, sec);
|
||||
}
|
||||
|
||||
/**
|
||||
* 四舍五入保留指定小数位数
|
||||
*
|
||||
* @param value 要处理的数值
|
||||
* @param decimalPlaces 保留的小数位数
|
||||
* @return 处理后的数值
|
||||
*/
|
||||
private static double round(double value, int decimalPlaces) {
|
||||
if (decimalPlaces < 0) {
|
||||
throw new IllegalArgumentException("小数位数不能为负数");
|
||||
}
|
||||
|
||||
BigDecimal bd = new BigDecimal(Double.toString(value));
|
||||
bd = bd.setScale(decimalPlaces, RoundingMode.HALF_UP);
|
||||
return bd.doubleValue();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.example.demo.common.util;
|
||||
|
||||
import com.example.demo.common.utils.CoordinateConverterUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.example.demo.common.utils.CoordinateConverterUtil.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("CoordinateConverterUtil工具类测试")
|
||||
public class CoordinateConverterUtilTest {
|
||||
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGEO() {
|
||||
// 创建WGS84椭球参数实例
|
||||
CoordinateConverterUtil.Ellipsoid wgs84 = new CoordinateConverterUtil.WGS84Ellipsoid();
|
||||
// 创建CGCS2000椭球参数实例
|
||||
CoordinateConverterUtil.Ellipsoid cgcs2000 = new CoordinateConverterUtil.CGCS2000Ellipsoid();
|
||||
|
||||
// 测试点:北京某点的大致坐标(39°54'27"N, 116°23'17"E, 50m)
|
||||
double latitude = dmsToRadians(39, 54, 27.0); // 纬度(弧度)
|
||||
double longitude = dmsToRadians(116, 23, 17.0); // 经度(弧度)
|
||||
double height = 50.0; // 大地高(米)
|
||||
|
||||
CoordinateConverterUtil.GeodeticCoordinate geodetic = new CoordinateConverterUtil.GeodeticCoordinate(latitude, longitude, height);
|
||||
System.out.println("原始大地坐标: " + geodetic);
|
||||
System.out.println("纬度(度分秒): " + radiansToDmsString(latitude));
|
||||
System.out.println("经度(度分秒): " + radiansToDmsString(longitude));
|
||||
|
||||
// 测试WGS84正算
|
||||
CoordinateConverterUtil.CartesianCoordinate cartesianWgs84 = geodeticToCartesian(geodetic, wgs84);
|
||||
System.out.println("\nWGS84正算结果: " + cartesianWgs84);
|
||||
|
||||
// 测试WGS84反算
|
||||
CoordinateConverterUtil.GeodeticCoordinate geodeticWgs84 = cartesianToGeodetic(cartesianWgs84, wgs84);
|
||||
System.out.println("WGS84反算结果: " + geodeticWgs84);
|
||||
System.out.println("反算纬度(度分秒): " + radiansToDmsString(geodeticWgs84.getLatitude()));
|
||||
System.out.println("反算经度(度分秒): " + radiansToDmsString(geodeticWgs84.getLongitude()));
|
||||
|
||||
// 测试CGCS2000正算
|
||||
CoordinateConverterUtil.CartesianCoordinate cartesianCgcs2000 = geodeticToCartesian(geodetic, cgcs2000);
|
||||
System.out.println("\nCGCS2000正算结果: " + cartesianCgcs2000);
|
||||
|
||||
// 测试CGCS2000反算
|
||||
CoordinateConverterUtil.GeodeticCoordinate geodeticCgcs2000 = cartesianToGeodetic(cartesianCgcs2000, cgcs2000);
|
||||
System.out.println("CGCS2000反算结果: " + geodeticCgcs2000);
|
||||
|
||||
// 验证正算反算的精度
|
||||
double latDiff = Math.toDegrees(Math.abs(geodetic.getLatitude() - geodeticWgs84.getLatitude())) * 3600;
|
||||
double lonDiff = Math.toDegrees(Math.abs(geodetic.getLongitude() - geodeticWgs84.getLongitude())) * 3600;
|
||||
double hDiff = Math.abs(geodetic.getHeight() - geodeticWgs84.getHeight());
|
||||
|
||||
System.out.println("\n正算反算精度验证:");
|
||||
System.out.printf("纬度差异: %.6f 秒\n", latDiff);
|
||||
System.out.printf("经度差异: %.6f 秒\n", lonDiff);
|
||||
System.out.printf("大地高差异: %.6f 米\n", hDiff);
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,12 @@ import com.example.demo.parser.process.domain.ConfigDocument;
|
||||
import com.example.demo.parser.process.core.EnhancedTemplateGenerator;
|
||||
import com.example.demo.parser.process.core.Xml2AFSIMTransformation;
|
||||
import com.example.demo.parser.process.util.FormatUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -13,9 +19,33 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,编号01")
|
||||
public class ApplicationTest__01 {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
@DisplayName("testOne - 平台信息的基本语法转化(草稿01) - 【已验证】")
|
||||
public void testOne() {
|
||||
|
||||
List<String> dataList = new ArrayList<>() {{
|
||||
add("20250923_6b399e.xml");
|
||||
|
@ -5,6 +5,12 @@ import com.example.demo.parser.process.domain.ConfigDocument;
|
||||
import com.example.demo.parser.process.core.EnhancedTemplateGenerator;
|
||||
import com.example.demo.parser.process.core.Xml2AFSIMTransformation;
|
||||
import com.example.demo.parser.process.util.FormatUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -13,9 +19,33 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,编号02")
|
||||
public class ApplicationTest__02 {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
@DisplayName("testOne - 转化 section 循环问题(草稿02) - 【已验证】")
|
||||
public void testOne() {
|
||||
|
||||
List<String> dataList = new ArrayList<>() {{
|
||||
add("20250923_5e813d.xml");
|
||||
|
@ -5,6 +5,12 @@ import com.example.demo.parser.process.domain.ConfigDocument;
|
||||
import com.example.demo.parser.process.core.EnhancedTemplateGenerator;
|
||||
import com.example.demo.parser.process.core.Xml2AFSIMTransformation;
|
||||
import com.example.demo.parser.process.util.FormatUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -13,9 +19,33 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,编号03")
|
||||
public class ApplicationTest__03 {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
@DisplayName("testOne - 枚举、自定义函数、直接量正则替换(草稿03) - 【已验证】")
|
||||
public void testOne() {
|
||||
|
||||
List<String> dataList = new ArrayList<>() {{
|
||||
add("20250923_4c32c8.xml");
|
||||
|
@ -5,6 +5,12 @@ import com.example.demo.parser.process.domain.ConfigDocument;
|
||||
import com.example.demo.parser.process.core.EnhancedTemplateGenerator;
|
||||
import com.example.demo.parser.process.core.Xml2AFSIMTransformation;
|
||||
import com.example.demo.parser.process.util.FormatUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -13,9 +19,33 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,编号04")
|
||||
public class ApplicationTest__04 {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
@DisplayName("testOne - 多层级XML(草稿04) - 【已验证】")
|
||||
public void testOne() {
|
||||
|
||||
List<String> dataList = new ArrayList<>() {{
|
||||
add("20250923_02d1d0.xml");
|
||||
|
@ -1,19 +1,28 @@
|
||||
package com.example.demo.parser.process.domain;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 测试LevelConfig的loopCount字段修复
|
||||
*
|
||||
* @author 岳佳君 (2025年09月27日 17:53:39)
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("测试循环")
|
||||
public class TestLoopCountFix {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@Test
|
||||
public void testOne() throws IOException {
|
||||
// 读取default.json文件
|
||||
String templateContent = Files.readString(
|
||||
Path.of("src/main/resources/data/02-单个空中平台任务数据/default.json"),
|
||||
|
@ -7,13 +7,41 @@ import com.example.demo.parser.process.domain.ConfigValue;
|
||||
import com.example.demo.parser.process.domain.LevelConfig;
|
||||
import com.example.demo.parser.process.domain.ValueConfig;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,JSON来源,02")
|
||||
public class ConfigDataCreator__02 {
|
||||
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
@Test
|
||||
public void testOne() {
|
||||
System.out.println(JSON.toJSONString(createConfigDocument()));
|
||||
String result1 = EnhancedTemplateGenerator.generateCodeWithFormat(
|
||||
JSON.parseObject(JSON.toJSONString(createConfigDocument()), Map.class),
|
||||
|
@ -7,13 +7,41 @@ import com.example.demo.parser.process.domain.ConfigValue;
|
||||
import com.example.demo.parser.process.domain.LevelConfig;
|
||||
import com.example.demo.parser.process.domain.ValueConfig;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,JSON来源,03")
|
||||
public class ConfigDataCreator__03 {
|
||||
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
@Test
|
||||
public void testOne() {
|
||||
System.out.println(JSON.toJSONString(createConfigDocument()));
|
||||
String result1 = EnhancedTemplateGenerator.generateCodeWithFormat(
|
||||
JSON.parseObject(JSON.toJSONString(createConfigDocument()), Map.class),
|
||||
|
@ -7,15 +7,43 @@ import com.example.demo.parser.process.domain.ConfigValue;
|
||||
import com.example.demo.parser.process.domain.LevelConfig;
|
||||
import com.example.demo.parser.process.domain.ValueConfig;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
@DisplayName("XML转Afsim,草稿,JSON来源,03")
|
||||
public class ConfigDataCreator__04 {
|
||||
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* 每个测试方法执行前的初始化操作
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个测试方法执行后的清理操作
|
||||
*/
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
@Test
|
||||
public void testOne() {
|
||||
System.out.println(JSON.toJSONString(createConfigDocument()));
|
||||
String result1 = EnhancedTemplateGenerator.generateCodeWithFormat(
|
||||
JSON.parseObject(JSON.toJSONString(createConfigDocument()), Map.class),
|
||||
|
@ -34,10 +34,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* <li>极值/边界值检查处理模块测试</li>
|
||||
* <li>数据KV映射处理模块测试</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author demo043项目组
|
||||
*
|
||||
* @author 岳佳君 (2025年09月28日 09:13:09)
|
||||
* @version 1.0.0
|
||||
* @since 2024年
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@Slf4j
|
||||
|
Loading…
x
Reference in New Issue
Block a user