# Geometry :

Subject: Re: [geometry] [Spatial Index] bug & question
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2013-06-18 04:59:11

> TONGARI wrote:
>>
>> I'll try that if I get the github update.
>> BTW, didn't we miss a 'contains' predicate (within in reverse order)?
>>
>
> remember why we decided to not provide it. Maybe because there is no such
> boolean operation in BG. Or maybe because it can be expressed with other
> predicates, e.g.: intersects() && !covered_by() && !overlaps().

contains is indeed reverse to within, at least according to OGC specs
which is derived from the Dimensionally Extended 9 Intersection Matrix.
You can compare de9im for within and contains here:

AFAIR, the de9im calculation has not been completed for anything but segments.

> something more general. We could use some operator to 'reverse' spatial
> predicates, e.g. bitwise NOT.

(see my question at the end)

> Then it would look like this:
>
> // return values covered by g1 and those which have got g2 within
> rt.query(covered_by(g1) && ~within(g2), ...);
>
> // return values which haven't got g within
> rt.query(!~within(g), ...);
> // probably the same as
> rt.query(~!within(g), ...);
>
> Are you ok with this operator? Or maybe some function would be better?

I like the expressivness of that, but I'm worried that
mixing native operator! and customised overloaded operator~
with slightly bent semantic would cause confusions.

About operator~, do you mean it reverse order of application of predicate(s) or
something more sophisticated like generate some kind of 'complement' of the set
of given predicates? The latter sounds more aligned to bitwise NOT, doesn't it?
Or, have I lost the discussion track?

Best regards,

```--
Mateusz Loskot, http://mateusz.loskot.net
```

Geometry list run by mateusz at loskot.net