From 28cd6f0649ff5d249bbb724a392db8cdd1c0ef5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dhji=28=EC=A7=80=EB=8C=80=ED=95=9C=29?= Date: Tue, 20 Aug 2024 13:24:53 +0900 Subject: [PATCH] feat: airspaceutils and areautil mearge --- .../com/palnet/comn/utils/AirAreaUtils.java | 75 +------------------ 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/pav-server/src/main/java/com/palnet/comn/utils/AirAreaUtils.java b/pav-server/src/main/java/com/palnet/comn/utils/AirAreaUtils.java index 4974280e..7f557445 100644 --- a/pav-server/src/main/java/com/palnet/comn/utils/AirAreaUtils.java +++ b/pav-server/src/main/java/com/palnet/comn/utils/AirAreaUtils.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.geotools.geojson.feature.FeatureJSON; import org.geotools.geojson.geom.GeometryJSON; import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.JTSFactoryFinder; import org.geotools.referencing.CRS; import org.geotools.referencing.GeodeticCalculator; import org.json.simple.JSONArray; @@ -21,7 +20,6 @@ import org.locationtech.proj4j.BasicCoordinateTransform; import org.locationtech.proj4j.CRSFactory; import org.locationtech.proj4j.ProjCoordinate; import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.FactoryException; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.TransformException; @@ -39,12 +37,11 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; -// TODO areaUtils, airspaceUtils merge -// TODO airspaceUtils의 검증 관련 로직은 해당 표시에서 적용. @Slf4j public class AirAreaUtils { private final int PERIMETER_OF_EARTH = 40075 * 1000; // 지구 둘레(m) + private final String RESOURCE_BASE_PATH = "air/airspace/"; private final String COMMON_PATH = "common/"; private final String CUSTOM_PATH = "custom/"; @@ -767,64 +764,6 @@ public class AirAreaUtils { return coordList; } - /* - // 라인 버퍼 생성 샘플 - public static void main(String[] args) throws FactoryException, TransformException { - // EPSG:4326 좌표계 정의 - CoordinateReferenceSystem crs4326 = CRS.decode("EPSG:4326"); - - // EPSG:3857 좌표계 정의 (투영 좌표계) -// CoordinateReferenceSystem crs3857 = CRS.decode("EPSG:3857"); - CoordinateReferenceSystem crs3857 = CRS.decode("EPSG:5181"); - - // 좌표 변환기 설정 - MathTransform transformTo3857 = CRS.findMathTransform(crs4326, crs3857); - MathTransform transformTo4326 = CRS.findMathTransform(crs3857, crs4326); - - // GeometryFactory 생성 - GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); - - // LineString 좌표 정의 (EPSG:4326) - Coordinate[] coordinates = new Coordinate[]{ - new Coordinate(127.0, 37.0), - new Coordinate(127.1, 37.1), - new Coordinate(127.2, 37.2) - }; - List coordinates1 = AirAreaUtils.swapCoordinates(Arrays.asList(coordinates)); - LineString lineString = geometryFactory.createLineString(coordinates1.toArray(new Coordinate[0])); - - // LineString을 EPSG:3857로 변환 - LineString transformedLineString = (LineString) JTS.transform(lineString, transformTo3857); - - // 거리 (단위: 미터) - double distance = 1000; // 1km - - // Buffer를 사용하여 LineString을 둘러싼 Polygon 생성 (EPSG:3857) - Polygon bufferedPolygon = (Polygon) transformedLineString.buffer(distance); - - // Buffered Polygon을 EPSG:4326로 변환 - Polygon finalPolygon = (Polygon) JTS.transform(bufferedPolygon, transformTo4326); - List finalCoordinates = Arrays.stream(finalPolygon.getCoordinates()).map(coordinate -> new de.micromata.opengis.kml.v_2_2_0.Coordinate(coordinate.y, coordinate.x)).collect(Collectors.toList()); - - // 결과 출력 - KmlUtils.KmlRq bufferRq = KmlUtils.KmlRq.builder() - .name("test") - .type(KmlUtils.TYPE.POLYGON) - .coordinates(finalCoordinates) - .build(); - - KmlUtils.KmlRq lineRq = KmlUtils.KmlRq.builder() - .name("test") - .type(KmlUtils.TYPE.LINESTRING) - .coordinates(Arrays.stream(coordinates).map(coordinate -> new de.micromata.opengis.kml.v_2_2_0.Coordinate(coordinate.x, coordinate.y)).collect(Collectors.toList())) - .build(); - String str = KmlUtils.createKmlPolygons(List.of(bufferRq, lineRq)); - System.out.println(str); - - } - */ - - public static Coordinate transformCoordinate(Coordinate sourceCoord, String sourceCRSCode, String targetCRSCode) throws Exception { // 소스와 타겟 CRS 정의 CoordinateReferenceSystem sourceCRS = CRS.decode(sourceCRSCode); @@ -837,16 +776,4 @@ public class AirAreaUtils { return JTS.transform(sourceCoord, null, transform); } - public static void main(String[] args) { - try { - Coordinate sourceCoord = new Coordinate(37.111, 127.1133); - Coordinate transformedCoord = transformCoordinate(sourceCoord, "EPSG:4326", "EPSG:5181"); - System.out.println("Transformed Coordinate1: " + transformedCoord); - Coordinate transformedCoord2 = transformCoordinate(transformedCoord, "EPSG:5181", "EPSG:4326"); - System.out.println("Transformed Coordinate2: " + transformedCoord2); - } catch (Exception e) { - e.printStackTrace(); - } - } - }