#wgs84 #distance #approximation #geodesic #projection #calculations #geospatial

flat_projection

Fast geodesic distance approximations via flat surface projection

5 releases (3 breaking)

Uses old Rust 2015

0.4.0 Sep 14, 2020
0.3.0 Sep 20, 2019
0.2.0 Apr 12, 2018
0.1.1 Jan 28, 2018
0.1.0 Jan 28, 2018

#153 in Geospatial

Download history 9/week @ 2024-07-22 8/week @ 2024-07-29 26/week @ 2024-08-05 46/week @ 2024-08-12 7/week @ 2024-09-02 9/week @ 2024-09-09 18/week @ 2024-09-16 47/week @ 2024-09-23 18/week @ 2024-09-30 14/week @ 2024-10-07 17/week @ 2024-10-14 13/week @ 2024-10-21 32/week @ 2024-10-28 35/week @ 2024-11-04

98 downloads per month

MIT license

18KB
131 lines

flat-projection

Build Status

Fast geodesic distance approximations via flat surface projection

The FlatProjection struct can by used to project geographical coordinates from WGS84 into a cartesian coordinate system. In the projected form approximated distance and bearing calculations can be performed much faster than on a sphere. The precision of these calculations is very precise for distances up to about 500 km.

Usage

extern crate flat_projection;

use flat_projection::FlatProjection;

fn main() {
    let (lon1, lat1) = (6.186389, 50.823194);
    let (lon2, lat2) = (6.953333, 51.301389);

    let proj = FlatProjection::new(51.05);

    let p1 = proj.project(lon1, lat1);
    let p2 = proj.project(lon2, lat2);

    let distance = p1.distance(&p2);
    // -> 75.648 km
}

Benchmark

$ cargo bench

distance/flat           time:   [322.21 ps 323.82 ps 326.41 ps]
distance/haversine      time:   [12.604 ns 12.831 ns 13.162 ns]
distance/vincenty       time:   [346.79 ns 348.00 ns 349.61 ns]

According to these results the flat surface approximation is about 40x faster than the Haversine formula.

License

This project is released under the MIT license.

Dependencies

~150KB