Skip to content

glide-rs/seeyou-cupx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

seeyou-cupx

A Rust library for parsing and writing SeeYou CUPX files, commonly used in aviation and gliding for waypoints with attached pictures.

CUPX files consist of two concatenated ZIP archives: a "pics" archive containing images and a "points" archive containing a POINTS.CUP file with waypoint and task data. For more details, see the official CUPX file format specification.

Installation

Add this to your Cargo.toml:

[dependencies]
seeyou-cupx = "0.1.0"

Usage

Reading CUPX files

use seeyou_cupx::CupxFile;
use std::io::Read;

let (mut cupx, warnings) = CupxFile::from_path("waypoints.cupx")?;

// Access waypoint data
for waypoint in cupx.waypoints() {
    println!("{}: {}, {}", waypoint.name, waypoint.latitude, waypoint.longitude);
}

// Access pictures
for pic_name in cupx.picture_names() {
    println!("Picture: {}", pic_name);
}

// Read a specific picture
let mut reader = cupx.read_picture("airport.jpg")?;
let mut buffer = Vec::new();
reader.read_to_end(&mut buffer)?;

# Ok::<(), seeyou_cupx::Error>(())

Writing CUPX files

use seeyou_cupx::cup::CupFile;
use seeyou_cupx::CupxWriter;
use std::path::Path;

let cup_file = CupFile::default();

CupxWriter::new(&cup_file)
    .add_picture("airport.jpg", Path::new("images/airport.jpg"))
    .add_picture("runway.jpg", Path::new("images/runway.jpg"))
    .write_to_path("output.cupx")?;

# Ok::<(), seeyou_cupx::Error>(())

Encoding Support

By default, the library automatically detects the text encoding of CUP files. If you know the encoding beforehand:

use seeyou_cupx::cup::Encoding;
use seeyou_cupx::CupxFile;

let (cupx, warnings) = CupxFile::from_path_with_encoding("waypoints.cupx", Encoding::Utf8)?;

# Ok::<(), seeyou_cupx::Error>(())

Dependencies

This library uses seeyou-cup for parsing and writing the underlying CUP file format.

License

Licensed under either of:

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 dually licensed as above, without any additional terms or conditions.

About

A Rust library for parsing and writing SeeYou CUPX files, commonly used in aviation and gliding for waypoints with attached pictures

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Contributors

Languages