Package org.springframework.data.geo

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


  @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

  @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

    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

    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

    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

    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(3.106856, Metrics.MILES))),
        ExampleSolrBean.class);

    Assert.assertEquals(1, result.getContent().size());
  }
View Full Code Here

    Assert.assertThat(parser.createFunctionFragment(function, 0), Is.is("{!func}foo(37.767624,-122.48526)"));
  }

  @Test
  public void testCreateFunctionFragmentConvertsDistanceProperty() {
    Foo function = new Foo(Arrays.asList(new Distance(5, Metrics.KILOMETERS)));

    Assert.assertThat(parser.createFunctionFragment(function, 0), Is.is("{!func}foo(5.0)"));
  }
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.findByLocationWithin(new Point(45.15, -93.85), new Distance(5));
    Assert.assertEquals(1, found.size());
    Assert.assertEquals(locatedInBuffalow.getId(), found.get(0).getId());
  }
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 Point(45.15, -93.85), new Distance(5));
    Assert.assertEquals(1, found.size());
    Assert.assertEquals(locatedInBuffalow.getId(), found.get(0).getId());
  }
View Full Code Here

TOP

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

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.