本文整理汇总了C#中Cluster.InsertDeco方法的典型用法代码示例。如果您正苦于以下问题:C# Cluster.InsertDeco方法的具体用法?C# Cluster.InsertDeco怎么用?C# Cluster.InsertDeco使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cluster
的用法示例。
在下文中一共展示了Cluster.InsertDeco方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GatherIntoClusters
/**
* @brief Gather the separate decoded characters into clusters.
*/
private static void GatherIntoClusters ()
{
while (allDecos.Count > 0) {
/*
* Find leftmost character.
*/
Deco deco = allDecos.First.Value;
allDecos.RemoveFirst ();
bool debug = false; // (deco.x >= 1420) && (deco.x <= 1540) && (deco.y >= 2210) && (deco.y <= 2250);
if (debug) Console.WriteLine ("GatherIntoClusters*: " + deco.x + "," + deco.y + " <" + deco.c + ">");
/*
* Sometimes there are stray marks around that look like ' and ..
* Skip over them so they don't obscure a nearby legitimate number.
* See BAB 39^07'N.
*/
if ((deco.c == '\'') || (deco.c == '.')) continue;
/*
* Create a cluster for it.
*/
Cluster cluster = new Cluster ();
cluster.vertical = landscape;
/*
* Append first character to cluster and likewise with all
* subsequent nearby characters to its right that overlap on
* the Y axis.
*/
useit:
if (debug) Console.WriteLine ("GatherIntoClusters*: " + deco.c);
cluster.InsertDeco (deco);
if ((deco.c == 'N') || (deco.c == 'S') || (deco.c == 'E') || (deco.c == 'W')) goto endclus;
for (LinkedListNode<Deco> ptr = allDecos.First; ptr != null; ptr = ptr.Next) {
Deco dd = ptr.Value; // scan by ascending X value
if (debug) Console.WriteLine ("GatherIntoClusters*: ? " + dd.c + " " + dd.x + "," + dd.y);
if (dd.x > cluster.hix + MAXGAP) break; // if too far right, nothing more can match
if (dd.x < cluster.hix - 2) continue; // if too far left, just ignore it
/*
* We have char dd just to the right of char deco
* but we don't know if they are vertically aligned.
*
* Sometimes we mis-decode an apostrophe as a dot.
* Eg, HOP 36^40'N
* So we have to fix it in context.
*/
int ydiff = dd.y - deco.y;
if (dd.c == '.') {
if ((ydiff >= -YOVER) && (ydiff <= YOVER)) {
// the dot is near the top of the line of chars
dd.c = '\'';
} else {
ydiff += dd.h - deco.h;
if ((ydiff < -YOVER) || (ydiff > YOVER)) continue;
// the dot is near the bottom of the line of chars
}
dd.y = deco.y;
dd.h = deco.h;
} else {
if ((ydiff < -YOVER) || (ydiff > YOVER)) continue;
}
/*
* Remove from allDecos and append to cluster.
*/
allDecos.Remove (ptr);
deco = dd;
goto useit;
}
/*
* If valid size, append to list of all clusters and draw box around it.
*/
endclus:
if (verbose) Console.WriteLine ("cluster " + cluster.lox + "," + cluster.loy + " <" + cluster.Result + ">");
if (cluster.IsLatLon) {
clusters.AddLast (cluster);
}
}
}