Пример #1
0
        public QueryToken ToQueryToken(string fieldName, Func <object, string> addQueryParameter)
        {
            var shapeToken = GetShapeToken(addQueryParameter);

            QueryToken relationToken;

            switch (_relation)
            {
            case SpatialRelation.Within:
                relationToken = WhereToken.Within(fieldName, shapeToken, _distanceErrorPct);
                break;

            case SpatialRelation.Contains:
                relationToken = WhereToken.Contains(fieldName, shapeToken, _distanceErrorPct);
                break;

            case SpatialRelation.Disjoint:
                relationToken = WhereToken.Disjoint(fieldName, shapeToken, _distanceErrorPct);
                break;

            case SpatialRelation.Intersects:
                relationToken = WhereToken.Intersects(fieldName, shapeToken, _distanceErrorPct);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(relationToken);
        }
        protected void Spatial(string fieldName, string shapeWKT, SpatialRelation relation, double distErrorPercent)
        {
            fieldName = EnsureValidFieldName(fieldName, isNestedPath: false);

            AppendOperatorIfNeeded(WhereTokens);
            NegateIfNeeded(fieldName);

            var        wktToken = ShapeToken.Wkt(AddQueryParameter(shapeWKT));
            QueryToken relationToken;

            switch (relation)
            {
            case SpatialRelation.Within:
                relationToken = WhereToken.Within(fieldName, wktToken, distErrorPercent);
                break;

            case SpatialRelation.Contains:
                relationToken = WhereToken.Contains(fieldName, wktToken, distErrorPercent);
                break;

            case SpatialRelation.Disjoint:
                relationToken = WhereToken.Disjoint(fieldName, wktToken, distErrorPercent);
                break;

            case SpatialRelation.Intersects:
                relationToken = WhereToken.Intersects(fieldName, wktToken, distErrorPercent);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(relation), relation, null);
            }

            WhereTokens.AddLast(relationToken);
        }