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


C# Bounds.Extend方法代码示例

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


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

示例1: ComputeBounds

        /// <summary>
        /// Computes the bounding box for the given object.
        /// Note that this method walks the object's DOM, so may have poor performance for large objects.
        /// </summary>
        /// <param name="kmlFeature">{KmlFeature|KmlGeometry} object The feature or geometry whose bounds should be computed</param>
        /// <returns>A bounds object based on the <paramref name="kmlFeature"/> (or an empty bounds object)</returns>
        /// <remarks>
        /// Based on the methods at:
        /// http://code.google.com/p/earth-api-utility-library/source/browse/trunk/extensions/src/dom/utils.js
        /// </remarks>
        public static Bounds ComputeBounds(dynamic kmlFeature)
        {
            Bounds bounds = new Bounds();
            Action<dynamic> eachNode = feature =>
            {
                ApiType type = GEHelpers.GetApiType(feature);
                switch (type)
                {
                    case ApiType.KmlGroundOverlay:
                        dynamic llb = feature.getLatLonBox();

                        if (llb != null)
                        {
                            double alt = feature.getAltitude();
                            bounds.Extend(new Coordinate(llb.getNorth(), llb.getEast(), alt));
                            bounds.Extend(new Coordinate(llb.getNorth(), llb.getWest(), alt));
                            bounds.Extend(new Coordinate(llb.getSouth(), llb.getEast(), alt));
                            bounds.Extend(new Coordinate(llb.getSouth(), llb.getWest(), alt));
                        }

                        break;

                    case ApiType.KmlModel:
                        bounds.Extend(new Coordinate(feature.getLocation()));
                        break;

                    case ApiType.KmlLinearRing:
                    case ApiType.KmlLineString:
                        dynamic coords = feature.getCoordinates();

                        if (coords != null)
                        {
                            int count = coords.getLength();
                            for (int i = 0; i < count; i++)
                            {
                                bounds.Extend(new Coordinate(coords.get(i)));
                            }
                        }

                        break;

                    case ApiType.KmlCoord:
                    case ApiType.KmlLocation:
                    case ApiType.KmlPoint:
                        bounds.Extend(new Coordinate(feature));
                        break;

                    case ApiType.KmlPlacemark:
                        dynamic geometry = feature.getGeometry();
                        if (GEHelpers.IsApiType(geometry, ApiType.KmlPoint))
                        {
                            bounds.Extend(new Coordinate(geometry));
                        }

                        break;
                }
            };

            KmlHelpers.WalkKmlDom(kmlFeature, eachNode, true, true);

            return bounds;
        }
开发者ID:kaptaniderya,项目名称:winforms-geplugin-control-library,代码行数:72,代码来源:KmlHelpers.cs


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