Package org.springframework.data.geo

Examples of org.springframework.data.geo.Box


  public void findsPeopleByLocationWithinBox() {
    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    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));
  }
View Full Code Here


  }

  @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));
  }
View Full Code Here

    }

    @Test
    public void testToPolygon() throws Exception {
        assertEquals(new Polygon(POINT_1,POINT_6,POINT_2, POINT_5),GeoConverter.toPolygon(new Box(POINT_1, POINT_2)));
    }
View Full Code Here

  @Test
  public void testCreateQueryWithNearUsingBox() throws NoSuchMethodException, SecurityException {
    Method method = SampleRepository.class.getMethod("findByLocationNear", Box.class);

    Query query = createQueryForMethodWithArgs(method, new Object[] { new Box(new Point(48.303056, 14.290556),
        new Point(48.306377, 14.283128)) });
    Assert.assertEquals("store:[48.303056,14.290556 TO 48.306377,14.283128]", queryParser.getQueryString(query));
  }
View Full Code Here

    ProductBean locatedInNYC = createProductBean("200", 5, true);
    locatedInNYC.setLocation("40.7143,-74.006");

    repo.save(Arrays.asList(locatedInBuffalow, locatedInNYC));

    List<ProductBean> found = repo.findByLocationNear(new Box(new Point(45, -94), new Point(46, -93)));
    Assert.assertEquals(1, found.size());
    Assert.assertEquals(locatedInBuffalow.getId(), found.get(0).getId());
  }
View Full Code Here

        queryParser.createQueryStringFromCriteria(criteria));
  }

  @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));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.geo.Box

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.