Skip to content

Commit f1fe657

Browse files
authored
Merge pull request #53 from yuiseki/main
Release 2026-01-14 04:50:37 UTC
2 parents 64827c9 + 48bc532 commit f1fe657

File tree

3 files changed

+45
-64
lines changed

3 files changed

+45
-64
lines changed

Cargo.lock

Lines changed: 32 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vt-optimizer-rs"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
edition = "2024"
55
license = "MIT"
66
description = "A fast CLI to inspect and optimize MBTiles/PMTiles vector tiles."
@@ -32,7 +32,7 @@ tracing = "0.1"
3232
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
3333
serde = { version = "1", features = ["derive"] }
3434
serde_json = "1"
35-
rusqlite = { version = "0.31", features = ["bundled"] }
35+
rusqlite = { version = "0.38", features = ["bundled"] }
3636
tempfile = "3.10"
3737
hilbert_2d = "1.1"
3838
varint-rs = "2.2"

src/mbtiles.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,8 @@ fn build_histogram(
11551155
let mut index: u64 = 0;
11561156
while let Some(row) = rows.next().context("read histogram row")? {
11571157
let row_zoom: u8 = row.get(0)?;
1158-
let length: u64 = row.get(1)?;
1158+
let length: i64 = row.get(1)?;
1159+
let length = u64::try_from(length).context("tile length must be non-negative")?;
11591160
if let Some(target) = zoom
11601161
&& row_zoom != target
11611162
{
@@ -1306,7 +1307,8 @@ fn build_zoom_histograms(
13061307
let mut total_index: u64 = 0;
13071308
while let Some(row) = rows.next().context("read zoom histogram row")? {
13081309
let zoom: u8 = row.get(0)?;
1309-
let length: u64 = row.get(1)?;
1310+
let length: i64 = row.get(1)?;
1311+
let length = u64::try_from(length).context("tile length must be non-negative")?;
13101312
total_index += 1;
13111313
let Some(accum) = accums.get_mut(&zoom) else {
13121314
continue;
@@ -1471,7 +1473,8 @@ fn fetch_zoom_counts(conn: &Connection) -> Result<BTreeMap<u8, u64>> {
14711473
let mut counts = BTreeMap::new();
14721474
while let Some(row) = rows.next().context("read zoom count row")? {
14731475
let zoom: u8 = row.get(0)?;
1474-
let count: u64 = row.get(1)?;
1476+
let count: i64 = row.get(1)?;
1477+
let count = u64::try_from(count).context("tile count must be non-negative")?;
14751478
counts.insert(zoom, count);
14761479
}
14771480
Ok(counts)
@@ -1526,12 +1529,13 @@ pub fn inspect_mbtiles_with_options(path: &Path, options: InspectOptions) -> Res
15261529
let query = select_tile_count_query(&conn, options.zoom.is_some())?;
15271530
let count = match options.zoom {
15281531
Some(z) => conn
1529-
.query_row(&query, [z], |row| row.get(0))
1532+
.query_row(&query, [z], |row| row.get::<_, i64>(0))
15301533
.context("failed to read tile count (zoom)")?,
15311534
None => conn
1532-
.query_row(&query, [], |row| row.get(0))
1535+
.query_row(&query, [], |row| row.get::<_, i64>(0))
15331536
.context("failed to read tile count")?,
15341537
};
1538+
let count = u64::try_from(count).context("tile count must be non-negative")?;
15351539
if let Some(spinner) = spinner {
15361540
spinner.finish_and_clear();
15371541
}
@@ -1609,7 +1613,8 @@ pub fn inspect_mbtiles_with_options(path: &Path, options: InspectOptions) -> Res
16091613
let zoom: u8 = row.get(0)?;
16101614
let x: u32 = row.get(1)?;
16111615
let y: u32 = row.get(2)?;
1612-
let length: u64 = row.get(3)?;
1616+
let length: i64 = row.get(3)?;
1617+
let length = u64::try_from(length).context("tile length must be non-negative")?;
16131618
let tile_data: Option<Vec<u8>> = if need_tile_data {
16141619
Some(row.get(4)?)
16151620
} else {

0 commit comments

Comments
 (0)