diff --git a/lib/src/fnc/operate.rs b/lib/src/fnc/operate.rs index 08ee5d2d..f10871a4 100644 --- a/lib/src/fnc/operate.rs +++ b/lib/src/fnc/operate.rs @@ -193,6 +193,13 @@ pub fn inside_none(a: &Value, b: &Value) -> Result { } } +pub fn outside(a: &Value, b: &Value) -> Result { + match a.intersects(b) { + true => Ok(Value::False), + false => Ok(Value::True), + } +} + pub fn intersects(a: &Value, b: &Value) -> Result { match a.intersects(b) { true => Ok(Value::True), diff --git a/lib/src/sql/expression.rs b/lib/src/sql/expression.rs index 323ef5d6..e263aa19 100644 --- a/lib/src/sql/expression.rs +++ b/lib/src/sql/expression.rs @@ -109,6 +109,7 @@ impl Expression { Operator::AllInside => fnc::operate::inside_all(&l, &r), Operator::AnyInside => fnc::operate::inside_any(&l, &r), Operator::NoneInside => fnc::operate::inside_none(&l, &r), + Operator::Outside => fnc::operate::outside(&l, &r), Operator::Intersects => fnc::operate::intersects(&l, &r), _ => unreachable!(), } diff --git a/lib/src/sql/operator.rs b/lib/src/sql/operator.rs index ed5660d1..17776ed3 100644 --- a/lib/src/sql/operator.rs +++ b/lib/src/sql/operator.rs @@ -48,6 +48,7 @@ pub enum Operator { AllInside, // ⊆ AnyInside, // ⊂ NoneInside, // ⊄ + Outside, // ∈ Intersects, // ∩ } @@ -106,6 +107,7 @@ impl fmt::Display for Operator { Operator::AllInside => write!(f, "ALL INSIDE"), Operator::AnyInside => write!(f, "ANY INSIDE"), Operator::NoneInside => write!(f, "NONE INSIDE"), + Operator::Outside => write!(f, "OUTSIDE"), Operator::Intersects => write!(f, "INTERSECTS"), } } @@ -195,7 +197,7 @@ pub fn phrases(i: &str) -> IResult<&str, Operator> { map(tag_no_case("NONE INSIDE"), |_| Operator::NoneInside), map(tag_no_case("NOT INSIDE"), |_| Operator::NotInside), map(tag_no_case("INSIDE"), |_| Operator::Inside), - map(tag_no_case("OUTSIDE"), |_| Operator::NotInside), + map(tag_no_case("OUTSIDE"), |_| Operator::Outside), map(tag_no_case("INTERSECTS"), |_| Operator::Intersects), )), ))(i)?;