|
|
@ -3,6 +3,7 @@ package com.palnet.comn.utils; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightPlanAreaCoordModel; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightPlanAreaCoordModel; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.locationtech.jts.geom.*; |
|
|
|
import org.locationtech.jts.geom.*; |
|
|
|
|
|
|
|
import org.locationtech.jts.operation.buffer.BufferOp; |
|
|
|
import org.locationtech.jts.operation.buffer.BufferParameters; |
|
|
|
import org.locationtech.jts.operation.buffer.BufferParameters; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
@ -19,12 +20,20 @@ public class AreaUtils { |
|
|
|
|
|
|
|
|
|
|
|
GeometryFactory geometryFactory = new GeometryFactory(); |
|
|
|
GeometryFactory geometryFactory = new GeometryFactory(); |
|
|
|
LineString line = new GeometryFactory().createLineString(coordList.toArray(new Coordinate[] {})); |
|
|
|
LineString line = new GeometryFactory().createLineString(coordList.toArray(new Coordinate[] {})); |
|
|
|
|
|
|
|
|
|
|
|
Geometry geometry = geometryFactory.createGeometry(line); |
|
|
|
Geometry geometry = geometryFactory.createGeometry(line); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// buffer
|
|
|
|
|
|
|
|
int nSegments = 10; |
|
|
|
int cap = BufferParameters.CAP_SQUARE; |
|
|
|
int cap = BufferParameters.CAP_SQUARE; |
|
|
|
Geometry buffer = geometry.buffer(bufferZone,20,cap); |
|
|
|
int join = BufferParameters.JOIN_ROUND; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BufferParameters bufferParam = new BufferParameters(nSegments, cap, join, join); |
|
|
|
|
|
|
|
// Geometry buffer = geometry.buffer(bufferZone,20,cap);
|
|
|
|
|
|
|
|
BufferOp ops = new BufferOp(geometry, bufferParam); |
|
|
|
|
|
|
|
|
|
|
|
Coordinate[] coords = buffer.getCoordinates(); |
|
|
|
Geometry bufTrans = ops.getResultGeometry((bufferZone/177763.63662580872)*2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Coordinate[] coords = bufTrans.getCoordinates(); |
|
|
|
|
|
|
|
|
|
|
|
bufferList.addAll(Arrays.asList(coords)); |
|
|
|
bufferList.addAll(Arrays.asList(coords)); |
|
|
|
|
|
|
|
|
|
|
@ -33,15 +42,31 @@ public class AreaUtils { |
|
|
|
|
|
|
|
|
|
|
|
public List<Coordinate> convertCoordinates(List<BasFlightPlanAreaCoordModel> coordList) { |
|
|
|
public List<Coordinate> convertCoordinates(List<BasFlightPlanAreaCoordModel> coordList) { |
|
|
|
|
|
|
|
|
|
|
|
List<Coordinate> convertCoordList = new ArrayList<>(); |
|
|
|
List<Coordinate> coordinates = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
for(BasFlightPlanAreaCoordModel coord : coordList) { |
|
|
|
for(BasFlightPlanAreaCoordModel coord : coordList) { |
|
|
|
Coordinate coordinate = new Coordinate(coord.getLon(), coord.getLat()); |
|
|
|
Coordinate coordinate = new Coordinate(coord.getLon(), coord.getLat()); |
|
|
|
|
|
|
|
|
|
|
|
convertCoordList.add(coordinate); |
|
|
|
coordinates.add(coordinate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return coordinates; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<BasFlightPlanAreaCoordModel> convertModel(List<Coordinate> bufferList) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BasFlightPlanAreaCoordModel> bufferCoordList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(Coordinate buffer : bufferList) { |
|
|
|
|
|
|
|
BasFlightPlanAreaCoordModel bufferCoord = new BasFlightPlanAreaCoordModel(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bufferCoord.setLat(buffer.getY()); |
|
|
|
|
|
|
|
bufferCoord.setLon(buffer.getX()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bufferCoordList.add(bufferCoord); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return convertCoordList; |
|
|
|
return bufferCoordList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|