Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support geodesic area and perimeter calculations from geographlib-rs #988

Merged
merged 11 commits into from
Mar 6, 2023
Prev Previous commit
Next Next commit
Adding more asserts to tests
  • Loading branch information
phayes committed Feb 27, 2023
commit cd74de158883fa82c793882a1b5f625344acf92f
25 changes: 25 additions & 0 deletions geo/src/algorithm/geodesic_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ mod test {
(x: 125., y: -15.),
];
assert_relative_eq!(-7786102826806.07, polygon.geodesic_area_signed());
phayes marked this conversation as resolved.
Show resolved Hide resolved

let geoid = geographiclib_rs::Geodesic::wgs84();
assert_relative_eq!(geoid.area() -7786102826806.07, polygon.geodesic_area_unsigned());
}

#[test]
Expand All @@ -383,6 +386,7 @@ mod test {
(x: 125., y: -15.),
];
assert_relative_eq!(7786102826806.07, polygon.geodesic_area_signed());
assert_relative_eq!(7786102826806.07, polygon.geodesic_area_unsigned());
}

#[test]
Expand Down Expand Up @@ -415,6 +419,17 @@ mod test {

assert_relative_eq!(1203317999173.7063, poly.geodesic_area_signed());
assert_relative_eq!(1203317999173.7063, poly.geodesic_area_unsigned());
assert_relative_eq!(5307742.446635911, poly.geodesic_perimeter());

let (perimeter, area) = poly.geodesic_perimeter_area_signed();

assert_relative_eq!(5307742.446635911, perimeter);
assert_relative_eq!(1203317999173.7063, area);

let (perimeter, area) = poly.geodesic_perimeter_area_unsigned();

assert_relative_eq!(5307742.446635911, perimeter);
assert_relative_eq!(1203317999173.7063, area);
}

#[test]
Expand Down Expand Up @@ -474,6 +489,16 @@ mod test {
],
];
assert_relative_eq!(18462065880.09138, diamond.geodesic_area_unsigned());
assert_relative_eq!(18462065880.09138, diamond.geodesic_area_signed());
assert_relative_eq!(941333.0085011568, diamond.geodesic_perimeter());

let (perimeter, area) = diamond.geodesic_perimeter_area_signed();
assert_relative_eq!(941333.0085011568, perimeter);
assert_relative_eq!(18462065880.09138, area);

let (perimeter, area) = diamond.geodesic_perimeter_area_unsigned();
assert_relative_eq!(941333.0085011568, perimeter);
assert_relative_eq!(18462065880.09138, area);
}

}