Examples of Distance


Examples of org.springframework.data.geo.Distance

        return criteria.is(true);
      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 {
          if (distance.getMetric() != null) {
            criteria.nearSphere(point);
          } else {
            criteria.near(point);
          }
          criteria.maxDistance(distance.getNormalizedValue());
        }
        return criteria;
      case WITHIN:

        Object parameter = parameters.next();
View Full Code Here

Examples of org.springframework.data.geo.Distance

      if (query != null) {
        nearQuery.query(query);
      }

      Distance maxDistance = accessor.getMaxDistance();
      if (maxDistance != null) {
        nearQuery.maxDistance(maxDistance).in(maxDistance.getMetric());
      }

      Pageable pageable = accessor.getPageable();
      if (pageable != null) {
        nearQuery.with(pageable);
View Full Code Here

Examples of org.springframework.data.geo.Distance

    query = query.in(Metrics.MILES);
    assertThat(query.getMetric(), is((Metric) Metrics.MILES));
    assertThat(query.getMaxDistance(), is(ONE_FIFTY_KILOMETERS));
    assertThat(query.isSpherical(), is(true));

    query = query.maxDistance(new Distance(200, Metrics.KILOMETERS));
    assertThat(query.getMetric(), is((Metric) Metrics.MILES));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

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

    Query query = createQueryForMethodWithArgs(method,
        new Object[] { new Point(48.303056, 14.290556), new Distance(5) });
    Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=store d=5.0}", queryParser.getQueryString(query));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

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

    Query query = createQueryForMethodWithArgs(method, new Object[] { new Point(48.303056, 14.290556),
        new Distance(1, Metrics.MILES) });
    Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void testCreateQueryWithWithin() throws NoSuchMethodException, SecurityException {
    Method method = SampleRepository.class.getMethod("findByLocationWithin", Point.class, Distance.class);

    Query query = createQueryForMethodWithArgs(method,
        new Object[] { new Point(48.303056, 14.290556), new Distance(5) });
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=5.0}", queryParser.getQueryString(query));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

  @Test
  public void testCreateQueryWithWithinWhereUnitIsMiles() throws NoSuchMethodException, SecurityException {
    Method method = SampleRepository.class.getMethod("findByLocationWithin", Point.class, Distance.class);

    Query query = createQueryForMethodWithArgs(method, new Object[] { new Point(48.303056, 14.290556),
        new Distance(1, Metrics.MILES) });
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

    SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

    StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

    org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
        queryMethod, new Object[] { new Point(48.303056, 14.290556), new Distance(5) }));

    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=5.0}", queryParser.getQueryString(query));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

    SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

    StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

    org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
        queryMethod, new Object[] { new Point(48.303056, 14.290556), new Distance(1, Metrics.MILES) }));

    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
  }
View Full Code Here

Examples of org.springframework.data.geo.Distance

    solrTemplate.saveBeans(Arrays.asList(searchableBeanInBuffalow, searchableBeanInNYC));
    solrTemplate.commit();

    Page<ExampleSolrBean> result = solrTemplate.queryForPage(
        new SimpleQuery(new Criteria("store").near(new Point(45.15, -93.85), new Distance(5))), ExampleSolrBean.class);

    Assert.assertEquals(1, result.getContent().size());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.