|
|
@ -10,7 +10,7 @@ import com.palnet.biz.jpa.entity.type.ReviewedType; |
|
|
|
import com.palnet.biz.jpa.repository.dos.*; |
|
|
|
import com.palnet.biz.jpa.repository.dos.*; |
|
|
|
import com.palnet.comn.code.ErrorCode; |
|
|
|
import com.palnet.comn.code.ErrorCode; |
|
|
|
import com.palnet.comn.exception.CustomException; |
|
|
|
import com.palnet.comn.exception.CustomException; |
|
|
|
import com.palnet.comn.utils.AirspaceUtils; |
|
|
|
import com.palnet.comn.utils.AirAreaUtils; |
|
|
|
import com.palnet.comn.utils.AreaUtils; |
|
|
|
import com.palnet.comn.utils.AreaUtils; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -196,10 +196,10 @@ public class DronOneStopService { |
|
|
|
// Buffer 추출 - 테두리 좌표
|
|
|
|
// Buffer 추출 - 테두리 좌표
|
|
|
|
List<Coordinate> coordBuffers = areaUtils.createCircle(centerPoint, bufferZone); |
|
|
|
List<Coordinate> coordBuffers = areaUtils.createCircle(centerPoint, bufferZone); |
|
|
|
|
|
|
|
|
|
|
|
AirspaceUtils airspaceUtils = AirspaceUtils.getInstance(); |
|
|
|
AirAreaUtils airAreaUtils = AirAreaUtils.getInstance(); |
|
|
|
Geometry rqGeometry = airspaceUtils.createGeometryByCoordinate(coordBuffers); |
|
|
|
Geometry rqGeometry = airAreaUtils.createGeometryByCoordinate(coordBuffers, AirAreaUtils.GeometryType.POLYGON); |
|
|
|
|
|
|
|
|
|
|
|
AirspaceUtils.FeatureInfo targetfeatureInfo = AirspaceUtils.FeatureInfo.builder() |
|
|
|
AirAreaUtils.FeatureInfo targetfeatureInfo = AirAreaUtils.FeatureInfo.builder() |
|
|
|
.lowElev(0D) |
|
|
|
.lowElev(0D) |
|
|
|
.highElev(fltElev) |
|
|
|
.highElev(fltElev) |
|
|
|
.geometry(rqGeometry) |
|
|
|
.geometry(rqGeometry) |
|
|
@ -212,10 +212,10 @@ public class DronOneStopService { |
|
|
|
- 김포공항 관제지역 미승인 - F: 관제권내 제한고도 |
|
|
|
- 김포공항 관제지역 미승인 - F: 관제권내 제한고도 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
// 김포지역의 고도 데이터가 있는 경우만 검증
|
|
|
|
// 김포지역의 고도 데이터가 있는 경우만 검증
|
|
|
|
List<AirspaceUtils.FeatureInfo> airspaces = airspaceUtils.getAirspaces(AirspaceUtils.AirspaceType.GIMPO); |
|
|
|
List<AirAreaUtils.FeatureInfo> airspaces = airAreaUtils.getAirAreaList(AirAreaUtils.AirAreaType.GIMPO); |
|
|
|
|
|
|
|
|
|
|
|
if (airspaces.isEmpty()) { |
|
|
|
if (airspaces.isEmpty()) { |
|
|
|
log.warn("airspace is empty: {}", AirspaceUtils.AirspaceType.GIMPO); |
|
|
|
log.warn("airspace is empty: {}", AirAreaUtils.AirAreaType.GIMPO); |
|
|
|
throw new CustomException(ErrorCode.TS_ETC); |
|
|
|
throw new CustomException(ErrorCode.TS_ETC); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -223,19 +223,19 @@ public class DronOneStopService { |
|
|
|
Geometry targetGeometry = targetfeatureInfo.getGeometry(); |
|
|
|
Geometry targetGeometry = targetfeatureInfo.getGeometry(); |
|
|
|
|
|
|
|
|
|
|
|
// 중복되는 공역 추출
|
|
|
|
// 중복되는 공역 추출
|
|
|
|
List<AirspaceUtils.FeatureInfo> duplicatedAirspaces = airspaces.stream() |
|
|
|
List<AirAreaUtils.FeatureInfo> duplicatedAirspaceList = airspaces.stream() |
|
|
|
.filter(featureInfo -> featureInfo.getGeometry().intersects(targetGeometry)) |
|
|
|
.filter(featureInfo -> featureInfo.getGeometry().intersects(targetGeometry)) |
|
|
|
.collect(ArrayList::new, ArrayList::add, ArrayList::addAll); |
|
|
|
.collect(ArrayList::new, ArrayList::add, ArrayList::addAll); |
|
|
|
|
|
|
|
|
|
|
|
// 중복되는 공역이 없을 경우 "미대상 지역"
|
|
|
|
// 중복되는 공역이 없을 경우 "미대상 지역"
|
|
|
|
if (duplicatedAirspaces.isEmpty()) { |
|
|
|
if (duplicatedAirspaceList.isEmpty()) { |
|
|
|
result.setApprovalCd(ApprovalCd.UNTARGETED_AREA); |
|
|
|
result.setApprovalCd(ApprovalCd.UNTARGETED_AREA); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 중복되는 공역으로 부터 가장 낮은 허용고도 추출
|
|
|
|
// 중복되는 공역으로 부터 가장 낮은 허용고도 추출
|
|
|
|
double minHighElev = duplicatedAirspaces.stream() |
|
|
|
double minHighElev = duplicatedAirspaceList.stream() |
|
|
|
.mapToDouble(AirspaceUtils.FeatureInfo::getHighElev) |
|
|
|
.mapToDouble(AirAreaUtils.FeatureInfo::getHighElev) |
|
|
|
.min() |
|
|
|
.min() |
|
|
|
.orElse(0); |
|
|
|
.orElse(0); |
|
|
|
|
|
|
|
|
|
|
@ -254,7 +254,7 @@ public class DronOneStopService { |
|
|
|
Point centerGeometry = geometryFactory.createPoint(centerPoint); |
|
|
|
Point centerGeometry = geometryFactory.createPoint(centerPoint); |
|
|
|
|
|
|
|
|
|
|
|
// 제한 구역 체크
|
|
|
|
// 제한 구역 체크
|
|
|
|
for (AirspaceUtils.FeatureInfo checkAirspace : duplicatedAirspaces) { |
|
|
|
for (AirAreaUtils.FeatureInfo checkAirspace : duplicatedAirspaceList) { |
|
|
|
Geometry airspaceGeometry = checkAirspace.getGeometry(); |
|
|
|
Geometry airspaceGeometry = checkAirspace.getGeometry(); |
|
|
|
if (!airspaceGeometry.contains(centerGeometry)) { |
|
|
|
if (!airspaceGeometry.contains(centerGeometry)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -272,7 +272,7 @@ public class DronOneStopService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Double allowRadiusDouble = calculateAllowRadius(duplicatedAirspaces, centerGeometry); |
|
|
|
Double allowRadiusDouble = calculateAllowRadius(duplicatedAirspaceList, centerGeometry); |
|
|
|
Long allowRadius = allowRadiusDouble != null ? (long) Math.floor(allowRadiusDouble) : null; |
|
|
|
Long allowRadius = allowRadiusDouble != null ? (long) Math.floor(allowRadiusDouble) : null; |
|
|
|
Long reqRadius = allowRadius != null ? (long) Math.floor(allowRadius / 10.0) * 10 : null; |
|
|
|
Long reqRadius = allowRadius != null ? (long) Math.floor(allowRadius / 10.0) * 10 : null; |
|
|
|
result.setAllowRadius(allowRadius); |
|
|
|
result.setAllowRadius(allowRadius); |
|
|
@ -281,17 +281,17 @@ public class DronOneStopService { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Double calculateAllowRadius(List<AirspaceUtils.FeatureInfo> duplicatedAirspaces, Point centerGeometry) { |
|
|
|
private Double calculateAllowRadius(List<AirAreaUtils.FeatureInfo> duplicatedAirspaces, Point centerGeometry) { |
|
|
|
if (duplicatedAirspaces == null || duplicatedAirspaces.isEmpty()) { |
|
|
|
if (duplicatedAirspaces == null || duplicatedAirspaces.isEmpty()) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
List<AirspaceUtils.FeatureInfo> objectAirspaces = duplicatedAirspaces.stream().filter(airspace -> airspace.getHighElev() == 0).collect(Collectors.toList()); |
|
|
|
List<AirAreaUtils.FeatureInfo> objectAirspaces = duplicatedAirspaces.stream().filter(airspace -> airspace.getHighElev() == 0).collect(Collectors.toList()); |
|
|
|
if (objectAirspaces.isEmpty()) { |
|
|
|
if (objectAirspaces.isEmpty()) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
Double minDistance = null; |
|
|
|
Double minDistance = null; |
|
|
|
|
|
|
|
|
|
|
|
for (AirspaceUtils.FeatureInfo airspace : duplicatedAirspaces) { |
|
|
|
for (AirAreaUtils.FeatureInfo airspace : duplicatedAirspaces) { |
|
|
|
// 수평 타입의 airspace만 해당
|
|
|
|
// 수평 타입의 airspace만 해당
|
|
|
|
// 중심 좌표가 수평 airspace 내부에 있는 것만 해당
|
|
|
|
// 중심 좌표가 수평 airspace 내부에 있는 것만 해당
|
|
|
|
Geometry airspaceGeometry = airspace.getGeometry(); |
|
|
|
Geometry airspaceGeometry = airspace.getGeometry(); |
|
|
@ -331,19 +331,18 @@ public class DronOneStopService { |
|
|
|
List<Double> distances = new ArrayList<>(); |
|
|
|
List<Double> distances = new ArrayList<>(); |
|
|
|
for (int i = 0; i < coordinates.length - 1; i++) { |
|
|
|
for (int i = 0; i < coordinates.length - 1; i++) { |
|
|
|
// 중심점과 선분위에서 가까운 좌표 계산 - 지구의 곡률을 고려한 좌표
|
|
|
|
// 중심점과 선분위에서 가까운 좌표 계산 - 지구의 곡률을 고려한 좌표
|
|
|
|
Coordinate nearestCoordinate = AirspaceUtils.getClosestPoint(coordinates[i], coordinates[i + 1], centerCoordinate); |
|
|
|
Coordinate nearestCoordinate = AirAreaUtils.getClosestPoint(coordinates[i], coordinates[i + 1], centerCoordinate); |
|
|
|
if (Double.isNaN(nearestCoordinate.x) || Double.isNaN(nearestCoordinate.y)) { |
|
|
|
if (Double.isNaN(nearestCoordinate.x) || Double.isNaN(nearestCoordinate.y)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// 좌표와 좌표의 거리 계산
|
|
|
|
// 좌표와 좌표의 거리 계산
|
|
|
|
Double distance = AirspaceUtils.calculatePointAndPointDistance(nearestCoordinate, centerCoordinate); |
|
|
|
Double distance = AirAreaUtils.calculatePointAndPointDistance(nearestCoordinate, centerCoordinate); |
|
|
|
distances.add(distance); |
|
|
|
distances.add(distance); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 중심 좌표와 가장 가까운 점 사이의 거리
|
|
|
|
// 중심 좌표와 가장 가까운 점 사이의 거리
|
|
|
|
Double distance = distances.stream().min(Double::compare).orElse(null); |
|
|
|
return distances.stream().min(Double::compare).orElse(null); |
|
|
|
return distance; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|