private void UpdateMapTexture(CombinedMapData mapToUpdate, double elevation)
 {
     CombinedMapData expectedMap = mapFactory.CreateEmptyMapAtLocation(mapToUpdate.BottomLeftLocation, elevation, mapToUpdate.ShapeDelta);
     expectedMap.ZoomLevel = currentZoomLevel;
     if (!expectedMap.IsSameTexture(mapToUpdate))
     {
         mapToUpdate.ZoomLevel = expectedMap.ZoomLevel;
         mapFactory.UpdateMapTexture(mapToUpdate);
     }
 }
 private CombinedMapData SwapTileToNewLocation(CombinedMapData prevTile, LatLong newLocation)
 {
     CombinedMapData newTile = new CombinedMapData(prevTile);
     newTile.BottomLeftLocation = newLocation;
     mapFactory.RetrieveOrUpdateMapTerrain(newTile);
     AddTileToEngine(newTile);
     RemoveTileFromEngine(prevTile);
     UpdateMapTexture(newTile, currentElevation);
     return newTile;
 }
 private bool TerrainUpdateRequired(CombinedMapData currentMap, CombinedMapData expectedMap)
 {
     if (currentMap == null) return true;
     if (expectedMap.IsSameShape(currentMap)) return false;
     return true;
 }
 private void AddTileToEngine(CombinedMapData tile)
 {
     ShapeChangeEventArgs e = new ShapeChangeEventArgs(tile, ShapeChangeEventArgs.ChangeAction.Add);
     FireMapChangedEvent(e);
 }
 private void RemoveTileFromEngine(CombinedMapData tile)
 {
     ShapeChangeEventArgs se = new ShapeChangeEventArgs(tile, ShapeChangeEventArgs.ChangeAction.Remove);
     FireMapChangedEvent(se);
 }
 public CombinedMapData CreateEmptyMapAtLocation(LatLong location, double elevation, double delta)
 {
     CombinedMapData newMap = new CombinedMapData();
     newMap.ShapeDelta = delta;
     newMap.BottomLeftLocation = location;
     newMap.ZoomLevel = EarthProjection.GetZoomFromElevation(elevation);
     return newMap;
 }
 private void AddTileToArray(CombinedMapData tile, int row, int column)
 {
     tile.TextureIndex = row * TILE_COUNT + column + Earth3DControl.TEXTURE_OFFSET;
     CombinedMapData previousTile = currentTiles[row, column];
     if (previousTile == tile)
     {
         return;
     }
     currentTiles[row, column] = tile;
     AddTileToEngine(tile);
 }
 public void UpdateMapTerrain(CombinedMapData mapToUpdate)
 {
     MapDescriptor desc = mapToUpdate.GetMapDescriptor();
     if (!TerrainToProcess.Contains(desc))
     {
         desc.Tag = mapToUpdate;
         TerrainToProcess.Enqueue(desc);
     }
 }
 public void UpdateMapTexture(CombinedMapData mapToUpdate)
 {
     if (mapToUpdate.ZoomLevel > EarthTiles.MaxGoogleZoom) mapToUpdate.ZoomLevel = EarthTiles.MaxGoogleZoom;
     MapDescriptor desc = mapToUpdate.GetMapDescriptor();
     if (!TexturesToProcess.Contains(desc))
         TexturesToProcess.Enqueue(desc);
 }
 public void RetrieveOrUpdateMapTerrain(CombinedMapData newMap)
 {
     MapDescriptor md = new MapDescriptor(
         newMap.BottomLeftLocation.Latitude,
         newMap.BottomLeftLocation.Longitude,
         newMap.ZoomLevel,
         newMap.ShapeDelta);
     if(previouslyCreatedTerrain.ContainsKey(md))
     {
         newMap.CopyShapeFrom(previouslyCreatedTerrain[md]);
         FireMapUpdateCompletedEvent(new ShapeChangeEventArgs(newMap, ShapeChangeEventArgs.ChangeAction.Add));
     }
     else
     {
         UpdateMapTerrain(newMap);
     }
 }
 public bool IsSameShape(CombinedMapData other)
 {
     if (!other.ShapeDelta.Equals(this.ShapeDelta)) return false;
     if (!other.BottomLeftLocation.Equals(this.BottomLeftLocation)) return false;
     return true;
 }
 public bool Equals(CombinedMapData other)
 {
     if (!other.GetMapDescriptor().Equals(desc)) return false;
     if (other.TextureMipMaps != this.TextureMipMaps) return false;
     return base.Equals(other);
 }
 public CombinedMapData(CombinedMapData copy)
     : this()
 {
     desc = new MapDescriptor(copy.BottomLeftLocation.Latitude, copy.BottomLeftLocation.Longitude, copy.ZoomLevel, copy.ShapeDelta);
     this.TextureIndex = copy.TextureIndex;
 }
 public bool IsSameTexture(CombinedMapData other)
 {
     if (other.ShapeDelta != this.ShapeDelta) return false;
     if (!other.BottomLeftLocation.Equals(this.BottomLeftLocation)) return false;
     if (other.ZoomLevel != this.ZoomLevel) return false;
     if (other.TextureImage == null) return false;
     return true;
 }