Add SQL OUTSIDE operator for geometry types
This commit is contained in:
parent
fb27185435
commit
6f93c38cd2
3 changed files with 11 additions and 1 deletions
|
@ -193,6 +193,13 @@ pub fn inside_none(a: &Value, b: &Value) -> Result<Value, Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn outside(a: &Value, b: &Value) -> Result<Value, Error> {
|
||||||
|
match a.intersects(b) {
|
||||||
|
true => Ok(Value::False),
|
||||||
|
false => Ok(Value::True),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn intersects(a: &Value, b: &Value) -> Result<Value, Error> {
|
pub fn intersects(a: &Value, b: &Value) -> Result<Value, Error> {
|
||||||
match a.intersects(b) {
|
match a.intersects(b) {
|
||||||
true => Ok(Value::True),
|
true => Ok(Value::True),
|
||||||
|
|
|
@ -109,6 +109,7 @@ impl Expression {
|
||||||
Operator::AllInside => fnc::operate::inside_all(&l, &r),
|
Operator::AllInside => fnc::operate::inside_all(&l, &r),
|
||||||
Operator::AnyInside => fnc::operate::inside_any(&l, &r),
|
Operator::AnyInside => fnc::operate::inside_any(&l, &r),
|
||||||
Operator::NoneInside => fnc::operate::inside_none(&l, &r),
|
Operator::NoneInside => fnc::operate::inside_none(&l, &r),
|
||||||
|
Operator::Outside => fnc::operate::outside(&l, &r),
|
||||||
Operator::Intersects => fnc::operate::intersects(&l, &r),
|
Operator::Intersects => fnc::operate::intersects(&l, &r),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ pub enum Operator {
|
||||||
AllInside, // ⊆
|
AllInside, // ⊆
|
||||||
AnyInside, // ⊂
|
AnyInside, // ⊂
|
||||||
NoneInside, // ⊄
|
NoneInside, // ⊄
|
||||||
|
Outside, // ∈
|
||||||
Intersects, // ∩
|
Intersects, // ∩
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ impl fmt::Display for Operator {
|
||||||
Operator::AllInside => write!(f, "ALL INSIDE"),
|
Operator::AllInside => write!(f, "ALL INSIDE"),
|
||||||
Operator::AnyInside => write!(f, "ANY INSIDE"),
|
Operator::AnyInside => write!(f, "ANY INSIDE"),
|
||||||
Operator::NoneInside => write!(f, "NONE INSIDE"),
|
Operator::NoneInside => write!(f, "NONE INSIDE"),
|
||||||
|
Operator::Outside => write!(f, "OUTSIDE"),
|
||||||
Operator::Intersects => write!(f, "INTERSECTS"),
|
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("NONE INSIDE"), |_| Operator::NoneInside),
|
||||||
map(tag_no_case("NOT INSIDE"), |_| Operator::NotInside),
|
map(tag_no_case("NOT INSIDE"), |_| Operator::NotInside),
|
||||||
map(tag_no_case("INSIDE"), |_| Operator::Inside),
|
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),
|
map(tag_no_case("INTERSECTS"), |_| Operator::Intersects),
|
||||||
)),
|
)),
|
||||||
))(i)?;
|
))(i)?;
|
||||||
|
|
Loading…
Reference in a new issue