List of usage examples for org.springframework.data.geo Distance Distance
public Distance(double value)
From source file:com.couchbase.trombi.controllers.SearchController.java
@RequestMapping(value = "/near/{x}/{y}/{distance}", method = RequestMethod.GET) public Iterable<Coworker> findNearPoint(@PathVariable double x, @PathVariable double y, @PathVariable int distance) { Point center = new Point(x, y); Distance radius = new Distance(distance); return coworkerRepository.findAllByMainLocationCoordinatesNear(center, radius); }
From source file:com.frank.search.solr.core.query.Criteria.java
/** * Creates new {@link Criteria.Predicate} for {@code !geodist} * * @param location//from www .j a v a 2s .c o m * {@link org.springframework.data.geo.Point} in degrees * @param distance * @return */ public Criteria within(Point location, Distance distance) { Assert.notNull(location); assertPositiveDistanceValue(distance); predicates.add(new Predicate(OperationKey.WITHIN, new Object[] { location, distance != null ? distance : new Distance(0) })); return this; }
From source file:com.frank.search.solr.core.query.Criteria.java
/** * Creates new {@link Criteria.Predicate} for {@code !bbox} for a specified * distance. The difference between this and {@code within} is this is * approximate while {@code within} is exact. * * @param location//from w w w . ja v a 2 s. co m * @param distance * @return * @throws IllegalArgumentException * if location is null * @throws org.springframework.dao.InvalidDataAccessApiUsageException * if distance is negative */ public Criteria near(Point location, Distance distance) { Assert.notNull(location, "Location must not be 'null' for near criteria."); assertPositiveDistanceValue(distance); predicates.add(new Predicate(OperationKey.NEAR, new Object[] { location, distance != null ? distance : new Distance(0) })); return this; }
From source file:org.springframework.data.solr.core.DefaultQueryParserTests.java
@Test public void testNear() { Criteria criteria = new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(5)); Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=field_1 d=5.0}", queryParser.createQueryStringFromCriteria(criteria)); }
From source file:org.springframework.data.solr.core.query.CriteriaTests.java
@Test public void testNear() { Point location = new Point(48.303056, 14.290556); Criteria criteria = new Criteria("field_1").near(location, new Distance(5)); Predicate entry = getPredicateByPosition(criteria.getPredicates(), 0); Assert.assertEquals(OperationKey.NEAR.getKey(), entry.getKey()); Assert.assertEquals(location, ((Object[]) entry.getValue())[0]); Assert.assertEquals(5, ((Distance) ((Object[]) entry.getValue())[1]).getValue(), 0); }
From source file:org.springframework.data.solr.core.query.CriteriaTests.java
@Test(expected = IllegalArgumentException.class) public void testNearWithNullLocation() { new Criteria("field_1").near(null, new Distance(5)); }
From source file:org.springframework.data.solr.core.query.CriteriaTests.java
@Test(expected = InvalidDataAccessApiUsageException.class) public void testNearWithNegativeDistance() { new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(-1)); }
From source file:org.springframework.data.solr.core.query.CriteriaTests.java
@Test public void testWithin() { Point location = new Point(48.303056, 14.290556); Criteria criteria = new Criteria("field_1").within(location, new Distance(5)); Predicate entry = getPredicateByPosition(criteria.getPredicates(), 0); Assert.assertEquals(OperationKey.WITHIN.getKey(), entry.getKey()); Assert.assertEquals(location, ((Object[]) entry.getValue())[0]); Assert.assertEquals(5, ((Distance) ((Object[]) entry.getValue())[1]).getValue(), 0); }
From source file:org.springframework.data.solr.core.query.CriteriaTests.java
@Test(expected = IllegalArgumentException.class) public void testWithinWithNullLocation() { new Criteria("field_1").within(null, new Distance(5)); }