/// <summary> /// Creates a new search condition to lookup for records around the given coordinates /// </summary> /// <param name="location">The coordinates to use for the search</param> /// <param name="maxDistance">The radius in meters to search around the coordinates</param> public CBHelperSearchCondition(GeoCoordinate location, double maxDistance) { List<double> points = new List<double>(); points.Add(location.Latitude); points.Add(location.Longitude); this.field = "cb_location"; this.conditionOperator = CBConditionOperator.CBOperatorEqual; Dictionary<string, object> searchQuery = new Dictionary<string, object>(); searchQuery.Add("$near", points); if (maxDistance != -1) { searchQuery.Add("$maxDistance", (maxDistance / 1000) / 111.12); } this.value = searchQuery; this.limit = -1; this.Offset = -1; this.CommandType = CBDataAggregationCommandType.CBDataAggregationMatch; }
/// <summary> /// Shortcut to initialise a simple condition object /// /// The possible operators for each condition are: /// CBOperatorEqual, /// CBOperatorLess, /// CBOperatorLessOrEqual, /// CBOperatorBigger, /// CBOperatorBiggerOrEqual, /// CBOperatorAll, /// CBOperatorExists, /// CBOperatorMod, /// CBOperatorNe, /// CBOperatorIn, /// CBOperatorNin, /// CBOperatorSize, /// CBOperatorType /// </summary> /// <param name="field">The name of the field to run the search over</param> /// <param name="op">The operator</param> /// <param name="value">The value to compare against</param> public CBHelperSearchCondition(string field, CBConditionOperator op, string value) { this.field = field; this.conditionOperator = op; this.value = value; this.Limit = -1; this.Offset = -1; this.CommandType = CBDataAggregationCommandType.CBDataAggregationMatch; }