aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2026-04-05 17:26:06 +0200
committerDaniel Schadt <kingdread@gmx.de>2026-04-05 17:26:06 +0200
commit83f9dc870c15493c62a1aaf08802d11c4c11f82c (patch)
tree52f80aaccac10f441a5e0466eaa9aa74640309f6
parent1dd019bd986e6ce0fbe2394e154c6e37f1738c35 (diff)
downloadhittekaart-83f9dc870c15493c62a1aaf08802d11c4c11f82c.tar.gz
hittekaart-83f9dc870c15493c62a1aaf08802d11c4c11f82c.tar.bz2
hittekaart-83f9dc870c15493c62a1aaf08802d11c4c11f82c.zip
implement OsmAnd/MbTiles in python interfaceosmand-sqlite
-rw-r--r--hittekaart-py/hittekaart_py/hittekaart_py.pyi5
-rw-r--r--hittekaart-py/src/lib.rs32
2 files changed, 26 insertions, 11 deletions
diff --git a/hittekaart-py/hittekaart_py/hittekaart_py.pyi b/hittekaart-py/hittekaart_py/hittekaart_py.pyi
index 0efe011..b3d110c 100644
--- a/hittekaart-py/hittekaart_py/hittekaart_py.pyi
+++ b/hittekaart-py/hittekaart_py/hittekaart_py.pyi
@@ -14,7 +14,10 @@ class Storage:
def Folder(path: bytes) -> "Storage": ...
@staticmethod
- def Sqlite(path: bytes) -> "Storage": ...
+ def OsmAnd(path: bytes) -> "Storage": ...
+
+ @staticmethod
+ def MbTiles(path: bytes) -> "Storage": ...
class HeatmapRenderer:
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))
}