-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a0ab05
commit 9b9490e
Showing
5 changed files
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,23 @@ | ||
// Copyright (c) BruTile developers team. All rights reserved. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using BruTile.Cache; | ||
|
||
namespace BruTile.FileSystem; | ||
|
||
public class FileTileSource | ||
public class FileTileSource(ITileSchema tileSchema, string directory, string format, TimeSpan? cacheExpireTime = null, | ||
string? name = null, Attribution? attribution = null) : ILocalTileSource | ||
{ | ||
private readonly FileCache _fileCache; | ||
private readonly FileCache _fileCache = new(directory, format, cacheExpireTime ?? TimeSpan.Zero); | ||
|
||
public FileTileSource(string directory, string format, TimeSpan cacheExpireTime) | ||
{ | ||
_fileCache = new FileCache(directory, format, cacheExpireTime); | ||
} | ||
|
||
public FileTileSource(FileCache fileCache) | ||
{ | ||
_fileCache = fileCache; | ||
} | ||
public ITileSchema Schema { get; } = tileSchema; | ||
public string Name { get; } = name ?? directory; | ||
public Attribution Attribution { get; } = attribution ?? new Attribution(); | ||
|
||
public Task<byte[]> GetTileAsync(TileInfo tileInfo) | ||
public Task<byte[]?> GetTileAsync(TileInfo tileInfo) | ||
{ | ||
var bytes = _fileCache.Find(tileInfo.Index) | ||
?? throw new FileNotFoundException("The tile was not found at it's expected location"); | ||
var bytes = _fileCache.Find(tileInfo.Index); | ||
return Task.FromResult(bytes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) BruTile developers team. All rights reserved. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
|
||
namespace BruTile; | ||
|
||
public interface ILocalTileSource : ITileSource | ||
{ | ||
Task<byte[]?> GetTileAsync(TileInfo tileInfo); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) BruTile developers team. All rights reserved. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using System; | ||
|
||
namespace BruTile; | ||
|
||
[Obsolete("Use ILocalTileSource or IHttpTileSource instead", true)] | ||
public interface ITileProvider | ||
{ | ||
Task<byte[]?> GetTileAsync(TileInfo tileInfo); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters