Example usage for org.springframework.data.geo GeoResults getAverageDistance

List of usage examples for org.springframework.data.geo GeoResults getAverageDistance

Introduction

In this page you can find the example usage for org.springframework.data.geo GeoResults getAverageDistance.

Prototype

public Distance getAverageDistance() 

Source Link

Document

Returns the average distance of all GeoResult s in this list.

Usage

From source file:com.idrene.emefana.repositories.RepositoriesTest.java

@Test
public void closestestPointsToMwengeTest() {
    Point mwenge = new Point(39.229809, -6.769280);
    GeoResults<Provider> geoResults = providerRepository.findByLocationNearAndNameIgnoreCase(mwenge,
            new Distance(10, Metrics.KILOMETERS), "Kariakoo");

    assertNotNull(geoResults);/*from w w w  . jav a  2 s.co m*/
    geoResults.forEach(gp -> System.out.println(gp.getContent().getName() + " - " + gp.getDistance()));
    assertTrue(geoResults.getAverageDistance().getValue() > 0);
}

From source file:org.springframework.data.mongodb.core.geo.GeoSpatialTests.java

@Test
public void geoNear() {

    NearQuery geoNear = NearQuery.near(-73, 40, Metrics.KILOMETERS).num(10).maxDistance(150);

    GeoResults<Venue> result = template.geoNear(geoNear, Venue.class);

    assertThat(result.getContent().size(), is(not(0)));
    assertThat(result.getAverageDistance().getMetric(), is((Metric) Metrics.KILOMETERS));
}