use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class GeoConvertersUnitTests method convertsCircleToDocumentAndBackCorrectlyMilesDistance.
// DATAMONGO-858
@Test
public void convertsCircleToDocumentAndBackCorrectlyMilesDistance() {
Distance radius = new Distance(3, Metrics.MILES);
Circle circle = new Circle(new Point(1, 2), radius);
Document document = CircleToDocumentConverter.INSTANCE.convert(circle);
Circle result = DocumentToCircleConverter.INSTANCE.convert(document);
assertThat(result).isEqualTo(circle);
assertThat(result.getRadius()).isEqualTo(radius);
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class GeoConvertersUnitTests method convertsCircleCorrectlyWhenUsingNonDoubleForCoordinates.
// DATAMONGO-1607
@Test
public void convertsCircleCorrectlyWhenUsingNonDoubleForCoordinates() {
Document circle = new Document();
circle.put("center", new Document().append("x", 1).append("y", 2));
circle.put("radius", 3L);
assertThat(DocumentToCircleConverter.INSTANCE.convert(circle)).isEqualTo(new Circle(new Point(1, 2), new Distance(3)));
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class MongoConvertersUnitTests method convertsCircleToDocumentAndBackCorrectly.
// DATAMONGO-858
@Test
void convertsCircleToDocumentAndBackCorrectly() {
Circle circle = new Circle(new Point(1, 2), 3);
Document document = GeoConverters.CircleToDocumentConverter.INSTANCE.convert(circle);
Shape shape = GeoConverters.DocumentToCircleConverter.INSTANCE.convert(document);
assertThat(shape).isEqualTo(circle);
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class AbstractGeoSpatialTests method withinCenter.
@Test
public void withinCenter() {
Circle circle = new Circle(-73.99171, 40.738868, 0.01);
Query query = query(where("location").within(circle));
List<Venue> venues = template.find(query, Venue.class);
assertThat(venues).hasSize(7);
assertThat(template.count(query, Venue.class)).isEqualTo(7);
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class AbstractGeoSpatialTests method withinCenterSphere.
@Test
public void withinCenterSphere() {
Circle circle = new Circle(-73.99171, 40.738868, 0.003712240453784);
Query query = query(where("location").withinSphere(circle));
List<Venue> venues = template.find(query, Venue.class);
assertThat(venues).hasSize(11);
assertThat(template.count(query, Venue.class)).isEqualTo(11);
}
Aggregations