Package org.springframework.data.geo

Examples of org.springframework.data.geo.Polygon


   */
  @Test
  public void shouldWriteEntityWithGeoPolygonCorrectly() {

    ClassWithGeoPolygon object = new ClassWithGeoPolygon();
    object.polygon = new Polygon(new Point(1, 2), new Point(3, 4), new Point(4, 5));

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

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


   */
  @Test
  public void shouldReadEntityWithGeoPolygonCorrectly() {

    ClassWithGeoPolygon object = new ClassWithGeoPolygon();
    object.polygon = new Polygon(new Point(1, 2), new Point(3, 4), new Point(4, 5));

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

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

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

    Polygon polygon = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(5, 6));

    DBObject dbo = GeoConverters.PolygonToDbObjectConverter.INSTANCE.convert(polygon);
    Shape shape = GeoConverters.DbObjectToPolygonConverter.INSTANCE.convert(dbo);

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

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

    Polygon polygon = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(5, 6));

    DBObject dbo = PolygonToDbObjectConverter.INSTANCE.convert(polygon);
    Polygon result = DbObjectToPolygonConverter.INSTANCE.convert(dbo);

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

    Point first = new Point(-78.99171, 35.738868);
    Point second = new Point(-78.99171, 45.738868);
    Point third = new Point(-68.99171, 45.738868);
    Point fourth = new Point(-68.99171, 35.738868);

    List<Person> result = repository.findByLocationWithin(new Polygon(first, second, third, fourth));
    assertThat(result.size(), is(1));
    assertThat(result, hasItem(dave));
  }
View Full Code Here

    Point first = new Point(-73.99756, 40.73083);
    Point second = new Point(-73.99756, 40.741404);
    Point third = new Point(-73.988135, 40.741404);
    Point fourth = new Point(-73.988135, 40.73083);

    Polygon polygon = new Polygon(first, second, third, fourth);

    List<Venue> venues = template.find(query(where("location").within(polygon)), Venue.class);
    assertThat(venues.size(), is(4));
  }
View Full Code Here

        assertEquals("1.23 -4.56", GeoConverter.toWktCoords(POINT_1));
    }

    @Test
    public void testToWkt() throws Exception {
        assertEquals("POLYGON((1.23 -4.56,-1.23 4.56,0.0 2.0,1.23 -4.56))",GeoConverter.toWkt(new Polygon(POINT_1,POINT_2,POINT_3)));
    }
View Full Code Here

        assertEquals("POLYGON((1.23 -4.56,-1.23 4.56,0.0 2.0,1.23 -4.56))",GeoConverter.toWkt(new Polygon(POINT_1,POINT_2,POINT_3)));
    }

    @Test
    public void testToWellKnownText() throws Exception {
        assertEquals("POLYGON((1.23 -4.56,-1.23 4.56,0.0 2.0,1.23 -4.56))",GeoConverter.toWellKnownText(new Polygon(POINT_1,POINT_2,POINT_3)));
        assertEquals("POINT(1.23 -4.56)",GeoConverter.toWellKnownText(POINT_1));
        assertEquals("POINT(-1.23 4.56)",GeoConverter.toWellKnownText(POINT_2));
        assertEquals("POINT(0.0 2.0)",GeoConverter.toWellKnownText(POINT_3));

    }
View Full Code Here

    }

    @Test
    public void testToPolygon() throws Exception {
        assertEquals(new Polygon(POINT_1,POINT_6,POINT_2, POINT_5),GeoConverter.toPolygon(new Box(POINT_1, POINT_2)));
    }
View Full Code Here

        assertEquals(new Polygon(POINT_1,POINT_6,POINT_2, POINT_5),GeoConverter.toPolygon(new Box(POINT_1, POINT_2)));
    }

    @Test
    public void testFromWellKnownText() throws Exception {
        assertEquals(new Polygon(POINT_1,POINT_2,POINT_3),GeoConverter.fromWellKnownText("POLYGON((1.23 -4.56,-1.23 4.56,0.0 2.0,1.23 -4.56))"));
    }
View Full Code Here

TOP

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

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.