Skip to main content

SrtmServiceBuilder

Struct SrtmServiceBuilder 

Source
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

Source

pub fn new<P: AsRef<Path>>(data_dir: P) -> Self

Create a new builder with the specified data directory.

Source

pub fn from_env() -> Result<Self>

Create a builder configured from environment variables.

§Environment Variables
VariableDescriptionDefault
HTG_DATA_DIRDirectory containing .hgt filesRequired
HTG_CACHE_SIZEMaximum tiles in cache100
HTG_DOWNLOAD_SOURCENamed source: “ardupilot”*None
HTG_DOWNLOAD_URLURL template for custom downloads*None
HTG_DOWNLOAD_GZIPWhether URL serves gzip files*false

*Only used when download feature is enabled.

§Named Sources
  • ardupilot or ardupilot-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.

Source

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.

Source

pub fn cache_size(self, size: u64) -> Self

Set the maximum number of tiles to keep in cache.

Default is 100 tiles.

Source

pub fn build(self) -> SrtmService

Build the SrtmService.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.