Package org.springframework.data.mongodb.core.geo

Examples of org.springframework.data.mongodb.core.geo.Sphere


   */
  @Test
  public void shouldWriteEntityWithGeoSphereCorrectly() {

    ClassWithGeoSphere object = new ClassWithGeoSphere();
    Sphere sphere = new Sphere(new Point(1, 2), 3);
    Distance radius = sphere.getRadius();
    object.sphere = sphere;

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

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("sphere"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("sphere"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", sphere.getCenter().getX()).append("y", sphere
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here


   */
  @Test
  public void shouldWriteEntityWithGeoSphereWithMetricDistanceCorrectly() {

    ClassWithGeoSphere object = new ClassWithGeoSphere();
    Sphere sphere = new Sphere(new Point(1, 2), new Distance(3, Metrics.KILOMETERS));
    Distance radius = sphere.getRadius();
    object.sphere = sphere;

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

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("sphere"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("sphere"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", sphere.getCenter().getX()).append("y", sphere
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here

   */
  @Test
  public void shouldReadEntityWithGeoSphereCorrectly() {

    ClassWithGeoSphere object = new ClassWithGeoSphere();
    object.sphere = new Sphere(new Point(1, 2), 3);

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

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

   */
  @Test
  public void shouldWriteEntityWithGeoShapeCorrectly() {

    ClassWithGeoShape object = new ClassWithGeoShape();
    Sphere sphere = new Sphere(new Point(1, 2), 3);
    Distance radius = sphere.getRadius();
    object.shape = sphere;

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

    assertThat(dbo, is(notNullValue()));
    assertThat(dbo.get("shape"), is(instanceOf(DBObject.class)));
    assertThat(
        dbo.get("shape"),
        is((Object) new BasicDBObject("center", new BasicDBObject("x", sphere.getCenter().getX()).append("y", sphere
            .getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric",
            radius.getMetric().toString())));
  }
View Full Code Here

  @Test
  @Ignore
  public void shouldReadEntityWithGeoShapeCorrectly() {

    ClassWithGeoShape object = new ClassWithGeoShape();
    Sphere sphere = new Sphere(new Point(1, 2), 3);
    object.shape = sphere;

    DBObject dbo = new BasicDBObject();
    converter.write(object, dbo);
View Full Code Here

   * @param circle must not be {@literal null}
   * @return
   */
  public Criteria withinSphere(Circle circle) {
    Assert.notNull(circle);
    criteria.put("$within", new GeoCommand(new Sphere(circle)));
    return this;
  }
View Full Code Here

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

    Sphere sphere = new Sphere(new Point(1, 2), 3);

    DBObject dbo = GeoConverters.SphereToDbObjectConverter.INSTANCE.convert(sphere);
    org.springframework.data.geo.Shape shape = GeoConverters.DbObjectToSphereConverter.INSTANCE.convert(dbo);

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

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

    Sphere sphere = new Sphere(new Point(1, 2), 3);

    DBObject dbo = SphereToDbObjectConverter.INSTANCE.convert(sphere);
    Sphere result = DbObjectToSphereConverter.INSTANCE.convert(dbo);

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

   */
  @Test
  public void convertsSphereToDbObjectAndBackCorrectlyWithKilometerDistance() {

    Distance radius = new Distance(3, Metrics.KILOMETERS);
    Sphere sphere = new Sphere(new Point(1, 2), radius);

    DBObject dbo = SphereToDbObjectConverter.INSTANCE.convert(sphere);
    Sphere result = DbObjectToSphereConverter.INSTANCE.convert(dbo);

    assertThat(result, is(sphere));
    assertThat(result.getRadius(), is(radius));
    assertThat(result.getClass().equals(org.springframework.data.mongodb.core.geo.Sphere.class), is(true));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.geo.Sphere

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.