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


C# Cluster.SetCenter方法代码示例

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


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

示例1: BuildXformMatrix

    /**
     * @brief Build and print latlon <-> pixel transformation matrix.
     */
    private static void BuildXformMatrix ()
    {
        if (verbose) {
            Console.WriteLine ("assuming " + (landscape ? "landscape" : "portrait") + " orientation");
        }

        /*
         * Tell each cluster what the decided orientation is, in case they are confused
         * (ie, at the intersection of a vertical and horizontal line).
         */
        foreach (Cluster cluster in clusters) {
            cluster.SetOrientation (landscape);
        }

        /*
         * Find the lowest and highest lon's and lat's.
         */
        Cluster highestLat = null;
        Cluster highestLon = null;
        Cluster lowestLat  = null;
        Cluster lowestLon  = null;
        foreach (Cluster cluster in clusters) {
            if ((cluster.CenterX == 0) && (cluster.CenterY == 0)) continue;
            double lat = cluster.Latitude;
            double lon = cluster.Longitude;
            if (lat != 0) {
                if ((highestLat == null) || (highestLat.Latitude < lat)) highestLat = cluster;
                if ((lowestLat  == null) || (lowestLat.Latitude  > lat)) lowestLat  = cluster;
            }
            if (lon != 0) {
                if ((highestLon == null) || (highestLon.Longitude < lon)) highestLon = cluster;
                if ((lowestLon  == null) || (lowestLon.Longitude  > lon)) lowestLon  = cluster;
            }
        }

        if (verbose) {
            Console.WriteLine ("raw  lowestLat = " + (lowestLat  == null ? "null" : lowestLat.Latitude.ToString ()));
            Console.WriteLine ("raw highestLat = " + (highestLat == null ? "null" : highestLat.Latitude.ToString ()));
            Console.WriteLine ("raw  lowestLon = " + (lowestLon  == null ? "null" : lowestLon.Longitude.ToString ()));
            Console.WriteLine ("raw highestLon = " + (highestLon == null ? "null" : highestLon.Longitude.ToString ()));
        }

        /*
         * If fewer than two of each complain.
         * But some charts only have one of one of them (two of the other),
         * so we can fake them by assuming 1:1 pixel ratio.
         */
        string oneLinerValue = null;
        if ((lowestLat == highestLat) || (lowestLon == highestLon)) {
            if ((lowestLat == null) || (lowestLon == null) ||
                ((lowestLat == highestLat) && (lowestLon == highestLon)) ||
                !oneLiners.TryGetValue (lowestLat.Result + "," + lowestLon.Result, out oneLinerValue)) {
                throw new Exception ("fewer than two lats or lons found");
            }
        }

        /*
         * Just one latitude given, make second one by using the given two longitude lines.
         */
        if (highestLat == lowestLat) {
            Cluster madeUpLat = new Cluster (oneLinerValue);
            double f = madeUpLat.Latitude - lowestLat.Latitude;
            f /= highestLon.Longitude - lowestLon.Longitude;
            f /= Math.Cos ((lowestLat.Latitude + madeUpLat.Latitude) / 360.0 * Math.PI);
            int madeUpLatPixX = (int)((highestLon.CenterY - lowestLon.CenterY) * f + 0.5) + lowestLat.CenterX;
            int madeUpLatPixY = (int)((highestLon.CenterX - lowestLon.CenterX) * f + 0.5) + lowestLat.CenterY;
            madeUpLat.SetCenter (madeUpLatPixX, madeUpLatPixY);
            clusters.AddLast (madeUpLat);
            if (madeUpLat.Latitude > lowestLat.Latitude) {
                highestLat = madeUpLat;
            } else {
                lowestLat = madeUpLat;
            }
        }

        /*
         * Just one longitude given, make second one by using the given two latitude lines.
         */
        if (highestLon == lowestLon) {
            Cluster madeUpLon = new Cluster (oneLinerValue);
            double f = madeUpLon.Longitude - lowestLon.Longitude;
            f /= highestLat.Latitude - lowestLat.Latitude;
            f *= Math.Cos ((lowestLat.Latitude + highestLat.Latitude) / 360.0 * Math.PI);
            int madeUpLonPixX = (int)((lowestLat.CenterY - highestLat.CenterY) * f + 0.5) + lowestLon.CenterX;
            int madeUpLonPixY = (int)((lowestLat.CenterX - highestLat.CenterX) * f + 0.5) + lowestLon.CenterY;
            madeUpLon.SetCenter (madeUpLonPixX, madeUpLonPixY);
            clusters.AddLast (madeUpLon);
            if (madeUpLon.Longitude > lowestLon.Longitude) {
                highestLon = madeUpLon;
            } else {
                lowestLon = madeUpLon;
            }
        }

        /*
         * Extract values.
         */
//.........这里部分代码省略.........
开发者ID:ajluca1984,项目名称:avare,代码行数:101,代码来源:ReadArptDgmPng.cs


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