[postgis-devel] Recognizing "kind" of geometry

strk strk at keybit.net
Fri Mar 5 14:00:32 PST 2010


Guys,
it hits my attention that a common need when dealing
with geometry values is knowing if it is formed by
POINTS, LINES or POLYGONS.
Also, I belive it's often useful to know if it's
EMPTY, or formed by a mix of the above 4 types.

This is surely true for GUI clients, which threat
points/lines/polygons differently, do nothing with
empties and often dunno what to do with mixed.

Starting from this need, I envision the possibility
to expose a simple function to give exactly that
information. I tried using ST_Dimension for this
at first, but w/out success.

Altough ST_Dimension seems to be the one we're
looking for (0:point 1:line 2:poly) it fails
in the empty case (exception up to 1.5, null in trunk)
and gives the max dimension found in a collection
(failing to give the 'mixed' information).

Do other see a need for such a function ?
Values it could return, taking the well-known ones
from JTS/GEOS literacy, are:

 PUNTUAL
 LINEAL
 AREAL
 MIXED
 EMPTY

Having such function you could finally attach
an "is AREAL" constraint to your tables rather
than the current "is MULTIPOLYGON" one often requiring
the use of ST_Multi() against topological functions...

Also, you could distinguish a collection of polygons
(say, returned from ST_Polygonize) from a collection
of mixed-types.

Thoughts ? Flames ? Candies ?

--strk;

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



More information about the postgis-devel mailing list