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


C# Bounds.Center方法代码示例

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


在下文中一共展示了Bounds.Center方法的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;
        }
开发者ID:kaptaniderya,项目名称:winforms-geplugin-control-library,代码行数:55,代码来源:KmlHelpers.cs


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