public void CreatePage(int quadKey) { //不重复生成 rwl.EnterReadLock(); try { if (AddressMapping.ContainsKey(quadKey) && AddressMapping[quadKey].tileStatus == TileStatus.Loading) { return; } } finally { rwl.ExitReadLock(); } PhysicalTileInfo info = new PhysicalTileInfo(); info.tileStatus = TileStatus.Loading; rwl.EnterWriteLock(); try { info.QuadKey = quadKey; AddressMapping[quadKey] = info; tileGenerator.GeneratePageTask(quadKey); } finally { rwl.ExitWriteLock(); } }
//找到最深miplevel的可用quadtree page private int SearchPage(int x, int y, int targetMip, int quadKey) { if (!Contains(x, y, quadKey)) { return(-1); } int currMip = getMip(quadKey); if (currMip > targetMip) { int[] childs = getChilds(quadKey); foreach (var child in childs) { int page = SearchPage(x, y, targetMip, child); if (page != -1) { return(page); } } } rwl.EnterReadLock(); try { if (AddressMapping.ContainsKey(quadKey) && AddressMapping[quadKey].tileStatus == TileStatus.LoadingComplete) { return(quadKey); } else { return(-1); } } finally { rwl.ExitReadLock(); } //找到指定深度 }