<div dir="ltr"><div><div>Hi All,<br></div>     Working on the question of Delaunay triangulation in PostGIS 2.1/GEOS 3.4.  I wrote a quick function to wrap the existing ST_DelaunayTriangulation so that it would output a TIN Z instead, which is a very hackerish string-replace with no checks for the validity of the TIN (convert triangulation to text, replace references to POLYGON Z and GEOMETRYCOLLECTION Z, feed back into GeomFromEWKT):<br>
<br><span style="font-family:courier new,monospace">CREATE OR REPLACE FUNCTION chp07.AsTIN(geometry)<br>  RETURNS geometry AS<br>$BODY$</span><br><br><span style="font-family:courier new,monospace">WITH dt AS<br>(<br>SELECT ST_AsText(ST_DelaunayTriangles(ST_Collect($1))) AS atext<br>
),<br>replacedt AS<br>(<br>SELECT replace(atext, 'POLYGON Z', '') as ttext<br>  FROM dt<br>),<br>replacegc AS<br>(<br>SELECT replace(ttext, 'GEOMETRYCOLLECTION Z', 'TIN') AS tintext<br>  from replacedt<br>
),<br>tingeom AS<br>(<br>SELECT ST_GeomFromEWKT(tintext) AS the_geom FROM replacegc<br>)<br><br>SELECT the_geom FROM tingeom<br><br>$BODY$<br>  LANGUAGE sql VOLATILE<br>  COST 100;<br>ALTER FUNCTION chp07.AsTIN(geometry)<br>
  OWNER TO postgres;</span><br></div><br><div><div><div>Anyway, the function is a patch so I can generate a TIN from a point cloud and be able to output to the web via X3D and ST_DelaunayTriangulation, but wonder now where in the timeline is a function that creates a TIN from a point cloud lest others are doing smarter things than a couple of nested replace()?  How does this relate to the potential integration of CGAL (<a href="http://www.oslandia.com/tech/?p=1235">http://www.oslandia.com/tech/?p=1235</a>) etc..<br>
</div><div><br></div><div>Thanks,<br>Best,<br>Steve Mather<br></div></div></div><div class="gmail_extra"><br></div></div>