Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonytonyjan/geodesics
geodesics calculates the geodesic distance between 2 points with latitude and longitude on ellipsoid Earth using Lambert's formula.
https://github.com/tonytonyjan/geodesics
distance geodesic lambert latitude longitude ruby
Last synced: about 1 month ago
JSON representation
geodesics calculates the geodesic distance between 2 points with latitude and longitude on ellipsoid Earth using Lambert's formula.
- Host: GitHub
- URL: https://github.com/tonytonyjan/geodesics
- Owner: tonytonyjan
- Created: 2019-05-11T17:03:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-11T17:14:23.000Z (over 5 years ago)
- Last Synced: 2024-10-20T09:57:07.548Z (2 months ago)
- Topics: distance, geodesic, lambert, latitude, longitude, ruby
- Language: Ruby
- Size: 37.3 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# geodesics
[![Build Status](https://travis-ci.org/tonytonyjan/geodesics.svg?branch=master)](https://travis-ci.org/tonytonyjan/geodesics)
**geodesics** calculates the geodesic distance between 2 points with latitude and longitude on ellipsoid Earth using Lambert's formula.
## Features
- It is extensible using [strategy pattern][strategy pattern]. By default:
- Use [haversine formula][haversine] for central angle calculation.
- Use [Lambert's formula][lambert] for
geodesic calculation.
- The error rate is **less than 1%**. Passed a test set of [500,000 geodesics](test/dataset.dat) for the WGS84 ellipsoid.## Installation
```
gem install geodesics
```## Usage
### Decimal Degree as Input
```rb
require 'geodesics'
latitude1 = 22.633333
longitude1 = 120.266670
latitude2 = 25.105497
longitude2 = 121.597366
Geodesics.distance(latitude1, longitude1, latitude2, longitude2)
# => 306035.64651391446
```- Distance unit is **meter**.
- `Geodesics#distance` is an alias of `Geodesics#distance_degree`### Raidan as Input
```rb
Geodesics.distance_radian(latitude1, longitude1, latitude2, longitude2)
```### Customize Strategy
```rb
class MyStrategy
def distance(point1, point2)
# you implementation here
end
end
g = Geodesics.new(strategy: MyStrategy.new)
g.distance(latitude1, longitude1, latitude2, longitude2)
g.distance_radian(latitude1, longitude1, latitude2, longitude2)
```[strategy pattern]: https://en.wikipedia.org/wiki/Strategy_pattern
[haversine]: https://en.wikipedia.org/wiki/Versine#Haversine
[lambert]: https://www.jstor.org/stable/24531873
[kristianmandrup/geo-distance]: https://github.com/kristianmandrup/geo-distance