diff --git a/src/main/java/com/palnet/comn/utils/FlightUtils.java b/src/main/java/com/palnet/comn/utils/FlightUtils.java index 4c7cd13..bbde995 100644 --- a/src/main/java/com/palnet/comn/utils/FlightUtils.java +++ b/src/main/java/com/palnet/comn/utils/FlightUtils.java @@ -6,6 +6,7 @@ import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LineString; import org.locationtech.jts.geom.Point; +import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.geom.impl.CoordinateArraySequence; import org.locationtech.jts.operation.buffer.BufferOp; import org.locationtech.jts.operation.buffer.BufferParameters; @@ -33,6 +34,7 @@ public class FlightUtils { return bufferCoords; } + public static boolean contains(Coordinate[] bufferCoords, Coordinate[] containsPoint) { GeometryFactory geometryFactory = new GeometryFactory(); @@ -47,4 +49,21 @@ public class FlightUtils { return contains; } + + public static boolean overlaps(Coordinate[] bufferCoords, Coordinate[] overlapCoords) { + + GeometryFactory geometryFactory = new GeometryFactory(); + + Polygon bufferPoly = geometryFactory.createPolygon(bufferCoords); + + Polygon overPoly = geometryFactory.createPolygon(overlapCoords); + + Geometry geoBuffer = geometryFactory.createGeometry(bufferPoly); + + Geometry geoOver = geometryFactory.createGeometry(overPoly); + + boolean overlaps = geoBuffer.overlaps(geoOver); + + return overlaps; + } }