document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. bool Get2HyperNodes(IDictionary<int, IFeature> pIntNodes,
  2. IDictionary<int, IFeature> pExtNodes,
  3. ref IFeature pIntNode1, ref IFeature pIntNode2,
  4. ref IFeature pExtNode1, ref IFeature pExtNode2)
  5. {
  6.     bool result = false;
  7.     double maxDistance = 0.0;
  8.  
  9.     // Loop through all of the internal node features
  10.     foreach (KeyValuePair<int, IFeature> intNode1 in pIntNodes)
  11.     {
  12.         // Look for a corresponding external world feature.  There *should* always be one
  13.         // but in rare cases there’s not
  14.         if (pExtNodes.ContainsKey(intNode1.Key))
  15.         {
  16.             IFeature externalNode1 = pExtNodes[intNode1.Key];
  17.             IFeature internalNode1 = intNode1.Value;
  18.  
  19.             // Compare this node with all other nodes..
  20.             foreach (KeyValuePair<int, IFeature> intNode2 in pIntNodes)
  21.             {
  22.                 // .. except with itself
  23.                 if (intNode2.Key != intNode1.Key)
  24.                 {
  25.                     if (pExtNodes.ContainsKey(intNode2.Key))
  26.                     {
  27.                         IFeature externalNode2 = pExtNodes[intNode2.Key];
  28.                         IFeature internalNode2 = intNode2.Value;
  29.  
  30.                         if (GetDistance(internalNode1, internalNode2) > maxDistance)
  31.                         {
  32.                             pIntNode1 = internalNode1;
  33.                             pExtNode1 = externalNode1;
  34.                             pIntNode2 = internalNode2;
  35.                             pExtNode2 = externalNode2;
  36.                             result = true;
  37.                         }
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.     }
  43.     return result;
  44. }
  45. double GetDistance(IFeature pointFeature1, IFeature pointFeature2)
  46. {
  47.     ILine simpleLine = new ESRI.ArcGIS.Geometry.Line();
  48.     simpleLine.FromPoint = (IPoint)pointFeature1.ShapeCopy;
  49.     simpleLine.ToPoint = (IPoint)pointFeature1.ShapeCopy;
  50.     return simpleLine.Length;
  51. }
');