List of usage examples for org.springframework.data.geo Polygon Polygon
public Polygon(Point x, Point y, Point z, Point... others)
From source file:com.afmobi.mongodb.repository.PersonRepositoryIntegrationTests.java
@Test public void findsPeopleByLocationWithinPolygon() { Point point = new Point(-73.99171, 40.738868); dave.setLocation(point);/*w ww. ja va 2 s. c om*/ repository.save(dave); Point first = new Point(-78.99171, 35.738868); Point second = new Point(-78.99171, 45.738868); Point third = new Point(-68.99171, 45.738868); Point fourth = new Point(-68.99171, 35.738868); List<Person> result = repository.findByLocationWithin(new Polygon(first, second, third, fourth)); assertThat(result.size(), is(1)); assertThat(result, hasItem(dave)); }
From source file:org.springframework.data.mongodb.core.geo.GeoSpatialTests.java
@Test public void withinPolygon() { Point first = new Point(-73.99756, 40.73083); Point second = new Point(-73.99756, 40.741404); Point third = new Point(-73.988135, 40.741404); Point fourth = new Point(-73.988135, 40.73083); Polygon polygon = new Polygon(first, second, third, fourth); List<Venue> venues = template.find(query(where("location").within(polygon)), Venue.class); assertThat(venues.size(), is(4));/* w w w . j a v a 2 s .c o m*/ }