The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

dtonnofer (12) [Avatar] Offline
#1
The query

SELECT ST_AsEWKT(ST_Collect(the_geom)) FROM (
SELECT ST_GeomFromEWKT('MULTIPOINTM(-1 1 4, 0 0 2, 2 3 2)') As the_geom
UNION ALL
SELECT ST_GeomFromEWKT('MULTILINESTRINGM((0 0 1,0 1 2,1 1 3),
(-1 1 1,-1 -1 2))') As the_geom
UNION ALL
SELECT ST_GeomFromEWKT('POLYGONM((-0.25 -1.25 1,-0.25 1.25 2,
2.5 1.25 3,2.5 -1.25 1,-0.25 -1.25 1),
(2.25 0 2,1.25 1 1,1.25 -1 1,2.25 0 2),
(1 -1 2,1 1 2,0 0 2,1 -1 2))') As the_geom) As foo;

does not correspond to the output, which is the output for listing .2.5:

GEOMETRYCOLLECTION(MULTIPOINT(-1 1,0 0,2 3),
MULTILINESTRING((0 0,0 1,1 1),(-1 1,-1 -1)),
POLYGON((-0.25 -1.25,-0.25 1.25,2.5 1.25,2.5 -1.25,-0.25 -1.25),
(2.25 0,1.25 1,1.25 -1,2.25 0),(1 -1,1 1,0 0,1 -1)))

The correct output is

GEOMETRYCOLLECTIONM(MULTIPOINTM(-1 1 4,0 0 2,2 3 2),MULTILINESTRINGM((0 0 1,0 1 2,1 1 3),(-1 1 1,-1 -1 2)),POLYGONM((-0.25 -1.25 1,-0.25 1.25 2,2.5 1.25 3,2.5 -1.25 1,-0.25 -1.25
1),(2.25 0 2,1.25 1 1,1.25 -1 1,2.25 0 2),(1 -1 2,1 1 2,0 0 2,1 -1 2)))

It would be advantageous to indirectly indicate which "AS" values are relevant and which not. This may be done using "foo1", "foo2", if the significance of that metavariable is clear to the reader (this is not necessarily the case) or by using "anything1", "anything2"....:

SELECT ST_AsEWKT(ST_Collect(the_geom)) FROM (

SELECT ST_GeomFromEWKT('MULTIPOINTM(-1 1 4, 0 0 2, 2 3 2)') As the_geom

UNION ALL

SELECT ST_GeomFromEWKT('MULTILINESTRINGM((0 0 1,0 1 2,1 1 3), (-1 1 1,-1 -1 2))') As anything1

UNION ALL

SELECT ST_GeomFromEWKT('POLYGONM((-0.25 -1.25 1,-0.25 1.25 2,2.5 1.25 3,2.5 -1.25 1,-0.25 -1.25 1),(2.25 0 2,1.25 1 1,1.25 -1 1,2.25 0 2),(1 -1 2,1 1 2,0 0 2,1 -1 2))') As anything2) AS anything3;