Example usage for org.springframework.data.geo Circle Circle

List of usage examples for org.springframework.data.geo Circle Circle

Introduction

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

Prototype

public Circle(Point center, double radius) 

Source Link

Document

Creates a new Circle from the given Point and radius.

Usage

From source file:org.springframework.data.geo.GeoModuleIntegrationTests.java

@Test // DATACMNS-475
public void deserializesCircle() throws Exception {

    String json = "{\"center\":{\"x\":10.0,\"y\":20.0},\"radius\":{\"value\":10.0,\"metric\":\"KILOMETERS\"}}";
    Circle reference = new Circle(new Point(10.0, 20.0), new Distance(10, Metrics.KILOMETERS));

    assertThat(mapper.readValue(json, Circle.class)).isEqualTo(reference);
    assertThat(mapper.writeValueAsString(reference)).isEqualTo(json);
}

From source file:example.springdata.redis.commands.GeoOperationsTests.java

/**
 * Lookup points within a circle around coordinates.
 *//*www  . ja  v  a 2s  .  co m*/
@Test
public void geoRadius() {

    Circle circle = new Circle(new Point(13.583333, 37.316667), //
            new Distance(100, DistanceUnit.KILOMETERS));
    GeoResults<GeoLocation<String>> result = geoOperations.geoRadius("Sicily", circle);

    assertThat(result).hasSize(2).extracting("content.name").contains("Arigento", "Palermo");
}

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

/**
 * @see DATASOLR-142//  w ww.  ja  v  a2  s.com
 */
@Test
public void testWithinCircleWorksCorrectly() {
    Criteria criteria = new Criteria("field_1")
            .within(new Circle(new Point(48.303056, 14.290556), new Distance(1, Metrics.KILOMETERS)));
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=1.0}",
            queryParser.createQueryStringFromCriteria(criteria));
}