jgdtrans

Crates.iojgdtrans
lib.rsjgdtrans
version
sourcesrc
created_at2024-06-29 13:28:17.004902
updated_at2024-10-06 11:23:53.713385
descriptionCoordinate Transformer by Gridded Correction Parameter (par file)
homepage
repositoryhttps://github.com/paqira/jgdtrans-rs
max_upload_size
id1287384
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(paqira)

documentation

README

jgdtrans for Rust

Crates.io Version GitHub Actions Workflow Status docs.rs Crates.io License

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 by serde crate, this requires dependency on serde.

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

  1. Geospatial Information Authority of Japan (GIAJ, 国土地理院): https://www.gsi.go.jp/, (English) https://www.gsi.go.jp/ENGLISH/.
  2. 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.
  3. Other implementation: Python https://github.com/paqira/jgdtrans-py, Java https://github.com/paqira/jgdtrans-java, JavaScript/TypeScript https://github.com/paqira/jgdtrans-js.
Commit count: 291

cargo fmt