Skip to content

Commit

Permalink
remove geos tests over concerns about licensing. it wasn't a critical…
Browse files Browse the repository at this point in the history
… feature anyway
  • Loading branch information
michaelkirk committed Dec 10, 2024
1 parent 35170e3 commit 2e7c7a5
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
uses: actions/checkout@v3
- run: cargo check --all-targets --no-default-features
# we don't want to test `proj-network` because it only enables the `proj` feature
- run: cargo test --features "use-proj use-serde earcutr multithreading geos-tests"
- run: cargo test --features "use-proj use-serde earcutr multithreading"

geo_traits:
name: geo-traits
Expand Down
2 changes: 0 additions & 2 deletions geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use-proj = ["proj"]
proj-network = ["use-proj", "proj/network"]
use-serde = ["serde", "geo-types/serde"]
multithreading = ["i_overlay/allow_multithreading", "geo-types/multithreading"]
geos-tests = ["geos"]

[dependencies]
earcutr = { version = "0.4.2", optional = true }
Expand All @@ -29,7 +28,6 @@ geographiclib-rs = { version = "0.2.3", default-features = false }
log = "0.4.11"
num-traits = "0.2"
proj = { version = "0.27.0", optional = true }
geos = { version = "9.1.1", features = ["geo"], optional = true }
robust = "1.1.0"
rstar = "0.12.0"
serde = { version = "1.0", optional = true, features = ["derive"] }
Expand Down
4 changes: 1 addition & 3 deletions geo/src/algorithm/validation/geometry_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,14 @@ mod tests {
LINESTRING(0. 0.,0. 0.)
)
);
// the geos crate doesn't support converting geo::GeometryCollection to -> geos::Geom
assert_validation_errors!(
gc,
vec![InvalidGeometryCollection::InvalidGeometry(
GeometryIndex(2),
Box::new(InvalidGeometry::InvalidLineString(
InvalidLineString::TooFewPoints
)),
)],
compare_with_geos: false
)]
);
}

Expand Down
9 changes: 3 additions & 6 deletions geo/src/algorithm/validation/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,18 @@ mod tests {
#[test]
fn test_line_valid() {
let l = Line::new((0., 0.), (1., 1.));
// GEOS doesn't have a Line type
assert_valid!(l, compare_with_geos: false);
assert_valid!(l);
}

#[test]
fn test_line_invalid_not_finite_coords() {
let l = Line::new((0., 0.), (f64::NEG_INFINITY, 0.));
// GEOS doesn't have a Line type
assert_validation_errors!(l, vec![InvalidLine::NonFiniteCoord(CoordIndex(1))], compare_with_geos: false);
assert_validation_errors!(l, vec![InvalidLine::NonFiniteCoord(CoordIndex(1))]);
}

#[test]
fn test_line_invalid_same_points() {
let l = Line::new((0., 0.), (0., 0.));
// GEOS doesn't have a Line type
assert_validation_errors!(l, vec![InvalidLine::IdenticalCoords], compare_with_geos: false);
assert_validation_errors!(l, vec![InvalidLine::IdenticalCoords]);
}
}
4 changes: 1 addition & 3 deletions geo/src/algorithm/validation/line_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ mod tests {
#[test]
fn test_linestring_invalid_too_few_points_without_duplicate() {
let ls = wkt!(LINESTRING(0. 0.));
// NOTE: Rather than build an invalid LineString GEOS errors at construction time, so
// we can't compare with GEOS here.
assert_validation_errors!(&ls, vec![InvalidLineString::TooFewPoints], compare_with_geos: false);
assert_validation_errors!(&ls, vec![InvalidLineString::TooFewPoints]);
}

#[test]
Expand Down
38 changes: 0 additions & 38 deletions geo/src/algorithm/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,6 @@ pub(crate) use test_macros::*;
mod test_macros {
macro_rules! assert_valid {
($to_validate:expr) => {
assert_valid!(
$to_validate,
compare_with_geos: true
);
};
($to_validate:expr, compare_with_geos: true) => {
assert_valid!(
$to_validate,
compare_with_geos: false
);
#[cfg(feature = "geos-tests")]
{
use geos::Geom;
let geos_geom: geos::Geometry = $to_validate.try_into().unwrap();
assert!(geos_geom.is_valid(), "GEOS thought the geometry was invalid");
}
};
($to_validate:expr, compare_with_geos: false) => {
assert!(
$to_validate.is_valid(),
"Validation errors: {:?}",
Expand All @@ -160,26 +142,6 @@ mod test_macros {

macro_rules! assert_validation_errors {
($to_validate:expr, $errors:expr) => {
assert_validation_errors!(
$to_validate,
$errors,
compare_with_geos: true
);
};
($to_validate:expr, $errors:expr, compare_with_geos: true) => {
assert_validation_errors!(
$to_validate,
$errors,
compare_with_geos: false
);
#[cfg(feature = "geos-tests")]
{
use geos::Geom;
let geos_geom: geos::Geometry = $to_validate.try_into().unwrap();
assert!(!geos_geom.is_valid(), "GEOS thought the geometry was valid");
}
};
($to_validate:expr, $errors:expr, compare_with_geos: false) => {
assert!(!$to_validate.is_valid());
assert!(
!$errors.is_empty(),
Expand Down
10 changes: 3 additions & 7 deletions geo/src/algorithm/validation/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,24 @@ mod tests {
#[test]
fn test_triangle_valid() {
let t = Triangle((0., 0.).into(), (0., 1.).into(), (0.5, 2.).into());
// GEOS doesn't have a Triangle type
assert_valid!(t, compare_with_geos: false);
assert_valid!(t);
}

#[test]
fn test_triangle_invalid_same_points() {
let t = Triangle((0., 0.).into(), (0., 1.).into(), (0., 1.).into());
// GEOS doesn't have a Triangle type
assert_validation_errors!(
t,
vec![InvalidTriangle::IdenticalCoords(
CoordIndex(1),
CoordIndex(2)
)],
compare_with_geos: false
)]
);
}

#[test]
fn test_triangle_invalid_points_collinear() {
let t = Triangle((0., 0.).into(), (1., 1.).into(), (2., 2.).into());
// GEOS doesn't have a Triangle type
assert_validation_errors!(t, vec![InvalidTriangle::CollinearCoords], compare_with_geos: false);
assert_validation_errors!(t, vec![InvalidTriangle::CollinearCoords]);
}
}

0 comments on commit 2e7c7a5

Please sign in to comment.