Example usage for org.springframework.data.mongodb.core.query NearQuery near

List of usage examples for org.springframework.data.mongodb.core.query NearQuery near

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query NearQuery near.

Prototype

public static NearQuery near(double x, double y, Metric metric) 

Source Link

Document

Creates a new NearQuery starting at the given coordinates using the given Metric to adapt given values to further configuration.

Usage

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));
}