PyramidIO¶
-
class
toasty.pyramid.
PyramidIO
(base_dir, scheme='L/Y/YX')[source]¶ Bases:
object
Manage I/O on a tile pyramid.
Methods Summary
Get the scheme for buiding tile paths as used in the WTML standard.
open_metadata_for_read
(basename)Open a metadata file in read mode.
open_metadata_for_write
(basename)Open a metadata file in write mode.
read_toasty_image
(pos, mode[, default])Read a toasty Image for the specified tile position.
tile_path
(pos[, extension])Get the path for a tile, creating its containing directories.
write_toasty_image
(pos, image)Write a toasty Image for the specified tile position.
Methods Documentation
-
get_path_scheme
()[source]¶ Get the scheme for buiding tile paths as used in the WTML standard.
- Returns
- The naming scheme, a string resembling
{1}/{3}/{3}_{2}
.
- The naming scheme, a string resembling
Notes
The naming scheme is currently hardcoded to be the format given above, but in the future other options might become available.
-
open_metadata_for_read
(basename)[source]¶ Open a metadata file in read mode.
- Parameters
- basenamestr
The basename of the metadata file
- Returns
- A readable and closeable file-like object returning bytes.
-
open_metadata_for_write
(basename)[source]¶ Open a metadata file in write mode.
- Parameters
- basenamestr
The basename of the metadata file
- Returns
- A writable and closeable file-like object accepting bytes.
-
read_toasty_image
(pos, mode, default='none')[source]¶ Read a toasty Image for the specified tile position.
- Parameters
- pos
Pos
The tile position to read.
- mode
toasty.image.ImageMode
The image data mode to read. This will affect the file extension probed and the mode of the returned image.
- defaultstr, defaults to “none”
What to do if the specified tile file does not exist. If this is “none”,
None
will be returned instead of an image. If this is “masked”, an all-masked image will be returned, usingmake_maskable_buffer()
. Otherwise,ValueError
will be raised.
- pos
-
tile_path
(pos, extension='png')[source]¶ Get the path for a tile, creating its containing directories.
- Parameters
- posPos
The tile to get a path for.
- extensionstr, default: “png”
The file extension to use in the path.
- Returns
- The path as a string.
Notes
This function does I/O itself — it creates the parent directories containing the tile path. It is not an error for the parent directories to already exist.
-
write_toasty_image
(pos, image)[source]¶ Write a toasty Image for the specified tile position.
- Parameters
- pos
Pos
The tile position to write.
- image
toasty.image.Image
The image to write.
- pos
-