[postgis-devel] Adding intersects support for GeometryCollection/Box

Paul Ramsey pramsey at cleverelephant.ca
Wed Jun 4 10:15:17 PDT 2008


I would rather see a complete implementation of intersects() for
geometrycollection than something that does only bbox. I think the
semantics are clear (I hope):

foreach geom in geometrycollection
  if intersects(geom, othergeom) return true
end
return false

You may have to check (god, I wish this was documented, maybe it is,
check the lwgeom readmes) on whether we even allow
geometrycollection(geometrycollection()). I think we only allow
geometrycollection(multi*()), so that there is a fixed amount of
potential recursion in the structures.

You'll also have to deal with the intersects(geomcoll, geomcoll) case,
but the semantics are the same: the intersection of any pair of parts
implies the intersection of the whole.

Paul

On Wed, Jun 4, 2008 at 9:00 AM, Markus Schneider <schneider at lat-lon.de> wrote:
> Hello,
>
> I am wondering about the things that need to be done to get the intersects
> predicate for geometries of type GeometryCollection working.
>
> Our WMS implementation (http://www.deegree.org) uses statements of the following
> form to retrieve geometries inside the view window:
>
> SELECT X1.GEOM,X1.NAME,X1.ID FROM MULTITEST X1
> WHERE X1.GEOM && SetSRID('BOX3D(...)'::box3d,...)
> AND intersects (X1.GEOM, SetSRID('BOX3D(...)'::box3d,...))
>
> As already discussed on postgis-users (thanks, Martin!), this statement
> currently leads to an error message if any geometries of type GeometryCollection
> are involved in the intersects-test:
>
> ERROR: Relate Operation called with a LWGEOMCOLLECTION type.  This is unsupported
> SQL Status:XX000
>
> For our special use case, we would only need
> intersects(GeometryCollection,Box3D). As I see it, the relevant function is in
> lwgeom/lwgeom_geos_c.c, line 2016 (SVN-version):
>
> Datum intersects(PG_FUNCTION_ARGS)
> {
> ...
> }
>
> Is this correct? And do you think that it is feasible to evaluate the intersects
> predicate between a Box3D and GeometryCollection by checking if any geometry
> contained in the GeometryCollection intersects the Box3D?
>
> As GeometryCollections can be nested (and may contain GeometryCollections as
> members), one would have to perform a recursion in the GeometryCollection to
> find all (non-GeometryCollection) geometries to be tested, right?
>
> Do you think that this is a good approach? And is there a chance to get this
> into the PostGIS code base? As I am new to PostGIS development, I am not sure if
> I can implement this, but the problem itself does not look too complicated...
>
>
> Best regards,
>
> --
> Markus Schneider
>
> l a t / l o n  GmbH
> Aennchenstrasse 19               53177 Bonn, Germany
> phone ++49 +228 18496-0          fax ++49 +228 18496-29
> http://www.lat-lon.de            http://www.deegree.org
>
> -------------------------------------------------------
> On June 17 is deegree day - Am 17. Juni ist deegree day
>              http://deegree.org/deegreeday
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>



More information about the postgis-devel mailing list