aboutsummaryrefslogtreecommitdiff
path: root/hittekaart-py/src
diff options
context:
space:
mode:
Diffstat (limited to 'hittekaart-py/src')
-rw-r--r--hittekaart-py/src/lib.rs32
1 files changed, 22 insertions, 10 deletions
diff --git a/hittekaart-py/src/lib.rs b/hittekaart-py/src/lib.rs
index c0f3f6c..7a88bab 100644
--- a/hittekaart-py/src/lib.rs
+++ b/hittekaart-py/src/lib.rs
@@ -87,7 +87,8 @@ impl Track {
#[derive(Debug, Clone, PartialEq, Eq)]
enum StorageType {
Folder(PathBuf),
- Sqlite(PathBuf),
+ OsmAnd(PathBuf),
+ MbTiles(PathBuf),
}
/// Represents a storage target.
@@ -113,22 +114,28 @@ impl Storage {
Storage(StorageType::Folder(path.into()))
}
- /// Output to the given SQLite file.
- ///
- /// This will create a single table 'tiles' with the columns 'zoom', 'x', 'y' and 'data'.
+ /// Output to the given SQLite file in a OsmAnd compatible format.
///
/// Note that you cannot "append" to an existing database, it must be a non-existing file.
#[staticmethod]
- #[pyo3(name = "Sqlite")]
- fn sqlite(path: &[u8]) -> Self {
+ #[pyo3(name = "OsmAnd")]
+ fn osmand(path: &[u8]) -> Self {
+ let path = OsStr::from_bytes(path);
+ Storage(StorageType::OsmAnd(path.into()))
+ }
+
+ #[staticmethod]
+ #[pyo3(name = "MbTiles")]
+ fn mbtiles(path: &[u8]) -> Self {
let path = OsStr::from_bytes(path);
- Storage(StorageType::Sqlite(path.into()))
+ Storage(StorageType::MbTiles(path.into()))
}
fn __repr__(&self) -> String {
match self.0 {
StorageType::Folder(ref path) => format!("<Storage.Folder path='{}'>", path.display()),
- StorageType::Sqlite(ref path) => format!("<Storage.Sqlite path='{}'>", path.display()),
+ StorageType::OsmAnd(ref path) => format!("<Storage.OsmAnd path='{}'>", path.display()),
+ StorageType::MbTiles(ref path) => format!("<Storage.MbTiles path='{}'>", path.display()),
}
}
}
@@ -140,8 +147,13 @@ impl Storage {
let storage = hittekaart::storage::Folder::new(path.clone());
Ok(Box::new(storage))
}
- StorageType::Sqlite(ref path) => {
- let storage = hittekaart::storage::Sqlite::connect(path.clone())
+ StorageType::OsmAnd(ref path) => {
+ let storage = hittekaart::storage::OsmAnd::open(path.clone())
+ .map_err(|e| err_to_py(&e))?;
+ Ok(Box::new(storage))
+ }
+ StorageType::MbTiles(ref path) => {
+ let storage = hittekaart::storage::MbTiles::open(path.clone())
.map_err(|e| err_to_py(&e))?;
Ok(Box::new(storage))
}