--Build a donut with an ant hole
SELECT ST_MakePolygon(
ST_ExteriorRing(ST_Buffer(foo.line,10)),
- ARRAY[ST_Translate(foo.line,1,1),ST_ExteriorRing(ST_Buffer(ST_MakePoint(20,20),1)) ]
+ ARRAY[ST_Translate(foo.line,1,1),
+ ST_ExteriorRing(ST_Buffer(ST_MakePoint(20,20),1)) ]
)
FROM
(SELECT ST_ExteriorRing(ST_Buffer(ST_MakePoint(10,10),10,10))
it creates new rows. For example it can be use to expand MULTIPOLYGONS into POLYGONS.</para>
<programlisting>
-SELECT sometable.field1, sometable.field1, (ST_Dump(sometable.the_geom)).geom As the_geom
+SELECT sometable.field1, sometable.field1,
+(ST_Dump(sometable.the_geom)).geom As the_geom
FROM sometable
</programlisting>
</varlistentry>
<varlistentry>
- <term>ST_AddPoint(linestring, point, [<position>])</term>
+ <term>ST_AddPoint(linestring geometry, point geometry)</term>
+ <term>ST_AddPoint(linestring geometry, point geometry, position integer)</term>
<listitem>
- <para>Adds a point to a LineString before point <pos>
+ <para>Adds a point to a LineString before point <position>
(0-based index). Third parameter can be omitted or set to -1 for
appending.</para>
+ <programlisting>
+--guarantee all linestrings in a table are closed
+--by adding the start point of each linestring to the end of the line string
+--only for those that are not closed
+UPDATE sometable
+ SET the_geom = ST_AddPoint(the_geom, ST_StartPoint(the_geom))
+ FROM sometable
+ WHERE ST_IsClosed(the_geom) = false;
+ </programlisting>
</listitem>
</varlistentry>
<para>The extent() function is an "aggregate" function
in the terminology of PostgreSQL. That means that it operators
on lists of data, in the same way the sum() and mean() functions
- do. For example, "SELECT EXTENT(GEOM) FROM GEOMTABLE"
- will return a BOX3D giving the maximum extend of all features in
- the table. Similarly, "SELECT EXTENT(GEOM) FROM GEOMTABLE
+ do. For example, "SELECT ST_Extent(GEOM) FROM GEOMTABLE"
+ will return a BOX3D giving the maximum extent of all features in
+ the table. Similarly, "SELECT ST_Extent(GEOM) FROM GEOMTABLE
GROUP BY CATEGORY" will return one extent result for each
category.</para>
</listitem>