postgresql - I need to combine 2 queries postgis -


i have 2 queries:

1st query :

select st_astext( st_makeline(sp) ) (select   st_pointn(geom, generate_series(1, st_npoints(geom))) sp    -- extract individual linestrings   (select (st_dump(st_boundary(geom))).geom    geometriess    ) linestrings ) segments; 

in table there : "polygon((0 0,1 0,1 1,0 1,0 0))"

after query there : "linestring(0 0,1 0,1 1,0 1,0 0)"

and 2nd query :

 line (select geom geometries) select st_x(st_pointn(geom,num)) x,         st_y(st_pointn(geom,num)) y  line,    (select generate_series(1, (select st_numpoints(geom) line)) num)  series; 

it splits linestring points x , y.

i need combine them, don't know how.

the following test table creates 2 polygons, different numbers of points, combines them together, , grabs each point of boundary using generate_series st_npoints iterate through each polygon.

create table test (id serial, geom geometry); insert test (geom) values (st_geomfromtext('polygon((0 0, 0 1, 1 1, 1 0, 0 0))')); insert test (geom) values (st_geomfromtext('polygon((100 100, 100 200, 200 200, 250 300, 200 100, 100 100))'));   dumped (select (st_dump(geom)) dump        (select st_collect(geom) geom test) g),     points (select (dump).path, st_npoints((dump).geom) npoints, (dump).geom dumped),     polygons (select path[1] polygonid,                   st_boundary(geom) geom,                   generate_series(1,npoints) x points)  select polygonid,          st_x(st_pointn(geom,x)),          st_y(st_pointn(geom,x))   polygons; 

returns:

 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 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -