[GRASS-SVN] r58284 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 22 11:31:44 PST 2013


Author: martinl
Date: 2013-11-22 11:31:43 -0800 (Fri, 22 Nov 2013)
New Revision: 58284

Modified:
   grass/trunk/lib/vector/Vlib/area_pg.c
Log:
vlib/pg: fix Vect__get_area_points_pg()


Modified: grass/trunk/lib/vector/Vlib/area_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/area_pg.c	2013-11-22 16:46:28 UTC (rev 58283)
+++ grass/trunk/lib/vector/Vlib/area_pg.c	2013-11-22 19:31:43 UTC (rev 58284)
@@ -92,9 +92,16 @@
         sprintf(buf_id, "%d", (int) BLine->offset);
         strcat(stmt_id, buf_id);
     }
+    /* Not really working - why?
     G_asprintf(&stmt, "SELECT geom FROM \"%s\".edge_data WHERE edge_id IN (%s) "
                "ORDER BY POSITION(edge_id::text in '%s')", pg_info->toposchema_name,
                stmt_id, stmt_id);
+    */
+    G_asprintf(&stmt, "SELECT geom FROM \"%s\".edge_data AS t "
+               "JOIN (SELECT id, row_number() over() AS id_sorter FROM "
+               "(SELECT UNNEST(ARRAY[%s]) AS id) AS y) x ON "
+               "t.edge_id in (%s) AND x.id = t.edge_id "
+               "ORDER BY x.id_sorter", pg_info->toposchema_name, stmt_id, stmt_id);
     G_free(stmt_id);
     
     G_debug(2, "SQL: %s", stmt);



More information about the grass-commit mailing list