| Crates.io | compass_data |
| lib.rs | compass_data |
| version | 0.0.7 |
| created_at | 2024-07-30 00:02:10.752649+00 |
| updated_at | 2026-01-25 18:06:29.471313+00 |
| description | A library for working with Compass cave survey data |
| homepage | |
| repository | https://github.com/zheylmun/compass_data |
| max_upload_size | |
| id | 1319320 |
| size | 237,933 |
A Rust library for reading, writing, and working with Compass
cave survey project files (.mak) and survey data files (.dat).
This library enables interoperation and data sharing between cave survey software by providing a complete implementation of the Compass file formats. It supports:
.mak): Parse and create project files that organize multiple survey data files.dat): Parse and serialize individual survey data with shots, stations, and metadatause compass_data::Project;
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read a project file (parses metadata but doesn't load survey data yet)
let project = Project::read(&PathBuf::from("cave.mak"))?;
println!("Project has {} survey files", project.survey_files.len());
// Access file metadata without loading survey data
for dat_file in &project.survey_files {
println!(" File: {}", dat_file.file_path.display());
println!(" Datum: {:?}", dat_file.file_state.datum);
}
// Load all survey data from disk
let loaded_project = project.load_survey_files()?;
// Now access the actual survey data
for dat_file in &loaded_project.survey_files {
for survey in dat_file.surveys() {
println!("Survey: {} - {} shots", survey.name, survey.shots.len());
}
}
Ok(())
}
use compass_data::Survey;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let contents = std::fs::read_to_string("survey.dat")?;
let surveys = Survey::parse_dat_file(&contents)?;
for survey in &surveys {
println!("Cave: {}", survey.cave_name);
println!("Survey: {}", survey.name);
println!("Date: {}", survey.date);
println!("Shots: {}", survey.shots.len());
}
Ok(())
}
use compass_data::Survey;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Parse and re-serialize (round-trip)
let contents = std::fs::read_to_string("survey.dat")?;
let surveys = Survey::parse_dat_file(&contents)?;
for survey in &surveys {
let serialized = survey.serialize();
std::fs::write(format!("{}.dat", survey.name), serialized)?;
}
Ok(())
}
| Type | Description |
|---|---|
[Project] |
A Compass project file containing references to survey data files |
[DatFile] |
A survey data file reference with its associated state |
[Survey] |
A single survey containing shots, team info, date, and parameters |
[Shot] |
A single survey shot with distance, azimuth, inclination, and LRUD |
[Datum] |
Geodetic datum (NAD27, NAD83, WGS84, etc.) |
[FileState] |
Rolling state captured when a file is encountered during parsing |
serde: Enable serialization/deserialization with serdecli: Build the compass CLI tool for inspecting project and survey filesWhen built with the cli feature, a command-line tool is available:
# Install
cargo install compass_data --features cli
# Inspect a project file
compass inspect project cave.mak
# Inspect with full survey data
compass inspect project cave.mak --load
# Inspect a survey data file
compass inspect survey cave.dat
# Show detailed shot data
compass inspect survey cave.dat --verbose
The Compass file formats are documented at:
Licensed under either:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.