Package org.springframework.data.geo

Examples of org.springframework.data.geo.Point


   */
  @Test
  public void convertsCircleToDbObjectAndBackCorrectlyMilesDistance() {

    Distance radius = new Distance(3, Metrics.MILES);
    Circle circle = new Circle(new Point(1, 2), radius);

    DBObject dbo = CircleToDbObjectConverter.INSTANCE.convert(circle);
    Circle result = DbObjectToCircleConverter.INSTANCE.convert(dbo);

    assertThat(result, is(circle));
View Full Code Here


   * @see DATAMONGO-858
   */
  @Test
  public void convertsPolygonToDbObjectAndBackCorrectly() {

    Polygon polygon = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(5, 6));

    DBObject dbo = PolygonToDbObjectConverter.INSTANCE.convert(polygon);
    Polygon result = DbObjectToPolygonConverter.INSTANCE.convert(dbo);

    assertThat(result, is(polygon));
View Full Code Here

   * @see DATAMONGO-858
   */
  @Test
  public void convertsSphereToDbObjectAndBackCorrectlyWithNeutralDistance() {

    Sphere sphere = new Sphere(new Point(1, 2), 3);

    DBObject dbo = SphereToDbObjectConverter.INSTANCE.convert(sphere);
    Sphere result = DbObjectToSphereConverter.INSTANCE.convert(dbo);

    assertThat(result, is(sphere));
View Full Code Here

   */
  @Test
  public void convertsSphereToDbObjectAndBackCorrectlyWithKilometerDistance() {

    Distance radius = new Distance(3, Metrics.KILOMETERS);
    Sphere sphere = new Sphere(new Point(1, 2), radius);

    DBObject dbo = SphereToDbObjectConverter.INSTANCE.convert(sphere);
    Sphere result = DbObjectToSphereConverter.INSTANCE.convert(dbo);

    assertThat(result, is(sphere));
View Full Code Here

   * @see DATAMONGO-858
   */
  @Test
  public void convertsPointToListAndBackCorrectly() {

    Point point = new Point(1, 2);

    DBObject dbo = PointToDbObjectConverter.INSTANCE.convert(point);
    Point result = DbObjectToPointConverter.INSTANCE.convert(dbo);

    assertThat(result, is(point));
    assertThat(result.getClass().equals(Point.class), is(true));
  }
View Full Code Here

    assertThat(result, not(hasItems(carter, boyd, stefan, leroi, alicia)));
  }

  @Test
  public void findsPeopleByLocationNear() {
    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    repository.save(dave);

    List<Person> result = repository.findByLocationNear(point);
    assertThat(result.size(), is(1));
View Full Code Here

    assertThat(result, hasItem(dave));
  }

  @Test
  public void findsPeopleByLocationWithinCircle() {
    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    repository.save(dave);

    List<Person> result = repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170));
    assertThat(result.size(), is(1));
View Full Code Here

    assertThat(result, hasItem(dave));
  }

  @Test
  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 findsPeopleByLocationWithinPolygon() {

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

  }

  @Test
  public void executesGeoNearQueryForResultsCorrectly() {

    Point point = new Point(-73.99171, 40.738868);
    dave.setLocation(point);
    repository.save(dave);

    GeoResults<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS));
    assertThat(results.getContent().isEmpty(), is(false));
  }
View Full Code Here

TOP

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

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.