use of com.mongodb.client.model.geojson.Position in project mongo-java-driver by mongodb.
the class GeometryEncoderHelper method encodeLinearRing.
private static void encodeLinearRing(final List<Position> ring, final BsonWriter writer) {
writer.writeStartArray();
for (Position position : ring) {
encodePosition(writer, position);
}
writer.writeEndArray();
}
use of com.mongodb.client.model.geojson.Position in project mongo-java-driver by mongodb.
the class GeometryEncoderHelper method encodeMultiPoint.
private static void encodeMultiPoint(final BsonWriter writer, final MultiPoint value) {
writer.writeStartArray();
for (Position position : value.getCoordinates()) {
encodePosition(writer, position);
}
writer.writeEndArray();
}
use of com.mongodb.client.model.geojson.Position in project morphia by mongodb.
the class TestGeoQueries method testWithinOutsideBox.
@Test
public void testWithinOutsideBox() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(box("loc", new Point(new Position(0, 0)), new Point(new Position(.4, .5)))).iterator(new FindOptions().limit(1)).tryNext();
Assert.assertNull(found);
}
use of com.mongodb.client.model.geojson.Position in project morphia by mongodb.
the class TestGeoQueries method testGeoWithinPolygon.
@Test
public void testGeoWithinPolygon() {
final Place place1 = new Place("place1", new double[] { 0, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(polygon("loc", new Point(new Position(0, 0)), new Point(new Position(0, 5)), new Point(new Position(2, 3)), new Point(new Position(2, 0)))).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
use of com.mongodb.client.model.geojson.Position in project morphia by mongodb.
the class TestGeoQueries method testWithinBox.
@Test
public void testWithinBox() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(box("loc", new Point(new Position(0, 0)), new Point(new Position(2, 2)))).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
Aggregations