Ejemplo n.º 1
0
 private static Shape fromSpatial4JShape(com.spatial4j.core.shape.Shape shape) {
   if (shape instanceof com.spatial4j.core.shape.Point) {
     com.spatial4j.core.shape.Point point = (com.spatial4j.core.shape.Point) shape;
     return point(point.getX(), point.getY());
   }
   if (shape instanceof com.spatial4j.core.shape.Circle) {
     com.spatial4j.core.shape.Circle circle = (com.spatial4j.core.shape.Circle) shape;
     return circle(
         point(circle.getCenter().getX(), circle.getCenter().getY()), circle.getRadius());
   }
   if (shape instanceof com.spatial4j.core.shape.Rectangle) {
     com.spatial4j.core.shape.Rectangle rectangle = (com.spatial4j.core.shape.Rectangle) shape;
     return rectangle(
         rectangle.getMinX(), rectangle.getMaxX(), rectangle.getMinY(), rectangle.getMaxY());
   }
   if (shape instanceof com.spatial4j.core.shape.impl.BufferedLineString) {
     com.spatial4j.core.shape.impl.BufferedLineString spatialLineString =
         (com.spatial4j.core.shape.impl.BufferedLineString) shape;
     List<com.spatial4j.core.shape.Point> spatialPoints = spatialLineString.getPoints();
     Point[] points = new Point[spatialPoints.size()];
     for (int i = 0; i < points.length; i++)
       points[i] = point(spatialPoints.get(i).getX(), spatialPoints.get(i).getY());
     return lineString(points);
   }
   if (shape instanceof com.spatial4j.core.shape.jts.JtsGeometry)
     return fromJtsGeometry((JtsGeometry) shape);
   throw new IllegalArgumentException("Unsupported shape type: " + shape.getClass().getName());
 }
Ejemplo n.º 2
0
 @Override
 public double area(Circle circle) {
   return circle.getArea(null);
 }