Skip to content

Commit

Permalink
Merge pull request #55: include example
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Jan 16, 2024
2 parents 766915d + 43a1feb commit c4de165
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: script/download-test-data.sh
- run: cargo build --all-targets
- run: cargo test
- run: cargo test --no-default-features
- run: cargo test --features test_full
Expand Down
16 changes: 16 additions & 0 deletions examples/direct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use geographiclib_rs::{DirectGeodesic, Geodesic};
fn main() {
let g = Geodesic::wgs84();
let jfk_lat = 40.64;
let jfk_lon = -73.78;
let northeast_azimuth = 45.0;

let (lat, lon, az) = g.direct(jfk_lat, jfk_lon, northeast_azimuth, 10e6);

use approx::assert_relative_eq;
assert_relative_eq!(lat, 32.621100463725796);
assert_relative_eq!(lon, 49.05248709295982, epsilon = 1e-13);
assert_relative_eq!(az, 140.4059858768007);

println!("lat: {lat}, lon: {lon}, az: {az}");
}
4 changes: 1 addition & 3 deletions src/geodesic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,9 +1648,7 @@ mod tests {
fn test_arcdirect() {
// Corresponds with ArcDirectCheck from Java, or test_arcdirect from Python
let geod = Geodesic::wgs84();
for (_line_num, (lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12)) in
TESTCASES.iter().enumerate()
{
for (lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12) in TESTCASES.iter() {
let (
_computed_a12,
computed_lat2,
Expand Down

0 comments on commit c4de165

Please sign in to comment.