Examples of Distance


Examples of org.springframework.data.geo.Distance

    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationNear(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS));
    // then
    assertThat(count, is(equalTo(1L)));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

   *
   * @param maxDistance
   * @return
   */
  public NearQuery maxDistance(double maxDistance) {
    return maxDistance(new Distance(maxDistance, getMetric()));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

   * @return
   */
  public NearQuery maxDistance(double maxDistance, Metric metric) {

    Assert.notNull(metric);
    return maxDistance(new Distance(maxDistance, metric));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void shouldWriteEntityWithGeoCircleCorrectly() {

    ClassWithGeoCircle object = new ClassWithGeoCircle();
    Circle circle = new Circle(new Point(1, 2), 3);
    Distance radius = circle.getRadius();
    object.circle = circle;

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("circle"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("circle"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", circle.getCenter().getX()).append("y", circle
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void shouldWriteEntityWithGeoSphereCorrectly() {

    ClassWithGeoSphere object = new ClassWithGeoSphere();
    Sphere sphere = new Sphere(new Point(1, 2), 3);
    Distance radius = sphere.getRadius();
    object.sphere = sphere;

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("sphere"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("sphere"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", sphere.getCenter().getX()).append("y", sphere
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

   */
  @Test
  public void shouldWriteEntityWithGeoSphereWithMetricDistanceCorrectly() {

    ClassWithGeoSphere object = new ClassWithGeoSphere();
    Sphere sphere = new Sphere(new Point(1, 2), new Distance(3, Metrics.KILOMETERS));
    Distance radius = sphere.getRadius();
    object.sphere = sphere;

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("sphere"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("sphere"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", sphere.getCenter().getX()).append("y", sphere
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void shouldWriteEntityWithGeoShapeCorrectly() {

    ClassWithGeoShape object = new ClassWithGeoShape();
    Sphere sphere = new Sphere(new Point(1, 2), 3);
    Distance radius = sphere.getRadius();
    object.shape = sphere;

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("shape"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("shape"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", sphere.getCenter().getX()).append("y", sphere
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

   *
   * @param center
   * @param radius
   */
  public Sphere(Point center, double radius) {
    this(center, new Distance(radius));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

      double distance = ((Double) object.get("dis")).doubleValue();
      DBObject content = (DBObject) object.get("obj");

      T doWith = delegate.doWith(content);

      return new GeoResult<T>(doWith, new Distance(distance, metric));
    }
View Full Code Here

Examples of org.springframework.data.geo.Distance

      return new GeoResults<T>(result, near.getMetric());
    }

    DBObject stats = (DBObject) commandResult.get("stats");
    double averageDistance = stats == null ? 0 : (Double) stats.get("avgDistance");
    return new GeoResults<T>(result, new Distance(averageDistance, near.getMetric()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.