cheap-ruler-rs
Port to safe Rust of cheap-ruler and cheap-ruler-cpp, a collection of very fast approximations to common geodesic measurements.
The approximations are based on WGS84 and its ellipsoidal model of the Earth. The results of calculations are accurate to small differences of the latitude provided at construction, and are less computationally expensive.
See cheap-ruler's readme for accuracy claims compared to the Vincenty formulas.
Usage
Here's example program to print the distance and bearing between two points:
extern crate cheap_ruler;
extern crate geo_types;
use ;
Unit of distance
This Rust port additionally allows the distance unit of the ruler to be changed and retrieved at any point after construction at the cost of larger memory size of the ruler struct itself (40 bytes instead of 16 bytes), but with no additional overhead.
extern crate cheap_ruler;
use ;
geo_types
The library uses the geo-types crate for representation of points and
coordinates. The one exception are the BBox functions, which use a custom Rect
implementation that does not automatically swap min/max bounds:
extern crate cheap_ruler;
extern crate geo_types;
use ;
use ;
Benchmarks
Cheap ruler's distance calculation is about 16 times faster than the geo crate's haversine algorithm implementation (times below are from a machine with Intel Core i7-8550U).
distance/cheap_ruler time: [291.10 ps 292.38 ps 293.89 ps]
distance/haversine time: [4.7215 ns 4.8545 ns 5.0086 ns]
distance/vincenty time: [315.83 ns 320.75 ns 325.93 ns]
Changelog
See the CHANGELOG file for details.
License
This library is licensed under the ISC License. See the LICENSE file for the full license content.
TODO
- Use idiomatic Rust for methods that follow C++ conventions.