static public Geography FromCache(int geographyId) { lock (loadCacheLock) { return(Geography.FromBasic(GeographyCache.GetGeography(geographyId))); } }
static public BasicGeography[] GetGeographyLine(int leafGeographyId) { List <BasicGeography> result = new List <BasicGeography>(); BasicGeography currentNode = GeographyCache.GetGeography(leafGeographyId); // This iterates until the zero-parentid root node is found while (currentNode.GeographyId != 0) { result.Add(currentNode); if (currentNode.ParentGeographyId != 0) { currentNode = GeographyCache.GetGeography(currentNode.ParentGeographyId); } else { currentNode = new BasicGeography(0, 0, string.Empty); } } result.Reverse(); return(result.ToArray()); }
public static int CountGeographyChildren(int parentGeographyId) { lock (loadCacheLock) { // Prime the cache BasicGeography partent = GeographyCache.GetGeography(parentGeographyId); return(GetHashedGeographies()[parentGeographyId].Count - 1); } }
static public BasicGeography[] GetGeographies(int[] ids) { List <BasicGeography> result = new List <BasicGeography>(); lock (loadCacheLock) { foreach (int i in ids) { result.Add(GeographyCache.GetGeography(i)); } return(result.ToArray()); } }
static public BasicGeography[] GetGeographyChildren(int parentGeographyId) { List <BasicGeography> result = new List <BasicGeography>(); lock (loadCacheLock) { // Prime the cache BasicGeography partent = GeographyCache.GetGeography(parentGeographyId); //TODO: Possible to miss a child geography here if it was added since last cache reload. Dictionary <int, List <BasicGeography> > hashedGeographies = GetHashedGeographies(); foreach (BasicGeography b in hashedGeographies[parentGeographyId]) { if (b.Identity != parentGeographyId) { result.Add(b); } } return(result.ToArray()); } }