Package org.springframework.data.geo

Examples of org.springframework.data.geo.Point


  }

  @Test
  public void executesGeoPageQueryForResultsCorrectly() {

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

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(0, 20));
    assertThat(results.getContent().isEmpty(), is(false));

    // DATAMONGO-607
    assertThat(results.getAverageDistance().getMetric(), is((Metric) Metrics.KILOMETERS));
View Full Code Here


   * @see DATAMONGO-445
   */
  @Test
  public void executesGeoPageQueryForWithPageRequestForPageInBetween() {

    Point farAway = new Point(-73.9, 40.7);
    Point here = new Point(-73.99, 40.73);

    dave.setLocation(farAway);
    oliver.setLocation(here);
    carter.setLocation(here);
    boyd.setLocation(here);
    leroi.setLocation(here);

    repository.save(Arrays.asList(dave, oliver, carter, boyd, leroi));

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(1, 2));

    assertThat(results.getContent().isEmpty(), is(false));
    assertThat(results.getNumberOfElements(), is(2));
    assertThat(results.isFirst(), is(false));
View Full Code Here

   * @see DATAMONGO-445
   */
  @Test
  public void executesGeoPageQueryForWithPageRequestForPageAtTheEnd() {

    Point point = new Point(-73.99171, 40.738868);

    dave.setLocation(point);
    oliver.setLocation(point);
    carter.setLocation(point);

    repository.save(Arrays.asList(dave, oliver, carter));

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(1, 2));
    assertThat(results.getContent().isEmpty(), is(false));
    assertThat(results.getNumberOfElements(), is(1));
    assertThat(results.isFirst(), is(false));
    assertThat(results.isLast(), is(true));
View Full Code Here

   * @see DATAMONGO-445
   */
  @Test
  public void executesGeoPageQueryForWithPageRequestForJustOneElement() {

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

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(0, 2));

    assertThat(results.getContent().isEmpty(), is(false));
    assertThat(results.getNumberOfElements(), is(1));
    assertThat(results.isFirst(), is(true));
View Full Code Here

   * @see DATAMONGO-445
   */
  @Test
  public void executesGeoPageQueryForWithPageRequestForJustOneElementEmptyPage() {

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

    GeoPage<Person> results = repository.findByLocationNear(new Point(-73.99, 40.73), new Distance(2000,
        Metrics.KILOMETERS), new PageRequest(1, 2));

    assertThat(results.getContent().isEmpty(), is(true));
    assertThat(results.getNumberOfElements(), is(0));
    assertThat(results.isFirst(), is(false));
View Full Code Here

  }

  @Test
  public void bindsMetricDistanceParameterToNearSphereCorrectly() throws Exception {

    Point point = new Point(10, 20);
    Distance distance = new Distance(2.5, Metrics.KILOMETERS);

    Query query = query(where("location").nearSphere(point).maxDistance(distance.getNormalizedValue()).and("firstname")
        .is("Dave"));
    assertBindsDistanceToQuery(point, distance, query);
View Full Code Here

  }

  @Test
  public void bindsDistanceParameterToNearCorrectly() throws Exception {

    Point point = new Point(10, 20);
    Distance distance = new Distance(2.5);

    Query query = query(where("location").near(point).maxDistance(distance.getNormalizedValue()).and("firstname")
        .is("Dave"));
    assertBindsDistanceToQuery(point, distance, query);
View Full Code Here

      case FALSE:
        return criteria.is(false);
      case NEAR:

        Distance distance = accessor.getMaxDistance();
        Point point = accessor.getGeoNearLocation();
        point = point == null ? nextAs(parameters, Point.class) : point;

        if (distance == null) {
          return criteria.near(point);
        } else {
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private GeoResults<Object> doExecuteQuery(Query query) {

      Point nearLocation = accessor.getGeoNearLocation();
      NearQuery nearQuery = NearQuery.near(nearLocation);

      if (query != null) {
        nearQuery.query(query);
      }
View Full Code Here

    if (value instanceof double[]) {
      double[] typedValue = (double[]) value;
      if (typedValue.length != 2) {
        throw new IllegalArgumentException("The given double[] must have exactly 2 elements!");
      } else {
        return new Point(typedValue[0], typedValue[1]);
      }
    }

    return (Point) value;
  }
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.