From 1fafe18af03f8e0167867345e74328fabbf33258 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 15 Dec 2023 02:16:55 -0500 Subject: [PATCH] fixes --- martin-tile-utils/src/lib.rs | 4 +- mbtiles/src/copier.rs | 7 +- mbtiles/tests/copy.rs | 68 ++++++++----------- .../copy__convert@v1__bbox__flat-flat.snap | 9 ++- .../copy__convert@v1__bbox__flat-hash.snap | 9 ++- .../copy__convert@v1__bbox__flat-norm.snap | 15 +++- .../copy__convert@v1__bbox__hash-flat.snap | 9 ++- .../copy__convert@v1__bbox__hash-hash.snap | 9 ++- .../copy__convert@v1__bbox__hash-norm.snap | 15 +++- .../copy__convert@v1__bbox__norm-flat.snap | 9 ++- .../copy__convert@v1__bbox__norm-hash.snap | 9 ++- .../copy__convert@v1__bbox__norm-norm.snap | 15 +++- mbtiles/tests/validate.rs | 54 ++++++++++++++- 13 files changed, 162 insertions(+), 70 deletions(-) diff --git a/martin-tile-utils/src/lib.rs b/martin-tile-utils/src/lib.rs index efbbfa9c0..2b187e7e2 100644 --- a/martin-tile-utils/src/lib.rs +++ b/martin-tile-utils/src/lib.rs @@ -11,7 +11,7 @@ use tile_grid::{tms, Tms, Xyz}; pub const EARTH_CIRCUMFERENCE: f64 = 40_075_016.685_578_5; pub const EARTH_RADIUS: f64 = EARTH_CIRCUMFERENCE / 2.0 / PI; -pub const MAX_ZOOM: u8 = 30; +pub const MAX_ZOOM: u8 = 24; use std::sync::OnceLock; fn web_merc() -> &'static Tms { @@ -209,6 +209,8 @@ pub fn tile_index(lon: f64, lat: f64, zoom: u8) -> (u32, u32) { #[must_use] pub fn xyz_to_bbox(zoom: u8, min_x: u32, min_y: u32, max_x: u32, max_y: u32) -> [f64; 4] { assert!(zoom <= MAX_ZOOM, "zoom {zoom} must be <= {MAX_ZOOM}"); + assert!(min_x <= max_x, "min_x {min_x} must be <= max_x {max_x}"); + assert!(min_y <= max_y, "min_y {min_y} must be <= max_y {max_y}"); let left_top_bounds = web_merc().xy_bounds(&Xyz::new(u64::from(min_x), u64::from(min_y), zoom)); let right_bottom_bounds = web_merc().xy_bounds(&Xyz::new(u64::from(max_x), u64::from(max_y), zoom)); diff --git a/mbtiles/src/copier.rs b/mbtiles/src/copier.rs index cebc70942..452cbbe4b 100644 --- a/mbtiles/src/copier.rs +++ b/mbtiles/src/copier.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use clap::{Args, ValueEnum}; use enum_display::EnumDisplay; use log::{debug, info, trace}; -use martin_tile_utils::bbox_to_xyz; +use martin_tile_utils::{bbox_to_xyz, MAX_ZOOM}; use serde::{Deserialize, Serialize}; use sqlite_hashes::rusqlite::Connection; use sqlx::{query, Executor as _, Row, SqliteConnection}; @@ -605,9 +605,8 @@ impl MbtileCopierInt { if !self.options.bbox.is_empty() { sql.push_str(" AND (\n"); for (idx, bbox) in self.options.bbox.iter().enumerate() { - // Use maximum zoom value for easy filtering, converting it on the fly to the actual zoom level - const MAX_ZOOM: u8 = 30; - + // Use maximum zoom value for easy filtering, + // converting it on the fly to the actual zoom level let (min_x, min_y, max_x, max_y) = bbox_to_xyz(bbox.left, bbox.bottom, bbox.right, bbox.top, MAX_ZOOM); trace!("Bounding box {bbox} converted to {min_x},{min_y},{max_x},{max_y} at zoom {MAX_ZOOM}"); diff --git a/mbtiles/tests/copy.rs b/mbtiles/tests/copy.rs index ddbbf842a..fcbb272ca 100644 --- a/mbtiles/tests/copy.rs +++ b/mbtiles/tests/copy.rs @@ -247,55 +247,41 @@ async fn convert( let mem = Mbtiles::new(":memory:")?; let (frm_mbt, _frm_cn) = new_file!(convert, frm_type, METADATA_V1, TILES_V1, "{frm}-{to}"); - // let mut opt = copier(&frm_mbt, &mem); - // opt.dst_type_cli = Some(dst_type); - // let dmp = dump(&mut opt.run().await?).await?; - // pretty_assert_eq!(databases.dump("v1", dst_type), &dmp); - // - // let mut opt = copier(&frm_mbt, &mem); - // opt.dst_type_cli = Some(dst_type); - // opt.zoom_levels.push(6); - // let z6only = dump(&mut opt.run().await?).await?; - // assert_snapshot!(z6only, "v1__z6__{frm}-{to}"); - - // Bounding box -180,-85.0511287798066,-146.25,-81.09321385260837 - // - // converted to - // - // 0,973078527,100663296,1073741823 at zoom 30 + let mut opt = copier(&frm_mbt, &mem); + opt.dst_type_cli = Some(dst_type); + let dmp = dump(&mut opt.run().await?).await?; + pretty_assert_eq!(databases.dump("v1", dst_type), &dmp); - // ( - // - // ( - // tile_column * (1 << (30 - zoom_level)) - // ) BETWEEN 0 AND 100663296 - // - // AND - // - // ( - // tile_row * (1 << (30 - zoom_level)) - // ) BETWEEN 100663296 AND 0 - // - // ) + let mut opt = copier(&frm_mbt, &mem); + opt.dst_type_cli = Some(dst_type); + opt.zoom_levels.push(6); + let z6only = dump(&mut opt.run().await?).await?; + assert_snapshot!(z6only, "v1__z6__{frm}-{to}"); let mut opt = copier(&frm_mbt, &mem); opt.dst_type_cli = Some(dst_type); - let bounds = xyz_to_bbox(5, 0, invert_y_value(5, 2), 2, invert_y_value(5, 0)).into(); - opt.bbox.push(bounds); + // Filter (0, 0, 2, 2) in mbtiles coordinates, which is (0, 2^5-1-2, 2, 2^5-1-0) = (0, 29, 2, 31) in XYZ coordinates, and slightly decrease it + let mut bbox = xyz_to_bbox(5, 0, invert_y_value(5, 2), 2, invert_y_value(5, 0)); + bbox[0] += 180.0 / f64::from(1 << 5) * 0.1; + bbox[1] += 90.0 / f64::from(1 << 5) * 0.1; + bbox[2] -= 180.0 / f64::from(1 << 5) * 0.1; + bbox[3] -= 90.0 / f64::from(1 << 5) * 0.1; + opt.bbox.push(bbox.into()); + let dmp = dump(&mut opt.run().await?).await?; assert_snapshot!(dmp, "v1__bbox__{frm}-{to}"); - // let mut opt = copier(&frm_mbt, &mem); - // opt.dst_type_cli = Some(dst_type); - // opt.min_zoom = Some(6); - // pretty_assert_eq!(&z6only, &dump(&mut opt.run().await?).await?); - // - // let mut opt = copier(&frm_mbt, &mem); - // opt.dst_type_cli = Some(dst_type); - // opt.min_zoom = Some(6); - // opt.max_zoom = Some(6); - // pretty_assert_eq!(&z6only, &dump(&mut opt.run().await?).await?); + let mut opt = copier(&frm_mbt, &mem); + opt.dst_type_cli = Some(dst_type); + opt.min_zoom = Some(6); + pretty_assert_eq!(&z6only, &dump(&mut opt.run().await?).await?); + + let mut opt = copier(&frm_mbt, &mem); + opt.dst_type_cli = Some(dst_type); + opt.min_zoom = Some(6); + opt.max_zoom = Some(6); + pretty_assert_eq!(&z6only, &dump(&mut opt.run().await?).await?); Ok(()) } diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-flat.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-flat.snap index c42f0c9fb..510f57545 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-flat.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-flat.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -26,7 +26,12 @@ CREATE TABLE tiles ( tile_row integer NOT NULL, tile_data blob, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, blob(edit-v1) )', + '( 5, 1, 2, blob() )', + '( 5, 2, 2, blob(remove) )', + '( 6, 1, 4, blob(edit-v1) )', +] [[]] type = 'index' diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-hash.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-hash.snap index 2312027a7..d7da64239 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-hash.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-hash.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -27,7 +27,12 @@ CREATE TABLE tiles_with_hash ( tile_data blob, tile_hash text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', + '( 5, 1, 2, blob(), "D41D8CD98F00B204E9800998ECF8427E" )', + '( 5, 2, 2, blob(remove), "0F6969D7052DA9261E31DDB6E88C136E" )', + '( 6, 1, 4, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', +] [[]] type = 'index' diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-norm.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-norm.snap index 76d5da307..ae37bc9bf 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-norm.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__flat-norm.snap @@ -9,7 +9,11 @@ sql = ''' CREATE TABLE images ( tile_id text NOT NULL PRIMARY KEY, tile_data blob)''' -values = [] +values = [ + '( "0F6969D7052DA9261E31DDB6E88C136E", blob(remove) )', + '( "D41D8CD98F00B204E9800998ECF8427E", blob() )', + '( "EFE0AE5FD114DE99855BC2838BE97E1D", blob(edit-v1) )', +] [[]] type = 'table' @@ -21,7 +25,12 @@ CREATE TABLE map ( tile_row integer NOT NULL, tile_id text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, "EFE0AE5FD114DE99855BC2838BE97E1D" )', + '( 5, 1, 2, "D41D8CD98F00B204E9800998ECF8427E" )', + '( 5, 2, 2, "0F6969D7052DA9261E31DDB6E88C136E" )', + '( 6, 1, 4, "EFE0AE5FD114DE99855BC2838BE97E1D" )', +] [[]] type = 'table' @@ -31,7 +40,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-flat.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-flat.snap index c42f0c9fb..510f57545 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-flat.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-flat.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -26,7 +26,12 @@ CREATE TABLE tiles ( tile_row integer NOT NULL, tile_data blob, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, blob(edit-v1) )', + '( 5, 1, 2, blob() )', + '( 5, 2, 2, blob(remove) )', + '( 6, 1, 4, blob(edit-v1) )', +] [[]] type = 'index' diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-hash.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-hash.snap index 2312027a7..d7da64239 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-hash.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-hash.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -27,7 +27,12 @@ CREATE TABLE tiles_with_hash ( tile_data blob, tile_hash text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', + '( 5, 1, 2, blob(), "D41D8CD98F00B204E9800998ECF8427E" )', + '( 5, 2, 2, blob(remove), "0F6969D7052DA9261E31DDB6E88C136E" )', + '( 6, 1, 4, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', +] [[]] type = 'index' diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-norm.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-norm.snap index 76d5da307..ae37bc9bf 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-norm.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__hash-norm.snap @@ -9,7 +9,11 @@ sql = ''' CREATE TABLE images ( tile_id text NOT NULL PRIMARY KEY, tile_data blob)''' -values = [] +values = [ + '( "0F6969D7052DA9261E31DDB6E88C136E", blob(remove) )', + '( "D41D8CD98F00B204E9800998ECF8427E", blob() )', + '( "EFE0AE5FD114DE99855BC2838BE97E1D", blob(edit-v1) )', +] [[]] type = 'table' @@ -21,7 +25,12 @@ CREATE TABLE map ( tile_row integer NOT NULL, tile_id text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, "EFE0AE5FD114DE99855BC2838BE97E1D" )', + '( 5, 1, 2, "D41D8CD98F00B204E9800998ECF8427E" )', + '( 5, 2, 2, "0F6969D7052DA9261E31DDB6E88C136E" )', + '( 6, 1, 4, "EFE0AE5FD114DE99855BC2838BE97E1D" )', +] [[]] type = 'table' @@ -31,7 +40,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-flat.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-flat.snap index c42f0c9fb..510f57545 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-flat.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-flat.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -26,7 +26,12 @@ CREATE TABLE tiles ( tile_row integer NOT NULL, tile_data blob, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, blob(edit-v1) )', + '( 5, 1, 2, blob() )', + '( 5, 2, 2, blob(remove) )', + '( 6, 1, 4, blob(edit-v1) )', +] [[]] type = 'index' diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-hash.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-hash.snap index 2312027a7..d7da64239 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-hash.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-hash.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -27,7 +27,12 @@ CREATE TABLE tiles_with_hash ( tile_data blob, tile_hash text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', + '( 5, 1, 2, blob(), "D41D8CD98F00B204E9800998ECF8427E" )', + '( 5, 2, 2, blob(remove), "0F6969D7052DA9261E31DDB6E88C136E" )', + '( 6, 1, 4, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', +] [[]] type = 'index' diff --git a/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-norm.snap b/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-norm.snap index 76d5da307..ae37bc9bf 100644 --- a/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-norm.snap +++ b/mbtiles/tests/snapshots/copy__convert@v1__bbox__norm-norm.snap @@ -9,7 +9,11 @@ sql = ''' CREATE TABLE images ( tile_id text NOT NULL PRIMARY KEY, tile_data blob)''' -values = [] +values = [ + '( "0F6969D7052DA9261E31DDB6E88C136E", blob(remove) )', + '( "D41D8CD98F00B204E9800998ECF8427E", blob() )', + '( "EFE0AE5FD114DE99855BC2838BE97E1D", blob(edit-v1) )', +] [[]] type = 'table' @@ -21,7 +25,12 @@ CREATE TABLE map ( tile_row integer NOT NULL, tile_id text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' -values = [] +values = [ + '( 5, 1, 1, "EFE0AE5FD114DE99855BC2838BE97E1D" )', + '( 5, 1, 2, "D41D8CD98F00B204E9800998ECF8427E" )', + '( 5, 2, 2, "0F6969D7052DA9261E31DDB6E88C136E" )', + '( 6, 1, 4, "EFE0AE5FD114DE99855BC2838BE97E1D" )', +] [[]] type = 'table' @@ -31,7 +40,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "D41D8CD98F00B204E9800998ECF8427E" )', + '( "agg_tiles_hash", "012434681F0EBF296906D6608C54D632" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', diff --git a/mbtiles/tests/validate.rs b/mbtiles/tests/validate.rs index 7192d4538..5ec1e9891 100644 --- a/mbtiles/tests/validate.rs +++ b/mbtiles/tests/validate.rs @@ -1,4 +1,7 @@ -use martin_tile_utils::MAX_ZOOM; +#![allow(clippy::unreadable_literal)] + +use insta::{assert_debug_snapshot, assert_display_snapshot, assert_snapshot}; +use martin_tile_utils::{bbox_to_xyz, MAX_ZOOM}; use mbtiles::MbtError::InvalidTileIndex; use mbtiles::{create_metadata_table, Mbtiles}; use rstest::rstest; @@ -92,13 +95,16 @@ async fn tile_coordinate(#[case] prefix: &str, #[case] suffix: &str) { ok!("1, {prefix} 1 {suffix}"); ok!("2, {prefix} 3 {suffix}"); ok!("3, {prefix} 7 {suffix}"); - ok!("30, {prefix} 0 {suffix}"); - ok!("30, {prefix} 1073741823 {suffix}"); + ok!("24, {prefix} 0 {suffix}"); + ok!("24, {prefix} 16777215 {suffix}"); + // ok!("30, {prefix} 0 {suffix}"); + // ok!("30, {prefix} 1073741823 {suffix}"); err!("0, {prefix} 1 {suffix}"); err!("1, {prefix} 2 {suffix}"); err!("2, {prefix} 4 {suffix}"); err!("3, {prefix} 8 {suffix}"); + err!("24, {prefix} 16777216 {suffix}"); err!("30, {prefix} 1073741824 {suffix}"); err!("{MAX_ZOOM}, {prefix} 1073741824 {suffix}"); err!("{}, {prefix} 0 {suffix}", MAX_ZOOM + 1); // unsupported zoom @@ -117,3 +123,45 @@ async fn tile_data() { err!("0, 0, 0, CAST('abc' AS TEXT)"); err!("0, 0, 0, CAST(123 AS TEXT)"); } + +#[test] +fn test_box() { + fn tst(left: f64, bottom: f64, right: f64, top: f64, zoom: u8) -> String { + let (x0, y0, x1, y1) = bbox_to_xyz(left, bottom, right, top, zoom); + format!("({x0}, {y0}, {x1}, {y1})") + } + + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 0), @"(0, 0, 0, 0)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 1), @"(0, 1, 0, 1)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 2), @"(0, 3, 0, 3)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 3), @"(0, 7, 0, 7)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 4), @"(0, 14, 1, 15)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 5), @"(0, 29, 2, 31)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 6), @"(0, 58, 5, 63)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 7), @"(0, 116, 11, 126)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 8), @"(0, 233, 23, 253)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 9), @"(0, 466, 47, 507)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 10), @"(1, 933, 94, 1014)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 11), @"(3, 1866, 188, 2029)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 12), @"(6, 3732, 377, 4059)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 13), @"(12, 7465, 755, 8119)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 14), @"(25, 14931, 1510, 16239)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 15), @"(51, 29863, 3020, 32479)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 16), @"(102, 59727, 6041, 64958)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 17), @"(204, 119455, 12083, 129917)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 18), @"(409, 238911, 24166, 259834)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 19), @"(819, 477823, 48332, 519669)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 20), @"(1638, 955647, 96665, 1039339)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 21), @"(3276, 1911295, 193331, 2078678)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 22), @"(6553, 3822590, 386662, 4157356)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 23), @"(13107, 7645181, 773324, 8314713)"); + assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 24), @"(26214, 15290363, 1546649, 16629427)"); + + // All these are incorrect + // assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 25), @"(33554431, 33554431, 33554431, 33554431)"); + // assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 26), @"(67108863, 67108863, 67108863, 67108863)"); + // assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 27), @"(134217727, 134217727, 134217727, 134217727)"); + // assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 28), @"(268435455, 268435455, 268435455, 268435455)"); + // assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 29), @"(536870911, 536870911, 536870911, 536870911)"); + // assert_snapshot!(tst(-179.43749999999955,-84.76987877980656,-146.8124999999996,-81.37446385260833, 30), @"(1073741823, 1073741823, 1073741823, 1073741823)"); +}