[postgis-users] Topology newbie question - put in a triangle, get out a quad, minus the Z values

Sandro Santilli strk at keybit.net
Tue Dec 4 02:12:23 PST 2012


If I've understood correctly you're complaining that the faces do not
get the Z value ? But you're querying the minimum bounding rectangle,
not the face geometry.

Try this:

=# select st_astext(st_getfacegeometry('ma_topo', face_id))
   from ma_topo.face where face_id > 0;
               st_astext
---------------------------------------
 POLYGON Z ((2 2 2,4 2 2,3 1 9,2 2 2))
(1 row)

--strk;

On Mon, Dec 03, 2012 at 02:39:06PM -0500, John Morrison wrote:
> Hi;
> 
> Sorry if this is a dumb newbie question.  I am trying to build a topology
> trimesh (in what to me is the obvious way) from an unreasonably large SRTM
> raster.  I can get the nodes and edges into the database, but the
> Polygonize function doesn't create the expected triangles (two per raster
> pixel), but instead creates a single square.
> 
> I tried to produce an SQL file which highlights the behavior (which, for
> all I know, is fully expected).  Please find attached two such files.  I
> did read the source to the Polygonize function, and when I call
> st_polygonize on the edge_data column (as it does), I get back the expected
> triangle with Z value...
> 
> Here's test01.sql (in case it doesn't survive the MTAs), in which I
> simplified away use of 3D coords and SRID:
> 
> SELECT CreateTopology('ma_topo'); -- No Z
> SELECT AddEdge('ma_topo', ST_GeomFromText('LINESTRING(2 2, 4 2)'));
> SELECT AddEdge('ma_topo', ST_GeomFromText('LINESTRING(4 2, 3 1)'));
> SELECT AddEdge('ma_topo', ST_GeomFromText('LINESTRING(3 1, 2 2)'));
> SELECT Polygonize('ma_topo');
> -- Correctly shows a single triangle in the Topology
> SELECT St_AsText(foo.geom) FROM (SELECT (st_dump(st_polygonize(geom))).geom
> FROM ma_topo.edge_data) as foo;
> SELECT ST_AsText(mbr) FROM ma_topo.face;
> 
> Here's test00.sql, which exhibits the same quad/tri behavior, but
> additionally is missing the Z value...
> 
> SELECT CreateTopology('ma_topo', 4326, 0, true); -- Has Z
> SELECT AddEdge('ma_topo', ST_GeomFromText('SRID=4326;LINESTRINGZ(2 2 2, 4 2
> 2)'));
> SELECT AddEdge('ma_topo', ST_GeomFromText('SRID=4326;LINESTRINGZ(4 2 2, 3 1
> 9)'));
> SELECT AddEdge('ma_topo', ST_GeomFromText('SRID=4326;LINESTRINGZ(3 1 9, 2 2
> 2)'));
> SELECT Polygonize('ma_topo');
> -- Correctly shows a single triangle in the Topology
> SELECT St_AsText(foo.geom) FROM (SELECT (st_dump(st_polygonize(geom))).geom
> FROM ma_topo.edge_data) as foo;
> SELECT ST_AsText(mbr) FROM ma_topo.face;
> 
> 
> FYI I am using the latest PostGIS (from source control, rebuilt yesterday
> in an attempt to ensure this was not simply a case of outdated software),
> running under FC16 x86_64.  Again, sorry if this is a dumb question, but I
> am new to SQL, PostGres, and PostGIS - yes, the trifecta.
> 
> Thanks for any help you can give me, including any advice as to approach...
> 
> -jm


More information about the postgis-users mailing list