Browse Source

비행계획서 - 필터 정밀도 향상 , 폴리곤 생성시 간헐적 오류발생 수정 , 사용자에게 오류메세지 전달 작업

feature/auth
박재우 2 years ago
parent
commit
5be6451482
  1. 1
      src/main/java/com/palnet/biz/api/bas/flight/controller/BasFlightController.java
  2. 27
      src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java
  3. 16
      src/main/java/com/palnet/comn/utils/AreaUtils.java

1
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<Map>(resultMap));
} catch (Exception e) {
log.error("IGNORE : {}", e);

27
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<Coordinate> rqCoord = new ArrayList<>();
List<Coordinate> 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);
}
}
}
}
}

16
src/main/java/com/palnet/comn/utils/AreaUtils.java

@ -72,7 +72,7 @@ public class AreaUtils {
*/
public boolean overlaps(List<Coordinate> 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<Coordinate> targetCoordList, List<Coordinate> 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<Coordinate> 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);

Loading…
Cancel
Save