Add nearSphere to MongodbExpressions. #1438

Closed
christophstrobl opened this Issue Jul 17, 2015 · 0 comments

Projects

None yet

2 participants

@christophstrobl

Since $near cannot operate on a 2dsphere index using the legacy coordinate format it would be helpful to have something like a MongodbExpressions.nearSphere.

class MongodbOps {

  // ...
  public static final Operator<Boolean> NEARSPHERE = new OperatorImpl<Boolean>(NS, "NEARSPHERE");
}

class MongodbExpressions {

  // ...
  public static BooleanExpression nearSphere(Expression<Double[]> expr, double latVal, double longVal) {
    return BooleanOperation.create(MongodbOps.NEARSPHERE, expr, ConstantImpl.create(new Double[]{latVal, longVal}));
  }
}

class MongodbSerializer {

  public Object visit(Operation<?> expr, Void context) {

    // ...
    } else if (op == MongodbOps.NEARSPHERE) {
      return asDBObject(asDBKey(expr, 0), asDBObject("$nearSphere", asDBValue(expr, 1)));
    }
  }
}

It would also be nice to have support for $minDistance and $maxDistance.

@timowest timowest added the progress label Jul 17, 2015
@Shredder121 Shredder121 closed this in #1439 Jul 23, 2015
@timowest timowest added this to the 4.0.3 milestone Jul 24, 2015
@timowest timowest removed the progress label Jul 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment