Package org.springframework.data.geo

Examples of org.springframework.data.geo.Point


  @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


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

    Query query = createQueryForMethodWithArgs(method, new Object[] { new Box(new Point(48.303056, 14.290556),
        new Point(48.306377, 14.283128)) });
    Assert.assertEquals("store:[48.303056,14.290556 TO 48.306377,14.283128]", 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

    solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
    solrTemplate.commit();

    Query q = new SimpleQuery("*:*");
    q.addProjectionOnField(new DistanceField("distance", "store", new Point(45.15, -93.85)));
    Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
    for (ExampleSolrBean bean : result) {
      Assert.assertThat(bean.getDistance(), IsNull.notNullValue());
    }

View Full Code Here

  }

  @Test
  public void testWriteWithCustomType() {
    BeanWithCustomTypes bean = new BeanWithCustomTypes();
    bean.location = new Point(48.362893D, 14.534437D);

    SolrInputDocument document = new SolrInputDocument();
    converter.write(bean, document);

    Assert.assertEquals("48.362893,14.534437", document.getFieldValue("location"));
View Full Code Here

  }

  @Test
  public void testWriteWithCustomTypeList() {
    BeanWithCustomTypes bean = new BeanWithCustomTypes();
    bean.locations = Arrays.asList(new Point(48.362893D, 14.534437D), new Point(48.208602D, 16.372996D));

    SolrInputDocument document = new SolrInputDocument();
    converter.write(bean, document);

    Assert.assertEquals(Arrays.asList("48.362893,14.534437", "48.208602,16.372996"),
View Full Code Here

    Assert.assertThat(parser.createFunctionFragment(function, 0), Is.is("{!func}foo(bar(nested))"));
  }

  @Test
  public void testCreateFunctionFragmentConvertsPointProperty() {
    Foo function = new Foo(Arrays.asList(new Point(37.767624D, -122.48526D)));

    Assert.assertThat(parser.createFunctionFragment(function, 0), Is.is("{!func}foo(37.767624,-122.48526)"));
  }
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.