/** * ************************************************************************* The method which * testing, if the line intersect the triangle * * @param newL - Geometry of line * @return boolean true - line intersect triangle false - line doesn't intersect triangle */ public boolean containsLine(LineString newL) { Coordinate[] newPoints = {A, B, C, A}; CoordinateArraySequence newPointsTriangle = new CoordinateArraySequence(newPoints); LinearRing trianglesPoints = new LinearRing(newPointsTriangle, new GeometryFactory()); return newL.crosses(trianglesPoints.convexHull()); }
/** * ************************************************************************* The method which * testing triangle, if the triangles is'nt line * * @return boolean true - the triangle is triangle false - the triangle is line */ protected boolean isTriangle() { Coordinate[] newPoint = new Coordinate[4]; newPoint[0] = A; newPoint[1] = B; newPoint[2] = C; newPoint[3] = A; CoordinateArraySequence newPointsTriangle = new CoordinateArraySequence(newPoint); LinearRing trianglesPoints = new LinearRing(newPointsTriangle, new GeometryFactory()); if (trianglesPoints.convexHull().getGeometryType() == "Polygon") return true; else return false; }
/** * A geometry spanning all longitudes between latitude1 and latitude2. In latlong space this is a * rectangle. On the globe it is the spherical section between two parallel planes (both at right * angles to the axis). */ static Geometry betweenTwoLatitudes(double latitude1, double latitude2) { GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); LinearRing border = geometryFactory.createLinearRing( new Coordinate[] { new Coordinate(MIN_LONGITUDE, latitude1), new Coordinate(MIN_LONGITUDE, latitude2), new Coordinate(MAX_LONGITUDE, latitude2), new Coordinate(MAX_LONGITUDE, latitude1), new Coordinate(MIN_LONGITUDE, latitude1) }); return border.convexHull(); }