Skip to content

Commit

Permalink
Use MbtType directly
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Nov 9, 2023
1 parent 99ffdc2 commit d68f612
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions mbtiles/src/mbtiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ pub struct LevelDetail {
pub bounding_box: [f32; 4],
}

#[derive(Clone, Debug, PartialEq, Serialize)]
#[derive(Clone, Debug, PartialEq)]
pub struct Statistics {
pub file_path: String,
pub file_size: f64,
pub schema: String,
pub schema: MbtType,
pub page_size: Option<i32>,
pub level_details: Vec<LevelDetail>,
}
Expand Down Expand Up @@ -298,11 +298,7 @@ impl Mbtiles {
FROM tiles
GROUP BY zoom_level"#
);
let mb_type_string = match self.detect_type(&mut *conn).await? {
MbtType::Flat => "flat",
MbtType::FlatWithHash => "flat with hash",
MbtType::Normalized { .. } => "normalized",
};
let mbt_type = self.detect_type(&mut *conn).await?;
let level_rows = tile_infos_query.fetch_all(&mut *conn).await?;
let mut level_details: Vec<LevelDetail> = level_rows
.into_iter()
Expand Down Expand Up @@ -379,7 +375,7 @@ impl Mbtiles {
Ok(Statistics {
file_path: self.filepath.clone(),
file_size,
schema: mb_type_string.to_owned(),
schema: mbt_type,
page_size,
level_details,
})
Expand Down Expand Up @@ -1020,7 +1016,7 @@ mod tests {
"../tests/fixtures/mbtiles/world_cities.mbtiles"
);
assert_eq!(res.file_size, 0.046875);
assert_eq!(res.schema, "flat");
assert_eq!(res.schema, MbtType::Flat);
assert_eq!(res.page_size, Some(4096));

assert_eq!(res.level_details.len(), 8);
Expand Down

0 comments on commit d68f612

Please sign in to comment.