From 5be645148205cf43cbf346c2f5baacda61c83b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=9E=AC=EC=9A=B0?= <박재우@DESKTOP-EF7ECBO> Date: Wed, 31 Aug 2022 16:45:01 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=96=89=EA=B3=84=ED=9A=8D=EC=84=9C?= =?UTF-8?q?=20-=20=ED=95=84=ED=84=B0=20=EC=A0=95=EB=B0=80=EB=8F=84=20?= =?UTF-8?q?=ED=96=A5=EC=83=81=20,=20=ED=8F=B4=EB=A6=AC=EA=B3=A4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=8B=9C=20=EA=B0=84=ED=97=90=EC=A0=81=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=EB=B0=9C=EC=83=9D=20=EC=88=98=EC=A0=95=20,?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=EC=9E=90=EC=97=90=EA=B2=8C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=A0=84=EB=8B=AC=20?= =?UTF-8?q?=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BasFlightController.java | 1 + .../bas/flight/service/BasFlightService.java | 27 ++++++++++++++----- .../java/com/palnet/comn/utils/AreaUtils.java | 16 ++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/palnet/biz/api/bas/flight/controller/BasFlightController.java b/src/main/java/com/palnet/biz/api/bas/flight/controller/BasFlightController.java index ad4ad0f..b1b27b4 100644 --- a/src/main/java/com/palnet/biz/api/bas/flight/controller/BasFlightController.java +++ b/src/main/java/com/palnet/biz/api/bas/flight/controller/BasFlightController.java @@ -99,6 +99,7 @@ public class BasFlightController { log.error("IGNORE : {}", e); resultMap.put("result", false); resultMap.put("errorCode", e.getErrorCode()); + resultMap.put("errorMessage", e.getMessage()); return ResponseEntity.ok().body(new SuccessResponse(resultMap)); } catch (Exception e) { log.error("IGNORE : {}", e); diff --git a/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java b/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java index fe68698..e396b2b 100644 --- a/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java +++ b/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java @@ -10,6 +10,7 @@ import com.palnet.comn.exception.CustomException; import org.apache.commons.lang3.StringUtils; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; +import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Polygon; import org.springframework.stereotype.Service; @@ -143,11 +144,13 @@ public class BasFlightService { if("CIRCLE".equals(area.getAreaType())) { effectiveCoordBufferList = areaUtils.createCircle(effectiveCoordList.get(0), area.getBufferZone()); } - effectiveCoordBufferList.add(effectiveCoordBufferList.get(0)); // 유효한 비행구역 검증하기. for(BasFlightPlanAreaModel rqArea : rq.getAreaList()) { - boolean checking = false; + boolean overlapCheck = false; + boolean overlapCheck2 = false; + boolean containCheck = false; + boolean containCheck2 = false; List rqCoord = new ArrayList<>(); List rqCoordBufferList = new ArrayList<>(); @@ -167,13 +170,25 @@ public class BasFlightService { if("CIRCLE".equals(rqArea.getAreaType())) { rqCoordBufferList = areaUtils.createCircle(rqCoord.get(0), rqArea.getBufferZone()); } - rqCoordBufferList.add(rqCoordBufferList.get(0)); - //검증 - checking = areaUtils.overlaps(rqCoordBufferList, effectiveCoordBufferList); - if(checking) { + + overlapCheck = areaUtils.overlaps(rqCoordBufferList, effectiveCoordBufferList); + overlapCheck2 = areaUtils.overlaps(effectiveCoordBufferList, rqCoordBufferList); + if(overlapCheck || overlapCheck2) { throw new CustomException(ErrorCode.PLAN_DATA_DUPLICATE); } + for(Coordinate coord : effectiveCoordBufferList) { + containCheck = areaUtils.contains(rqCoordBufferList, coord); + if(containCheck) { + throw new CustomException(ErrorCode.PLAN_DATA_DUPLICATE); + } + } + for(Coordinate coord : rqCoordBufferList) { + containCheck2 = areaUtils.contains(effectiveCoordBufferList , coord); + if(containCheck2) { + throw new CustomException(ErrorCode.PLAN_DATA_DUPLICATE); + } + } } } } diff --git a/src/main/java/com/palnet/comn/utils/AreaUtils.java b/src/main/java/com/palnet/comn/utils/AreaUtils.java index 1083c4e..7a73f1c 100644 --- a/src/main/java/com/palnet/comn/utils/AreaUtils.java +++ b/src/main/java/com/palnet/comn/utils/AreaUtils.java @@ -72,7 +72,7 @@ public class AreaUtils { */ public boolean overlaps(List targetCoordList) { boolean result = false; - + targetCoordList.add(targetCoordList.get(0)); Polygon targetPolygon = geometryFactory.createPolygon(targetCoordList.toArray(new Coordinate[] {})); /* 공역 데이터 */ @@ -101,9 +101,19 @@ public class AreaUtils { * @return boolean - true(비정상), false(정상) */ public boolean overlaps(List targetCoordList, List effectiveCoordList) { + targetCoordList.add(targetCoordList.get(0)); Polygon targetPolygon = geometryFactory.createPolygon(targetCoordList.toArray(new Coordinate[] {})); + Coordinate[] coords = targetPolygon.getCoordinates(); + for(Coordinate coord : coords) { + System.out.println(coord.x + "," + coord.y); + } + effectiveCoordList.add(effectiveCoordList.get(0)); Polygon effectivePolygon = geometryFactory.createPolygon(effectiveCoordList.toArray(new Coordinate[] {})); - + System.out.println("ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ"); + Coordinate[] coords2 = effectivePolygon.getCoordinates(); + for(Coordinate coord : coords2) { + System.out.println(coord.x + "," + coord.y); + } return targetPolygon.overlaps(effectivePolygon); } @@ -139,7 +149,7 @@ public class AreaUtils { */ public boolean contains(List areaCoordList, Coordinate targetCoordinate) { boolean result = true; - + areaCoordList.add(areaCoordList.get(0)); if(targetCoordinate != null) { Polygon plan = geometryFactory.createPolygon(areaCoordList.toArray(new Coordinate[]{})); // 비행 구역 Point target = geometryFactory.createPoint(targetCoordinate);