当前位置: 首页>>代码示例>>C#>>正文


C# SpatialContext.ReadShape方法代码示例

本文整理汇总了C#中Spatial4n.Core.Context.SpatialContext.ReadShape方法的典型用法代码示例。如果您正苦于以下问题:C# SpatialContext.ReadShape方法的具体用法?C# SpatialContext.ReadShape怎么用?C# SpatialContext.ReadShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spatial4n.Core.Context.SpatialContext的用法示例。


在下文中一共展示了SpatialContext.ReadShape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        /// <summary>
        /// Parses a string such as "Intersects(-10,20,-8,22) distErrPct=0.025".
        /// </summary>
        /// <param name="v"></param>
        /// <param name="ctx"></param>
        /// <returns></returns>
        public SpatialArgs Parse(String v, SpatialContext ctx)
        {
            int idx = v.IndexOf('(');
            int edx = v.LastIndexOf(')');

            if (idx < 0 || idx > edx)
            {
                throw new ArgumentException("missing parens: " + v);
            }

            SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).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 ArgumentException("missing body : " + v);
            }

            var shape = ctx.ReadShape(body);
            var args = new SpatialArgs(op, shape);

            if (v.Length > (edx + 1))
            {
                body = v.Substring(edx + 1).Trim();
                if (body.Length > 0)
                {
                    Dictionary<String, String> aa = ParseMap(body);
                    args.DistErrPct = ReadDouble(aa["distErrPct"]); aa.Remove(DIST_ERR_PCT);
                    args.DistErr = ReadDouble(aa["distErr"]); aa.Remove(DIST_ERR);
                    if (aa.Count != 0)
                    {
                        throw new ArgumentException("unused parameters: " + aa);
                    }
                }
            }
            args.Validate();
            return args;
        }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:46,代码来源:SpatialArgsParser.cs

示例2: Parse

		public SpatialArgs Parse(String v, SpatialContext ctx)
		{
			int idx = v.IndexOf('(');
			int edx = v.LastIndexOf(')');

			if (idx < 0 || idx > edx)
			{
				throw new InvalidSpatialArgument("missing parens: " + v);
			}

			SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).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 InvalidSpatialArgument("missing body : " + v);
			}

			var shape = ctx.ReadShape(body);
			var args = new SpatialArgs(op, shape);

			if (v.Length > (edx + 1))
			{
				body = v.Substring(edx + 1).Trim();
				if (body.Length > 0)
				{
					Dictionary<String, String> aa = ParseMap(body);
					args.Min = ReadDouble(aa["min"]);
					args.Max = ReadDouble(aa["max"]);
					args.SetDistPrecision(ReadDouble(aa["distPrec"]));
					if (aa.Count > 3)
					{
						throw new InvalidSpatialArgument("unused parameters: " + aa);
					}
				}
			}
			return args;
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:40,代码来源:SpatialArgsParser.cs

示例3: InitWorldBounds

        protected void InitWorldBounds()
        {
            String worldBoundsStr;
            if (!Args.TryGetValue("worldBounds", out worldBoundsStr) || worldBoundsStr == null)
                return;

            //kinda ugly we do this just to read a rectangle.  TODO refactor
            var simpleCtx = new SpatialContext(Units, Calculator, null);
            WorldBounds = (Rectangle)simpleCtx.ReadShape(worldBoundsStr);
        }
开发者ID:ccurrens,项目名称:Spatial4n,代码行数:10,代码来源:SpatialContextFactory.cs


注:本文中的Spatial4n.Core.Context.SpatialContext.ReadShape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。