bool Get2HyperNodes(IDictionary<int, IFeature> pIntNodes,
IDictionary<int, IFeature> pExtNodes,
ref IFeature pIntNode1, ref IFeature pIntNode2,
ref IFeature pExtNode1, ref IFeature pExtNode2)
{
bool result = false;
double maxDistance = 0.0;
// Loop through all of the internal node features
foreach (KeyValuePair<int, IFeature> intNode1 in pIntNodes)
{
// Look for a corresponding external world feature. There *should* always be one
// but in rare cases there’s not
if (pExtNodes.ContainsKey(intNode1.Key))
{
IFeature externalNode1 = pExtNodes[intNode1.Key];
IFeature internalNode1 = intNode1.Value;
// Compare this node with all other nodes..
foreach (KeyValuePair<int, IFeature> intNode2 in pIntNodes)
{
// .. except with itself
if (intNode2.Key != intNode1.Key)
{
if (pExtNodes.ContainsKey(intNode2.Key))
{
IFeature externalNode2 = pExtNodes[intNode2.Key];
IFeature internalNode2 = intNode2.Value;
if (GetDistance(internalNode1, internalNode2) > maxDistance)
{
pIntNode1 = internalNode1;
pExtNode1 = externalNode1;
pIntNode2 = internalNode2;
pExtNode2 = externalNode2;
result = true;
}
}
}
}
}
}
return result;
}
double GetDistance(IFeature pointFeature1, IFeature pointFeature2)
{
ILine simpleLine = new ESRI.ArcGIS.Geometry.Line();
simpleLine.FromPoint = (IPoint)pointFeature1.ShapeCopy;
simpleLine.ToPoint = (IPoint)pointFeature1.ShapeCopy;
return simpleLine.Length;
}