pub struct SrtmServiceBuilder { /* private fields */ }Expand description
Builder for creating SrtmService with custom configuration.
§Example
ⓘ
use htg::SrtmServiceBuilder;
let service = SrtmServiceBuilder::new("/data/srtm")
.cache_size(100)
.build();§With Auto-Download (requires download feature)
ⓘ
use htg::{SrtmServiceBuilder, download::DownloadConfig};
let service = SrtmServiceBuilder::new("/data/srtm")
.cache_size(100)
.auto_download(DownloadConfig::with_url_template(
"https://example.com/srtm/{filename}.hgt.gz", // compression auto-detected
))
.build()?;Implementations§
Source§impl SrtmServiceBuilder
impl SrtmServiceBuilder
Sourcepub fn new<P: AsRef<Path>>(data_dir: P) -> Self
pub fn new<P: AsRef<Path>>(data_dir: P) -> Self
Create a new builder with the specified data directory.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a builder configured from environment variables.
§Environment Variables
| Variable | Description | Default |
|---|---|---|
HTG_DATA_DIR | Directory containing .hgt files | Required |
HTG_CACHE_SIZE | Maximum tiles in cache | 100 |
HTG_DOWNLOAD_SOURCE | Named source: “ardupilot”* | None |
HTG_DOWNLOAD_URL | URL template for custom downloads* | None |
HTG_DOWNLOAD_GZIP | Whether URL serves gzip files* | false |
*Only used when download feature is enabled.
§Named Sources
ardupilotorardupilot-srtm1- ArduPilot SRTM1 (30m resolution, ~25MB/tile)ardupilot-srtm3- ArduPilot SRTM3 (90m resolution, ~2.8MB/tile)
§URL Template Placeholders
{filename}- Full filename (e.g., “N35E138”){lat_prefix}- N or S{lat}- Latitude digits (e.g., “35”){lon_prefix}- E or W{lon}- Longitude digits (e.g., “138”){continent}- Continent subdirectory (e.g., “Eurasia”, “North_America”)
§Example
# Using ArduPilot source (recommended)
export HTG_DATA_DIR=/data/srtm
export HTG_DOWNLOAD_SOURCE=ardupilot
# Or using custom URL template
export HTG_DATA_DIR=/data/srtm
export HTG_CACHE_SIZE=50
export HTG_DOWNLOAD_URL="https://example.com/srtm/{filename}.hgt.gz"ⓘ
use htg::SrtmServiceBuilder;
let service = SrtmServiceBuilder::from_env()?.build()?;§Errors
Returns an error if HTG_DATA_DIR is not set.
Sourcepub fn data_dir<P: AsRef<Path>>(self, path: P) -> Self
pub fn data_dir<P: AsRef<Path>>(self, path: P) -> Self
Set the data directory.
Overrides the directory set in the constructor or from environment.
Sourcepub fn cache_size(self, size: u64) -> Self
pub fn cache_size(self, size: u64) -> Self
Set the maximum number of tiles to keep in cache.
Default is 100 tiles.
Sourcepub fn build(self) -> SrtmService
pub fn build(self) -> SrtmService
Build the SrtmService.
Auto Trait Implementations§
impl Freeze for SrtmServiceBuilder
impl RefUnwindSafe for SrtmServiceBuilder
impl Send for SrtmServiceBuilder
impl Sync for SrtmServiceBuilder
impl Unpin for SrtmServiceBuilder
impl UnsafeUnpin for SrtmServiceBuilder
impl UnwindSafe for SrtmServiceBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more