* New Features *
+ - ST_DelaunayTriangles (Sandro Santilli / Vizzuality)
- ST_NearestValue, ST_Neighborhood (Bborie Park / UC Davis)
- ST_Raster2WorldCoord, ST_World2RasterCoord (Bborie Park / UC Davis)
- #1643, Tiger Geocoder - Tiger 2011 loader (Regina Obe / Paragon Corporation)
</refsection>
</refentry>
+ <refentry id="ST_DelaunayTriangles">
+ <refnamediv>
+ <refname>ST_DelaunayTriangles</refname>
+
+ <refpurpose>
+Return a Delaunay triangulation around the given input points.
+ </refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>geometry <function>ST_DelaunayTriangles</function></funcdef>
+ <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+ <paramdef><type>float </type> <parameter>tolerance</parameter></paramdef>
+ <paramdef><type>int4 </type> <parameter>flags</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+Return a <ulink
+url="http://en.wikipedia.org/wiki/Delaunay_triangulation">Delaunay
+triangulation</ulink> around the vertices of the input geometry.
+Output is a COLLECTION of polygons (for flags=0) or a MULTILINESTRING
+(for flags=1). The tolerance, if any, is used to snap input vertices
+togheter.
+ </para>
+
+ <para>Availability: 2.1.0 - requires GEOS >= 3.4.0.</para>
+
+ </refsection>
+
+ <refsection>
+ <title>See Also</title>
+ <para>
+<xref linkend="ST_Dump" />
+ </para>
+ </refsection>
+ </refentry>
+
<refentry id="ST_Difference">
<refnamediv>
<refname>ST_Difference</refname>
Datum ST_UnaryUnion(PG_FUNCTION_ARGS);
Datum ST_Equals(PG_FUNCTION_ARGS);
Datum ST_BuildArea(PG_FUNCTION_ARGS);
+Datum ST_DelaunayTriangles(PG_FUNCTION_ARGS);
Datum pgis_union_geometry_array(PG_FUNCTION_ARGS);
PG_RETURN_POINTER(result);
}
+/*
+ * Take the vertices of a geometry and builds
+ * Delaunay triangles around them.
+ */
+PG_FUNCTION_INFO_V1(ST_DelaunayTriangles);
+Datum ST_DelaunayTriangles(PG_FUNCTION_ARGS)
+{
+ GSERIALIZED *result;
+ GSERIALIZED *geom;
+ LWGEOM *lwgeom_in, *lwgeom_out;
+ double tolerance = 0.0;
+ int flags = 0;
+
+ geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ tolerance = PG_GETARG_FLOAT8(1);
+ flags = PG_GETARG_INT32(2);
+
+ lwgeom_in = lwgeom_from_gserialized(geom);
+ lwgeom_out = lwgeom_delaunay_triangulation(lwgeom_in, tolerance, flags);
+ lwgeom_free(lwgeom_in) ;
+
+ if ( ! lwgeom_out ) {
+ PG_FREE_IF_COPY(geom, 0);
+ PG_RETURN_NULL();
+ }
+
+ result = geometry_serialize(lwgeom_out) ;
+ lwgeom_free(lwgeom_out) ;
+
+ PG_FREE_IF_COPY(geom, 0);
+ PG_RETURN_POINTER(result);
+}
+
/*
* ST_Snap
*
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
+--------------------------------------------------------------------------------
+-- ST_DelaunayTriangles
+--------------------------------------------------------------------------------
+
+-- ST_DelaunayTriangles(g1 geometry, tolerance float8, flags int4)
+--
+-- Builds Delaunay triangulation out of geometry vertices.
+--
+-- Returns a collection of triangular polygons with flags=0
+-- or a multilinestring with flags=1
+--
+-- If a tolerance is given it will be used to snap the input points
+-- each-other.
+--
+--
+-- Availability: 2.1.0
+-- Requires GEOS >= 3.4.0
+--
+CREATE OR REPLACE FUNCTION ST_DelaunayTriangles(g1 geometry, tolerance float8 DEFAULT 0.0, flags int4 DEFAULT 0)
+ RETURNS geometry
+ AS 'MODULE_PATHNAME', 'ST_DelaunayTriangles'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
+
--------------------------------------------------------------------------------
-- Aggregates and their supporting functions
relate_bnr
endif
+ifeq ($(shell expr $(POSTGIS_GEOS_VERSION) ">=" 34),1)
+ # GEOS-3.4 adds:
+ # ST_DelaunayTriangles
+ TESTS += \
+ delaunaytriangles
+endif
+
ifeq ($(HAVE_JSON),yes)
# JSON-C adds:
# ST_GeomFromGeoJSON()
--- /dev/null
+-- TODO: normalize !
+SELECT 1, ST_AsText(ST_DelaunayTriangles('MULTIPOINT(5 5, 6 0, 7 9)'::geometry));
+SELECT 2, ST_AsText(ST_DelaunayTriangles('MULTIPOINT(5 5, 6 0, 7 9, 8 9)'::geometry));
+SELECT 3, ST_AsText(ST_DelaunayTriangles('MULTIPOINT(5 5, 6 0, 7 9, 8 9)'::geometry, 2));
+SELECT 4, ST_AsText(ST_DelaunayTriangles('MULTIPOINT(5 5, 6 0, 7 9, 8 9)'::geometry, 2, 1));
--- /dev/null
+1|GEOMETRYCOLLECTION(POLYGON((5 5,6 0,7 9,5 5)))
+2|GEOMETRYCOLLECTION(POLYGON((5 5,6 0,8 9,5 5)),POLYGON((5 5,8 9,7 9,5 5)))
+3|GEOMETRYCOLLECTION(POLYGON((5 5,6 0,7 9,5 5)))
+4|MULTILINESTRING((5 5,7 9),(5 5,6 0),(6 0,7 9))