• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Context.SpatialContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SpatialContext类属于Spatial4n.Core.Context命名空间,在下文中一共展示了SpatialContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetTestData

        /** Reads the stream, consuming a format that is a tab-separated values of 3 columns:
         * an "id", a "name" and the "shape".  Empty lines and lines starting with a '#' are skipped.
         * The stream is closed.
         */
        public static IEnumerator<SpatialTestData> GetTestData(Stream @in, SpatialContext ctx)
        {
            List<SpatialTestData> results = new List<SpatialTestData>();
            TextReader bufInput = new StreamReader(@in, Encoding.UTF8);
            try
            {
                String line;
                while ((line = bufInput.ReadLine()) != null)
                {
                    if (line.Length == 0 || line[0] == '#')
                        continue;

                    SpatialTestData data = new SpatialTestData();
                    String[] vals = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    if (vals.Length != 3)
                        throw new ArgumentException("bad format; expecting 3 tab-separated values for line: " + line);
                    data.id = vals[0];
                    data.name = vals[1];
                    try
                    {
                        data.shape = ctx.ReadShapeFromWkt(vals[2]);
                    }
                    catch (ParseException e)
                    {
                        throw new ApplicationException(e.Message, e);
                    }
                    results.Add(data);
                }
            }
            finally
            {
                bufInput.Dispose();
            }
            return results.GetEnumerator();
        }
开发者ID:apache,项目名称:lucenenet,代码行数:39,代码来源:SpatialTestData.cs


示例2: ResolveDistErr

 /// <summary>
 /// Gets the error distance that specifies how precise the query shape is. This
 /// looks at <see cref="DistErr"/>, <see cref="DistErrPct"/>, and 
 /// <paramref name="defaultDistErrPct"/>.
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="defaultDistErrPct">0 to 0.5</param>
 /// <returns>&gt;= 0</returns>
 public virtual double ResolveDistErr(SpatialContext ctx, double defaultDistErrPct)
 {
     if (DistErr != null)
         return DistErr.Value;
     double distErrPct = (this.distErrPct ?? defaultDistErrPct);
     return CalcDistanceFromErrPct(Shape, distErrPct, ctx);
 }
开发者ID:apache,项目名称:lucenenet,代码行数:15,代码来源:SpatialArgs.cs


