-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update docs * Update docs/advanced/backends.md Co-authored-by: Kyle Barron <kylebarron2@gmail.com> * Update docs/advanced/backends.md Co-authored-by: Kyle Barron <kylebarron2@gmail.com> * Update docs/advanced/backends.md Co-authored-by: Kyle Barron <kylebarron2@gmail.com> * InMemoryBackend -> MemoryBackend Co-authored-by: Kyle Barron <kylebarron2@gmail.com>
- Loading branch information
1 parent
bc0ac5d
commit 098dcac
Showing
6 changed files
with
113 additions
and
6 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
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,54 @@ | ||
"""cogeo-mosaic In-Memory backend.""" | ||
|
||
from typing import Dict, Tuple, Type | ||
|
||
import attr | ||
from morecantile import TileMatrixSet | ||
from rio_tiler.constants import WEB_MERCATOR_TMS | ||
from rio_tiler.io import BaseReader, COGReader | ||
|
||
from cogeo_mosaic.backends.base import BaseBackend, _convert_to_mosaicjson | ||
from cogeo_mosaic.mosaic import MosaicJSON | ||
|
||
|
||
@attr.s | ||
class MemoryBackend(BaseBackend): | ||
"""InMemory Backend Adapter | ||
Examples: | ||
>>> with MemoryBackend(mosaicJSON) as mosaic: | ||
mosaic.tile(0, 0, 0) | ||
""" | ||
|
||
mosaic_def: MosaicJSON = attr.ib(converter=_convert_to_mosaicjson) | ||
reader: Type[BaseReader] = attr.ib(default=COGReader) | ||
reader_options: Dict = attr.ib(factory=dict) | ||
backend_options: Dict = attr.ib(factory=dict) | ||
|
||
# TMS is outside the init because mosaicJSON and cogeo-mosaic only | ||
# works with WebMercator (mercantile) for now. | ||
tms: TileMatrixSet = attr.ib(init=False, default=WEB_MERCATOR_TMS) | ||
|
||
# default values for bounds and zoom | ||
bounds: Tuple[float, float, float, float] = attr.ib( | ||
init=False, default=(-180, -90, 180, 90) | ||
) | ||
minzoom: int = attr.ib(init=False, default=0) | ||
maxzoom: int = attr.ib(init=False, default=30) | ||
|
||
path: str = attr.ib(init=False, default=":memory:") | ||
|
||
_backend_name = "MEM" | ||
|
||
def __attrs_post_init__(self): | ||
"""Post Init.""" | ||
self.minzoom = self.mosaic_def.minzoom | ||
self.maxzoom = self.mosaic_def.maxzoom | ||
self.bounds = self.mosaic_def.bounds | ||
|
||
def write(self, overwrite: bool = True): | ||
"""Write mosaicjson document.""" | ||
pass | ||
|
||
def _read(self) -> MosaicJSON: | ||
pass |
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
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