-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added examples to utiles of basic mbtiles usage (#125)
- Loading branch information
1 parent
7117683
commit d2b341e
Showing
7 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use anyhow::Result; | ||
use std::path::PathBuf; | ||
use utiles::mbt::{MbtilesAsync, MbtilesClientAsync}; | ||
use utiles_core::utile; | ||
use utiles_core::Tile; | ||
fn get_utiles_test_osm_mbtiles_path() -> PathBuf { | ||
let pwd = std::env::current_dir().unwrap(); | ||
let repo_root = pwd.parent().unwrap().parent().unwrap(); | ||
repo_root.join("test-data/mbtiles/osm-standard.z0z4.mbtiles") | ||
} | ||
|
||
fn printsep() { | ||
// 80 chars | ||
println!("{}", "-".repeat(80)); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let src = get_utiles_test_osm_mbtiles_path(); | ||
println!("mbtiles path: {:?}", src); | ||
|
||
printsep(); | ||
let mbt = MbtilesClientAsync::open_existing(src).await?; // .await | ||
println!("mbtiles: {:?}", mbt); | ||
|
||
printsep(); | ||
let metadata = mbt.metadata_rows().await?; | ||
println!("metadata: {:?}", metadata); | ||
|
||
printsep(); | ||
let count = mbt.tiles_count().await?; | ||
println!("tiles count: {:?}", count); | ||
|
||
printsep(); | ||
let tile = utile!(0, 0, 0); | ||
let a_tile = mbt.query_tile(&tile).await?; | ||
if let Some(tile_data) = a_tile { | ||
println!("tile (size): {:?}", tile_data.len()); | ||
} else { | ||
println!("tile not found: {:?}", tile); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use anyhow::Result; | ||
use std::path::PathBuf; | ||
use utiles::mbt::Mbtiles; | ||
use utiles_core::utile; | ||
use utiles_core::Tile; | ||
fn get_utiles_test_osm_mbtiles_path() -> PathBuf { | ||
let pwd = std::env::current_dir().unwrap(); | ||
let repo_root = pwd.parent().unwrap().parent().unwrap(); | ||
repo_root.join("test-data/mbtiles/osm-standard.z0z4.mbtiles") | ||
} | ||
|
||
fn printsep() { | ||
// 80 chars | ||
println!("{}", "-".repeat(80)); | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let src = get_utiles_test_osm_mbtiles_path(); | ||
println!("mbtiles path: {:?}", src); | ||
|
||
printsep(); | ||
let mbt = Mbtiles::open_existing(src) // .await | ||
.expect("Failed to open mbtiles"); | ||
println!("mbtiles: {:?}", mbt); | ||
printsep(); | ||
|
||
let metadata = mbt.metadata(); | ||
println!("metadata: {:?}", metadata); | ||
|
||
printsep(); | ||
let count = mbt.tiles_count(); | ||
println!("tiles count: {:?}", count); | ||
|
||
printsep(); | ||
let tile = utile!(0, 0, 0); | ||
let a_tile = mbt.query_tile(&tile)?; | ||
if let Some(tile_data) = a_tile { | ||
println!("tile (size): {:?}", tile_data.len()); | ||
} else { | ||
println!("tile not found: {:?}", tile); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters