- Add parameters for geography ST_Buffer (Thomas Bonfort)
- TopoGeom_addElement, TopoGeom_remElement (Sandro Santilli)
- populate_topology_layer (Sandro Santilli)
+ - #1758, ST_Normalize (Sandro Santilli)
- #2259, ST_Voronoi (Dan Baston)
- #2991, Enable ST_Transform to use PROJ.4 text (Mike Toews)
- #3059, Allow passing per-dimension parameters in ST_Expand (Dan Baston)
</refsection>
</refentry>
+ <refentry id="ST_Normalize">
+ <refnamediv>
+ <refname>ST_Normalize</refname>
+
+ <refpurpose>Returns the geometry in its canonical form.</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>geometry <function>ST_Normalized</function></funcdef>
+ <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+ Returns the geometry in its normalized/canonical form.
+ May reorder vertices in polygon rings, rings in a polygon,
+ elements in a multi-geometry complex.
+ </para>
+
+ <para>
+ Mostly only useful for testing purposes (comparing expected
+ and obtained results).
+ </para>
+
+ </refsection>
+
+ <refsection>
+ <title>Examples</title>
+
+ <programlisting>
+SELECT ST_AsText(ST_Normalize(ST_GeomFromText(
+ 'GEOMETRYCOLLECTION(
+ POINT(2 3),
+ MULTILINESTRING((0 0, 1 1),(2 2, 3 3)),
+ POLYGON(
+ (0 10,0 0,10 0,10 10,0 10),
+ (4 2,2 2,2 4,4 4,4 2),
+ (6 8,8 8,8 6,6 6,6 8)
+ )
+ )'
+)));
+ st_astext
+----------------------------------------------------------------------------------------------------------------------------------------------------
+ GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(6 6,8 6,8 8,6 8,6 6),(2 2,4 2,4 4,2 4,2 2)),MULTILINESTRING((2 2,3 3),(0 0,1 1)),POINT(2 3))
+(1 row)
+ </programlisting>
+ </refsection>
+ <refsection>
+ <title>See Also</title>
+ <para>
+ <xref linkend="ST_Equals" />,
+ </para>
+ </refsection>
+ </refentry>
+
<refentry id="ST_RemovePoint">
<refnamediv>
<refname>ST_RemovePoint</refname>
PG_RETURN_POINTER(out);
}
+Datum ST_Normalize(PG_FUNCTION_ARGS);
+PG_FUNCTION_INFO_V1(ST_Normalize);
+Datum ST_Normalize(PG_FUNCTION_ARGS)
+{
+ GSERIALIZED *in, *out;
+ LWGEOM *lwgeom_in, *lwgeom_out;
+
+ POSTGIS_DEBUG(2, "ST_Normalize called");
+
+ in = PG_GETARG_GSERIALIZED_P_COPY(0);
+
+ lwgeom_in = lwgeom_from_gserialized(in);
+ POSTGIS_DEBUGF(3, "Deserialized: %s", lwgeom_summary(lwgeom_in, 0));
+
+ lwgeom_out = lwgeom_normalize(lwgeom_in);
+ POSTGIS_DEBUGF(3, "Normalized: %s", lwgeom_summary(lwgeom_out, 0));
+
+ out = geometry_serialize(lwgeom_out);
+ lwgeom_free(lwgeom_in);
+ lwgeom_free(lwgeom_out);
+
+ PG_FREE_IF_COPY(in, 0);
+
+ PG_RETURN_POINTER(out);
+}
+
+
/**
* @return:
* 0==2d
LANGUAGE 'c' VOLATILE STRICT
COST 10;
+-- Availability: 2.3.0
+CREATE OR REPLACE FUNCTION ST_Normalize(geom geometry)
+ RETURNS geometry
+ AS 'MODULE_PATHNAME', 'ST_Normalize'
+ LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
+ COST 20; -- 20 as it delegates to GEOS
+
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION ST_zmflag(geometry)
RETURNS smallint
lwgeom_regress \
measures \
minimum_bounding_circle \
+ normalize \
operators \
out_geometry \
out_geography \
--- /dev/null
+select 1, ST_AsText(ST_Normalize(
+'GEOMETRYCOLLECTION(POINT(2 3),MULTILINESTRING((0 0, 1 1),(2 2, 3 3)))'
+::geometry));
+
+select 2, ST_AsText(ST_Normalize(
+'POLYGON((0 10,0 0,10 0,10 10,0 10),(4 2,2 2,2 4,4 4,4 2),(6 8,8 8,8 6,6 6,6 8))'
+::geometry));
--- /dev/null
+1|GEOMETRYCOLLECTION(MULTILINESTRING((2 2,3 3),(0 0,1 1)),POINT(2 3))
+2|POLYGON((0 0,0 10,10 10,10 0,0 0),(6 6,8 6,8 8,6 8,6 6),(2 2,4 2,4 4,2 4,2 2))
+