本文整理汇总了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)));
}
示例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;
}
示例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;
}
示例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();
}
}
示例5: GetCentroidTest
public void GetCentroidTest()
{
BoundingBox b1 = new BoundingBox(20, 30, 40, 55);
Assert.AreEqual(new Point(30, 42.5), b1.GetCentroid());
}
示例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
};
}
示例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);
}
示例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();
}
}
示例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
};
}