Postgresql 我需要将两个查询合并到postgis中

Postgresql 我需要将两个查询合并到postgis中,postgresql,postgis,Postgresql,Postgis,我有两个问题: 第一个问题: SELECT ST_AsText( ST_MakeLine(sp) ) FROM (SELECT ST_PointN(geom, generate_series(1, ST_NPoints(geom))) as sp FROM -- extract the individual linestrings (SELECT (ST_Dump(ST_Boundary(geom))).geom FROM geometriess ) AS linest

我有两个问题:

第一个问题:

SELECT ST_AsText( ST_MakeLine(sp) )
FROM
(SELECT
  ST_PointN(geom, generate_series(1, ST_NPoints(geom))) as sp
FROM
   -- extract the individual linestrings
  (SELECT (ST_Dump(ST_Boundary(geom))).geom
   FROM geometriess
   ) AS linestrings
) AS segments;
表中有:“多边形((0,10,1,1,0 1,0 0))”

此查询之后将出现:“LINESTRING(0,1 0,1,0 1,0 0)”

第二个问题:

 with line as (select geom from geometries)
select ST_X(ST_PointN(geom,num)) as x, 
       ST_Y(ST_PointN(geom,num)) as y 
from line,
   (select generate_series(1, (select ST_NumPoints(geom) from line)) as num) 
as series;
它将线字符串拆分为点x和点y


我需要组合它们,但我不知道如何组合。

下面的测试表创建了两个具有不同点数的多边形,将它们组合在一起,然后使用generate_series with st_npoints获取边界的每个点,以迭代每个多边形

create table test (id serial, geom geometry);
insert into test (geom) values (ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'));
insert into test (geom) values (ST_GeomFromText('POLYGON((100 100, 100 200, 200 200, 250 300, 200 100, 100 100))'));


with dumped as (select (st_dump(geom)) as dump from 
      (select st_collect(geom) as geom from test) g),
    points as (select (dump).path, st_npoints((dump).geom) as npoints, (dump).geom from dumped),
    polygons as (select path[1] as polygonid, 
                 st_boundary(geom) as geom, 
                 generate_series(1,npoints) as x from points)
 select polygonid, 
        st_x(st_pointn(geom,x)), 
        st_y(st_pointn(geom,x)) 
 from polygons;
返回:

 polygonid | st_x | st_y 
-----------+------+------
     1 |    0 |    0
     1 |    0 |    1
     1 |    1 |    1
     1 |    1 |    0
     1 |    0 |    0
     2 |  100 |  100
     2 |  100 |  200
     2 |  200 |  200
     2 |  250 |  300
     2 |  200 |  100
     2 |  100 |  100

你能解释一下你到底想做什么吗。你好像把点从一条直线上倒出来,然后重新组合它们?我想从多边形st_x和st_yI那里得到一个答案,这将把点从多边形的边界上拉出来,如果你是这样问的话?