Expand description
Library that reading/writing ISG-format.
use std::fs;
use libisg;
use libisg::{Data, DataBounds, ISG};
let s = fs::read_to_string("Example 1.isg").unwrap();
let isg = libisg::from_str(&s).unwrap();
// use data
let (a_max, b_max, delta_a, delta_b) = match isg.header.data_bounds {
DataBounds::GridGeodetic { lat_max, lon_max, delta_lat, delta_lon, .. } => {
(lat_max, lon_max, delta_lat, delta_lon)
},
_ => unimplemented!("`Example 1.isg` is grid geodetic"),
};
match &isg.data {
Data::Grid(data) => {
for (nrow, row) in data.iter().enumerate() {
for (ncol, value) in row.iter().enumerate() {
let a = a_max - delta_a * nrow;
let b = b_max + delta_b * ncol;
// do something
}
}
}
Data::Sparse(data) => {
for row in data {
let (a, b, value) = row;
// do something
}
}
}
§Serialize/Deserialize
§ISG format
Use from_str
and to_string
fns.
use std::fs;
use libisg;
let s = fs::read_to_string("Example 1.isg").unwrap();
// deserialize
let isg = libisg::from_str(&s).unwrap();
// serialize
assert_eq!(s, libisg::to_string(&isg));
§serde
ISG
supports serde
protocol.
use std::fs;
use serde_json;
use libisg;
let s = fs::read_to_string("Example 1.isg").unwrap();
let isg = libisg::from_str(&s).unwrap();
// serialize
let json = serde_json::to_string(&isg).unwrap();
// deserialize
assert_eq!(isg, serde_json::from_str(&json).unwrap());
§Notes
Structs§
- Creation
Date - Value of
creation date
- Header
- Header section of ISG.
- ISG
- ISG format.
- Parse
Error - Error on parsing ISG format
- Parse
Value Error - Error on parsing header value of ISG format
- Validation
Error - Error on validation
Enums§
- Coord
- Represents Coordinate
- Coord
Type - Value of
coord type
- Coord
Units - Value of
coord units
- Data
- Data section of ISG.
- Data
Bounds - Bounds and delta (
lat min
etc.) - Data
Format - Value of
data format
- Data
Ordering - Value of
data ordering
- Data
Type - Value of
data type
- Data
Units - Value of
data units
- Model
Type - Value of
model type
- Tide
System - Value of
tide system