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


C# Shape.GetBoundingBox方法代码示例

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


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

示例1: CalcDistanceFromErrPct

 /// <summary>
 /// Computes the distance given a shape and the {@code distErrPct}.  The
 /// algorithm is the fraction of the distance from the center of the query
 /// shape to its furthest bounding box corner.
 /// </summary>
 /// <param name="shape">Mandatory.</param>
 /// <param name="distErrPct">0 to 0.5</param>
 /// <param name="ctx">Mandatory</param>
 /// <returns>A distance (in degrees).</returns>
 public static double CalcDistanceFromErrPct(Shape shape, double distErrPct, SpatialContext ctx)
 {
     if (distErrPct < 0 || distErrPct > 0.5)
     {
         throw new ArgumentException("distErrPct " + distErrPct + " must be between [0 to 0.5]", "distErrPct");
     }
     if (distErrPct == 0 || shape is Point)
     {
         return 0;
     }
     Rectangle bbox = shape.GetBoundingBox();
     //The diagonal distance should be the same computed from any opposite corner,
     // and this is the longest distance that might be occurring within the shape.
     double diagonalDist = ctx.GetDistCalc().Distance(
         ctx.MakePoint(bbox.GetMinX(), bbox.GetMinY()), bbox.GetMaxX(), bbox.GetMaxY());
     return diagonalDist*0.5*distErrPct;
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:26,代码来源:SpatialArgs.cs

示例2: GetMaxLevelForPrecision

		/**
		 * See {@link com.spatial4j.core.query.SpatialArgs#getDistPrecision()}.
		 * A grid level looked up via {@link #getLevelForDistance(double)} is returned.
		 *
		 * @param shape
		 * @param precision 0-0.5
		 * @return 1-maxLevels
		 */
		public int GetMaxLevelForPrecision(Shape shape, double precision)
		{
			if (precision < 0 || precision > 0.5)
			{
				throw new ArgumentException("Precision " + precision + " must be between [0-0.5]", "precision");
			}
			if (precision == 0 || shape is Point)
			{
				return maxLevels;
			}
			double bboxArea = shape.GetBoundingBox().GetArea(ctx);
			if (bboxArea == 0)
			{
				return maxLevels;
			}
			double avgSideLenFromCenter = Math.Sqrt(bboxArea) / 2;
			return GetLevelForDistance(avgSideLenFromCenter * precision);
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:26,代码来源:SpatialPrefixTree.cs

示例3: MakeRecipDistanceValueSource

 /// <summary>
 /// Returns a ValueSource with values ranging from 1 to 0, depending inversely
 /// on the distance from {@link #makeDistanceValueSource(com.spatial4j.core.shape.Point)}.
 /// The formula is <c>c/(d + c)</c> where 'd' is the distance and 'c' is
 /// one tenth the distance to the farthest edge from the center. Thus the
 /// scores will be 1 for indexed points at the center of the query shape and as
 /// low as ~0.1 at its furthest edges.
 /// </summary>
 /// <param name="queryShape"></param>
 /// <returns></returns>
 public ValueSource MakeRecipDistanceValueSource(Shape queryShape)
 {
     Rectangle bbox = queryShape.GetBoundingBox();
     double diagonalDist = ctx.GetDistCalc().Distance(
         ctx.MakePoint(bbox.GetMinX(), bbox.GetMinY()), bbox.GetMaxX(), bbox.GetMaxY());
     double distToEdge = diagonalDist*0.5;
     float c = (float) distToEdge*0.1f; //one tenth
     return new ReciprocalFloatFunction(MakeDistanceValueSource(queryShape.GetCenter()), 1f, c, c);
 }
开发者ID:raol,项目名称:lucene.net,代码行数:19,代码来源:SpatialStrategy.cs

示例4: GetRectangle

 private Rectangle GetRectangle(Shape shape)
 {
     return shape as Rectangle ?? shape.GetBoundingBox();
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:4,代码来源:BBoxStrategyThatSupportsAllShapes.cs

示例5: BufferShape

 /// <summary>Returns a new shape that is larger than shape by at distErr.</summary>
 /// <remarks>Returns a new shape that is larger than shape by at distErr.</remarks>
 protected internal virtual Shape BufferShape(Shape
     shape, double distErr)
 {
     //TODO move this generic code elsewhere?  Spatial4j?
     if (distErr <= 0)
     {
         throw new ArgumentException("distErr must be > 0");
     }
     SpatialContext ctx = grid.SpatialContext;
     if (shape is Point)
     {
         return ctx.MakeCircle((Point)shape, distErr);
     }
     else
     {
         if (shape is Circle)
         {
             var circle = (Circle)shape;
             double newDist = circle.GetRadius() + distErr;
             if (ctx.IsGeo() && newDist > 180)
             {
                 newDist = 180;
             }
             return ctx.MakeCircle(circle.GetCenter(), newDist);
         }
         else
         {
             Rectangle bbox = shape.GetBoundingBox();
             double newMinX = bbox.GetMinX() - distErr;
             double newMaxX = bbox.GetMaxX() + distErr;
             double newMinY = bbox.GetMinY() - distErr;
             double newMaxY = bbox.GetMaxY() + distErr;
             if (ctx.IsGeo())
             {
                 if (newMinY < -90)
                 {
                     newMinY = -90;
                 }
                 if (newMaxY > 90)
                 {
                     newMaxY = 90;
                 }
                 if (newMinY == -90 || newMaxY == 90 || bbox.GetWidth() + 2 * distErr > 360)
                 {
                     newMinX = -180;
                     newMaxX = 180;
                 }
                 else
                 {
                     newMinX = DistanceUtils.NormLonDEG(newMinX);
                     newMaxX = DistanceUtils.NormLonDEG(newMaxX);
                 }
             }
             else
             {
                 //restrict to world bounds
                 newMinX = Math.Max(newMinX, ctx.GetWorldBounds().GetMinX());
                 newMaxX = Math.Min(newMaxX, ctx.GetWorldBounds().GetMaxX());
                 newMinY = Math.Max(newMinY, ctx.GetWorldBounds().GetMinY());
                 newMaxY = Math.Min(newMaxY, ctx.GetWorldBounds().GetMaxY());
             }
             return ctx.MakeRectangle(newMinX, newMaxX, newMinY, newMaxY);
         }
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:67,代码来源:WithinPrefixTreeFilter.cs

示例6: AssertIntersect

        private void AssertIntersect(String msg, SpatialRelation expected, Shape a, Shape b)
        {
            SpatialRelation sect = a.Relate(b, ctx);
            if (sect == expected)
                return;
            if (expected == SpatialRelation.WITHIN || expected == SpatialRelation.CONTAINS)
            {
                if (a.GetType() == b.GetType()) // they are the same shape type
                    Assert.Equal(/*msg,*/ a, b);
                else
                {
                    //they are effectively points or lines that are the same location
                    Assert.True(!a.HasArea(), msg);
                    Assert.True(!b.HasArea(), msg);

                    Rectangle aBBox = a.GetBoundingBox();
                    Rectangle bBBox = b.GetBoundingBox();
                    if (aBBox.GetHeight() == 0 && bBBox.GetHeight() == 0
                        && (aBBox.GetMaxY() == 90 && bBBox.GetMaxY() == 90
                            || aBBox.GetMinY() == -90 && bBBox.GetMinY() == -90))
                    {
                        ; //== a point at the pole
                    }
                    else
                    {
                        Assert.Equal( /*msg,*/ aBBox, bBBox);
                    }
                }
            }
            else
            {
                Assert.Equal(/*msg,*/ expected, sect);
            }
        }
开发者ID:ccurrens,项目名称:Spatial4n,代码行数:34,代码来源:AbstractTestShapes.cs


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