@Override public Document convert(Sphere source) { if (source == null) { return null; } Document result = new Document(); result.put("center", PointToDocumentConverter.INSTANCE.convert(source.getCenter())); result.put("radius", source.getRadius().getNormalizedValue()); result.put("metric", source.getRadius().getMetric().toString()); return result; } }
@Override public Document convert(Circle source) { if (source == null) { return null; } Document result = new Document(); result.put("center", PointToDocumentConverter.INSTANCE.convert(source.getCenter())); result.put("radius", source.getRadius().getNormalizedValue()); result.put("metric", source.getRadius().getMetric().toString()); return result; } }
argument.add(((Circle) shape).getRadius().getNormalizedValue()); argument.add(((Sphere) shape).getRadius().getNormalizedValue());
document.put("maxDistance", maxDistance.getNormalizedValue()); document.put("minDistance", minDistance.getNormalizedValue());
criteria.maxDistance(it.getNormalizedValue()); minDistance.ifPresent(min -> criteria.minDistance(min.getNormalizedValue()));
@Override public Document convert(Sphere source) { if (source == null) { return null; } Document result = new Document(); result.put("center", PointToDocumentConverter.INSTANCE.convert(source.getCenter())); result.put("radius", source.getRadius().getNormalizedValue()); result.put("metric", source.getRadius().getMetric().toString()); return result; } }
@Override public Document convert(Circle source) { if (source == null) { return null; } Document result = new Document(); result.put("center", PointToDocumentConverter.INSTANCE.convert(source.getCenter())); result.put("radius", source.getRadius().getNormalizedValue()); result.put("metric", source.getRadius().getMetric().toString()); return result; } }
argument.add(((Circle) shape).getRadius().getNormalizedValue()); argument.add(((Sphere) shape).getRadius().getNormalizedValue());
document.put("maxDistance", maxDistance.getNormalizedValue()); document.put("minDistance", minDistance.getNormalizedValue());
criteria.maxDistance(it.getNormalizedValue()); minDistance.ifPresent(min -> criteria.minDistance(min.getNormalizedValue()));
@Override public int compareTo(@Nullable Distance that) { if (that == null) { return 1; } double difference = this.getNormalizedValue() - that.getNormalizedValue(); return difference == 0 ? 0 : difference > 0 ? 1 : -1; }
/** * Adds the given distance to the current one. The resulting {@link Distance} will be in the same metric as the * current one. * * @param other must not be {@literal null}. * @return */ public Distance add(Distance other) { Assert.notNull(other, "Distance to add must not be null!"); double newNormalizedValue = getNormalizedValue() + other.getNormalizedValue(); return new Distance(newNormalizedValue * metric.getMultiplier(), metric); }
private double convertDistanceToMeters(final Distance distance) { return distance.getNormalizedValue() * Metrics.KILOMETERS.getMultiplier() * 1000; }
private double convertDistanceToMeters(final Distance distance) { return distance.getNormalizedValue() * Metrics.KILOMETERS.getMultiplier() * 1000; }
/** * Adds the given {@link Distance} to the current one and forces the result to be in a given {@link Metric}. * * @param other must not be {@literal null}. * @param metric must not be {@literal null}. * @return */ public Distance add(Distance other, Metric metric) { Assert.notNull(other, "Distance to must not be null!"); Assert.notNull(metric, "Result metric must not be null!"); double newLeft = getNormalizedValue() * metric.getMultiplier(); double newRight = other.getNormalizedValue() * metric.getMultiplier(); return new Distance(newLeft + newRight, metric); }
/** * Returns a new {@link Distance} in the given {@link Metric}. This means that the returned instance will have the * same normalized value as the original instance. * * @param metric must not be {@literal null}. * @return */ public Distance in(Metric metric) { Assert.notNull(metric, "Metric must not be null!"); return this.metric.equals(metric) ? this : new Distance(getNormalizedValue() * metric.getMultiplier(), metric); }
@Override public boolean pointInCircle(Point p, Point center, Distance radiusDistance) { double radius = radiusDistance.getNormalizedValue(); return pointNear(p, new Point2D.Double(center.getX(), center.getY()), radius); }
@Override public boolean pointInCircle(Point p, Point center, Distance radiusDistance) { double radius = radiusDistance.getNormalizedValue(); return pointNear(p, new Point2D.Double(center.getX(), center.getY()), radius); }
@Override public boolean pointInCircle(Point p, Circle c) { Point2D center = new Point2D.Double(c.getCenter().getX(), c.getCenter().getY()); return pointNear(p, center, c.getRadius().getNormalizedValue()); }
@Override public boolean pointInCircle(Point p, Circle c) { Point2D center = new Point2D.Double(c.getCenter().getX(), c.getCenter().getY()); return pointNear(p, center, c.getRadius().getNormalizedValue()); }