Package org.springframework.data.geo

Examples of org.springframework.data.geo.Box


    @Override
    public Object doProcess(Predicate predicate, Field field) {
      String nearFragment;
      Object[] args = (Object[]) predicate.getValue();
      if (args[0] instanceof Box) {
        Box box = (Box) args[0];
        nearFragment = field.getName() + ":[";
        nearFragment += createRangeFragment(box.getFirst(), box.getSecond());
        nearFragment += "]";
      } else {
        nearFragment = createSpatialFunctionFragment(field.getName(), (org.springframework.data.geo.Point) args[0],
            (Distance) args[1], "bbox");
      }
View Full Code Here


    // then
    assertThat(pageAll, is(notNullValue()));
    assertThat(pageAll.getTotalElements(), is(equalTo(2L)));

    // when
    Page<SampleEntity> page = repository.findByLocationNear(new Box(new Point(3d, 46d), new Point(4d, 45d)), new PageRequest(0, 10));
    // then
    assertThat(page, is(notNullValue()));
    assertThat(page.getTotalElements(), is(equalTo(1L)));
  }
View Full Code Here

    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationNear(new Box(new Point(3d, 46d), new Point(4d, 45d)));
    // then
    assertThat(count, is(equalTo(1L)));
  }
View Full Code Here

  private void oneParameterBBox(GeoBoundingBoxFilterBuilder filter, Object value) {
    Assert.isTrue(value instanceof GeoBox || value instanceof Box, "single-element of boundedBy filter must be type of GeoBox or Box");

    GeoBox geoBBox;
    if (value instanceof Box) {
      Box sdbox = (Box) value;
      geoBBox = GeoBox.fromBox(sdbox);
    } else {
      geoBBox = (GeoBox) value;
    }
View Full Code Here

   * @see DATAMONGO-858
   */
  @Test
  public void convertsBoxToDbObjectAndBackCorrectly() {

    Box box = new Box(new Point(1, 2), new Point(3, 4));

    DBObject dbo = GeoConverters.BoxToDbObjectConverter.INSTANCE.convert(box);
    Shape shape = GeoConverters.DbObjectToBoxConverter.INSTANCE.convert(dbo);

    assertThat(shape, is((org.springframework.data.geo.Shape) box));
View Full Code Here

   * @see DATAMONGO-858
   */
  @Test
  public void convertsBoxToDbObjectAndBackCorrectly() {

    Box box = new Box(new Point(1, 2), new Point(3, 4));

    DBObject dbo = BoxToDbObjectConverter.INSTANCE.convert(box);
    Box result = DbObjectToBoxConverter.INSTANCE.convert(dbo);

    assertThat(result, is(box));
    assertThat(result.getClass().equals(Box.class), is(true));
  }
View Full Code Here

   * @see DATAMONGO-858
   */
  @Test
  public void convertsGeoCommandToDbObjectCorrectly() {

    Box box = new Box(new double[] { 1, 2 }, new double[] { 3, 4 });
    GeoCommand cmd = new GeoCommand(box);

    DBObject dbo = GeoCommandToDbObjectConverter.INSTANCE.convert(cmd);

    assertThat(dbo, is(notNullValue()));

    DBObject boxObject = (DBObject) dbo.get("$box");

    assertThat(boxObject,
        is((Object) Arrays.asList(GeoConverters.toList(box.getFirst()), GeoConverters.toList(box.getSecond()))));
  }
View Full Code Here

   */
  @Test
  public void shouldWriteEntityWithGeoBoxCorrectly() {

    ClassWithGeoBox object = new ClassWithGeoBox();
    object.box = new Box(new Point(1, 2), new Point(3, 4));

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);

    assertThat(dbo, is(notNullValue()));
View Full Code Here

   */
  @Test
  public void shouldReadEntityWithGeoBoxCorrectly() {

    ClassWithGeoBox object = new ClassWithGeoBox();
    object.box = new Box(new Point(1, 2), new Point(3, 4));

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);

    ClassWithGeoBox result = converter.read(ClassWithGeoBox.class, dbo);
View Full Code Here

    c.save(new BasicDBObject("x", new String[] { "a", "b" }).append("loc", new double[] { 0, 0 }));
    c.save(new BasicDBObject("x", new String[] { "b", "c" }).append("loc", new double[] { 0, 0 }));
    c.save(new BasicDBObject("x", new String[] { "c", "d" }).append("loc", new double[] { 0, 0 }));

    Query query = new Query(where("x").ne(new String[] { "a", "b" }).and("loc")
        .within(new Box(new double[] { 0, 0 }, new double[] { 1, 1 })));

    MapReduceResults<ValueObject> results = template.mapReduce(query, "jmrWithGeo", mapFunction, reduceFunction,
        ValueObject.class);

    Map<String, Float> m = copyToMap(results);
View Full Code Here

TOP

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

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.