|
|
|
@ -10,6 +10,10 @@ import org.locationtech.jts.geom.impl.CoordinateArraySequence;
|
|
|
|
|
import org.locationtech.jts.operation.buffer.BufferOp; |
|
|
|
|
import org.locationtech.jts.operation.buffer.BufferParameters; |
|
|
|
|
import org.locationtech.jts.util.GeometricShapeFactory; |
|
|
|
|
import org.locationtech.proj4j.BasicCoordinateTransform; |
|
|
|
|
import org.locationtech.proj4j.CRSFactory; |
|
|
|
|
import org.locationtech.proj4j.CoordinateReferenceSystem; |
|
|
|
|
import org.locationtech.proj4j.ProjCoordinate; |
|
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
@ -35,6 +39,34 @@ public class AreaUtils {
|
|
|
|
|
this.init(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* TODO 좌표계 변환 |
|
|
|
|
* |
|
|
|
|
* @param coordList |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<Coordinate> transform(List<Coordinate> coordList, String from, String to) { |
|
|
|
|
CRSFactory factory = new CRSFactory(); |
|
|
|
|
|
|
|
|
|
CoordinateReferenceSystem srcCRS = factory.createFromName(from); |
|
|
|
|
CoordinateReferenceSystem tgtCRS = factory.createFromName(to); |
|
|
|
|
|
|
|
|
|
BasicCoordinateTransform transform = new BasicCoordinateTransform(srcCRS, tgtCRS); |
|
|
|
|
|
|
|
|
|
List<Coordinate> result = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for(Coordinate coord : coordList) { |
|
|
|
|
ProjCoordinate projCoordinate = new ProjCoordinate(coord.getX(), coord.getY()); |
|
|
|
|
ProjCoordinate projTrasform = transform.transform(projCoordinate, new ProjCoordinate()); |
|
|
|
|
|
|
|
|
|
Coordinate target = new Coordinate(projTrasform.x, projTrasform.y); |
|
|
|
|
|
|
|
|
|
result.add(target); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* TODO 비행 구역 생성시 장애물 영역 포함 체크 |
|
|
|
|
* |
|
|
|
@ -95,7 +127,6 @@ public class AreaUtils {
|
|
|
|
|
*/ |
|
|
|
|
public List<Coordinate> buffer(List<Coordinate> coordList, Integer bufferZone) { |
|
|
|
|
List<Coordinate> bufferList = new ArrayList<>(); |
|
|
|
|
// GeometryFactory geometryFactory = new GeometryFactory();
|
|
|
|
|
|
|
|
|
|
LineString line = geometryFactory.createLineString(coordList.toArray(new Coordinate[] {})); |
|
|
|
|
Geometry geometry = geometryFactory.createGeometry(line); |
|
|
|
@ -108,7 +139,8 @@ public class AreaUtils {
|
|
|
|
|
BufferParameters bufferParam = new BufferParameters(nSegments, cap, join, join); |
|
|
|
|
BufferOp ops = new BufferOp(geometry, bufferParam); |
|
|
|
|
|
|
|
|
|
Geometry bufTrans = ops.getResultGeometry((bufferZone/177763.63662580872)*2); |
|
|
|
|
// Geometry bufTrans = ops.getResultGeometry((bufferZone/177763.63662580872)*2);
|
|
|
|
|
Geometry bufTrans = ops.getResultGeometry(bufferZone); |
|
|
|
|
|
|
|
|
|
Coordinate[] coords = bufTrans.getCoordinates(); |
|
|
|
|
|
|
|
|
@ -118,10 +150,8 @@ public class AreaUtils {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Coordinate> createCircle(Coordinate CircleCoord, Integer BufferZone) { |
|
|
|
|
List<Coordinate> coordList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
GeometricShapeFactory shapeFactory = new GeometricShapeFactory(); |
|
|
|
|
// GeometryFactory geometryFactory = new GeometryFactory();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double lng = CircleCoord.x; |
|
|
|
|
double lat = CircleCoord.y; |
|
|
|
@ -137,7 +167,7 @@ public class AreaUtils {
|
|
|
|
|
|
|
|
|
|
Geometry geometry = geometryFactory.createGeometry(circle); |
|
|
|
|
Coordinate[] coords = geometry.getCoordinates(); |
|
|
|
|
|
|
|
|
|
List<Coordinate> coordList = new ArrayList<>(); |
|
|
|
|
coordList.addAll(Arrays.asList(coords)); |
|
|
|
|
|
|
|
|
|
return coordList; |
|
|
|
|