Examples of Distance


Examples of org.springframework.data.geo.Distance

   * @see DATAMONGO-858
   */
  @Test
  public void convertsCircleToDbObjectAndBackCorrectlyMilesDistance() {

    Distance radius = new Distance(3, Metrics.MILES);
    Circle circle = new Circle(new Point(1, 2), radius);

    DBObject dbo = CircleToDbObjectConverter.INSTANCE.convert(circle);
    Circle result = DbObjectToCircleConverter.INSTANCE.convert(dbo);

View Full Code Here

Examples of org.springframework.data.geo.Distance

   * @see DATAMONGO-858
   */
  @Test
  public void convertsSphereToDbObjectAndBackCorrectlyWithKilometerDistance() {

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

    DBObject dbo = SphereToDbObjectConverter.INSTANCE.convert(sphere);
    Sphere result = DbObjectToSphereConverter.INSTANCE.convert(dbo);

View Full Code Here

Examples of org.springframework.data.geo.Distance

    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    repository.save(dave);

    GeoResults<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS));
    assertThat(results.getContent().isEmpty(), is(false));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    repository.save(dave);

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(0, 20));
    assertThat(results.getContent().isEmpty(), is(false));

    // DATAMONGO-607
    assertThat(results.getAverageDistance().getMetric(), is((Metric) Metrics.KILOMETERS));
View Full Code Here

Examples of org.springframework.data.geo.Distance

    boyd.setLocation(here);
    leroi.setLocation(here);

    repository.save(Arrays.asList(dave, oliver, carter, boyd, leroi));

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(1, 2));

    assertThat(results.getContent().isEmpty(), is(false));
    assertThat(results.getNumberOfElements(), is(2));
    assertThat(results.isFirst(), is(false));
View Full Code Here

Examples of org.springframework.data.geo.Distance

    oliver.setLocation(point);
    carter.setLocation(point);

    repository.save(Arrays.asList(dave, oliver, carter));

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(1, 2));
    assertThat(results.getContent().isEmpty(), is(false));
    assertThat(results.getNumberOfElements(), is(1));
    assertThat(results.isFirst(), is(false));
    assertThat(results.isLast(), is(true));
View Full Code Here

Examples of org.springframework.data.geo.Distance

    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    repository.save(dave);

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(0, 2));

    assertThat(results.getContent().isEmpty(), is(false));
    assertThat(results.getNumberOfElements(), is(1));
    assertThat(results.isFirst(), is(true));
View Full Code Here

Examples of org.springframework.data.geo.Distance

  public void executesGeoPageQueryForWithPageRequestForJustOneElementEmptyPage() {

    dave.setLocation(new Point(-73.99171, 40.738868));
    repository.save(dave);

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(1, 2));

    assertThat(results.getContent().isEmpty(), is(true));
    assertThat(results.getNumberOfElements(), is(0));
    assertThat(results.isFirst(), is(false));
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void bindsMetricDistanceParameterToNearSphereCorrectly() throws Exception {

    Point point = new Point(10, 20);
    Distance distance = new Distance(2.5, Metrics.KILOMETERS);

    Query query = query(where("location").nearSphere(point).maxDistance(distance.getNormalizedValue()).and("firstname")
        .is("Dave"));
    assertBindsDistanceToQuery(point, distance, query);
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void bindsDistanceParameterToNearCorrectly() throws Exception {

    Point point = new Point(10, 20);
    Distance distance = new Distance(2.5);

    Query query = query(where("location").near(point).maxDistance(distance.getNormalizedValue()).and("firstname")
        .is("Dave"));
    assertBindsDistanceToQuery(point, distance, query);
  }
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.