9个版本
0.3.5 | 2023年7月15日 |
---|---|
0.3.4 | 2023年7月2日 |
0.3.3 | 2023年3月13日 |
0.3.1 | 2022年9月13日 |
0.1.0 | 2021年9月1日 |
在 异步 中排名 225
每月下载 71 次
在 osrm_client 中使用
15KB
211 行代码
nominatim-rs
Rust对nominatim逆向地理编码API的API绑定。
我努力使这个库保持简单且易于初学者使用,以便您可以在自己的项目中轻松使用。如果您正在寻找新功能或发现错误,请在Github仓库上打开一个PR或issue,我会尽快处理。
示例
创建客户端
let client = Client::new(IdentificationMethod::from_user_agent(
"Example Application Name",
));
检查服务器状态
let status = client.status().await.unwrap();
println!("{}", client.status().await.unwrap());
返回
OK
使用简单查询搜索一些地点
let search_results = client.search("statue of liberty").await.unwrap();
for place in search_results {
println!("{}", place.display_name);
}
返回
Statue of Liberty, Flagpole Plaza, Manhattan Community Board 1, Manhattan, New York County, City of New York, New York, 10004, United States
Statue of Liberty, North Center Street, Plymouth, Marshall County, Indiana, 46563, United States
Statue of Liberty, Visnesvegen, Visnes, Karmøy, Rogaland, 4264, Norge
Statue of Liberty, East Grace Street, Chimborazo, Church Hill, Richmond, Virginia, 23298, United States
Statue of Liberty, East 12th Street, Des Moines, Polk County, Iowa, 50316, United States
Statue of Liberty, Locust Street, Cathedral Historic District, Dubuque, Dubuque County, Iowa, 52001, United States
Statue of Liberty, IA 946, South Port, Dubuque, Dubuque County, Iowa, 52001, United States
Statue of Liberty, Colorado Avenue, La Junta, Otero County, Colorado, 81050, United States
Statue of Liberty, North Main Street, Leon, Decatur County, Iowa, 50144, United States
Statue of Liberty, 23501, Macedonia Road, Hegar, Hockley, Waller County, Texas, 77447, United States
查找最近的经纬度对
let reverse_search = client
.reverse("40.689249", "-74.044500", None)
.await
.unwrap();
println!("{}", reverse_search.display_name);
返回
Statue of Liberty, Flagpole Plaza, Manhattan Community Board 1, Manhattan, New York County, City of New York, New York, 10004, United States
从OSM节点、线路或关系列表中查找地点
let lookup_results = client.lookup(vec!["R146656", "W50637691"]).await.unwrap();
for place in lookup_results {
println!("{}", place.display_name);
}
返回
Manchester, Greater Manchester, England, United Kingdom
Brandenburger Tor, Brandenburger Straße, Historische Innenstadt, Innenstadt, Potsdam, Brandenburg, 14467, Deutschland
更新日志
0.1.0:
- 初始发布。
0.2.0:
- 需要API访问的识别方法。
0.3.0:
- 将tokio/reqwest改为更常见的。
0.3.1:
- 为各种结构体添加
Clone/
Debug
。
0.3.2:
- 允许API端点不在URL的基路径上。
- 清理代码和文档。
0.3.3:
- 为HTTP请求添加10秒超时。
0.3.4:
- 通用化
Client::set_base_url
,允许TryInto<Url>
。 - 公开
Client::timeout
以进行自定义/无HTTP请求超时。 - 添加一个
rustls
功能,以便在不使用OpenSSL的情况下编译。
0.3.5:
- 更新
rustls
功能以更通用。
许可
MIT License
Copyright (c) 2023 Grant Handy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
依赖项
~3–20MB
~286K SLoC