List of usage examples for org.springframework.data.geo Box Box
public Box(double[] first, double[] second)
From source file:org.springframework.data.geo.GeoModuleIntegrationTests.java
@Test // DATACMNS-475 public void deserializesBox() throws Exception { String json = "{\"first\":{\"x\":1.0,\"y\":2.0},\"second\":{\"x\":2.0,\"y\":3.0}}"; Box reference = new Box(new Point(1, 2), new Point(2, 3)); assertThat(mapper.readValue(json, Box.class)).isEqualTo(reference); assertThat(mapper.writeValueAsString(reference)).isEqualTo(json); }
From source file:com.okode.demos.mmaps.controller.APIController.java
@ApiOperation("Find entities by filter and fields inside a view") @RequestMapping(value = "/findentities", method = RequestMethod.GET) private GeoJSON findEntitiesInsideViewByFilterFields(@RequestParam(defaultValue = "24.25079") float lat1, @RequestParam(defaultValue = "-35.912262") float lng1, @RequestParam(defaultValue = "53.46439") float lat2, @RequestParam(defaultValue = "28.951021") float lng2, @RequestParam(defaultValue = "office") String collection, @RequestParam(defaultValue = "{\"properties.address.region\":\"MADRID\"}") String filter, @RequestParam(defaultValue = "{\"_id\":0,\"type\":1,\"geometry\":1,\"properties.name\":1,\"properties.url\":1,\"properties.pictures\":1}") String fields) { Criteria isInsideView = Criteria.where("geometry.coordinates") .within(new Box(new Point(lng1, lat1), new Point(lng2, lat2))); Query query = new BasicQuery(filter, fields).addCriteria(isInsideView); return new GeoJSON(mongoTemplate.find(query, DBObject.class, collection)); }
From source file:com.afmobi.mongodb.repository.PersonRepositoryIntegrationTests.java
@Test public void findsPeopleByLocationWithinBox() { Point point = new Point(-73.99171, 40.738868); dave.setLocation(point);/*from w w w . j a v a 2 s .c o m*/ repository.save(dave); Box box = new Box(new Point(-78.99171, 35.738868), new Point(-68.99171, 45.738868)); List<Person> result = repository.findByLocationWithin(box); assertThat(result.size(), is(1)); assertThat(result, hasItem(dave)); }
From source file:org.springframework.data.mongodb.core.geo.GeoSpatialTests.java
@Test public void withinBox() { Box box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404)); List<Venue> venues = template.find(query(where("location").within(box)), Venue.class); assertThat(venues.size(), is(4));// www. ja v a 2s . c o m }
From source file:org.springframework.data.solr.core.DefaultQueryParserTests.java
@Test public void testNearWithCoords() { Criteria criteria = new Criteria("field_1") .near(new Box(new Point(48.303056, 14.290556), new Point(48.303056, 14.290556))); Assert.assertEquals("field_1:[48.303056,14.290556 TO 48.303056,14.290556]", queryParser.createQueryStringFromCriteria(criteria)); }