/** * All {@link Circle} implementations should use this definition of {@link Object#equals(Object)}. */ public static boolean equals(Circle thiz, Object o) { assert thiz != null; if (thiz == o) return true; if (!(o instanceof Circle)) return false; Circle circle = (Circle) o; if (!thiz.getCenter().equals(circle.getCenter())) return false; if (Double.compare(circle.getRadius(), thiz.getRadius()) != 0) return false; return true; }
/** * All {@link Circle} implementations should use this definition of {@link Object#hashCode()}. */ public static int hashCode(Circle thiz) { int result; long temp; result = thiz.getCenter().hashCode(); temp = thiz.getRadius() != +0.0d ? Double.doubleToLongBits(thiz.getRadius()) : 0L; result = 31 * result + (int) (temp ^ (temp >>> 32)); return result; } }
public SpatialRelation relate(Circle circle) { double crossDist = ctx.getDistCalc().distance(point, circle.getCenter()); double aDist = radiusDEG, bDist = circle.getRadius(); if (crossDist > aDist + bDist) return SpatialRelation.DISJOINT; if (crossDist < aDist && crossDist + bDist <= aDist) return SpatialRelation.CONTAINS; if (crossDist < bDist && crossDist + aDist <= bDist) return SpatialRelation.WITHIN; return SpatialRelation.INTERSECTS; }
public void writeCircle(DataOutput dataOutput, Circle c) throws IOException { writePoint(dataOutput, c.getCenter()); writeDim(dataOutput, c.getRadius()); }
/** Overloaded to provide a number format. */ public static String writeShape(Shape shape, NumberFormat nf) { if (shape instanceof Point) { Point point = (Point) shape; return nf.format(point.getX()) + " " + nf.format(point.getY()); } else if (shape instanceof Rectangle) { Rectangle rect = (Rectangle)shape; return nf.format(rect.getMinX()) + " " + nf.format(rect.getMinY()) + " " + nf.format(rect.getMaxX()) + " " + nf.format(rect.getMaxY()); } else if (shape instanceof Circle) { Circle c = (Circle) shape; return "Circle(" + nf.format(c.getCenter().getX()) + " " + nf.format(c.getCenter().getY()) + " " + "d=" + nf.format(c.getRadius()) + ")"; } return shape.toString(); }
Point center = v.getCenter(); gen.writeStartObject(); gen.writeFieldName("type");
Point center = v.getCenter(); output.append("{\"type\":\"Circle\",\"coordinates\":"); write(output, nf, center.getX(), center.getY());
final Geometry ctrGeom = ctx.getGeometryFrom(circle.getCenter());
org.locationtech.jts.geom.Point point = (org.locationtech.jts.geom.Point) geom; SpatialRelation rel = calcSqd.distance(circle.getCenter(), point.getX(), point.getY()) > radiusSquared ? SpatialRelation.DISJOINT : SpatialRelation.WITHIN; result[0] = rel.combine(result[0]);
Point center = v.getCenter(); double radius = v.getRadius(); enc.write(KEY_CIRCLE);
@Override public Query makeQuery(SpatialArgs args) { if(! SpatialOperation.is( args.getOperation(), SpatialOperation.Intersects, SpatialOperation.IsWithin )) throw new UnsupportedSpatialOperation(args.getOperation()); Shape shape = args.getShape(); if (shape instanceof Rectangle) { Rectangle bbox = (Rectangle) shape; return new ConstantScoreQuery(makeWithin(bbox)); } else if (shape instanceof Circle) { Circle circle = (Circle)shape; Rectangle bbox = circle.getBoundingBox(); return new DistanceRangeQuery(makeWithin(bbox), makeDistanceValueSource(circle.getCenter()), circle.getRadius()); } else { throw new UnsupportedOperationException("Only Rectangles and Circles are currently supported, " + "found [" + shape.getClass() + "]");//TODO } }
if (ctx.isGeo() && newDist > 180) newDist = 180; return ctx.makeCircle(circle.getCenter(), newDist); } else { Rectangle bbox = shape.getBoundingBox();