Search in sources :

Example 6 with Polygon

use of org.springframework.data.geo.Polygon in project spring-data-mongodb by spring-projects.

the class MappingMongoConverterUnitTests method shouldReadEntityWithGeoPolygonCorrectly.

// DATAMONGO-858
@Test
public void shouldReadEntityWithGeoPolygonCorrectly() {
    ClassWithGeoPolygon object = new ClassWithGeoPolygon();
    object.polygon = new Polygon(new Point(1, 2), new Point(3, 4), new Point(4, 5));
    org.bson.Document document = new org.bson.Document();
    converter.write(object, document);
    ClassWithGeoPolygon result = converter.read(ClassWithGeoPolygon.class, document);
    assertThat(result, is(notNullValue()));
    assertThat(result.polygon, is(object.polygon));
}
Also used : Point(org.springframework.data.geo.Point) Polygon(org.springframework.data.geo.Polygon) Document(org.springframework.data.mongodb.core.mapping.Document) Test(org.junit.Test)

Example 7 with Polygon

use of org.springframework.data.geo.Polygon in project spring-data-mongodb by spring-projects.

the class MongoConvertersUnitTests method convertsPolygonToDocumentAndBackCorrectly.

// DATAMONGO-858
@Test
public void convertsPolygonToDocumentAndBackCorrectly() {
    Polygon polygon = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(5, 6));
    Document document = GeoConverters.PolygonToDocumentConverter.INSTANCE.convert(polygon);
    Shape shape = GeoConverters.DocumentToPolygonConverter.INSTANCE.convert(document);
    assertThat(shape, is((org.springframework.data.geo.Shape) polygon));
}
Also used : Shape(org.springframework.data.geo.Shape) Point(org.springframework.data.geo.Point) Polygon(org.springframework.data.geo.Polygon) Document(org.bson.Document) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Point (org.springframework.data.geo.Point)7 Polygon (org.springframework.data.geo.Polygon)7 Document (org.bson.Document)2 Shape (org.springframework.data.geo.Shape)2 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)2 Document (org.springframework.data.mongodb.core.mapping.Document)2 BasicDBList (com.mongodb.BasicDBList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Venue (org.springframework.data.mongodb.core.Venue)1 Query (org.springframework.data.mongodb.core.query.Query)1 PartTree (org.springframework.data.repository.query.parser.PartTree)1