use of org.springframework.data.geo.Point in project spring-data-mongodb by spring-projects.
the class MongoOperationsUnitTests method geoNearRejectsNullEntityClassIfCollectionGiven.
// DATAMONGO-341
@Test
public void geoNearRejectsNullEntityClassIfCollectionGiven() {
final NearQuery query = NearQuery.near(new Point(10, 20));
new Execution() {
@Override
public void doWith(MongoOperations operations) {
operations.geoNear(query, null, "collection");
}
}.assertDataAccessException();
}
use of org.springframework.data.geo.Point in project spring-data-mongodb by spring-projects.
the class MongoOperationsUnitTests method geoNearRejectsNullEntityClass.
// DATAMONGO-341
@Test
public void geoNearRejectsNullEntityClass() {
final NearQuery query = NearQuery.near(new Point(10, 20));
new Execution() {
@Override
public void doWith(MongoOperations operations) {
operations.geoNear(query, null);
}
}.assertDataAccessException();
}
use of org.springframework.data.geo.Point in project spring-data-mongodb by spring-projects.
the class AbstractPersonRepositoryIntegrationTests method executesGeoPageQueryForWithPageRequestForPageInBetween.
// DATAMONGO-445
@Test
public void executesGeoPageQueryForWithPageRequestForPageInBetween() {
Point farAway = new Point(-73.9, 40.7);
Point here = new Point(-73.99, 40.73);
dave.setLocation(farAway);
oliver.setLocation(here);
carter.setLocation(here);
boyd.setLocation(here);
leroi.setLocation(here);
repository.saveAll(Arrays.asList(dave, oliver, carter, boyd, leroi));
GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000, Metrics.KILOMETERS), PageRequest.of(1, 2));
assertThat(results.getContent().isEmpty(), is(false));
assertThat(results.getNumberOfElements(), is(2));
assertThat(results.isFirst(), is(false));
assertThat(results.isLast(), is(false));
assertThat(results.getAverageDistance().getMetric(), is((Metric) Metrics.KILOMETERS));
assertThat(results.getAverageDistance().getNormalizedValue(), is(0.0));
}
use of org.springframework.data.geo.Point in project spring-data-mongodb by spring-projects.
the class AbstractPersonRepositoryIntegrationTests method executesGeoNearQueryForResultsCorrectlyWhenGivenMinAndMaxDistance.
// DATAMONGO-1110
@Test
public void executesGeoNearQueryForResultsCorrectlyWhenGivenMinAndMaxDistance() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave);
Range<Distance> range = Distance.between(new Distance(0.01, KILOMETERS), new Distance(2000, KILOMETERS));
GeoResults<Person> results = repository.findPersonByLocationNear(new Point(-73.99, 40.73), range);
assertThat(results.getContent().isEmpty(), is(false));
}
use of org.springframework.data.geo.Point in project spring-data-mongodb by spring-projects.
the class AbstractPersonRepositoryIntegrationTests method findsPeopleByLocationWithinCircle.
@Test
public void findsPeopleByLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave);
List<Person> result = repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170));
assertThat(result.size(), is(1));
assertThat(result, hasItem(dave));
}
Aggregations