| Crates.io | jgdtrans |
| lib.rs | jgdtrans |
| version | 0.3.1 |
| created_at | 2024-06-29 13:28:17.004902+00 |
| updated_at | 2025-04-11 13:34:20.162743+00 |
| description | Coordinate Transformer by Gridded Correction Parameter (par file) |
| homepage | |
| repository | https://github.com/paqira/jgdtrans-rs |
| max_upload_size | |
| id | 1287384 |
| size | 289,780 |
Unofficial coordinate transformer by Gridded Correction Parameter which Geospatial Information Authority of Japan (GIAJ, formerly GSIJ) distributing for Rust.
国土地理院が公開している .par ファイルによる変換(逆変換)の非公式な実装です。
Features:
serde: supports serialization/deserialization by serde crate,
this requires dependency on serde.This package does not contain parameter files, download it from GIAJ.
このパッケージはパラメータファイルを提供しません。公式サイトよりダウンロードしてください。
Sample code:
use std::error::Error;
use std::fs;
use jgdtrans::{Format, Point, Transformer};
fn main() -> Result<(), Box<dyn Error>> {
// Deserialize par-formatted file, e.g. SemiDyna2023.par
let s = fs::read_to_string("SemiDyna2023.par").expect("file not found 'SemiDyna2023.par'");
let tf = Transformer::from_str(&s, Format::SemiDynaEXE)?;
// Make the origin of transformation
let origin = Point::new_unchecked(35.0, 135.0, 2.34);
// Prints Point { latitude: 35.0, longitude: 135.0, altitude: 2.34 }
println!("{origin:?}");
// Perform forward transformation resulting a Point
let result = tf.forward(&origin)?;
// Prints Point { latitude: 34.99999831111111, longitude: 135.00000621666666, altitude: 2.33108 }
println!("{result:?}");
// Perform backward transformation
let p = tf.backward(&result)?;
// Prints Point { latitude: 35.0, longitude: 135.0, altitude: 2.34 }
println!("{p:?}");
// Perform backward transformation compatible to the GIAJ web app/APIs
let q = tf.backward_compat(&result)?;
// Prints Point { latitude: 34.999999999999986, longitude: 135.0, altitude: 2.339999999105295 }
println!("{q:?}");
Ok(())
}
MIT or Apache-2.0