/* Write the TWKB into the output buffer */
lwgeom_to_twkb_buf(geom, globals, &child_state);
+ /*If we have a header_buf, we know that this function is called inside a collection*/
+ /*and then we have to merge the bboxes of the included geometries*/
+ /*and put the result to the parent (the collection)*/
+ if( (globals->variant & TWKB_BBOX) && parent_state->header_buf )
+ {
+ LWDEBUG(4,"Merge bboxes");
+ for ( i = 0; i < ndims; i++ )
+ {
+ if(child_state.bbox_min[i]<parent_state->bbox_min[i])
+ parent_state->bbox_min[i] = child_state.bbox_min[i];
+ if(child_state.bbox_max[i]>parent_state->bbox_max[i])
+ parent_state->bbox_max[i] = child_state.bbox_max[i];
+ }
+ }
+
/* Did we have a box? If so, how big? */
bbox_size = 0;
if( globals->variant & TWKB_BBOX )
}
ts.idlist = idlist;
+ ts.header_buf = NULL;
ts.geom_buf = bytebuffer_create();
lwgeom_write_to_buffer(geom, &tg, &ts);
select 'POLYGON((1 1, 1 2, 2 2, 2 1, 1 1))'::text g
) foo;
-
---Aggregated geoemtries with preserved id
--- select st_astext(st_collect(g::geometry)), encode(ST_AsTWKBagg(g::geometry,0),'hex') from
--- (
--- select 'POINT(1 1)'::text g
--- union all
--- select 'POINT(2 2)'::text g
--- ) foo;
-
---Aggregated geoemtries with preserved id
--- select st_astext(st_collect(g::geometry)), encode(ST_AsTWKBagg(g::geometry,0),'hex') from
--- (
--- select 'MULTIPOINT((1 1),(2 2))'::text g
--- union all
--- select 'POINT(78 -78)'::text g
--- union all
--- select 'POLYGON((1 1, 1 2, 2 2, 2 1, 1 1))'::text g
--- ) foo;
-
-
+--GEOMETRYCOLLECTION with bounding box ref #3187
+select encode(st_astwkb(st_collect('point(4 1)'::geometry,'linestring(1 1, 0 3)'::geometry),0,0,0,false,true),'hex');
MULTIPOLYGON(((1 1, 1 20, 20 20, 20 1, 1 1),(3 3,3 4, 4 4,4 3,3 3)),((-1 1, -1 20, -20 20, -20 1, -1 1),(-3 3,-3 4, -4 4,-4 3,-3 3)))|06000202050202002626000025250005040400020200000101000205070300262500002526000503040002010000010200
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))|0700020100020202000204040202
GEOMETRYCOLLECTION(MULTIPOINT(1 1,2 2),POINT(78 -78),POLYGON((1 1,1 2,2 2,2 1,1 1)))|0700030400020202020201009c019b010300010502020002020000010100
+0701000802040201010800020008020201000202040202020104