| Crates.io | htg |
| lib.rs | htg |
| version | 0.2.1 |
| created_at | 2025-12-21 00:58:21.033208+00 |
| updated_at | 2025-12-21 17:47:46.077415+00 |
| description | High-performance SRTM elevation data library |
| homepage | |
| repository | https://github.com/pedrosanzmtz/htg |
| max_upload_size | |
| id | 1997177 |
| size | 159,599 |
High-performance, memory-efficient Rust library for querying elevation data from SRTM (Shuttle Radar Topography Mission) .hgt files.
.hgt filesdownload feature)[dependencies]
htg = "0.2"
# With auto-download support
htg = { version = "0.2", features = ["download"] }
use htg::SrtmService;
// Create service with data directory and cache size
let service = SrtmService::new("/path/to/hgt/files", 100);
// Query elevation (returns meters as i16)
let elevation = service.get_elevation(35.6762, 139.6503)?;
println!("Elevation: {}m", elevation);
// Query with bilinear interpolation (returns Option<f64>)
if let Some(elevation) = service.get_elevation_interpolated(35.6762, 139.6503)? {
println!("Interpolated: {:.1}m", elevation);
}
Enable the download feature to automatically fetch missing tiles:
use htg::{SrtmServiceBuilder, download::DownloadConfig};
// Using ArduPilot terrain server (recommended)
let service = SrtmServiceBuilder::new("/data/srtm")
.cache_size(100)
.auto_download(DownloadConfig::ardupilot())
.build()?;
// Tiles are downloaded automatically when needed
let elevation = service.get_elevation(35.6762, 139.6503)?;
use htg::{SrtmServiceBuilder, download::DownloadConfig};
let service = SrtmServiceBuilder::new("/data/srtm")
.auto_download(DownloadConfig::with_url_template(
"https://example.com/srtm/{filename}.hgt.gz",
))
.build()?;
use htg::SrtmServiceBuilder;
// Configure via environment variables:
// - HTG_DATA_DIR: Directory containing .hgt files (required)
// - HTG_CACHE_SIZE: Max tiles in cache (default: 100)
// - HTG_DOWNLOAD_SOURCE: "ardupilot", "ardupilot-srtm1", or "ardupilot-srtm3"
let service = SrtmServiceBuilder::from_env()?.build()?;
N35E138.hgt (latitude + longitude of SW corner)This is part of the htg workspace:
MIT