use of org.neo4j.ogm.cypher.function.DistanceComparison in project neo4j-ogm by neo4j.
the class RestaurantIntegrationTest method shouldQueryByDistanceUsingFilter.
@Test
public void shouldQueryByDistanceUsingFilter() {
Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Location(37.61649, -122.38681), 94128);
session.save(restaurant);
session.clear();
Filter filter = new Filter(new DistanceComparison(new DistanceFromPoint(37.61649, -122.38681, 1000 * 1000.0)), ComparisonOperator.LESS_THAN);
Collection<Restaurant> found = session.loadAll(Restaurant.class, filter);
assertThat(found).isNotNull();
assertThat(found.size() >= 1).isTrue();
}
use of org.neo4j.ogm.cypher.function.DistanceComparison in project neo4j-ogm by neo4j.
the class NodeQueryStatementsTest method testFindByDistance.
@Test
public void testFindByDistance() {
DistanceComparison function = new DistanceComparison(new DistanceFromPoint(37.4d, 112.9d, 1000.0d));
Filters filters = new Filters().add(new Filter(function, ComparisonOperator.EQUALS));
String statement = queryStatements.findByType("Restaurant", filters, 4).getStatement();
assertThat(statement).isEqualTo("MATCH (n:`Restaurant`) WHERE distance(point({latitude: n.latitude, longitude: n.longitude}),point({latitude: $lat, longitude: $lon})) = $distance WITH n MATCH p=(n)-[*0..4]-(m) RETURN p, ID(n)");
}
use of org.neo4j.ogm.cypher.function.DistanceComparison in project neo4j-ogm by neo4j.
the class FilterTest method toCypher_function.
@Test
public void toCypher_function() {
DistanceComparison function = new DistanceComparison(new DistanceFromPoint(37.4, 112.1, 1000.0));
Filter filter = new Filter(function, ComparisonOperator.LESS_THAN);
filter.setBooleanOperator(BooleanOperator.AND);
filter.setNegated(true);
assertThat(filter.toCypher("n", true)).isEqualTo("WHERE NOT(distance(point({latitude: n.latitude, longitude: n.longitude}),point({latitude: $lat, longitude: $lon})) < $distance ) ");
Map<String, Object> parameters = filter.parameters();
assertThat(parameters).containsEntry("lat", 37.4);
assertThat(parameters).containsEntry("lon", 112.1);
assertThat(parameters).containsEntry("distance", 1000.0);
}
Aggregations