本文整理汇总了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.
*/
//.........这里部分代码省略.........