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


C# BoundingBox.GetCentroid方法代码示例

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


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

示例1: TestVarious

		public void TestVarious()
		{
			BoundingBox b1 = new BoundingBox(20, 30, 40, 55);
			Assert.AreEqual(20, b1.Left);
			Assert.AreEqual(20, b1.Min.X);
			Assert.AreEqual(40, b1.Right);
			Assert.AreEqual(40, b1.Max.X);
			Assert.AreEqual(30, b1.Bottom);
			Assert.AreEqual(30, b1.Min.Y);
			Assert.AreEqual(55, b1.Top);
			Assert.AreEqual(55, b1.Max.Y);
			Assert.AreEqual(20, b1.Width);
			Assert.AreEqual(25, b1.Height);
			Assert.AreNotSame(b1, b1.Clone());
			Assert.IsTrue(b1.Contains(new Point(30, 40)));
			Assert.IsTrue(b1.Contains(new Point(20, 40)));
			Assert.IsFalse(b1.Contains(new Point(10, 10)));
			Assert.IsFalse(b1.Contains(new Point(50, 60)));
			Assert.IsFalse(b1.Contains(new Point(30, 60)));
			Assert.IsFalse(b1.Contains(new Point(50, 40)));
			Assert.IsFalse(b1.Contains(new Point(30, 15)));
			Assert.IsTrue(b1.Equals(new BoundingBox(20, 30, 40, 55)));
			Assert.AreEqual(new Point(30, 42.5), b1.GetCentroid());
			Assert.AreEqual(1, b1.LongestAxis);
			Assert.AreEqual(new BoundingBox(19, 29, 41, 56), b1.Grow(1));
			Assert.IsFalse(b1.Equals(null));
			Assert.IsFalse(b1.Equals((object)new Polygon()));
			Assert.AreEqual("20,30 40,55", b1.ToString());
			Assert.AreEqual(b1,new BoundingBox(40,55,20,30));
			Assert.AreEqual(Math.Sqrt(200), b1.Distance(new BoundingBox(50,65,60,75)));
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:31,代码来源:BoundingBoxTests.cs

示例2: GetFeaturesInView

 public System.Collections.Generic.IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution)
 {
     var features = new Features();
     IRaster raster = null;
     var view = new Viewport { Resolution = resolution, Center = box.GetCentroid(), Width = (box.Width / resolution), Height = (box.Height / resolution) };
     if (TryGetMap(view, ref raster))
     {
         IFeature feature = features.New();
         feature.Geometry = raster;
         features.Add(feature);
     }
     return features;
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:13,代码来源:ArcGISImageServiceProvider.cs

示例3: GetFeaturesInView

        public IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution)
        {
            //If there are no layers (probably not initialised) return nothing
            if (Capabilities.layers == null)
                return new Features();

            IFeatures features = new Features();
            IRaster raster = null;
            IViewport viewport = new Viewport { Resolution = resolution, Center = box.GetCentroid(), Width = (box.Width / resolution), Height = (box.Height / resolution) };
            if (TryGetMap(viewport, ref raster))
            {
                var feature = features.New();
                feature.Geometry = raster;
                features.Add(feature);
            }
            return features;
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:17,代码来源:ArcGisDynamicProvider.cs

示例4: ZoomToBox

 /// <summary>
 /// Zooms the map to fit a bounding box
 /// </summary>
 /// <remarks>
 /// NOTE: If the aspect ratio of the box and the aspect ratio of the mapsize
 /// isn't the same, the resulting map-envelope will be adjusted so that it contains
 /// the bounding box, thus making the resulting envelope larger!
 /// </remarks>
 /// <param name="bbox"></param>
 public void ZoomToBox(BoundingBox bbox)
 {
     if (bbox != null)
     {
         _Zoom = bbox.Width; //Set the private center value so we only fire one MapOnViewChange event
         if (Envelope.Height < bbox.Height)
             _Zoom *= bbox.Height / Envelope.Height;
         Center = bbox.GetCentroid();
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:Map.cs

示例5: GetCentroidTest

		public void GetCentroidTest()
		{
			BoundingBox b1 = new BoundingBox(20, 30, 40, 55);
			Assert.AreEqual(new Point(30, 42.5), b1.GetCentroid());
		}
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:5,代码来源:BoundingBoxTests.cs

示例6: CreateViewport

 private static Viewport CreateViewport(BoundingBox extent, double resolution, double renderResolutionMultiplier, double overscan)
 {
     var renderResolution = resolution / renderResolutionMultiplier;
     return new Viewport
     {
         Resolution = renderResolution,
         Center = extent.GetCentroid(),
         Width = extent.Width * overscan / renderResolution,
         Height = extent.Height * overscan / renderResolution
     };
 }
开发者ID:johnnythinkgeo,项目名称:Mapsui,代码行数:11,代码来源:RasterizingLayer.cs

示例7: NavigateTo

        public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit)
        {
            Viewport.Resolution = ZoomHelper.DetermineResolution(
                extent.Width, extent.Height, Viewport.Width, Viewport.Height, scaleMethod);
            Viewport.Center = extent.GetCentroid();

            OnRefreshGraphics();
            ViewChanged(true);
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:9,代码来源:Map.cs

示例8: ZoomToBox

 /// <summary>
 /// Zooms the map to fit a bounding box
 /// </summary>
 /// <remarks>
 /// NOTE: If the aspect ratio of the box and the aspect ratio of the mapsize
 /// isn't the same, the resulting map-envelope will be adjusted so that it contains
 /// the bounding box, thus making the resulting envelope larger!
 /// </remarks>
 /// <param name="bbox"></param>
 public void ZoomToBox(BoundingBox bbox)
 {
     if (bbox != null && bbox.IsValid)
     {
         
         _Zoom = bbox.Width; //Set the private center value so we only fire one MapOnViewChange event
         if (Envelope.Height < bbox.Height && Envelope.Height > 0)
             _Zoom *= bbox.Height / Envelope.Height;
         if (_Zoom < _MinimumZoom)
             _Zoom = _MinimumZoom;
         if (_Zoom > _MaximumZoom)
             _Zoom = _MaximumZoom;
         Center = bbox.GetCentroid();
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:24,代码来源:Map.cs

示例9: CreateViewport

 private static Viewport CreateViewport(BoundingBox extent, double resolution)
 {
     return new Viewport
         {
             Resolution = resolution,
             Center = extent.GetCentroid(),
             Width = extent.Width/resolution,
             Height = extent.Height/resolution
         };
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:10,代码来源:RasterizingProvider.cs


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