public QueryToken ToQueryToken(string fieldName, Func <object, string> addQueryParameter) { var shapeToken = GetShapeToken(addQueryParameter); WhereOperator whereOperator; switch (_relation) { case SpatialRelation.Within: whereOperator = WhereOperator.Spatial_Within; break; case SpatialRelation.Contains: whereOperator = WhereOperator.Spatial_Contains; break; case SpatialRelation.Disjoint: whereOperator = WhereOperator.Spatial_Disjoint; break; case SpatialRelation.Intersects: whereOperator = WhereOperator.Spatial_Intersects; break; default: throw new ArgumentOutOfRangeException(nameof(_relation), _relation, null); } return(WhereToken.Create(whereOperator, fieldName, null, new WhereToken.WhereOptions(shapeToken, _distanceErrorPct))); }
protected void WithinRadiusOf(string fieldName, double radius, double latitude, double longitude, SpatialUnits?radiusUnits, double distErrorPercent) { fieldName = EnsureValidFieldName(fieldName, isNestedPath: false); var tokens = GetCurrentWhereTokens(); AppendOperatorIfNeeded(tokens); NegateIfNeeded(tokens, fieldName); var whereToken = WhereToken.Create(WhereOperator.Spatial_Within, fieldName, null, new WhereToken.WhereOptions(ShapeToken.Circle(AddQueryParameter(radius), AddQueryParameter(latitude), AddQueryParameter(longitude), radiusUnits), distErrorPercent)); tokens.AddLast(whereToken); }
protected void Spatial(string fieldName, string shapeWkt, SpatialRelation relation, SpatialUnits?units, double distErrorPercent) { fieldName = EnsureValidFieldName(fieldName, isNestedPath: false); var tokens = GetCurrentWhereTokens(); AppendOperatorIfNeeded(tokens); NegateIfNeeded(tokens, fieldName); var wktToken = ShapeToken.Wkt(AddQueryParameter(shapeWkt), units); WhereOperator whereOperator; switch (relation) { case SpatialRelation.Within: whereOperator = WhereOperator.Spatial_Within; break; case SpatialRelation.Contains: whereOperator = WhereOperator.Spatial_Contains; break; case SpatialRelation.Disjoint: whereOperator = WhereOperator.Spatial_Disjoint; break; case SpatialRelation.Intersects: whereOperator = WhereOperator.Spatial_Intersects; break; default: throw new ArgumentOutOfRangeException(nameof(relation), relation, null); } tokens.AddLast(WhereToken.Create(whereOperator, fieldName, null, new WhereToken.WhereOptions(wktToken, distErrorPercent))); }