• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast, offline, reverse geocoder

Rust Reverse Geocoder

A fast reverse geocoder in Rust. Inspired by Python reverse-geocoder.

Links

Description

rrgeo takes a latitude and longitude as input and returns the closest city, country, latitude, and longitude, using a k-d tree to efficiently find the nearest neighbour based on a known list of locations. This can be useful if you need to reverse geocode a large number of coordinates quickly, or just need the rough location of coordinates but don't want the expense or complication of an online reverse geocoder.

This project contains (via Cargo workspaces) a library, a Axum REST API, an Actix REST API, a Warp REST API, and a command-line utility.

Usage

Command line search

Example usage:

> cargo run -p rrgeo-cmd --release 40 -73
0 ms to search
Location: (40.72788, -73.09761): West Sayville, New York, Suffolk County, US
Distance: 0.539337006499999

Web Servers

Example usage:

cargo run -p rrgeo-axum --release
cargo run -p rrgeo-actix --release
cargo run -p rrgeo-warp --release

Benchmarks

Benchmarked on Apple M1.

  • Core library benchmarked with cargo bench and criterion
  • Web servers benchmarked with oha

Core library:

> cargo bench
search                  time:   [416.30 ns 416.39 ns 416.49 ns]
Served via Axum
> cargo run -p rrgeo-axum --release
>  oha http://localhost:3000/\?lat\=40\&long\=\-73 -z 5sec
Summary:
  Success rate:	1.0000
  Total:	5.0009 secs
  Slowest:	0.0115 secs
  Fastest:	0.0000 secs
  Average:	0.0003 secs
  Requests/sec:	171372.8673

  Total data:	123.42 MiB
  Size/request:	151 B
  Size/sec:	24.68 MiB

Response time histogram:
  0.000 [1]      |
  0.001 [856908] |โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– 
  0.002 [22]     |
  0.003 [54]     |
  0.005 [7]      |
  0.006 [7]      |
  0.007 [8]      |
  0.008 [4]      |
  0.009 [4]      |
  0.010 [2]      |
  0.012 [4]      |

Latency distribution:
  10% in 0.0002 secs
  25% in 0.0002 secs
  50% in 0.0003 secs
  75% in 0.0004 secs
  90% in 0.0004 secs
  95% in 0.0005 secs
  99% in 0.0006 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0014 secs, 0.0010 secs, 0.0019 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0003 secs

Status code distribution:
  [200] 857021 responses
Served via Actix Web
> cargo run --release --bin rrgeo-actix
> oha http://localhost:3000/\?lat\=40\&long\=\-73 -z 5sec
Summary:
  Success rate:	1.0000
  Total:	5.0007 secs
  Slowest:	0.2903 secs
  Fastest:	0.0000 secs
  Average:	0.0003 secs
  Requests/sec:	161291.4437

  Total data:	85.38 MiB
  Size/request:	111 B
  Size/sec:	17.07 MiB

Response time histogram:
  0.000 [1]      |
  0.029 [805611] |โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– 
  0.058 [379]    |
  0.087 [192]    |
  0.116 [111]    |
  0.145 [231]    |
  0.174 [15]     |
  0.203 [6]      |
  0.232 [6]      |
  0.261 [11]     |
  0.290 [1]      |

Latency distribution:
  10% in 0.0001 secs
  25% in 0.0001 secs
  50% in 0.0001 secs
  75% in 0.0002 secs
  90% in 0.0004 secs
  95% in 0.0005 secs
  99% in 0.0017 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0015 secs, 0.0013 secs, 0.0017 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0003 secs

Status code distribution:
  [200] 806564 responses

Served via Warp
> cargo run --release --bin rrgeo-warp
> oha http://localhost:3000/\?lat\=40\&long\=\-73 -z 5sec
Summary:
  Success rate:	1.0000
  Total:	5.0009 secs
  Slowest:	0.0134 secs
  Fastest:	0.0000 secs
  Average:	0.0003 secs
  Requests/sec:	180231.7215

  Total data:	129.79 MiB
  Size/request:	151 B
  Size/sec:	25.95 MiB

Response time histogram:
  0.000 [1]      |
  0.001 [901133] |โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– 
  0.003 [77]     |
  0.004 [24]     |
  0.005 [58]     |
  0.007 [3]      |
  0.008 [7]      |
  0.009 [8]      |
  0.011 [3]      |
  0.012 [2]      |
  0.013 [2]      |

Latency distribution:
  10% in 0.0002 secs
  25% in 0.0002 secs
  50% in 0.0003 secs
  75% in 0.0003 secs
  90% in 0.0004 secs
  95% in 0.0005 secs
  99% in 0.0006 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0014 secs, 0.0010 secs, 0.0019 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0003 secs

Status code distribution:
  [200] 901318 responses

License

Licensed under either of

at your option.