FileTileCache¶
Namespace: ThinkGeo.Core
A cache on disk for encoded tiles - MVT and the like - one file per tile: {CacheDirectory}\{tileSource}\{zoom}\{x}\{y}.{FileExtension}.
public class FileTileCache
Inheritance object → FileTileCache
Remarks:
The tileSource every call takes says what the tiles come from - the tile URL template of a remote source (what MvtTilesAsyncLayer and VectorTileSource pass), the source id of a feature-source cut (FeatureSourceVectorTileSource) - and names the sub-directory they are kept in, as a short hash of the text, so the tiles of several sources share one cache directory without colliding. Null or empty is one unnamed source. It is not an id the caller has to invent: the source's own identity is the value. The raster caches do the same job with TileCache.CacheId.
Properties¶
FileExtension¶
Gets or sets the FileExtension.
public string FileExtension { get; set; }
Property Value¶
CacheDirectory¶
Gets or sets the CacheDirectory.
public string CacheDirectory { get; set; }
Property Value¶
ExpirationTime¶
Gets or sets the ExpirationTime.
public TimeSpan ExpirationTime { get; set; }
Property Value¶
Constructors¶
FileTileCache()¶
Initializes a new instance of the FileTileCache class.
public FileTileCache()
FileTileCache(string)¶
Initializes a new instance of the FileTileCache class.
public FileTileCache(string cacheDirectory)
Parameters¶
cacheDirectory string
Methods¶
OnGettingTile(GettingTileTileCacheEventArgs)¶
Performs on getting tile.
protected void OnGettingTile(GettingTileTileCacheEventArgs e)
Parameters¶
e GettingTileTileCacheEventArgs
The e.
Returns¶
OnGottenTile(GottenTileTileCacheEventArgs)¶
Performs on gotten tile.
protected void OnGottenTile(GottenTileTileCacheEventArgs e)
Parameters¶
e GottenTileTileCacheEventArgs
The e.
Returns¶
OnSavingTile(SavingTileTileCacheEventArgs)¶
Performs on saving tile.
protected void OnSavingTile(SavingTileTileCacheEventArgs e)
Parameters¶
e SavingTileTileCacheEventArgs
The e.
Returns¶
OnSavedTile(SavedTileTileCacheEventArgs)¶
Performs on saved tile.
protected void OnSavedTile(SavedTileTileCacheEventArgs e)
Parameters¶
e SavedTileTileCacheEventArgs
The e.
Returns¶
GetTileAsync(int, long, long, CancellationToken)¶
Returns tile async for the specified parameters.
public Task<Tile> GetTileAsync(int zoom, long x, long y, CancellationToken cancellationToken)
Parameters¶
zoom int
The zoom.
x long
The x-coordinate, in pixels.
y long
The y-coordinate, in pixels.
cancellationToken CancellationToken
A cancellation or authentication token, depending on context.
Returns¶
Task<Tile>
A task that represents the asynchronous operation and provides the result.
GetTileAsync(int, long, long, string, CancellationToken)¶
Returns tile async for the specified parameters.
public Task<Tile> GetTileAsync(int zoom, long x, long y, string tileSource, CancellationToken cancellationToken)
Parameters¶
zoom int
The zoom.
x long
The x-coordinate, in pixels.
y long
The y-coordinate, in pixels.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
cancellationToken CancellationToken
A cancellation or authentication token, depending on context.
Returns¶
Task<Tile>
A task that represents the asynchronous operation and provides the result.
GetTileAsyncCore(int, long, long, string, CancellationToken)¶
Returns tile async for the specified parameters.
protected Task<Tile> GetTileAsyncCore(int zoom, long x, long y, string tileSource, CancellationToken cancellationToken)
Parameters¶
zoom int
The zoom.
x long
The x-coordinate, in pixels.
y long
The y-coordinate, in pixels.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
cancellationToken CancellationToken
A cancellation or authentication token, depending on context.
Returns¶
Task<Tile>
A task that represents the asynchronous operation and provides the result.
SaveTileAsync(Tile, CancellationToken)¶
Saves the current object to the specified destination.
public Task SaveTileAsync(Tile tile, CancellationToken cancellationToken)
Parameters¶
tile Tile
The tile.
cancellationToken CancellationToken
A cancellation or authentication token, depending on context.
Returns¶
Task
A task that represents the asynchronous operation.
SaveTileAsync(Tile, string, CancellationToken)¶
Saves the current object to the specified destination.
public Task SaveTileAsync(Tile tile, string tileSource, CancellationToken cancellationToken)
Parameters¶
tile Tile
The tile.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
cancellationToken CancellationToken
A cancellation or authentication token, depending on context.
Returns¶
Task
A task that represents the asynchronous operation.
SaveTileAsyncCore(Tile, string, CancellationToken)¶
Provides the overridable implementation that saves the current object to the specified destination.
protected Task SaveTileAsyncCore(Tile tile, string tileSource, CancellationToken cancellationToken)
Parameters¶
tile Tile
The tile.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
cancellationToken CancellationToken
A cancellation or authentication token, depending on context.
Returns¶
Task
A task that represents the asynchronous operation.
DeleteTile(Tile)¶
Performs delete tile.
public void DeleteTile(Tile tile)
Parameters¶
tile Tile
The tile.
Returns¶
DeleteTile(Tile, string)¶
Performs delete tile.
public void DeleteTile(Tile tile, string tileSource)
Parameters¶
tile Tile
The tile.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
Returns¶
DeleteTileCore(Tile, string)¶
Provides the overridable implementation that performs delete tile.
protected void DeleteTileCore(Tile tile, string tileSource)
Parameters¶
tile Tile
The tile.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
Returns¶
ClearCache()¶
Clears all cached tiles by deleting the cache directory.
public void ClearCache()
Returns¶
ClearCache(string)¶
Clears the cached tiles of one tile source - the sub-directory kept for it - and leaves every other source's tiles in place.
public void ClearCache(string tileSource)
Parameters¶
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
Returns¶
DeleteTiles(RectangleShape, TileMatrixSet, string)¶
Deletes the cached tiles of one tile source that meet an extent, at every zoom level that has any, and leaves the rest. The walk is over the files that exist, not the tiles the extent could hold, so a wide extent over a deep pyramid costs what is on disk rather than what could be.
public void DeleteTiles(RectangleShape extent, TileMatrixSet tileMatrixSet, string tileSource)
Parameters¶
extent RectangleShape
The area whose tiles go, in the matrix set's coordinates.
tileMatrixSet TileMatrixSet
The grid the tiles were saved on; a zoom it does not have is skipped.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
Returns¶
ClearCacheCore()¶
Provides the overridable implementation that performs clear cache.
protected void ClearCacheCore()
Returns¶
DeleteTilesCore(RectangleShape, TileMatrixSet, string)¶
Provides the overridable implementation that deletes one tile source's tiles meeting an extent.
protected void DeleteTilesCore(RectangleShape extent, TileMatrixSet tileMatrixSet, string tileSource)
Parameters¶
extent RectangleShape
The area whose tiles go.
tileMatrixSet TileMatrixSet
The grid the tiles were saved on.
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
Returns¶
ClearCacheCore(string)¶
Provides the overridable implementation that clears one tile source's tiles.
protected void ClearCacheCore(string tileSource)
Parameters¶
tileSource string
What the tiles come from - the tile URL template of a remote source, or the source id of a feature-source cut; it names the sub-directory the tiles are kept in, see the class remarks.
Returns¶
ToSafeShortDirectoryName(string, int)¶
Generates a filesystem-safe short directory name for the supplied input.
public static string ToSafeShortDirectoryName(string input, int maxLength)
Parameters¶
input string
The input string to normalize.
maxLength int
The maximum length for the generated name.
Returns¶
string
A safe directory name derived from the input.
Events¶
GettingTile¶
Occurs when the GettingTile event is raised.
public event EventHandler<GettingTileTileCacheEventArgs> GettingTile;
GottenTile¶
Occurs when the GottenTile event is raised.
public event EventHandler<GottenTileTileCacheEventArgs> GottenTile;
SavingTile¶
Occurs when the SavingTile event is raised.
public event EventHandler<SavingTileTileCacheEventArgs> SavingTile;
SavedTile¶
Occurs when the SavedTile event is raised.
public event EventHandler<SavedTileTileCacheEventArgs> SavedTile;