浏览代码

vlib/pg: fix Vect__get_area_points_pg()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58284 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 年之前
父节点
当前提交
fcc231090a
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      lib/vector/Vlib/area_pg.c

+ 7 - 0
lib/vector/Vlib/area_pg.c

@@ -92,9 +92,16 @@ PGresult *build_stmt(const struct Plus_head *plus, const struct Format_info_pg *
         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);