Package org.springframework.data.geo

Examples of org.springframework.data.geo.Point


    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

    ProductBean locatedInNYC = createProductBean("200", 5, true);
    locatedInNYC.setLocation("40.7143,-74.006");

    repo.save(Arrays.asList(locatedInBuffalow, locatedInNYC));

    List<ProductBean> found = repo.findByLocationNear(new Box(new Point(45, -94), new Point(46, -93)));
    Assert.assertEquals(1, found.size());
    Assert.assertEquals(locatedInBuffalow.getId(), found.get(0).getId());
  }
View Full Code Here

    new Criteria("field_1").in();
  }

  @Test
  public void testNear() {
    Point location = new Point(48.303056, 14.290556);
    Criteria criteria = new Criteria("field_1").near(location, new Distance(5));
    Predicate entry = getPredicateByPosition(criteria.getPredicates(), 0);
    Assert.assertEquals(OperationKey.NEAR.getKey(), entry.getKey());
    Assert.assertEquals(location, ((Object[]) entry.getValue())[0]);
    Assert.assertEquals(5, ((Distance) ((Object[]) entry.getValue())[1]).getValue(), 0);
View Full Code Here

    new Criteria("field_1").near(null, new Distance(5));
  }

  @Test(expected = InvalidDataAccessApiUsageException.class)
  public void testNearWithNegativeDistance() {
    new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(-1));
  }
View Full Code Here

    new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(-1));
  }

  @Test
  public void testWithin() {
    Point location = new Point(48.303056, 14.290556);
    Criteria criteria = new Criteria("field_1").within(location, new Distance(5));
    Predicate entry = getPredicateByPosition(criteria.getPredicates(), 0);
    Assert.assertEquals(OperationKey.WITHIN.getKey(), entry.getKey());
    Assert.assertEquals(location, ((Object[]) entry.getValue())[0]);
    Assert.assertEquals(5, ((Distance) ((Object[]) entry.getValue())[1]).getValue(), 0);
View Full Code Here

   */
  @Test
  public void convertsPointCorrectly() {
    BeanWithPoint bean = new BeanWithPoint();
    bean.id = DEFAULT_BEAN_ID;
    bean.location = new Point(48.30975D, 14.28435D);

    BeanWithPoint loaded = saveAndLoad(bean);

    Assert.assertEquals(bean.location.getX(), loaded.location.getX(), 0.0F);
    Assert.assertEquals(bean.location.getY(), loaded.location.getY(), 0.0F);
View Full Code Here

    Assert.assertEquals("field_1:\\-100", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testNear() {
    Criteria criteria = new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(5));
    Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=field_1 d=5.0}",
        queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    new Criteria("field_1").near((Circle) null);
  }

  @Test
  public void testNearWithDistanceUnitMiles() {
    Criteria criteria = new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(1, Metrics.MILES));
    Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=field_1 d=1.609344}",
        queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

        queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testNearWithDistanceUnitKilometers() {
    Criteria criteria = new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(1,
        Metrics.KILOMETERS));
    Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=field_1 d=1.0}",
        queryParser.createQueryStringFromCriteria(criteria));
  }
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.