Lucene.Net.Spatial.Queries.SpatialOperation.Get C# (CSharp) Méthode

Get() public static méthode

public static Get ( string v ) : SpatialOperation
v string
Résultat SpatialOperation
        public static SpatialOperation Get(string v)
        {
            SpatialOperation op;
            if (!registry.TryGetValue(v, out op) || op == null)
            {
                if (!registry.TryGetValue(v.ToUpper(CultureInfo.InvariantCulture), out op) || op == null)
                    throw new ArgumentException("Unknown Operation: " + v, "v");
            }
            return op;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Parses a string such as "Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025".
        /// </summary>
        /// <param name="v">The string to parse. Mandatory.</param>
        /// <param name="ctx">The spatial context. Mandatory.</param>
        /// <returns>Not null.</returns>
        /// <exception cref="ArgumentException">if the parameters don't make sense or an add-on parameter is unknown.</exception>
        /// <exception cref="Spatial4n.Exceptions.ParseException">If there is a problem parsing the string.</exception>
        /// <exception cref="InvalidShapeException">When the coordinates are invalid for the shape.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="v"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
        public virtual SpatialArgs Parse(string v, SpatialContext ctx)
        {
            // LUCENENET specific - added guard clauses
            if (v is null)
            {
                throw new ArgumentNullException(nameof(v));
            }
            if (ctx is null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }

            int idx = v.IndexOf('(');
            int edx = v.LastIndexOf(')');

            if (idx < 0 || idx > edx)
            {
                throw new Spatial4n.Exceptions.ParseException("missing parens: " + v, -1);
            }

            SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx - 0).Trim());

            //Substring in .NET is (startPosn, length), But in Java it's (startPosn, endPosn)
            //see http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#substring(int, int)
            string body = v.Substring(idx + 1, edx - (idx + 1)).Trim();

            if (body.Length < 1)
            {
                throw new Spatial4n.Exceptions.ParseException("missing body : " + v, idx + 1);
            }

            var shape = ParseShape(body, ctx);
            var args  = NewSpatialArgs(op, shape);

            if (v.Length > (edx + 1))
            {
                body = v.Substring(edx + 1).Trim();
                if (body.Length > 0)
                {
                    IDictionary <string, string> aa = ParseMap(body);
                    ReadNameValuePairs(args, aa);
                    if (aa.Count == 0)
                    {
                        throw new ArgumentException("unused parameters: " + aa);
                    }
                }
            }
            args.Validate();
            return(args);
        }
All Usage Examples Of Lucene.Net.Spatial.Queries.SpatialOperation::Get