* New Features *
+ - #3169, ST_ApproximateMedialAxis (Sandro Santilli)
- Add |=| operator with CPA semantic and KNN support with PgSQL 9.5+
(Sandro Santilli / Boundless)
- #3131, KNN support for the geography type (Paul Ramsey / CartoDB)
- #899, -m shp2pgsql attribute names mapping -m switch
(Regina Obe / Sandro Santilli)
- #1678, Added GUC postgis.gdal_datapath to specify GDAL config
- variable GDAL_DATA
+ variable GDAL_DATA
- #2843, Support reprojection on raster import
(Sandro Santilli / Vizzuality)
- #2349, Support for encoded_polyline input/output (Kashif Rasul)
variable GDAL_SKIP
- Added GUC postgis.enable_outdb_rasters to enable access to
rasters with out-db bands
- - #2387 address_standardizer extension as part of PostGIS
- Stephen Woodbridge (imaptools.com), Walter Sinclair
+ - #2387, address_standardizer extension as part of PostGIS
+ Stephen Woodbridge (imaptools.com), Walter Sinclair
- #2341, New mask parameter for ST_MapAlgebra
- #2397, read encoding info automatically in shapefile loader
- #2430, ST_ForceCurve
- #2567, ST_CountAgg()
- #2632, ST_AsGML() support for curved features
- #2652, Add --upgrade-path switch to run_test.pl
- - #2754 sfcgal wrapped as an extension
+ - #2754, sfcgal wrapped as an extension
- #2227, Simplification with Visvalingam-Whyatt algorithm
ST_SimplifyVW, ST_SetEffectiveArea (Nicklas Avén)
- Functions to encode and decode TWKB
- ST_AsTWKB, ST_GeomFromTWKB (Paul Ramsey / Nicklas Avén / CartoDB)
+ ST_AsTWKB, ST_GeomFromTWKB (Paul Ramsey / Nicklas Avén / CartoDB)
* Enhancements *
../images/st_split03.png \
../images/st_split04.png \
../images/st_straightskeleton01.png \
+ ../images/st_approximatemedialaxis01.png \
../images/st_subdivide01.png \
../images/st_subdivide02.png \
../images/st_symdifference01.png \
--- /dev/null
+Style1;POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))\r
+Style2;MULTILINESTRING((184.188611699158 15.8113883008419,158.377223398316 20),(50 20,158.377223398316 20),(50 20,35 35),(35 153.150778481549,35 35),(35 153.150778481549,40.6970772062924 159.302922793708),(164.039879739868 164.039879739868,40.6970772062924 159.302922793708))\r
</refentry>
+ <refentry id="ST_ApproximateMedialAxis">
+ <refnamediv>
+ <refname>ST_ApproximateMedialAxis</refname>
+
+ <refpurpose>Compute the approximate medial axis of an areal geometry.</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>geometry <function>ST_ApproximateMedialAxis</function></funcdef>
+ <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+Return an approximate medial axis for the areal input based on
+its straight skeleton. Uses an SFCGAL specific API when built against
+a capable version (1.2.0+). Otherwise the function is just a wrapper
+around ST_StraightSkeleton (slower case).
+ </para>
+
+ <para>Availability: 2.2.0</para>
+ <para>&sfcgal_required;</para>
+ <para>&Z_support;</para>
+ <para>&P_support;</para>
+ <para>&T_support;</para>
+ </refsection>
+
+ <refsection><title>Examples</title>
+ <programlisting>SELECT ST_ApproximateMedialAxis(ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))'));</programlisting>
+
+ <informaltable>
+ <tgroup cols="1">
+ <tbody>
+ <row>
+ <entry><para><informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/st_approximatemedialaxis01.png" />
+ </imageobject>
+ <caption><para>A polygon and its approximate medial axis</para></caption>
+ </mediaobject>
+ </informalfigure></para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsection>
+
+ <refsection>
+ <title>See Also</title>
+
+ <para><xref linkend="ST_StraightSkeleton" /></para>
+ </refsection>
+
+ </refentry>
+
<refentry id="ST_IsPlanar">
<refnamediv>
#include "lwgeom_pg.h"
#include "lwgeom_sfcgal.h"
+#include "../postgis_config.h"
Datum postgis_sfcgal_version(PG_FUNCTION_ARGS);
Datum sfcgal_intersection3D(PG_FUNCTION_ARGS);
Datum sfcgal_extrude(PG_FUNCTION_ARGS);
Datum sfcgal_straight_skeleton(PG_FUNCTION_ARGS);
+Datum sfcgal_approximate_medial_axis(PG_FUNCTION_ARGS);
Datum sfcgal_is_planar(PG_FUNCTION_ARGS);
Datum sfcgal_orientation(PG_FUNCTION_ARGS);
Datum sfcgal_force_lhr(PG_FUNCTION_ARGS);
PG_RETURN_POINTER(output);
}
+PG_FUNCTION_INFO_V1(sfcgal_approximate_medial_axis);
+Datum sfcgal_approximate_medial_axis(PG_FUNCTION_ARGS)
+{
+#if POSTGIS_SFCGAL_VERSION < 12
+ lwpgerror("The SFCGAL version this PostGIS binary "
+ "was compiled against (%d) doesn't support "
+ "'sfcgal_geometry_approximate_medial_axis' function (1.2.0+ required)",
+ POSTGIS_SFCGAL_VERSION);
+ PG_RETURN_NULL();
+#else /* POSTGIS_SFCGAL_VERSION >= 12 */
+ GSERIALIZED *input, *output;
+ sfcgal_geometry_t *geom;
+ sfcgal_geometry_t *result;
+ srid_t srid;
+
+ sfcgal_postgis_init();
+
+ input = PG_GETARG_GSERIALIZED_P(0);
+ srid = gserialized_get_srid(input);
+ geom = POSTGIS2SFCGALGeometry(input);
+ PG_FREE_IF_COPY(input, 0);
+
+ result = sfcgal_geometry_approximate_medial_axis(geom);
+ sfcgal_geometry_delete(geom);
+
+ output = SFCGALGeometry2POSTGIS(result, 0, srid);
+ sfcgal_geometry_delete(result);
+
+ PG_RETURN_POINTER(output);
+#endif /* POSTGIS_SFCGAL_VERSION >= 12 */
+}
+
PG_FUNCTION_INFO_V1(sfcgal_intersection);
Datum sfcgal_intersection(PG_FUNCTION_ARGS)
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
+-- Availability: 2.2.0
+CREATE OR REPLACE FUNCTION ST_ApproximateMedialAxis(geometry)
+ RETURNS geometry
+#if POSTGIS_SFCGAL_VERSION < 12
+ AS $$
+ DECLARE
+ poly alias for $1;
+ ret GEOMETRY;
+ BEGIN
+ WITH components AS (
+ SELECT (ST_Dump(ST_StraightSkeleton(poly))).geom
+ ),
+ filtered AS (
+ SELECT ST_Collect(geom) g
+ FROM components
+ WHERE NOT ST_Touches(geom, ST_Boundary(poly))
+ )
+ SELECT
+ COALESCE(g, ST_SetSRID('MULTILINESTRING EMPTY', ST_Srid(poly)))
+ INTO ret
+ FROM filtered;
+ RETURN ret;
+ END; $$
+ LANGUAGE 'plpgsql'
+#else // POSTGIS_SFCGAL_VERSION >= 12
+ AS 'MODULE_PATHNAME','sfcgal_approximate_medial_axis'
+ LANGUAGE 'c'
+#endif // POSTGIS_SFCGAL_VERSION >= 12
+ IMMUTABLE STRICT COST 100;
+
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_IsPlanar(geometry)
RETURNS boolean
sfcgal/regress.sql \
sfcgal/tickets.sql \
sfcgal/concave_hull.sql \
- sfcgal/wmsservers.sql
+ sfcgal/wmsservers.sql \
+ sfcgal/approximatemedialaxis.sql
SFCGALTESTFLAGS = --sfcgal
endif
--- /dev/null
+SELECT 'square', ST_AsText(ST_ApproximateMedialAxis('POLYGON((0 0,1 0,1 1,0 1,0 0))'));
+SELECT 'rect1', ST_AsText(ST_ApproximateMedialAxis('POLYGON((0 0,2 0,2 1,0 1,0 0))'));
+
--- /dev/null
+square|MULTILINESTRING EMPTY
+rect1|MULTILINESTRING((0.5 0.5,1.5 0.5))