use of org.mongodb.morphia.geo.NamedCoordinateReferenceSystemConverter in project morphia by mongodb.
the class StandardGeoFieldCriteria method addTo.
@Override
public void addTo(final DBObject obj) {
BasicDBObjectBuilder query;
FilterOperator operator = getOperator();
switch(operator) {
case NEAR:
if (maxDistanceMeters != null) {
geometryAsDBObject.put("$maxDistance", maxDistanceMeters);
}
query = BasicDBObjectBuilder.start(NEAR.val(), geometryAsDBObject);
break;
case GEO_WITHIN:
case INTERSECTS:
query = BasicDBObjectBuilder.start(operator.val(), geometryAsDBObject);
if (crs != null) {
((DBObject) geometryAsDBObject.get("$geometry")).put("crs", new NamedCoordinateReferenceSystemConverter().encode(crs));
}
break;
default:
throw new UnsupportedOperationException(String.format("Operator %s not supported for geo-query", operator.val()));
}
obj.put(getField(), query.get());
}
Aggregations