示例3: MakeSPT

 //1m
 /// <summary>The factory  is looked up via "prefixTree" in args, expecting "geohash" or "quad".
 /// 	</summary>
 /// <remarks>
 /// The factory  is looked up via "prefixTree" in args, expecting "geohash" or "quad".
 /// If its neither of these, then "geohash" is chosen for a geo context, otherwise "quad" is chosen.
 /// </remarks>
 public static SpatialPrefixTree MakeSPT(IDictionary<string, string> args, SpatialContext ctx)
 {
     SpatialPrefixTreeFactory instance;
     string cname = args[PrefixTree];
     if (cname == null)
     {
         cname = ctx.IsGeo() ? "geohash" : "quad";
     }
     if ("geohash".Equals(cname, StringComparison.OrdinalIgnoreCase))
     {
         instance = new GeohashPrefixTree.Factory();
     }
     else
     {
         if ("quad".Equals(cname, StringComparison.OrdinalIgnoreCase))
         {
             instance = new QuadPrefixTree.Factory();
         }
         else
         {
             try
             {
                 Type c = Type.GetType(cname);
                 instance = (SpatialPrefixTreeFactory)System.Activator.CreateInstance(c);
             }
             catch (Exception e)
             {
                 throw new Exception(string.Empty, e);
             }
         }
     }
     instance.Init(args, ctx);
     return instance.NewSPT();
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:41,代码来源:SpatialPrefixTreeFactory.cs


示例4: TestSimpleCircle

        public void TestSimpleCircle(SpatialContext ctx)
        {
            base.ctx = ctx;

            double[] theXs = new double[] { -10, 0, 10 };
            foreach (double x in theXs)
            {
                double[] theYs = new double[] { -20, 0, 20 };
                foreach (double y in theYs)
                {
                    TestCircle(x, y, 0);
                    TestCircle(x, y, 5);
                }
            }

            testCircleReset(ctx);

            //INTERSECTION:
            //Start with some static tests that have shown to cause failures at some point:
            Assert.Equal( /*"getX not getY",*/
                SpatialRelation.INTERSECTS,
                ctx.MakeCircle(107, -81, 147).Relate(ctx.MakeRectangle(92, 121, -89, 74)));

            TestCircleIntersect();
        }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:25,代码来源:TestShapes2D.cs


示例5: QuadPrefixTree

 public QuadPrefixTree(SpatialContext ctx, Rectangle bounds, int maxLevels)
     : base(ctx, maxLevels)
 {
     //not really sure how big this should be
     // side
     // number
     xmin = bounds.GetMinX();
     xmax = bounds.GetMaxX();
     ymin = bounds.GetMinY();
     ymax = bounds.GetMaxY();
     levelW = new double[maxLevels];
     levelH = new double[maxLevels];
     levelS = new int[maxLevels];
     levelN = new int[maxLevels];
     gridW = xmax - xmin;
     gridH = ymax - ymin;
     xmid = xmin + gridW / 2.0;
     ymid = ymin + gridH / 2.0;
     levelW[0] = gridW / 2.0;
     levelH[0] = gridH / 2.0;
     levelS[0] = 2;
     levelN[0] = 4;
     for (int i = 1; i < levelW.Length; i++)
     {
         levelW[i] = levelW[i - 1] / 2.0;
         levelH[i] = levelH[i - 1] / 2.0;
         levelS[i] = levelS[i - 1] * 2;
         levelN[i] = levelN[i - 1] * 4;
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:30,代码来源:QuadPrefixTree.cs


示例6: QuadPrefixTree

        internal readonly int[] levelN; // number

        public QuadPrefixTree(SpatialContext ctx, IRectangle bounds, int maxLevels)
            : base(ctx, maxLevels)
        {
            xmin = bounds.MinX;
            xmax = bounds.MaxX;
            ymin = bounds.MinY;
            ymax = bounds.MaxY;

            levelW = new double[maxLevels];
            levelH = new double[maxLevels];
            levelS = new int[maxLevels];
            levelN = new int[maxLevels];

            gridW = xmax - xmin;
            gridH = ymax - ymin;
            this.xmid = xmin + gridW / 2.0;
            this.ymid = ymin + gridH / 2.0;
            levelW[0] = gridW / 2.0;
            levelH[0] = gridH / 2.0;
            levelS[0] = 2;
            levelN[0] = 4;

            for (int i = 1; i < levelW.Length; i++)
            {
                levelW[i] = levelW[i - 1] / 2.0;
                levelH[i] = levelH[i - 1] / 2.0;
                levelS[i] = levelS[i - 1] * 2;
                levelN[i] = levelN[i - 1] * 4;
            }
        }
开发者ID:apache,项目名称:lucenenet,代码行数:32,代码来源:QuadPrefixTree.cs


示例7: testMultiShape

        public void testMultiShape(SpatialContext ctx)
        {
            this.ctx = ctx;

            if(ctx.IsGeo()) return;//TODO not yet supported!

            //come up with some random shapes
            int NUM_SHAPES = random.Next(1, 5);
            var shapes = new List<Rectangle>(NUM_SHAPES);
            while (shapes.Count < NUM_SHAPES)
            {
                shapes.Add(RandomRectangle(20));
            }
            var multiShape = new MultiShape(shapes.Cast<Shape>(), ctx);

            //test multiShape.getBoundingBox();
            Rectangle msBbox = multiShape.GetBoundingBox();
            if (shapes.Count == 1)
            {
                Assert.Equal(shapes[0], msBbox.GetBoundingBox());
            }
            else
            {
                foreach (Rectangle shape in shapes)
                {
                    AssertRelation("bbox contains shape", SpatialRelation.CONTAINS, msBbox, shape);
                }
            }

            //TODO test multiShape.relate()
        }
开发者ID:ccurrens,项目名称:Spatial4n,代码行数:31,代码来源:AbstractTestShapes.cs


示例8: MakeSPT

 /// <summary>The factory  is looked up via "prefixTree" in args, expecting "geohash" or "quad".</summary>
 /// <remarks>
 /// The factory  is looked up via "prefixTree" in args, expecting "geohash" or "quad".
 /// If its neither of these, then "geohash" is chosen for a geo context, otherwise "quad" is chosen.
 /// </remarks>
 public static SpatialPrefixTree MakeSPT(IDictionary<string, string> args, SpatialContext ctx)
 {
     SpatialPrefixTreeFactory instance;
     string cname;
     if (!args.TryGetValue(PREFIX_TREE, out cname))
     {
         cname = ctx.IsGeo ? "geohash" : "quad";
     }
     if ("geohash".Equals(cname, StringComparison.OrdinalIgnoreCase))
     {
         instance = new GeohashPrefixTree.Factory();
     }
     else if ("quad".Equals(cname, StringComparison.OrdinalIgnoreCase))
     {
         instance = new QuadPrefixTree.Factory();
     }
     else
     {
         try
         {
             Type c = Type.GetType(cname);
             instance = (SpatialPrefixTreeFactory)Activator.CreateInstance(c);
         }
         catch (Exception e)
         {
             throw new ApplicationException(string.Empty, e);
         }
     }
     instance.Init(args, ctx);
     return instance.NewSPT();
 }
开发者ID:apache,项目名称:lucenenet,代码行数:36,代码来源:SpatialPrefixTreeFactory.cs


示例9: Init

        protected void Init(SpatialContext ctx, Rectangle bounds, int maxLevels)
        {
            this.xmin = bounds.GetMinX();
            this.xmax = bounds.GetMaxX();
            this.ymin = bounds.GetMinY();
            this.ymax = bounds.GetMaxY();

            levelW = new double[maxLevels];
            levelH = new double[maxLevels];
            levelS = new int[maxLevels];
            levelN = new int[maxLevels];

            gridW = xmax - xmin;
            gridH = ymax - ymin;
            xmid = xmin + gridW / 2.0;
            ymid = ymin + gridH / 2.0;
            levelW[0] = gridW / 2.0;
            levelH[0] = gridH / 2.0;
            levelS[0] = 2;
            levelN[0] = 4;

            for (int i = 1; i < levelW.Length; i++)
            {
                levelW[i] = levelW[i - 1] / 2.0;
                levelH[i] = levelH[i - 1] / 2.0;
                levelS[i] = levelS[i - 1] * 2;
                levelN[i] = levelN[i - 1] * 4;
            }

        }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:30,代码来源:QuadPrefixTree.cs


示例10: CalcBoxByDistFromPt

 public override Rectangle CalcBoxByDistFromPt(Point @from, double distance, SpatialContext ctx)
 {
     Debug.Assert(radius == ctx.GetUnits().EarthRadius());
     if (distance == 0)
         return from.GetBoundingBox();
     return DistanceUtils.CalcBoxByDistFromPtDEG(from.GetY(), from.GetX(), distance, ctx);
 }
开发者ID:ccurrens,项目名称:Spatial4n,代码行数:7,代码来源:GeodesicSphereDistCalc.cs


示例11: CircleImpl

 //we don't have a line shape so we use a rectangle for these axis
 public CircleImpl(Point p, double dist, SpatialContext ctx)
 {
     //We assume any normalization / validation of params already occurred (including bounding dist)
     this.point = p;
     this.distRadius = dist;
     this.ctx = ctx;
     this.enclosingBox = ctx.GetDistCalc().CalcBoxByDistFromPt(point, distRadius, ctx);
 }
开发者ID:ccurrens,项目名称:Spatial4n,代码行数:9,代码来源:CircleImpl.cs


示例12: CircleImpl

 //we don't have a line shape so we use a rectangle for these axis
 public CircleImpl(Point p, double radiusDEG, SpatialContext ctx)
 {
     //We assume any validation of params already occurred (including bounding dist)
     this.ctx = ctx;
     this.point = p;
     this.radiusDEG = radiusDEG;
     this.enclosingBox = ctx.GetDistCalc().CalcBoxByDistFromPt(point, this.radiusDEG, ctx, null);
 }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:9,代码来源:CircleImpl.cs


示例13: ShapeFieldCacheDistanceValueSource

 public ShapeFieldCacheDistanceValueSource(SpatialContext ctx, 
     ShapeFieldCacheProvider<IPoint> provider, IPoint from, double multiplier)
 {
     this.ctx = ctx;
     this.from = from;
     this.provider = provider;
     this.multiplier = multiplier;
 }
开发者ID:apache,项目名称:lucenenet,代码行数:8,代码来源:ShapeFieldCacheDistanceValueSource.cs


示例14: testCircleReset

 public static void testCircleReset(SpatialContext ctx)
 {
     Circle c = ctx.MakeCircle(3, 4, 5);
     Circle c2 = ctx.MakeCircle(5, 6, 7);
     c2.Reset(3, 4, 5); // to c1
     Assert.Equal(c, c2);
     Assert.Equal(c.GetBoundingBox(), c2.GetBoundingBox());
 }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:8,代码来源:TestShapes2D.cs


示例15: SpatialStrategy

	    /// <summary>
	    /// Constructs the spatial strategy with its mandatory arguments.
	    /// </summary>
	    /// <param name="ctx"></param>
	    /// <param name="fieldName"> </param>
	    protected SpatialStrategy(SpatialContext ctx, string fieldName)
		{
			if (ctx == null)
				throw new ArgumentException("ctx is required", "ctx");
			this.ctx = ctx;
			if (string.IsNullOrEmpty(fieldName))
				throw new ArgumentException("fieldName is required", "fieldName");
			this.fieldName = fieldName;
		}
开发者ID:raol,项目名称:lucene.net,代码行数:14,代码来源:SpatialStrategy.cs


示例16: DistanceToShapeValueSource

        private readonly double nullValue;//computed

        public DistanceToShapeValueSource(ValueSource shapeValueSource, IPoint queryPoint,
                                          double multiplier, SpatialContext ctx)
        {
            this.shapeValueSource = shapeValueSource;
            this.queryPoint = queryPoint;
            this.multiplier = multiplier;
            this.distCalc = ctx.DistCalc;
            this.nullValue =
                (ctx.IsGeo ? 180 * multiplier : double.MaxValue);
        }
开发者ID:apache,项目名称:lucenenet,代码行数:12,代码来源:DistanceToShapeValueSource.cs


示例17: BBoxStrategy

        public int precisionStep = 8; // same as solr default

        #endregion Fields

        #region Constructors

        public BBoxStrategy(SpatialContext ctx, String fieldNamePrefix)
            : base(ctx, fieldNamePrefix)
        {
            field_bbox = fieldNamePrefix;
            field_minX = fieldNamePrefix + SUFFIX_MINX;
            field_maxX = fieldNamePrefix + SUFFIX_MAXX;
            field_minY = fieldNamePrefix + SUFFIX_MINY;
            field_maxY = fieldNamePrefix + SUFFIX_MAXY;
            field_xdl = fieldNamePrefix + SUFFIX_XDL;
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:16,代码来源:BBoxStrategy.cs


示例18: GeohashPrefixTree

        public GeohashPrefixTree(SpatialContext ctx, int maxLevels)
            : base(ctx, maxLevels)
        {
            Rectangle bounds = ctx.GetWorldBounds();
            if (bounds.GetMinX() != -180)
                throw new ArgumentException("Geohash only supports lat-lon world bounds. Got " + bounds);
            int MAXP = GetMaxLevelsPossible();
            if (maxLevels <= 0 || maxLevels > MAXP)
                throw new ArgumentException("maxLen must be [1-" + MAXP + "] but got " + maxLevels);

        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:11,代码来源:GeohashPrefixTree.cs


示例19: testMakeRect

        public void testMakeRect(SpatialContext ctx)
        {
            this.ctx = ctx;

            //test rectangle constructor
            Assert.Equal(new RectangleImpl(1, 3, 2, 4),
                new RectangleImpl(new PointImpl(1, 2), new PointImpl(3, 4)));

            //test ctx.makeRect
            Assert.Equal(ctx.MakeRect(1, 3, 2, 4),
                ctx.MakeRect(ctx.MakePoint(1, 2), ctx.MakePoint(3, 4)));
        }
开发者ID:ccurrens,项目名称:Spatial4n,代码行数:12,代码来源:AbstractTestShapes.cs


示例20: GetTestQueries

        /**
         * Get Test Queries.  The InputStream is closed.
         */
        public static IEnumerator<SpatialTestQuery> GetTestQueries(
            SpatialArgsParser parser,
            SpatialContext ctx,
            string name,
            Stream @in)
        {

            List<SpatialTestQuery> results = new List<SpatialTestQuery>();

            TextReader bufInput = new StreamReader(@in, Encoding.UTF8);
            try
            {
                String line;
                for (int lineNumber = 1; (line = bufInput.ReadLine()) != null; lineNumber++)
                {
                    SpatialTestQuery test = new SpatialTestQuery();
                    test.line = line;
                    test.lineNumber = lineNumber;

                    try
                    {
                        // skip a comment
                        if (line.StartsWith("[", StringComparison.Ordinal))
                        {
                            int idx2 = line.IndexOf(']');
                            if (idx2 > 0)
                            {
                                line = line.Substring(idx2 + 1);
                            }
                        }

                        int idx = line.IndexOf('@');
                        StringTokenizer st = new StringTokenizer(line.Substring(0, idx - 0));
                        while (st.HasMoreTokens())
                        {
                            test.ids.Add(st.NextToken().Trim());
                        }
                        test.args = parser.Parse(line.Substring(idx + 1).Trim(), ctx);
                        results.Add(test);
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("invalid query line: " + test.line, ex);
                    }
                }
            }
            finally
            {
                bufInput.Dispose();
            }
            return results.GetEnumerator();
        }
开发者ID:apache,项目名称:lucenenet,代码行数:55,代码来源:SpatialTestQuery.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Spine.AnimationState类代码示例发布时间:2022-05-26
下一篇:
C# SparkleShare.SparklePlugin类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap