Beispiel #1
0
 @Override
 public boolean intersects(Rectangle r) {
   GeometryFactory gf = new GeometryFactory();
   GeometricShapeFactory f = new GeometricShapeFactory(gf);
   f.setBase(new Coordinate(r.x1(), r.y1()));
   f.setWidth(r.x2() - r.x1());
   f.setHeight(r.y2() - r.y1());
   Polygon rect = f.createRectangle();
   LineSegment line = new LineSegment(x1, y1, x2, y2);
   return RectangleIntersects.intersects(rect, line.toGeometry(gf));
 }
Beispiel #2
0
 /**
  * Make an ellipse centered at the given point with the given width and height.
  *
  * @param p Point
  * @param width Width
  * @param height Height
  * @return An ellipse centered at the given point with the given width and height
  * @throws SQLException if the width or height is non-positive
  */
 public static Polygon makeEllipse(Point p, double width, double height) throws SQLException {
   if (p == null) {
     return null;
   }
   if (height < 0 || width < 0) {
     throw new SQLException("Both width and height must be positive.");
   } else {
     GSF.setCentre(new Coordinate(p.getX(), p.getY()));
     GSF.setWidth(width);
     GSF.setHeight(height);
     return GSF.createEllipse();
   }
 }