public static HashSet <uint> Search(this GeometricGraph graph, int n, float minLatitude, float minLongitude, float maxLatitude, float maxLongitude) { List <long> longList = HilbertCurve.HilbertDistances(System.Math.Max(minLatitude, -90f), System.Math.Max(minLongitude, -180f), System.Math.Min(maxLatitude, 90f), System.Math.Min(maxLongitude, 180f), (long)n); longList.Sort(); HashSet <uint> uintSet = new HashSet <uint>(); int index = 0; uint vertex1 = 0; uint vertex2 = graph.VertexCount - 1U; for (; index < longList.Count && vertex1 < graph.VertexCount; ++index) { long num1 = longList[index]; long maxHilbert; for (maxHilbert = num1; index < longList.Count - 1 && longList[index + 1] <= maxHilbert + 1L; ++index) { maxHilbert = longList[index + 1]; } uint vertex; int count; float latitude; float longitude; if (num1 == maxHilbert) { if (graph.Search(num1, n, vertex1, vertex2, out vertex, out count)) { int num2 = count; for (; count > 0; --count) { if (graph.GetVertex(vertex + (uint)(count - 1), out latitude, out longitude) && (double)minLatitude < (double)latitude && ((double)minLongitude < (double)longitude && (double)maxLatitude > (double)latitude) && (double)maxLongitude > (double)longitude) { uintSet.Add(vertex + (uint)(count - 1)); } } vertex1 = vertex + (uint)num2; } } else if (graph.SearchRange(num1, maxHilbert, n, vertex1, vertex2, out vertex, out count)) { int num2 = count; for (; count > 0; --count) { if (graph.GetVertex(vertex + (uint)(count - 1), out latitude, out longitude) && (double)minLatitude < (double)latitude && ((double)minLongitude < (double)longitude && (double)maxLatitude > (double)latitude) && (double)maxLongitude > (double)longitude) { uintSet.Add(vertex + (uint)(count - 1)); } } vertex1 = vertex + (uint)num2; } } return(uintSet); }