pub struct Geocoder { /* private fields */ }Expand description
逆ジオコーディングエンジン
国土交通省「位置参照情報」(大字・町丁目レベル)の代表点データを保持し、 座標から最寄りの大字・町丁目を検索します。
§注意
位置参照情報は各町丁目の代表点(ポリゴンではない)のデータです。 検索結果は「代表点が最も近い町丁目」であり、厳密に「その座標を含む町丁目」 とは限りません。町丁目の境界付近では隣の町丁目が返ることがあります。
Implementations§
Source§impl Geocoder
impl Geocoder
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
データファイルから構築する
embedded-dataフィーチャーを無効にした場合、データファイルは
GitHub Releasesから取得するか、tools/build-dataで生成してください。
Sourcepub fn from_reader(reader: impl Read) -> Result<Self, Error>
pub fn from_reader(reader: impl Read) -> Result<Self, Error>
リーダーから構築する
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
圧縮済みデータのバイト列から構築する
Sourcepub fn reverse_geocode(
&self,
lat: f64,
lon: f64,
) -> Result<ReverseGeocodeResult<'_>, Error>
pub fn reverse_geocode( &self, lat: f64, lon: f64, ) -> Result<ReverseGeocodeResult<'_>, Error>
座標から最寄りの大字・町丁目を検索する
§エラー
座標が日本のメッシュ範囲(北緯20〜46度、東経122〜154度)の外の場合は
Error::OutOfJapanRangeを返します。
§例
use japan_reverse_geocoder::Geocoder;
let geocoder = Geocoder::new();
let result = geocoder.reverse_geocode(35.6812, 139.7671).unwrap();
println!(
"{}{}{} ({:.0}m)",
result.address.prefecture, result.address.city, result.address.town,
result.distance_meters
);Sourcepub fn nearest(
&self,
lat: f64,
lon: f64,
k: usize,
) -> Result<Vec<ReverseGeocodeResult<'_>>, Error>
pub fn nearest( &self, lat: f64, lon: f64, k: usize, ) -> Result<Vec<ReverseGeocodeResult<'_>>, Error>
座標に近い順にk件の大字・町丁目を検索する
収録レコード数より大きいkを指定した場合は全件を返します。
Sourcepub fn within_radius(
&self,
lat: f64,
lon: f64,
radius_meters: f64,
) -> Result<Vec<ReverseGeocodeResult<'_>>, Error>
pub fn within_radius( &self, lat: f64, lon: f64, radius_meters: f64, ) -> Result<Vec<ReverseGeocodeResult<'_>>, Error>
半径radius_meters以内の大字・町丁目を近い順に列挙する
半径が負・NaNの場合は空のベクターを返します。
Sourcepub fn data_version(&self) -> &str
pub fn data_version(&self) -> &str
収録データのバージョン表記(例: “19.0b”)
Auto Trait Implementations§
impl Freeze for Geocoder
impl RefUnwindSafe for Geocoder
impl Send for Geocoder
impl Sync for Geocoder
impl Unpin for Geocoder
impl UnsafeUnpin for Geocoder
impl UnwindSafe for Geocoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more