]> granicus.if.org Git - postgis/commitdiff
example of using new PostgreSQL 9.0+ ORDER BY aggregate feature for ST_MakeLine
authorRegina Obe <lr@pcorp.us>
Wed, 27 Jul 2011 11:52:51 +0000 (11:52 +0000)
committerRegina Obe <lr@pcorp.us>
Wed, 27 Jul 2011 11:52:51 +0000 (11:52 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7681 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_constructor.xml

index 3386e946fd04f6919e6aa10ea7376c4b18fe1050..3bdff321406f07863477693aa7d5e41944686ea7 100644 (file)
@@ -1224,7 +1224,15 @@ BOX3D(-989502.1875 528439.5625 10,-987121.375 529933.1875 10)
 SELECT gps.gps_track, ST_MakeLine(gps.the_geom) As newgeom
        FROM (SELECT gps_track,gps_time, the_geom
                        FROM gps_points ORDER BY gps_track, gps_time) As gps
-       GROUP BY gps.gps_track</programlisting>
+       GROUP BY gps.gps_track;</programlisting>
+       
+               <programlisting>
+-- If you are using PostgreSQL 9.0+ 
+-- (you can use the new ORDER BY support for aggregates)
+-- this is a more guaranteed way to get ordered linestring
+SELECT gps.gps_track, ST_MakeLine(gps.the_geom ORDER BY gps_track,gps_time) As newgeom
+       FROM gps_points 
+       GROUP BY gps.gps_track;</programlisting>
                </refsection>
                <refsection>
                        <title>Examples: Non-Spatial Aggregate version</title>