mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-23 16:42:35 +00:00
Fix bbox on collection level in TWKB output, #3187
git-svn-id: http://svn.osgeo.org/postgis/trunk@13801 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
582854374c
commit
d09a9bf053
|
@ -493,6 +493,21 @@ static int lwgeom_write_to_buffer(const LWGEOM *geom, TWKB_GLOBALS *globals, TWK
|
|||
/* 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 )
|
||||
|
@ -562,6 +577,7 @@ lwgeom_to_twkb_with_idlist(const LWGEOM *geom, int64_t *idlist, uint8_t variant,
|
|||
}
|
||||
|
||||
ts.idlist = idlist;
|
||||
ts.header_buf = NULL;
|
||||
ts.geom_buf = bytebuffer_create();
|
||||
lwgeom_write_to_buffer(geom, &tg, &ts);
|
||||
|
||||
|
|
|
@ -61,24 +61,6 @@ union all
|
|||
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');
|
||||
|
||||
|
|
|
@ -13,3 +13,4 @@ MULTIPOLYGON(((1 1, 1 2, 2 2, 2 1, 1 1)),((3 3,3 4,4 4,4 3,3 3)))|06000201050202
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue