本文整理汇总了C#中Bounds.Span方法的典型用法代码示例。如果您正苦于以下问题:C# Bounds.Span方法的具体用法?C# Bounds.Span怎么用?C# Bounds.Span使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds
的用法示例。
在下文中一共展示了Bounds.Span方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBoundsView
/// <summary>
/// Creates a kmlLookAt from a Bounds object.
/// </summary>
/// <param name="ge">the plug-in</param>
/// <param name="bounds">the bounds object to create the view of</param>
/// <param name="aspectRatio">Optional aspect ratio</param>
/// <param name="defaultRange">Optional default range</param>
/// <param name="scaleRange">Optional scale range</param>
/// <returns>A KmlLookAt based on the <paramref name="bounds"/> (or null)</returns>
public static dynamic CreateBoundsView(
dynamic ge,
Bounds bounds,
double aspectRatio = 1.0,
double defaultRange = 1000,
double scaleRange = 1.5)
{
Coordinate center = bounds.Center();
Coordinate boundsSpan = bounds.Span();
double lookAtRange = defaultRange;
dynamic lookat = null;
if (Convert.ToBoolean(boundsSpan.Latitude) || Convert.ToBoolean(boundsSpan.Longitude))
{
// Distance - using law of cosines for speed...
double distEW = new Coordinate(center.Latitude, bounds.East)
.Distance(new Coordinate(center.Latitude, bounds.West));
double distNS = new Coordinate(bounds.North, center.Longitude)
.Distance(new Coordinate(bounds.South, center.Longitude));
aspectRatio = Math.Min(Math.Max(aspectRatio, distEW / distNS), 1.0);
// Create a LookAt using the experimentally derived distance formula.
double alpha = Maths.ConvertDegreesToRadians(45.0 / (aspectRatio + 0.4) - 2.0);
double expandToDistance = Math.Max(distNS, distEW);
double beta = Math.Min(
Maths.ConvertDegreesToRadians(90),
alpha + expandToDistance / (2 * Maths.EarthMeanRadiusKilometres));
lookAtRange = scaleRange * Maths.EarthMeanRadiusKilometres *
(Math.Sin(beta) * Math.Sqrt(1 + 1 / Math.Pow(Math.Tan(alpha), 2)) - 1);
}
try
{
lookat = ge.createLookAt(string.Empty);
lookat.set(center.Latitude, center.Longitude, bounds.Top, bounds.Northeast.AltitudeMode, 0, 0, lookAtRange);
}
catch (RuntimeBinderException rbex)
{
Debug.WriteLine("CreateBoundsView: " + rbex.Message, "KmlHelpers");
}
return lookat;
}