[postgis-devel] About BOXES

Sandro Santilli strk at keybit.net
Fri Nov 25 08:18:34 PST 2011


Ok, here's the thing.

Now that QGis supports showing TopoGeometry objects on the map [1]
I'd want it to also be fast at selecting the ones falling into
the viewport. And I want this to be as simple as possible to do
at the QGis side.

Simple selecting by rectangle means:

  A && B

Now, what is && ? It's BBOX-overlaps operator.

I've looked into the wayback machine [2] and it turns out PostGIS
advertises use of the following syntax since 2002:

  A && 'BOX3D(90900 190900, 100100 200100)'::box3d 

For a long long time the only box we had was box3d.
The type had casts to and from GEOMETRY and had its own
set of methods (expand, xmin, ymin, xmax, ymax).

Looking in the actual code I could find _no_ version of PostGIS
defining the && operator on box3d, but for some reason I thought 
that was the case. Could be because the manual suggested to
use box3d type for that kind of query, and because all the &&
operator uses is really just the box.

Today we have multiple boxes:

 BOX3D
 BOX3D_EXTENT
 BOX2D
 BOX2Df

Do we really need all of them ? What for ?
Can we get rid of them all ? Why not ?

Note that my need is still just as simple as selecting all the
TopoGeometry objects that fall in the map viewport. And I know
such operation I want performed on bounding boxes. And I know
I'd like the interface to be as transparent as it was back in
2002:

  A && 'BOX3D(90900 190900, 100100 200100)'::box3d 

Only with A which is now a TopoGeometry (or, incidentally, a Raster
or a Geography).

I'm dreaming of a setup in which all the bounding-box-oriented
operators are actually defined on a bounding-box-type (be it BOX3D
to be backward compatible since 2002 or a new shiny type being an
evolution of that one) and all our types (geometry,geography,raster,
topogeometry) would define implicit casts to that new type...


[1] http://hub.qgis.org/projects/quantum-gis/repository/revisions/41de1a0045eff44a4fc81b1d02458fa32223666b
[2] http://web.archive.org/web/20021213153604/http://postgis.refractions.net/docs/x534.html#AEN538

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-devel mailing list