vincenty-rs

Crates.iovincenty-rs
lib.rsvincenty-rs
version1.0.6
sourcesrc
created_at2022-01-24 21:32:17.036121
updated_at2022-01-29 04:23:40.023744
descriptionExpose API for calculating distance using vincenty formulae
homepagehttps://github.com/vihu/vincenty-rs
repositoryhttps://github.com/vihu/vincenty-rs
max_upload_size
id520443
size77,830
Rahul Garg (vihu)

documentation

README

vincenty-rs

Overview

Expose API endpoint for calculating distance using vincenty formulae.

Notably, it allows you to input src and dst as query parameters, where either can be a permutation of:

  1. latitude,longitude (as floating points)
  2. H3 indices as String
  3. H3 indices as u64

An instance of this API with front-end written in yew is available at vincenty.vihu.dev

Check the examples for more usage information.

Usage

Start the tide server with cargo run --release

API Example

  • With lat,lng as src and dst:
$ http GET http://localhost:5000/distance\?src\="42.3541165,-71.0693514"\&dst\="40.7791472, -73.9680804" --body
{
    "data": {
        "distance": 298.396186,
        "dst": {
            "lat": 40.7791472,
            "lng": -73.9680804
        },
        "src": {
            "lat": 42.3541165,
            "lng": -71.0693514
        }
    }
}
  • With h3 string indices as src and dst:
$ http GET http://localhost:5000/distance\?src\="8c2a306638701ff"\&dst\="8c2a100894435ff" --body
{
    "data": {
        "distance": 298.394459,
        "dst": {
            "lat": 40.7791617074961,
            "lng": -73.96812482164383
        },
        "src": {
            "lat": 42.35408591768187,
            "lng": -71.06937831049969
        }
    }
}
  • With h3 u64 indices as src and dst:
$ http GET http://localhost:5000/distance\?src\=631246145620214271\&dst\=631243921460311551 --body
{
    "data": {
        "distance": 298.394459,
        "dst": {
            "lat": 40.7791617074961,
            "lng": -73.96812482164383
        },
        "src": {
            "lat": 42.35408591768187,
            "lng": -71.06937831049969
        }
    }
}
  • With a mix of h3 string and h3 u64:
$ http GET http://localhost:5000/distance\?src\="8c2a306638701ff"\&dst\=631243921460311551 --body
{
    "data": {
        "distance": 298.394459,
        "dst": {
            "lat": 40.7791617074961,
            "lng": -73.96812482164383
        },
        "src": {
            "lat": 42.35408591768187,
            "lng": -71.06937831049969
        }
    }
}
  • With a mix of h3 u64 and lat,lng:
$ http GET http://localhost:5000/distance\?src\="42.3541165,-71.0693514"\&dst\=631243921460311551 --body
{
    "data": {
        "distance": 298.398222,
        "dst": {
            "lat": 40.7791617074961,
            "lng": -73.96812482164383
        },
        "src": {
            "lat": 42.3541165,
            "lng": -71.0693514
        }
    }
}
Commit count: 14

cargo fmt