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


C# Geometry.GetBoundingBox方法代码示例

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


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

示例1: CreateLabel

        private static BaseLabel CreateLabel(Geometry feature, string text, float rotation, int priority, LabelStyle style, Map map,
                                  Graphics g)
        {
            BaseLabel lbl = null;

            SizeF size = VectorRenderer.SizeOfString(g, text, style.Font);

            if (feature is ILineal)
            {
                var line = feature as LineString;
                if (line != null)
                {
                    if (size.Width < 0.95 * line.Length / map.PixelWidth || !style.IgnoreLength)
                    {
                        var positiveLineString = PositiveLineString(line, false);
                        var lineStringPath = LineStringToPath(positiveLineString, map /*, false*/);
                        var rect = lineStringPath.GetBounds();

                        if (style.CollisionDetection && !style.CollisionBuffer.IsEmpty)
                        {
                            var cbx = style.CollisionBuffer.Width;
                            var cby = style.CollisionBuffer.Height;
                            rect.Inflate(2*cbx, 2*cby);
                            rect.Offset(-cbx, -cby);
                        }
                        var labelBox = new LabelBox(rect);

                        lbl = new PathLabel(text, lineStringPath, 0, priority, labelBox, style);
                    }
                }
                return lbl;
            }
            
            PointF position = Transform.WorldtoMap(feature.GetBoundingBox().GetCentroid(), map);

            position.X = position.X - size.Width*(short) style.HorizontalAlignment*0.5f;
            position.Y = position.Y - size.Height*(short) (2-(int)style.VerticalAlignment)*0.5f;
            if (position.X - size.Width > map.Size.Width || position.X + size.Width < 0 ||
                position.Y - size.Height > map.Size.Height || position.Y + size.Height < 0)
                return null;

            if (!style.CollisionDetection)
                lbl = new Label(text, position, rotation, priority, null, style);
            else
            {
                //Collision detection is enabled so we need to measure the size of the string
                lbl = new Label(text, position, rotation, priority,
                                new LabelBox(position.X - size.Width*0.5f - style.CollisionBuffer.Width,
                                             position.Y + size.Height*0.5f + style.CollisionBuffer.Height,
                                             size.Width + 2f*style.CollisionBuffer.Width,
                                             size.Height + style.CollisionBuffer.Height*2f), style);
            }

            /*
            if (feature is LineString)
            {
                var line = feature as LineString;

                //Only label feature if it is long enough, or it is definately wanted                
                if (line.Length / map.PixelSize > size.Width || style.IgnoreLength)
                {
                    CalculateLabelOnLinestring(line, ref lbl, map);
                }
                else
                    return null;
            }
            */
            return lbl;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:69,代码来源:LabelLayer.cs

示例2: Union

 public virtual BoundingBox Union(Geometry theGeom)
 {
     if (theGeom == null) return GetBoundingBox();
     return GetBoundingBox().Union(theGeom.GetBoundingBox());
 }
开发者ID:knji,项目名称:mvvmcross.plugins,代码行数:5,代码来源:Geometry.cs

示例3: Within

		/// <summary>
		/// Returns true if the primary geometry is wholly contained 
		/// within the comparison geometry.
		/// </summary>
		/// <param name="g1"></param>
		/// <param name="g2"></param>
		/// <returns></returns>
		public static bool Within(Geometry g1, Geometry g2)
		{
		    if (g1 == null) throw new ArgumentNullException("g1");
		    if (g2 == null) throw new ArgumentNullException("g2");

            // HACK: fake spatial relation using BoundingBox instances. Shhh...
		    return g2.GetBoundingBox().Contains(g2.GetBoundingBox());
		}
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:15,代码来源:SpatialRelations.cs

示例4: Intersects

		/// <summary>
		/// Returns true if there is any intersection between the two geometries.
		/// </summary>
		/// <param name="g1"></param>
		/// <param name="g2"></param>
		/// <returns></returns>
		public static bool Intersects(Geometry g1, Geometry g2)
		{
#warning BoundingBox intersection is wrong, wrong, wrong, but it won't be fixed until we use NTS

			if (g1 == null || g2 == null)
			{
				return false;
			}

			if (g1 == g2)
			{
				return true;
			}

			return g1.GetBoundingBox().Intersects(g2.GetBoundingBox());
		}
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:22,代码来源:SpatialRelations.cs

示例5: ExecuteIntersectionQuery

 /// <summary>
 /// Returns the data associated with all the geometries that are intersected by 'geom'
 /// </summary>
 /// <param name="geometry">Geometry to intersect with</param>
 /// <param name="ds">FeatureDataSet to fill data into</param>
 public void ExecuteIntersectionQuery(Geometry geometry, FeatureDataSet ds)
 {
     ExecuteIntersectionQuery(geometry.GetBoundingBox(), ds);
 }
开发者ID:goranpavlovic,项目名称:Gis,代码行数:9,代码来源:GdalRasterLayer.cs

示例6: CreateLabel

        private static Label CreateLabel(Geometry feature, string text, float rotation, int priority, LabelStyle style, Map map,
                                  Graphics g)
        {
            //SizeF size = g.MeasureString(text, style.Font);

            SizeF size = VectorRenderer.SizeOfString(g, text, style.Font);
            //PointF position = map.WorldToImage(feature.GetBoundingBox().GetCentroid());
            PointF position = Transform.WorldtoMap(feature.GetBoundingBox().GetCentroid(), map);

            position.X = position.X - size.Width*(short) style.HorizontalAlignment*0.5f;
            position.Y = position.Y - size.Height*(short) (2-(int)style.VerticalAlignment)*0.5f;
            if (position.X - size.Width > map.Size.Width || position.X + size.Width < 0 ||
                position.Y - size.Height > map.Size.Height || position.Y + size.Height < 0)
                return null;

            Label lbl;
            if (!style.CollisionDetection)
                lbl = new Label(text, position, rotation, priority, null, style);
            else
            {
                //Collision detection is enabled so we need to measure the size of the string
                lbl = new Label(text, position, rotation, priority,
                                new LabelBox(position.X - size.Width*0.5f - style.CollisionBuffer.Width,
                                             position.Y + size.Height*0.5f + style.CollisionBuffer.Height,
                                             size.Width + 2f*style.CollisionBuffer.Width,
                                             size.Height + style.CollisionBuffer.Height*2f), style);
            }
            if (feature is LineString)
            {
                LineString line = feature as LineString;

                //Only label feature if it is long enough, or it is definately wanted                
                if (line.Length/map.PixelSize > size.Width || style.IgnoreLength)
                    CalculateLabelOnLinestring(line, ref lbl, map);
                else
                    return null;
            }

            return lbl;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:40,代码来源:LabelLayer.cs

示例7: Difference

        /// <summary>
        /// Returns a geometry that represents the point set difference of this Geometry with anotherGeometry.
        /// </summary>
        public override Geometry Difference(Geometry geometry)
        {
            if (geometry == null) throw new ArgumentNullException("geometry");

            // HACK: fake the difference by using bounding boxes. Broken until we go to NTS in Beta 2
            if (IsEmpty())
            {
                return geometry;
            }

            if (geometry.IsEmpty())
            {
                return this;
            }

            return BoundingBoxOperations.Difference(GetBoundingBox(), geometry.GetBoundingBox());
        }
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:20,代码来源:Polygon.cs


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