diff options
Diffstat (limited to 'hittekaart/src/storage.rs')
| -rw-r--r-- | hittekaart/src/storage.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/hittekaart/src/storage.rs b/hittekaart/src/storage.rs index 137bf5d..6cb3629 100644 --- a/hittekaart/src/storage.rs +++ b/hittekaart/src/storage.rs @@ -204,6 +204,10 @@ impl Storage for OsmAnd { } fn store(&mut self, zoom: u32, x: u64, y: u64, data: &[u8]) -> Result<()> { + // SQLite can store all i64 values, but no values between i64::MAX and u64::MAX + // See https://github.com/rusqlite/rusqlite/issues/1722 + let x: i64 = x.try_into().expect("x coordinate too large for SQLite"); + let y: i64 = y.try_into().expect("y coordinate too large for SQLite"); self.connection.execute( "INSERT INTO tiles (z, x, y, image) VALUES (?, ?, ?, ?)", params![zoom, x, y, data], @@ -297,6 +301,10 @@ impl Storage for MbTiles { fn store(&mut self, zoom: u32, x: u64, y: u64, data: &[u8]) -> Result<()> { let inverted_y = 2u64.pow(zoom) - 1 - y; + // SQLite can store all i64 values, but no values between i64::MAX and u64::MAX + // See https://github.com/rusqlite/rusqlite/issues/1722 + let x: i64 = x.try_into().expect("x coordinate too large for SQLite"); + let inverted_y: i64 = inverted_y.try_into().expect("inverted_y coordinate too large for SQLite"); self.connection.execute( "INSERT INTO tiles (zoom_level, tile_column, tile_row, tile_data) VALUES (?, ?, ?, ?)", params![zoom, x, inverted_y, data], |
