4 releases
0.2.3 | Oct 6, 2024 |
---|---|
0.2.2 | Jul 5, 2024 |
0.2.1 | Jul 3, 2024 |
0.2.0 | Jun 29, 2024 |
#49 in Geospatial
264 downloads per month
275KB
4.5K
SLoC
jgdtrans for Rust
Unofficial coordinate transformer by Gridded Correction Parameter which Geospatial Information Authority of Japan (GIAJ, formerly GSIJ) distributing for Rust.
国土地理院が公開している .par ファイルによる変換(逆変換)の非公式な実装です。
Features:
- Offline transformation (no web API)
- オフライン変換(web API 不使用)
- Supports both original forward/backward transformation
- 順変換と逆変換の両方をサポート
- Supports verified backward transformation
- 精度を保証した逆変換のサポート
- Supports all TKY2JGD, PatchJGD, PatchJGD(H), HyokoRev, SemiDynaEXE and POS2JGD (geonetF3 and ITRF2014)
- Clean implementation
- 保守が容易な実装
- No dependency
- 依存パッケージなし
jdgtrans
requires nightly channel of Rust, it depends on a float_next_up_down
feature.
Optional Features
serde
: supports serialization/deserialization byserde
crate, this requires dependency onserde
.
Usage
This package does not contain parameter files, download it from GIAJ.
このパッケージはパラメータファイルを提供しません。公式サイトよりダウンロードしてください。
Sample code:
use std::error::Error;
use std::fs;
use jgdtrans::{Point, Transformer, Format};
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(())
}
Licence
MIT or Apache-2.0
Reference
- Geospatial Information Authority of Japan (GIAJ, 国土地理院): https://www.gsi.go.jp/, (English) https://www.gsi.go.jp/ENGLISH/.
- TKY2JGD for Windows Ver.1.3.79 (reference implementation): https://www.gsi.go.jp/sokuchikijun/tky2jgd_download.html, released under 国土地理院コンテンツ利用規約 which compatible to CC BY 4.0.
- Other implementation: Python https://github.com/paqira/jgdtrans-py, Java https://github.com/paqira/jgdtrans-java, JavaScript/TypeScript https://github.com/paqira/jgdtrans-js.
Dependencies
~160KB