Search in sources :

Example 6 with PolygonCoordinates

use of com.mongodb.client.model.geojson.PolygonCoordinates in project mongo-java-driver by mongodb.

the class GeometryEncoderHelper method encodeMultiPolygon.

private static void encodeMultiPolygon(final BsonWriter writer, final MultiPolygon value) {
    writer.writeStartArray();
    for (PolygonCoordinates polygonCoordinates : value.getCoordinates()) {
        encodePolygonCoordinates(writer, polygonCoordinates);
    }
    writer.writeEndArray();
}
Also used : PolygonCoordinates(com.mongodb.client.model.geojson.PolygonCoordinates)

Example 7 with PolygonCoordinates

use of com.mongodb.client.model.geojson.PolygonCoordinates in project spring-data-mongodb by spring-projects.

the class MongoTemplateMappingTests method writesAndReadsEntityWithOpenNativeMongoGeoJsonTypesCorrectly.

// DATAMONGO-2357
@Test
public void writesAndReadsEntityWithOpenNativeMongoGeoJsonTypesCorrectly() {
    WithOpenMongoGeoJson source = new WithOpenMongoGeoJson();
    source.id = "id-2";
    source.geometry = new MultiPolygon(Arrays.asList(new PolygonCoordinates(Arrays.asList(new Position(0, 0), new Position(0, 1), new Position(1, 1), new Position(1, 0), new Position(0, 0)))));
    template1.save(source);
    assertThat(template1.findOne(query(where("id").is(source.id)), WithOpenMongoGeoJson.class)).isEqualTo(source);
}
Also used : MultiPolygon(com.mongodb.client.model.geojson.MultiPolygon) Position(com.mongodb.client.model.geojson.Position) PolygonCoordinates(com.mongodb.client.model.geojson.PolygonCoordinates) Test(org.junit.Test)

Aggregations

PolygonCoordinates (com.mongodb.client.model.geojson.PolygonCoordinates)7 MultiPolygon (com.mongodb.client.model.geojson.MultiPolygon)4 Position (com.mongodb.client.model.geojson.Position)3 CodecConfigurationException (org.bson.codecs.configuration.CodecConfigurationException)3 CoordinateReferenceSystem (com.mongodb.client.model.geojson.CoordinateReferenceSystem)2 LineString (com.mongodb.client.model.geojson.LineString)2 MultiLineString (com.mongodb.client.model.geojson.MultiLineString)2 NamedCoordinateReferenceSystem (com.mongodb.client.model.geojson.NamedCoordinateReferenceSystem)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 Polygon (com.mongodb.client.model.geojson.Polygon)1