1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
//! The error of the vector tile build.
use std::path::PathBuf;
use geolith::error::GeolithError;
/// Why a vector tile build failed.
///
/// Errors from the shared readers and writers arrive as
/// [`TilesError::Geolith`]. The other variants name the step of the build
/// that failed and carry the path or thread involved.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum TilesError {
/// A reader, writer or encoder of the `geolith` library failed.
#[error(transparent)]
Geolith(#[from] GeolithError),
/// A file operation failed.
#[error("i/o error")]
Io(#[from] std::io::Error),
/// `--bbox` is not `west,south,east,north`.
#[error("invalid --bbox")]
InvalidBbox(#[source] GeolithError),
/// A sort run is cut, damaged, of another version, or cannot be written.
#[error(transparent)]
SortRun(#[from] crate::sort::error::SortRunError),
/// A volume the build writes to has less free space than the build needs.
#[error(
"not enough free disk on the volume of {}: the build needs about {need_gib} GiB there \
({what}) and {free_gib} GiB are free. Free the space, point --tmpdir or --output at a \
larger volume{}, or pass --no-disk-check to skip this check",
path.display(),
if *reclaim_chunks { "" } else { ", or pass --reclaim-chunks to lower the peak" }
)]
InsufficientDisk {
/// A path on the volume.
path: PathBuf,
/// GiB the build needs on the volume at its peak.
need_gib: u64,
/// GiB free on the volume.
free_gib: u64,
/// What the build puts on the volume.
what: &'static str,
/// Whether `--reclaim-chunks` is already set.
reclaim_chunks: bool,
},
/// `--reclaim-source-after-read` with a data folder that lacks an Overture
/// type the enabled layers read.
#[error(
"{} holds no Parquet file of {}; with --reclaim-source-after-read the build would delete \
what it reads and ship an incomplete archive. Download the missing types, or pass \
--allow-missing-type",
data.display(),
types.join(", ")
)]
MissingOvertureTypes {
/// The data folder.
data: PathBuf,
/// The `theme/type` names.
types: Vec<String>,
},
/// The merge opens every sort run at once, and the open-file limit is
/// lower than that and cannot be raised.
#[error(
"the merge needs {need} open files for {runs} sort runs, and the limit is {limit}: \
raise it with `ulimit -n {need}` (or a higher hard limit) and run again with --resume"
)]
TooManyRuns {
/// Sort runs to merge.
runs: usize,
/// The open-file limit in force.
limit: u64,
/// Files the merge needs.
need: u64,
},
/// The scratch directory for the sort chunks cannot be created.
#[error("failed to create chunk dir: {}", path.display())]
CreateChunkDir {
/// The directory.
path: PathBuf,
/// What the operating system said.
#[source]
source: std::io::Error,
},
/// The DEM cannot be opened or read: the inputs of `terrain --dem`.
#[error("opening the DEM {}", dems.iter().map(|d| d.display().to_string()).collect::<Vec<_>>().join(", "))]
OpenDem {
/// The `--dem` values.
dems: Vec<PathBuf>,
/// The reader error.
#[source]
source: GeolithError,
},
/// The splat PLY cannot be read.
#[error("reading {}", path.display())]
ReadPly {
/// The `--ply` value.
path: PathBuf,
/// The reader error.
#[source]
source: GeolithError,
},
/// The build area touches Survey of India land and `--india-boundary`
/// was not given.
#[error(
"the tile build area touches Survey of India land (the whole world without --bbox): \
pass --india-boundary <Survey of India lines GeoJSON>"
)]
IndiaBoundaryRequired,
/// `--india-boundary` holds no closed ring.
#[error("--india-boundary has no closed ring, so the Survey of India land cannot be built")]
IndiaBoundaryWithoutRing,
/// A lock was poisoned by a panic in another worker.
#[error("lock poisoned: {what}")]
LockPoisoned {
/// The data the lock guarded.
what: &'static str,
},
/// The OSM PBF cannot be opened, read or decoded.
#[error("OSM PBF {step}")]
OsmPbf {
/// What the reader was doing: `blob reader`, `blob read` or `decode`.
step: &'static str,
/// The reader error.
#[source]
source: osmpbf::Error,
},
/// A worker thread panicked.
#[error("{thread} thread panicked: {message}")]
ThreadPanicked {
/// The worker: `land polygon` or `water polygon`.
thread: &'static str,
/// The panic message.
message: String,
},
/// The thread pool of `--threads` could not be built.
#[error("cannot build a thread pool for --threads: {0}")]
ThreadPool(String),
/// `--resume` points at a directory that does not exist.
#[error(
"--resume requires --tmpdir to point at existing sort chunks, but {} does not exist",
path.display()
)]
ResumeDirMissing {
/// The `--tmpdir` value.
path: PathBuf,
},
/// `--resume` points at chunks that a `--reclaim-chunks` merge already
/// began to consume.
#[error(
"the sort chunks in {} cannot be resumed: an earlier merge with --reclaim-chunks began \
to consume them, so runs are missing or hollow and a merge now would leave tiles out. \
Delete the folder and build again from phase 1",
path.display()
)]
ChunksConsumed {
/// The `--tmpdir` value.
path: PathBuf,
},
/// `--resume` points at chunks of a phase 1 that did not finish.
#[error(
"the sort chunks in {} cannot be resumed: phase 1 did not finish (there is no valid \
phase1.complete marker; the chunks may also come from an older version). Delete the \
folder and build again from phase 1",
path.display()
)]
Phase1Incomplete {
/// The `--tmpdir` value.
path: PathBuf,
},
/// `--resume` found other runs than phase 1 wrote.
#[error(
"the sort chunks in {} cannot be resumed: phase 1 wrote {expected} runs and {found} are \
there; a merge now would leave tiles out. Delete the folder and build again from phase 1",
path.display()
)]
RunCountMismatch {
/// The `--tmpdir` value.
path: PathBuf,
/// The runs phase 1 wrote.
expected: usize,
/// The runs found.
found: usize,
},
/// `--resume` found no chunk file to continue from.
#[error("No chunk files found in {} — nothing to resume from", path.display())]
NoChunksToResume {
/// The `--tmpdir` value.
path: PathBuf,
},
/// The sources gave no tile feature.
#[error("No tile features generated — nothing to write")]
NothingToWrite,
/// The `PMTiles` metadata JSON cannot be serialised.
#[error("serializing PMTiles metadata")]
Metadata(#[source] serde_json::Error),
/// A shapefile directory holds no `.shp` file.
#[error("No .shp file found in {}", path.display())]
NoShapefile {
/// The directory.
path: PathBuf,
},
/// The shapefile path does not exist.
#[error("Shapefile path does not exist: {}", path.display())]
ShapefileMissing {
/// The path.
path: PathBuf,
},
/// `mlt-core` panicked while it encoded a tile.
#[error("mlt-core panicked during MVT→MLT encoding: {message}")]
MltPanic {
/// The panic message.
message: String,
},
/// An MVT tile cannot be parsed for the MLT conversion.
#[error("failed to parse MVT tile")]
MltParse(#[source] mlt_core::MltError),
/// An MLT layer cannot be encoded.
#[error("failed to encode MLT layer")]
MltEncode(#[source] mlt_core::MltError),
/// A tile of the archive cannot be encoded as MLT.
#[error("MLT encode of tile {z}/{x}/{y}")]
TileEncode {
/// Zoom of the tile.
z: u8,
/// Column of the tile.
x: u32,
/// Row of the tile.
y: u32,
/// Why the tile failed.
#[source]
source: Box<TilesError>,
},
/// The merge of the features of one tile panicked. A tile cannot be
/// skipped, so the build stops; the panic message is in the log.
#[error("merging the features of tile {z}/{x}/{y} panicked; see the log for the panic")]
TileMerge {
/// Zoom of the tile.
z: u8,
/// Column of the tile.
x: u32,
/// Row of the tile.
y: u32,
},
/// More features lost a piece to a caught clipper panic than the build
/// may lose. The pieces were skipped; the count is a sign of bad source
/// geometry, not of a bug to ignore.
#[error(
"{count} features lost geometry to a caught clipping panic, above the limit of \
{allowed}{first}. Look for invalid rings (a NaN vertex, for one) in the sources"
)]
GeometryFailures {
/// Failed features in this build.
count: u64,
/// The limit.
allowed: u64,
/// The first failure, as `"; first: ..."`, or empty.
first: String,
},
}
/// Result of the vector tile build.
pub type Result<T, E = TilesError> = std::result::Result<T, E>;