Skip to content

Commit

Permalink
Merge pull request #35 from mockersf/update
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
Ihor authored Aug 30, 2023
2 parents 69babb3 + 61759a6 commit 280fd98
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 185 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[workspace]
members = [
"lib",
"tests",
]

resolver = "2"
members = ["lib", "tests"]
6 changes: 3 additions & 3 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "geo-booleanop"
version = "0.3.2"
authors = ["Bodo Junglas <junglas@objectcode.de>"]
edition = "2018"
edition = "2021"
license = "MIT"
repository = "https://github.com/21re/rust-geo-booleanop"
description = "Rust implementation of the Martinez-Rueda Polygon Clipping Algorithm"
Expand All @@ -12,8 +12,8 @@ keywords = ["gis", "geo", "geography", "geospatial"]
[dependencies]
geo-types = { version = "0.7", default-features = false }
num-traits = "0.2"
robust = "0.2"
float_next_after = "0.1"
robust = "1.1"
float_next_after = "1.0"

[dev-dependencies]
rand = "0.8"
Expand Down
18 changes: 9 additions & 9 deletions lib/src/boolean/compare_segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ where
"missing right-event in compare_segments"
);

if Rc::ptr_eq(&se1_l, &se2_l) {
if Rc::ptr_eq(se1_l, se2_l) {
return Ordering::Equal;
}

// The main logic of compare segments is to check the orientation of the later/older
// SweepEvent w.r.t. the segment of the earlier/newer one. The logic is easier to
// express by swapping them here according to their temporal order. In case we have
// to swap, the result function must be inverted accordingly.
let (se_old_l, se_new_l, less_if) = if se1_l.is_before(&se2_l) {
let (se_old_l, se_new_l, less_if) = if se1_l.is_before(se2_l) {
(se1_l, se2_l, helper::less_if as fn(bool) -> Ordering)
} else {
(se2_l, se1_l, helper::less_if_inversed as fn(bool) -> Ordering)
Expand Down Expand Up @@ -112,7 +112,7 @@ mod test {
use super::super::sweep_event::SweepEvent;
use super::compare_segments;
use crate::splay::SplaySet;
use geo_types::Coordinate;
use geo_types::Coord;
use std::cmp::Ordering;
use std::rc::{Rc, Weak};

Expand Down Expand Up @@ -148,15 +148,15 @@ mod test {
) -> (Rc<SweepEvent<f64>>, Rc<SweepEvent<f64>>) {
let other = SweepEvent::new_rc(
contour_id,
Coordinate { x: other_x, y: other_y },
Coord { x: other_x, y: other_y },
false,
Weak::new(),
is_subject,
true,
);
let event = SweepEvent::new_rc(
contour_id,
Coordinate { x, y },
Coord { x, y },
true,
Rc::downgrade(&other),
is_subject,
Expand All @@ -181,8 +181,8 @@ mod test {
let min_other = tree.min().unwrap().get_other_event().unwrap();
let max_other = tree.max().unwrap().get_other_event().unwrap();

assert_eq!(max_other.point, Coordinate { x: 2.0, y: 3.0 });
assert_eq!(min_other.point, Coordinate { x: 1.0, y: 1.0 });
assert_eq!(max_other.point, Coord { x: 2.0, y: 3.0 });
assert_eq!(min_other.point, Coord { x: 1.0, y: 1.0 });
}

#[test]
Expand All @@ -198,8 +198,8 @@ mod test {
let min_other = tree.min().unwrap().get_other_event().unwrap();
let max_other = tree.max().unwrap().get_other_event().unwrap();

assert_eq!(min_other.point, Coordinate { x: 1.0, y: 1.0 });
assert_eq!(max_other.point, Coordinate { x: 2.0, y: 3.0 });
assert_eq!(min_other.point, Coord { x: 1.0, y: 1.0 });
assert_eq!(max_other.point, Coord { x: 2.0, y: 3.0 });
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/boolean/compute_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where
let result_transition = if !in_result {
ResultTransition::None
} else {
determine_result_transition(&event, operation)
determine_result_transition(event, operation)
};
event.set_result_transition(result_transition);

Expand Down
6 changes: 3 additions & 3 deletions lib/src/boolean/connect_edges.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::helper::Float;
use super::sweep_event::{ResultTransition, SweepEvent};
use geo_types::Coordinate;
use geo_types::Coord;
use std::collections::HashSet;
use std::rc::Rc;

Expand Down Expand Up @@ -137,8 +137,8 @@ pub struct Contour<F>
where
F: Float,
{
/// Raw coordinates of contour
pub points: Vec<Coordinate<F>>,
/// Raw Coords of contour
pub points: Vec<Coord<F>>,
/// Contour IDs of holes if any.
pub hole_ids: Vec<i32>,
/// Contour ID of parent if this contour is a hole.
Expand Down
12 changes: 6 additions & 6 deletions lib/src/boolean/divide_segment.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::helper::Float;
use super::sweep_event::SweepEvent;
use geo_types::Coordinate;
use geo_types::Coord;
use std::collections::BinaryHeap;
use std::rc::Rc;

#[cfg(feature = "debug-booleanop")]
use super::sweep_event::JsonDebug;

pub fn divide_segment<F>(se_l: &Rc<SweepEvent<F>>, inter: Coordinate<F>, queue: &mut BinaryHeap<Rc<SweepEvent<F>>>)
pub fn divide_segment<F>(se_l: &Rc<SweepEvent<F>>, inter: Coord<F>, queue: &mut BinaryHeap<Rc<SweepEvent<F>>>)
where
F: Float,
{
Expand Down Expand Up @@ -53,7 +53,7 @@ where
se_l.contour_id,
inter,
false,
Rc::downgrade(&se_l),
Rc::downgrade(se_l),
se_l.is_subject,
true,
);
Expand Down Expand Up @@ -92,7 +92,7 @@ mod test {
use super::super::segment_intersection::{intersection, LineIntersection};
use super::super::sweep_event::SweepEvent;
use super::*;
use geo_types::Coordinate;
use geo_types::Coord;
use std::collections::BinaryHeap;
use std::rc::{Rc, Weak};

Expand All @@ -105,13 +105,13 @@ mod test {
) -> (Rc<SweepEvent<f64>>, Rc<SweepEvent<f64>>) {
let other = SweepEvent::new_rc(
0,
Coordinate { x: other_x, y: other_y },
Coord { x: other_x, y: other_y },
false,
Weak::new(),
is_subject,
true,
);
let event = SweepEvent::new_rc(0, Coordinate { x, y }, true, Rc::downgrade(&other), is_subject, true);
let event = SweepEvent::new_rc(0, Coord { x, y }, true, Rc::downgrade(&other), is_subject, true);

(event, other)
}
Expand Down
17 changes: 5 additions & 12 deletions lib/src/boolean/fill_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use geo_types::{LineString, Polygon};
use std::collections::BinaryHeap;
use std::rc::{Rc, Weak};

use super::helper::BoundingBox;
use super::sweep_event::SweepEvent;
use super::Operation;
use super::helper::BoundingBox;

pub fn fill_queue<F>(
subject: &[Polygon<F>],
Expand All @@ -22,7 +22,7 @@ where

for polygon in subject {
contour_id += 1;
process_polygon(&polygon.exterior(), true, contour_id, &mut event_queue, sbbox, true);
process_polygon(polygon.exterior(), true, contour_id, &mut event_queue, sbbox, true);
for interior in polygon.interiors() {
process_polygon(interior, true, contour_id, &mut event_queue, sbbox, false);
}
Expand All @@ -33,14 +33,7 @@ where
if exterior {
contour_id += 1;
}
process_polygon(
&polygon.exterior(),
false,
contour_id,
&mut event_queue,
cbbox,
exterior,
);
process_polygon(polygon.exterior(), false, contour_id, &mut event_queue, cbbox, exterior);
for interior in polygon.interiors() {
process_polygon(interior, false, contour_id, &mut event_queue, cbbox, false);
}
Expand Down Expand Up @@ -94,13 +87,13 @@ fn process_polygon<F>(
#[cfg(test)]
mod test {
use super::*;
use geo_types::Coordinate;
use geo_types::Coord;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::rc::{Rc, Weak};

fn make_simple(x: f64, y: f64, is_subject: bool) -> Rc<SweepEvent<f64>> {
SweepEvent::new_rc(0, Coordinate { x, y }, false, Weak::new(), is_subject, true)
SweepEvent::new_rc(0, Coord { x, y }, false, Weak::new(), is_subject, true)
}

fn check_order_in_queue(first: Rc<SweepEvent<f64>>, second: Rc<SweepEvent<f64>>) {
Expand Down
18 changes: 9 additions & 9 deletions lib/src/boolean/helper.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use float_next_after::NextAfter as NextAfterFloat;
use geo_types::{Coordinate, CoordNum};
use geo_types::{Coord, CoordNum};
use num_traits::Float as NumTraitsFloat;
use std::cmp::Ordering;
use std::fmt::{Debug, Display};
Expand Down Expand Up @@ -51,17 +51,17 @@ pub fn less_if_inversed(condition: bool) -> Ordering {
}
}

/// A bounded 2D quadrilateral whose area is defined by minimum and maximum `Coordinates`.
/// A bounded 2D quadrilateral whose area is defined by minimum and maximum `Coords`.
///
/// A simple implementation copied from geo_types 0.4.0, because this version is a better
/// fit for the needs of this crate than the newer ones.
#[derive(PartialEq, Clone, Copy, Debug)]
pub struct BoundingBox<T>
where
T: CoordNum,
where
T: CoordNum,
{
pub min: Coordinate<T>,
pub max: Coordinate<T>,
pub min: Coord<T>,
pub max: Coord<T>,
}

impl<T: CoordNum> BoundingBox<T> {
Expand All @@ -78,10 +78,10 @@ impl<T: CoordNum> BoundingBox<T> {
pub mod test {
use super::Float;
use float_next_after::NextAfter as NextAfterFloat;
use geo_types::Coordinate;
use geo_types::Coord;

pub fn xy<X: Into<f64>, Y: Into<f64>>(x: X, y: Y) -> Coordinate<f64> {
Coordinate {
pub fn xy<X: Into<f64>, Y: Into<f64>>(x: X, y: Y) -> Coord<f64> {
Coord {
x: x.into(),
y: y.into(),
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/boolean/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use geo_types::{Coordinate, LineString, MultiPolygon, Polygon};
use geo_types::{Coord, LineString, MultiPolygon, Polygon};

pub mod compare_segments;
pub mod compute_fields;
Expand Down Expand Up @@ -90,11 +90,11 @@ where
F: Float,
{
let mut sbbox = BoundingBox {
min: Coordinate {
min: Coord {
x: F::infinity(),
y: F::infinity(),
},
max: Coordinate {
max: Coord {
x: F::neg_infinity(),
y: F::neg_infinity(),
},
Expand Down
4 changes: 2 additions & 2 deletions lib/src/boolean/possible_intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ where
}
LineIntersection::Point(inter) => {
if se1.point != inter && other1.point != inter {
divide_segment(&se1, inter, queue);
divide_segment(se1, inter, queue);
}
if se2.point != inter && other2.point != inter {
divide_segment(&se2, inter, queue);
divide_segment(se2, inter, queue);
}
1
}
Expand Down
Loading

0 comments on commit 280fd98

Please sign in to comment.