C# Class GPSTD_RM.BingMapsTiles

Manages a map tile cache. The class does not only manage a cache of map tiles but is also responsible for acquiring them from the Bing REST service.
Show file Open project: dideler/gps-tower-defense Class Usage Examples

Private Properties

Property Type Description
CancelActiveRequestsAndResetImages void
GetActivePlaneImages void
MoveToNextPhase void
SetTileImage void

Public Methods

Method Description
BingMapsTiles ( string bingMapKey, Microsoft.Xna.Framework.Graphics.Texture2D unavailableImage, SpriteBatch spriteBatch, Vector2 tileDimensions, int planeDimension ) : System

Initialize new Bing Maps tiles object.

Dispose ( ) : void

Delete all files the cache created and clear the active tile cube.

GetImageFromServer ( TileInformation requestInformation, GeoCoordinate centerCoordinate, int zoomLevel, BingMapsViewType viewType ) : void

Asynchronously gets a tile image from the Bing maps REST service.

InitializeActiveTilePlane ( GeoCoordinate centerGeocoordinate ) : void

Initializes the active tiles by requesting the images required in order to center the display at the specified geo-coordinate. If there are ongoing image requests, they will be cancelled first.

TileServerRequestCompleted ( object sender, OpenReadCompletedEventArgs e ) : void

Place images received from the REST service in the proper place in the active tile cube, and save them to the cache.

this ( int x, int y ) : TileInformation

Returns the tile information for the specified coordinates on the active tile plane.

The possible values supplied for x and y are under the assumption that ActiveTilePlaneSize is 5.

Private Methods

Method Description
CancelActiveRequestsAndResetImages ( ) : void

Cancels all currently ongoing tile image requests, and disposes of all current tile images.

GetActivePlaneImages ( GeoCoordinate centerCoordinate ) : void

Initializes the active tile plane by requesting images centered at the specified geo-coordinate.

MoveToNextPhase ( ) : void

Moves to the next phase of action when a previous phase completes.

SetTileImage ( OpenReadCompletedEventArgs e, TileInformation tileInformation ) : void

Sets the image from the image stream contained in the supplied asynchronous as the image for the tile represented by the supplied tile information. The image stream will be closed.

Method Details

BingMapsTiles() public method

Initialize new Bing Maps tiles object.
public BingMapsTiles ( string bingMapKey, Microsoft.Xna.Framework.Graphics.Texture2D unavailableImage, SpriteBatch spriteBatch, Vector2 tileDimensions, int planeDimension ) : System
bingMapKey string The key used to access the Bing maps service.
unavailableImage Microsoft.Xna.Framework.Graphics.Texture2D The image to display in tiles for which an actual image is /// unavailable.
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch A sprite batch that can be used to draw to the display.
tileDimensions Vector2 The dimensions of a map tile. These will be used as the map dimensions /// for REST service requests.
planeDimension int The size of the active tile plane. Must be an odd number and /// larger than 0.
return System

Dispose() public method

Delete all files the cache created and clear the active tile cube.
public Dispose ( ) : void
return void

GetImageFromServer() public method

Asynchronously gets a tile image from the Bing maps REST service.
public GetImageFromServer ( TileInformation requestInformation, GeoCoordinate centerCoordinate, int zoomLevel, BingMapsViewType viewType ) : void
requestInformation TileInformation The tile information which is to handle the request and receive the /// image.
centerCoordinate GeoCoordinate The geo-coordinate which should serve as the image center.
zoomLevel int The desired image zoom level.
viewType BingMapsViewType The desired image view type.
return void

InitializeActiveTilePlane() public method

Initializes the active tiles by requesting the images required in order to center the display at the specified geo-coordinate. If there are ongoing image requests, they will be cancelled first.
public InitializeActiveTilePlane ( GeoCoordinate centerGeocoordinate ) : void
centerGeocoordinate GeoCoordinate
return void

TileServerRequestCompleted() public method

Place images received from the REST service in the proper place in the active tile cube, and save them to the cache.
public TileServerRequestCompleted ( object sender, OpenReadCompletedEventArgs e ) : void
sender object
e System.Net.OpenReadCompletedEventArgs
return void

this() public method

Returns the tile information for the specified coordinates on the active tile plane.
The possible values supplied for x and y are under the assumption that ActiveTilePlaneSize is 5.
Either x or y are out of bounds.
public this ( int x, int y ) : TileInformation
x int X-coordinate of the desired tile. Must be between 0 and 4 inclusive.
y int Y-coordinate of the desired tile. Must be between 0 and 4 inclusive.
return TileInformation