ST_DFullyWithin

Bruce Rindahl bruce.rindahl at gmail.com
Thu Jan 25 15:45:19 PST 2024


" I don't think that word means what you think it means"

Say A is a point at 0.1,1
B is a line from 0,0 to 0,2

Then using the following code:
--------------------------------------------------------------
with a as (select st_makepoint(0.1,1) as geom),
b as (select st_makeline(st_makepoint(0,0),st_makepoint(0,2)) as geom)

select 'ST_Covers(ST_Buffer(A,Dist),B)',  ST_Covers(ST_Buffer(a.geom, 0.2),
b.geom) from a,b
union all
select  'ST_DFullyWithin(A,B,Dist)',  ST_DFullyWithin(a.geom,b.geom,0.2)
from a,b
union all
select 'ST_Covers(ST_Buffer(B,Dist),A)',  ST_Covers(ST_Buffer(b.geom, 0.2),
b.geom) from a,b
union all
select  'ST_DFullyWithin(B,A,Dist)',  ST_DFullyWithin(b.geom,a.geom,0.2)
from a,b
-------------------------------------------------------------


Yields:
QUERY                                                RESULT
"ST_Covers(ST_Buffer(A,Dist),B)"      false
"ST_DFullyWithin(A,B,Dist)"                false
"ST_Covers(ST_Buffer(B,Dist),A)"      true
"ST_DFullyWithin(B,A,Dist)"                false

I think the last row should also be true.



On Thu, Jan 25, 2024 at 1:14 PM Paul Ramsey <pramsey at cleverelephant.ca>
wrote:

>
>
> On Jan 25, 2024, at 11:57 AM, Martin Davis <mtnclimb at gmail.com> wrote:
>
> Another reason for keeping the meaning "ST_DFullyWithin(A, B) =
> ST_Covers(ST_Buffer(A, Dist), B)":
>
> I see the main use of this function in queries to be "find all the B
> features which are fully within distance D of an A feature".  So the A
> feature is the *constant* "query item", and it is evaluated against a set
> of B features.  It seems more intuitive for the constant feature to be the
> first argument in functions.
>
>
> Concur, this is also my intuition, which is why it’s coded the way it is…
>
> P
>
>
> PS note the definition needs to use Covers rather than Contains, due to
> that ol' quirky definition of Contains!
>
> On Thu, Jan 25, 2024 at 10:57 AM Paul Ramsey <pramsey at cleverelephant.ca>
> wrote:
>
>>
>>
>> On Jan 25, 2024, at 10:19 AM, Bruce Rindahl <bruce.rindahl at gmail.com>
>> wrote:
>>
>> I agree with Regina.  Also why are we coding this as a function in C when
>> it can be done either of two ways in SQL:
>>
>>
>> In general functions in SQL are less fun to upgrade. Will eventually do
>> this via Hausdorf.
>>
>> I don’t know that I agree about the parameter ordering, and I do not
>> think the name of the function provides any guidance when I re-write it in
>> object form,
>>
>> A.DFullyWithin(B,R)
>>
>> at least not in the same way that
>>
>> A.contains(B)
>>
>> makes parameter meaning clear.
>>
>> It’s the “D” that wrecks it.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20240125/2aee3d33/attachment-0001.htm>


More information about the postgis-devel mailing list