use diesel::expression::AsExpression;
use diesel::sql_types::SqlType;
use diesel::Expression;
diesel::infix_operator!(BBIntersects2D, " && ");
diesel::infix_operator!(BBOverlapsOrLeft, " &< ");
diesel::infix_operator!(BBOverlapsOrBelow, " &<| ");
diesel::infix_operator!(BBOverlapsOrRight, " &> ");
diesel::infix_operator!(BBStrictlyLeft, " << ");
diesel::infix_operator!(BBStrictlyBelow, " <<| ");
diesel::infix_operator!(GSame, " = ");
diesel::infix_operator!(BBStrictlyRight, " >> ");
diesel::infix_operator!(BBContainedBy, " @ ");
diesel::infix_operator!(BBOverlapsOrAbove, " |&> ");
diesel::infix_operator!(BBStrictlyAbove, " |>> ");
diesel::infix_operator!(BBContains, " ~ ");
diesel::infix_operator!(BBSame, " ~= ");
diesel::infix_operator!(Distance2d, " <-> ", diesel::sql_types::Double);
diesel::infix_operator!(Distance3dTrajectories, " <-> ", diesel::sql_types::Double);
diesel::infix_operator!(Distance2BBs, " <#> ", diesel::sql_types::Double);
diesel::infix_operator!(DistanceNdCentroidsBBs, " <<->> ", diesel::sql_types::Double);
diesel::infix_operator!(DistanceNdBBs, " <<#>> ", diesel::sql_types::Double);
pub fn contained_by<T, U>(left: T, right: U) -> BBContainedBy<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBContainedBy::new(left, right.as_expression())
}
pub fn contains<T, U>(left: T, right: U) -> BBContains<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBContains::new(left, right.as_expression())
}
pub fn intersects_2d<T, U>(left: T, right: U) -> BBIntersects2D<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBIntersects2D::new(left, right.as_expression())
}
pub fn overlaps_or_left<T, U>(left: T, right: U) -> BBOverlapsOrLeft<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBOverlapsOrLeft::new(left, right.as_expression())
}
pub fn overlaps_or_below<T, U>(left: T, right: U) -> BBOverlapsOrBelow<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBOverlapsOrBelow::new(left, right.as_expression())
}
pub fn overlaps_or_right<T, U>(left: T, right: U) -> BBOverlapsOrRight<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBOverlapsOrRight::new(left, right.as_expression())
}
pub fn overlaps_or_above<T, U>(left: T, right: U) -> BBOverlapsOrAbove<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBOverlapsOrAbove::new(left, right.as_expression())
}
pub fn strictly_left<T, U>(left: T, right: U) -> BBStrictlyLeft<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBStrictlyLeft::new(left, right.as_expression())
}
pub fn strictly_below<T, U>(left: T, right: U) -> BBStrictlyBelow<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBStrictlyBelow::new(left, right.as_expression())
}
pub fn strictly_right<T, U>(left: T, right: U) -> BBStrictlyRight<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBStrictlyRight::new(left, right.as_expression())
}
pub fn strictly_above<T, U>(left: T, right: U) -> BBStrictlyAbove<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBStrictlyAbove::new(left, right.as_expression())
}
pub fn g_same<T, U>(left: T, right: U) -> GSame<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
GSame::new(left, right.as_expression())
}
pub fn bb_same<T, U>(left: T, right: U) -> BBSame<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
BBSame::new(left, right.as_expression())
}
pub fn distance_2d<T, U>(left: T, right: U) -> Distance2d<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
Distance2d::new(left, right.as_expression())
}
pub fn distance_3d_trajectories<T, U>(left: T, right: U) -> Distance3dTrajectories<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
Distance3dTrajectories::new(left, right.as_expression())
}
pub fn distance_2d_bbs<T, U>(left: T, right: U) -> Distance2BBs<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
Distance2BBs::new(left, right.as_expression())
}
pub fn distance_nd_centroids_bbs<T, U>(
left: T,
right: U,
) -> DistanceNdCentroidsBBs<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
DistanceNdCentroidsBBs::new(left, right.as_expression())
}
pub fn distance_nd_bbs<T, U>(left: T, right: U) -> DistanceNdBBs<T, U::Expression>
where
T: Expression,
<T as diesel::Expression>::SqlType: SqlType,
U: AsExpression<T::SqlType>,
{
DistanceNdBBs::new(left, right.as_expression())
}