Question

I have a database table of areas that can contain each other resulting in a tree/forest structure. Each area has a parent pointer and top-level areas have a null parent.

I would like to change this so there is a single top-level area that contains everything to simplify querying. Then I don't need special cases for dealing with top-level areas because areas will always have a parent.

Is there any way (in PostGIS and Oracle Spatial) to insert an area with an "infinitely large" geometry so it will always be found with intersects queries?

Specifically, I'd like a geometry where the following are true regardless of G:

ROOT contains G = true
ROOT intersects G = true
ROOT overlaps G = false
Was it helpful?

Solution

I've not met anything that implements this concept, but you could (crudely) implement it with triggers; such that every time you insert a new row, the top level parent incorporates the new shape into itself.

The likely problem with this (or any similar approach) is that your performance won't be great; certainly Oracle doesn't handle manipulation of complex geometries that well, and you're potentially skewing your domain index(es).

You'll also find that in Oracle, there's an ordinate limit on sdo_geometry objects. From the Oracle documentation (http://docs.oracle.com/cd/B28359_01/appdev.111/b28400/sdo_objrelschema.htm#i1004087):

Because the maximum SDO_ORDINATE_ARRAY size is 1,048,576 numbers, the maximum number of vertices in an SDO_GEOMETRY object depends on the number of dimensions per vertex: 524,288 for two dimensions, 349,525 for three dimensions, and 262,144 for four dimensions.

This shouldn't be a problem if you simplify the parent shapes somewhat.

I'd say it's probably better to keep your special-casing than go down this route.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top