martin_core/tiles/cog/
errors.rs1use std::path::PathBuf;
4
5use png::EncodingError;
6use tiff::TiffError;
7
8#[non_exhaustive]
10#[derive(thiserror::Error, Debug)]
11pub enum CogError {
12 #[error("Couldn't decode {1} as tiff file: {0}")]
14 InvalidTiffFile(#[source] TiffError, PathBuf),
15
16 #[error(
18 "Requested zoom level {0} from file {1} is out of range. Possible zoom levels are {2} to {3}"
19 )]
20 ZoomOutOfRange(u8, PathBuf, u8, u8),
21
22 #[error("Couldn't find any image in the tiff file: {0}")]
24 NoImagesFound(PathBuf),
25
26 #[error("Couldn't seek to ifd number {1} (0 based indexing) in tiff file {2}: {0}")]
28 IfdSeekFailed(#[source] TiffError, usize, PathBuf),
29
30 #[error("Too many images in the tiff file: {0}")]
32 TooManyImages(PathBuf),
33
34 #[error("Couldn't find tags {1:?} at ifd {2} of tiff file {3}: {0}")]
36 TagsNotFound(#[source] TiffError, Vec<u16>, usize, PathBuf),
37
38 #[error(
40 "Unsupported planar configuration {2} at IFD {1} in TIFF file {0}. Only planar configuration 1 is supported."
41 )]
42 PlanarConfigurationNotSupported(PathBuf, usize, u16),
43
44 #[error("Failed to read {1}th chunk(0 based index) at ifd {2} from tiff file {3}: {0}")]
46 ReadChunkFailed(#[source] TiffError, u32, usize, PathBuf),
47
48 #[error("Failed to write header of png file at {0}: {1}")]
50 WritePngHeaderFailed(PathBuf, #[source] EncodingError),
51
52 #[error("Failed to write pixel bytes to png file at {0}: {1}")]
54 WriteToPngFailed(PathBuf, #[source] EncodingError),
55
56 #[error("The color type {0:?} and its bit depth of the tiff file {1} is not supported yet")]
58 NotSupportedColorTypeAndBitDepth(tiff::ColorType, PathBuf),
59
60 #[error("Striped tiff file is not supported, the tiff file is {0}")]
62 NotSupportedChunkType(PathBuf),
63
64 #[error("Coord transformation in {0} is invalid: {1}")]
66 InvalidGeoInformation(PathBuf, String),
67
68 #[error(
70 "The pixel size of the image {0} is not squared, the x_scale is {1}, the y_scale is {2}"
71 )]
72 NonSquaredImage(PathBuf, f64, f64),
73
74 #[error(
76 "Calculating the tile origin failed for {0}: the length of ModelTiepointTag should be >= 6, or the length of ModelTransformationTag should be >= 12"
77 )]
78 GetOriginFailed(PathBuf),
79
80 #[error(
82 "Get full resolution failed for {0}: either a valid ModelPixelScaleTag or ModelPixelScaleTag is required"
83 )]
84 GetFullResolutionFailed(PathBuf),
85
86 #[error("IO error {0}: {1}")]
88 IoError(#[source] std::io::Error, PathBuf),
89}