[PostGIS] #5828: Performace issue in ST_DFullyWithin
PostGIS
trac at osgeo.org
Sun Jan 5 19:38:42 PST 2025
#5828: Performace issue in ST_DFullyWithin
----------------------+---------------------------
Reporter: nbvfgh | Owner: pramsey
Type: defect | Status: new
Priority: blocker | Milestone: PostGIS 3.6.0
Component: postgis | Version: 3.5.x
Resolution: | Keywords:
----------------------+---------------------------
Comment (by nbvfgh):
It may not be necessary to actually calculate the buffer for extending the
distance of geometry A to determine whether geometry B is fully included
in the buffer for extending the distance of geometry A. Because in
reality, the point on geometry A that is closest to geometry B is the one
that determines whether geometry B is fully included in the buffer zone of
the extended distance of geometry A. We refer to this point as **P1**.
So, we can simplify this problem as "**Is geometry B completely contained
within the buffer zone of the extended distance from point P1?**" And the
buffer zone of a point is a circle, and we only need to consider its
radius. Under what circumstances does a circle contain a geometry? We call
the point on geometry B that is farthest from point P1 as **P2**, and
finally simplify the problem as "**Is the distance between P1 and P2 less
than the distance?**".
Finally, we can obtain the following equivalent formula:
{{{ST_DFullyWithin(A, B, R) <=> ST_Contains(ST_Buffer(A, R), B) <=>
ST_MaxDistance(ST_ClosestPoint(A, B), B) ≤ R}}}
Sorry for the lengthy explanation, and thank you for your patience.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5828#comment:1>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list