Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. // Pass in a dictionary of internal and external hypernode features, with the index
  2. // being the Smallworld identifier, and return a pair of internal nodes and corresponding
  3. // external nodes
  4. bool Get2HyperNodes(IDictionary<int, IFeature> pIntNodes,
  5. IDictionary<int, IFeature> pExtNodes,
  6. ref IFeature pIntNode1, ref IFeature pIntNode2,
  7. ref IFeature pExtNode1, ref IFeature pExtNode2)
  8. {
  9. bool result = false;
  10. double maxDistance = 0.0;
  11.  
  12. // Loop through all of the internal node features
  13. foreach (KeyValuePair<int, IFeature> intNode1 in pIntNodes)
  14. {
  15. // Look for a corresponding external world feature.  There *should* always be one
  16. // but in rare cases there’s not
  17. if (pExtNodes.ContainsKey(intNode1.Key))
  18. {
  19. IFeature externalNode1 = pExtNodes[intNode1.Key];
  20. IFeature internalNode1 = intNode1.Value;
  21.  
  22. // Compare this node with all other nodes..
  23. foreach (KeyValuePair<int, IFeature> intNode2 in pIntNodes)
  24. {
  25.     // .. except with itself
  26. if (intNode2.Key != intNode1.Key)
  27. {
  28. if (pExtNodes.ContainsKey(intNode2.Key))
  29. {
  30. IFeature externalNode2 = pExtNodes[intNode2.Key];
  31. IFeature internalNode2 = intNode2.Value;
  32.  
  33. if (GetDistance(internalNode1, internalNode2) > maxDistance)
  34. {
  35. pIntNode1 = internalNode1;
  36. pExtNode1 = externalNode1;
  37. pIntNode2 = internalNode2;
  38. pExtNode2 = externalNode2;
  39. result = true;
  40. }
  41. }
  42. }
  43. }  
  44. }
  45. }
  46. return result;
  47. }
  48. double GetDistance(IFeature pointFeature1, IFeature pointFeature2)
  49. {
  50. ILine simpleLine = new ESRI.ArcGIS.Geometry.Line();
  51. simpleLine.FromPoint = (IPoint) pointFeature1.ShapeCopy;
  52. simpleLine.ToPoint = (IPoint)pointFeature1.ShapeCopy;
  53. return simpleLine.Length;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement