From d0b400619b94e851d675e7a5ffb4479ba4b474d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Sat, 25 Jun 2022 12:04:43 +0100 Subject: [PATCH] Cleaner imports --- geo/src/algorithm/intersects/polygon.rs | 30 +++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/geo/src/algorithm/intersects/polygon.rs b/geo/src/algorithm/intersects/polygon.rs index dd946584e5..961d41949b 100644 --- a/geo/src/algorithm/intersects/polygon.rs +++ b/geo/src/algorithm/intersects/polygon.rs @@ -1,10 +1,8 @@ use super::{has_disjoint_bboxes, Intersects}; +use crate::geometry::*; use crate::utils::{coord_pos_relative_to_ring, CoordPos}; use crate::BoundingRect; -use crate::{ - CoordNum, Coordinate, GeoNum, Line, LineString, MultiLineString, MultiPolygon, Point, Polygon, - Rect, -}; +use crate::{CoordNum, GeoNum}; use rstar::{RTree, RTreeObject}; // the largest total number of segments geometries can have before the algorithm switches // to using an R*-tree for queries @@ -28,7 +26,7 @@ symmetric_intersects_impl!(Polygon, Point); impl Intersects> for Polygon where T: GeoNum, - geo_types::Line: RTreeObject, + Line: RTreeObject, { fn intersects(&self, line: &Line) -> bool { self.exterior().intersects(line) @@ -41,7 +39,7 @@ where impl Intersects> for Polygon where T: GeoNum, - geo_types::Line: RTreeObject, + Line: RTreeObject, { fn intersects(&self, linestring: &LineString) -> bool { if (self.exterior().0.len() + self.interiors().iter().map(|ls| ls.0.len()).sum::()) @@ -72,7 +70,7 @@ symmetric_intersects_impl!(Polygon, MultiLineString); impl Intersects> for Polygon where T: GeoNum, - geo_types::Line: RTreeObject, + Line: RTreeObject, { fn intersects(&self, rect: &Rect) -> bool { self.intersects(&rect.to_polygon()) @@ -83,22 +81,20 @@ symmetric_intersects_impl!(Rect, Polygon); impl Intersects> for Polygon where T: GeoNum, - geo_types::Line: RTreeObject, + Line: RTreeObject, { fn intersects(&self, polygon: &Polygon) -> bool { if has_disjoint_bboxes(self, polygon) { return false; } // switch to querying trees above some threshold x: polygons' combined segment count is higher than x - if (self.exterior().0.len() - + self.interiors().iter().map(|ls| ls.0.len()).sum::()) - * - (polygon.exterior().0.len() - + polygon - .interiors() - .iter() - .map(|ls| ls.0.len()) - .sum::()) + if (self.exterior().0.len() + self.interiors().iter().map(|ls| ls.0.len()).sum::()) + * (polygon.exterior().0.len() + + polygon + .interiors() + .iter() + .map(|ls| ls.0.len()) + .sum::()) > MAX_NAIVE_SEGMENTS { let lines_a: Vec<_> = self