GeoLocation

Struct GeoLocation 

Source
pub struct GeoLocation {
    pub longitude: DmsCoordinate,
    pub latitude: DmsCoordinate,
    pub geodetic_system: Option<String>,
}
Expand description

緯度経度情報

Fields§

§longitude: DmsCoordinate

経度(度分秒)

§latitude: DmsCoordinate

緯度(度分秒)

§geodetic_system: Option<String>

測地系コード

Implementations§

Source§

impl GeoLocation

Source

pub fn to_wgs84(&self, transformer: &JgdTransformer) -> Option<(f64, f64)>

WGS84座標系に変換した座標を取得

国土地理院のTKY2JGD/PatchJGDパラメータを使用して Tokyo Datum/JGD2000 → JGD2011 → WGS84 の変換を行う。

§Arguments
  • transformer - JgdTransformer インスタンス
§Returns

Some((経度, 緯度)) - WGS84座標系での10進数座標 None - 座標が取得できない場合

§Example
ⓘ
let transformer = JgdTransformer::new("TKY2JGD.par", "patch_files")?;
let (lng, lat) = location.to_wgs84(&transformer)?;
Examples found in repository?
examples/bench.rs (line 28)
5fn main() {
6    // ファイル読み込み
7    let xml_bytes = std::fs::read("107282 (1).xml").unwrap();
8    let (utf8, _, _) = encoding_rs::SHIFT_JIS.decode(&xml_bytes);
9    let xml_str = utf8.to_string();
10    
11    // パース計測
12    let start = Instant::now();
13    let boring = Boring300::parse_from_str(&xml_str).unwrap();
14    println!("Parse: {:?}", start.elapsed());
15    
16    // 変換器初期化計測
17    let start = Instant::now();
18    let transformer = JgdTransformer::with_survey_date(
19        "params/TKY2JGD.par",
20        "params/patch_files",
21        SurveyStartDate::new(2010, 5, 15),
22    ).unwrap();
23    println!("Transformer init: {:?}", start.elapsed());
24    
25    // 座標変換計測
26    let start = Instant::now();
27    let loc = boring.geo_location();
28    let result = loc.to_wgs84(&transformer);
29    println!("Coordinate transform: {:?}", start.elapsed());
30    println!("Result: {:?}", result);
31    
32    // 100回ループ計測
33    let start = Instant::now();
34    for _ in 0..100 {
35        let loc = boring.geo_location();
36        let _ = loc.to_wgs84(&transformer);
37    }
38    println!("100x transform: {:?}", start.elapsed());
39}
Source

pub fn to_decimal(&self) -> Option<(f64, f64)>

10進数座標を取得 (変換なし)

§Returns

Some((経度, 緯度)) - 10進数座標 None - 座標が取得できない場合

Source

pub fn datum(&self) -> GeodeticDatum

測地系を取得

Trait Implementations§

Source§

impl Clone for GeoLocation

Source§

fn clone(&self) -> GeoLocation

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GeoLocation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for GeoLocation

Source§

fn eq(&self, other: &GeoLocation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for GeoLocation

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.