Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/estin/geosuggest
suggest by name or find nearest by coordinates cities
https://github.com/estin/geosuggest
geocoding http rust
Last synced: 2 months ago
JSON representation
suggest by name or find nearest by coordinates cities
- Host: GitHub
- URL: https://github.com/estin/geosuggest
- Owner: estin
- License: mit
- Created: 2021-06-05T12:55:19.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-23T08:56:18.000Z (7 months ago)
- Last Synced: 2024-09-02T16:41:48.952Z (5 months ago)
- Topics: geocoding, http, rust
- Language: Rust
- Homepage:
- Size: 213 KB
- Stars: 8
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
geosuggest
Library/Service to suggest and to find nearest by coordinates cities
[Live demo](https://geosuggest.etatarkin.ru/) with [sources](https://github.com/estin/geosuggest/tree/master/geosuggest-demo)
Main features:
- library or service modes
- build index by free gazetteer data from [geonames.org](https://www.geonames.org/)
- suggest city by name
- find nearest city by coordinates
- MaxMind GeoIP2(Lite) city database support
- multi-language (based on configured index options)
- simple REST http [api](https://geosuggest.etatarkin.ru/swagger)
- no external services used### Based on:
- [strsim](https://crates.io/crates/strsim)
- [kiddo](https://crates.io/crates/kiddo)
- [geoip2](https://crates.io/crates/geoip2)
- [ntex](https://crates.io/crates/ntex)## Library
Crate usage [example](https://github.com/estin/geosuggest/tree/master/examples/src/simple.rs)
```console
$ cargo run -p geosuggest-examples --release --bin simple
```## Service
Install from sources (preferred).
```console
$ git clone https://github.com/estin/geosuggest.git
$ cd geosuggest
$ cargo build --release
```Build index file
```console
$ cargo run -p geosuggest-utils --bin geosuggest-build-index --release --features=cli,tracing -- \
from-urls \
--languages=ru,uk,be,zh,ja \
--output=/tmp/geosuggest-index.bincode
```Run
```console
$ GEOSUGGEST__INDEX_FILE=/tmp/geosuggest-index.bincode \
GEOSUGGEST__HOST=127.0.0.1 \
GEOSUGGEST__PORT=8080 \
GEOSUGGEST__URL_PATH_PREFIX="/" \
cargo run -p geosuggest --bin geosuggest --release
```Check
```console
$ curl -s "http://127.0.0.1:8080/api/city/suggest?pattern=Voronezh&limit=1" | jq
``````json
{
"items": [
{
"id": 472045,
"name": "Voronezh",
"country": {
"id": 2017370,
"code": "RU",
"name": "Russia"
},
"admin_division": {
"id": 472039,
"code": "RU.86",
"name": "Voronezj"
},
"admin2_division": null,
"timezone": "Europe/Moscow",
"latitude": 51.67204,
"longitude": 39.1843,
"population": 848752
}
],
"time": 24
}
```See also demo [Dockerfile](https://github.com/estin/geosuggest/blob/master/geosuggest-demo/Dockerfile)
## Test
```console
$ cargo test --workspace --all-features
```## License
This project is licensed under
* MIT license ([LICENSE](LICENSE) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT))