Package org.springframework.data.geo

Examples of org.springframework.data.geo.Point


  }

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

    assertThat(venues.size(), is(4));
  }

  @Test
  public void nearPoint() {
    Point point = new Point(-73.99171, 40.738868);
    List<Venue> venues = template.find(query(where("location").near(point).maxDistance(0.01)), Venue.class);
    assertThat(venues.size(), is(7));
  }
View Full Code Here

    assertThat(venues.size(), is(7));
  }

  @Test
  public void nearSphere() {
    Point point = new Point(-73.99171, 40.738868);
    Query query = query(where("location").nearSphere(point).maxDistance(0.003712240453784));
    List<Venue> venues = template.find(query, Venue.class);
    assertThat(venues.size(), is(11));
  }
View Full Code Here

    public String id;
    public String name;
    @GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_HAYSTACK, additionalField = "name") public Point location;

    public GeoSpatialEntityHaystack(double x, double y, String name) {
      this.location = new Point(x, y);
      this.name = name;
    }
View Full Code Here

    public String id;
    @GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2D, useGeneratedName = true) public Point location;

    public GeoSpatialEntity2dWithGeneratedIndex(double x, double y) {
      this.location = new Point(x, y);
    }
View Full Code Here

   */
  @Test
  public void shouldTakeSkipAndLimitSettingsFromGivenPageable() {

    Pageable pageable = new PageRequest(3, 5);
    NearQuery query = NearQuery.near(new Point(1, 1)).with(pageable);

    assertThat(query.getSkip(), is(pageable.getPageNumber() * pageable.getPageSize()));
    assertThat((Integer) query.toDBObject().get("num"), is((pageable.getPageNumber() + 1) * pageable.getPageSize()));
  }
 
View Full Code Here

  @Test
  public void shouldTakeSkipAndLimitSettingsFromGivenQuery() {

    int limit = 10;
    int skip = 5;
    NearQuery query = NearQuery.near(new Point(1, 1)).query(
        Query.query(Criteria.where("foo").is("bar")).limit(limit).skip(skip));

    assertThat(query.getSkip(), is(skip));
    assertThat((Integer) query.toDBObject().get("num"), is(limit));
  }
View Full Code Here

  public void shouldTakeSkipAndLimitSettingsFromPageableEvenIfItWasSpecifiedOnQuery() {

    int limit = 10;
    int skip = 5;
    Pageable pageable = new PageRequest(3, 5);
    NearQuery query = NearQuery.near(new Point(1, 1))
        .query(Query.query(Criteria.where("foo").is("bar")).limit(limit).skip(skip)).with(pageable);

    assertThat(query.getSkip(), is(pageable.getPageNumber() * pageable.getPageSize()));
    assertThat((Integer) query.toDBObject().get("num"), is((pageable.getPageNumber() + 1) * pageable.getPageSize()));
  }
 
View Full Code Here

   * @see DATAMONGO-829
   */
  @Test
  public void nearQueryShouldInoreZeroLimitFromQuery() {

    NearQuery query = NearQuery.near(new Point(1, 2)).query(Query.query(Criteria.where("foo").is("bar")));
    assertThat(query.toDBObject().get("num"), nullValue());
  }
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.