Example usage for org.springframework.data.geo Metrics MILES

List of usage examples for org.springframework.data.geo Metrics MILES

Introduction

In this page you can find the example usage for org.springframework.data.geo Metrics MILES.

Prototype

Metrics MILES

To view the source code for org.springframework.data.geo Metrics MILES.

Click Source Link

Usage

From source file:example.ComposedAnnotationIntegrationTest.java

/**
 * Issue a {@code geoNear} query using a 2d legacy index specified by the built-in {@link GeospatialIndex} annotation.
 *///from  ww  w.j  a v  a2  s  . c  om
@Test
public void findsVenuesWithRegularAnnotations() {

    GeoResults<Venue> geoResults = operations
            .geoNear(NearQuery.near(jessesHouse.getPoint()).maxDistance(10, Metrics.MILES), Venue.class);

    assertThat(geoResults.getContent(), hasSize(2));

    GeoResult<Venue> geoResult = geoResults.getContent().get(1);

    assertThat(geoResult.getContent(), is(equalTo(theWhiteResidence)));
    assertThat(geoResult.getDistance().getValue(), is(closeTo(7.7, 0.1)));
}

From source file:example.ComposedAnnotationIntegrationTest.java

/**
 * Issue a {@code geoNear} query using a 2d legacy index specified by a custom, composed {@link MyGeoIndexAnnotation}
 * annotation./* www.j av a2s  .  c o m*/
 */
@Test
public void findsVenuesWithComposedAnnotations() {

    GeoResults<ImprovedVenue> geoResults = operations.geoNear(
            NearQuery.near(theWhiteResidence.getPoint()).maxDistance(2, Metrics.MILES), ImprovedVenue.class);

    assertThat(geoResults.getContent(), hasSize(2));

    GeoResult<ImprovedVenue> geoResult = geoResults.getContent().get(1);

    assertThat(geoResult.getContent(), is(equalTo(carWash)));
    assertThat(geoResult.getDistance().getValue(), is(closeTo(1.2, 0.1)));
}

From source file:org.springframework.data.solr.core.DefaultQueryParserTests.java

@Test
public void testNearWithDistanceUnitMiles() {
    Criteria criteria = new Criteria("field_1").near(new Point(48.303056, 14.290556),
            new Distance(1, Metrics.MILES));
    Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=field_1 d=1.609344}",
            queryParser.createQueryStringFromCriteria(criteria));
}

From source file:org.springframework.data.solr.core.DefaultQueryParserTests.java

@Test
public void testWithinWithDistanceUnitMiles() {
    Criteria criteria = new Criteria("field_1").within(new Point(48.303056, 14.290556),
            new Distance(1, Metrics.MILES));
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=1.609344}",
            queryParser.createQueryStringFromCriteria(criteria));
}