Package org.springframework.data.elasticsearch.core.geo

Examples of org.springframework.data.elasticsearch.core.geo.GeoPoint


    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    // when
    Page<SampleEntity> page = repository.findByLocationWithin(new GeoPoint(45.7806d, 3.0875d), "2km", new PageRequest(0, 10));
    // then
    assertThat(page, is(notNullValue()));
    assertThat(page.getTotalElements(), is(equalTo(1L)));
  }
View Full Code Here


    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    // when
    Page<SampleEntity> page = repository.findByLocationWithin(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS), new PageRequest(0, 10));
View Full Code Here

    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test2");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    Page<SampleEntity> pageAll = repository.findAll(new PageRequest(0, 10));
View Full Code Here

    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    // when
    Page<SampleEntity> page = repository.findByLocationNear(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS), new PageRequest(0, 10));
View Full Code Here

    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationWithin(new GeoPoint(45.7806d, 3.0875d), "2km");
    // then
    assertThat(count, is(equalTo(1L)));
  }
View Full Code Here

    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationWithin(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS));
View Full Code Here

    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test2");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    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)));
View Full Code Here

    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationNear(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS));
View Full Code Here

        } else {
          dist.append((String) valArray[1]);
        }

        if (valArray[0] instanceof GeoPoint) {
          GeoPoint loc = (GeoPoint) valArray[0];
          ((GeoDistanceFilterBuilder) filter).lat(loc.getLat()).lon(loc.getLon()).distance(dist.toString());
        } else if (valArray[0] instanceof Point) {
          GeoPoint loc = GeoPoint.fromPoint((Point) valArray[0]);
          ((GeoDistanceFilterBuilder) filter).lat(loc.getLat()).lon(loc.getLon()).distance(dist.toString());
        } else {
          String loc = (String) valArray[0];
          if (loc.contains(",")) {
            String c[] = loc.split(",");
            ((GeoDistanceFilterBuilder) filter).lat(Double.parseDouble(c[0])).lon(Double.parseDouble(c[1])).distance(dist.toString());
          } else {
            ((GeoDistanceFilterBuilder) filter).geohash(loc).distance(dist.toString());
          }
        }
View Full Code Here

  }

  private void twoParameterBBox(GeoBoundingBoxFilterBuilder filter, Object[] values) {
    Assert.isTrue(isType(values, GeoPoint.class) || isType(values, String.class), " both elements of boundedBy filter must be type of GeoPoint or String(format lat,lon or geohash)");
    if (values[0] instanceof GeoPoint) {
      GeoPoint topLeft = (GeoPoint) values[0];
      GeoPoint bottomRight = (GeoPoint) values[1];
      filter.topLeft(topLeft.getLat(), topLeft.getLon());
      filter.bottomRight(bottomRight.getLat(), bottomRight.getLon());
    } else {
      String topLeft = (String) values[0];
      String bottomRight = (String) values[1];
      filter.topLeft(topLeft);
      filter.bottomRight(bottomRight);
View Full Code Here

TOP

Related Classes of org.springframework.data.elasticsearch.core.geo.GeoPoint

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.