From: Sandro Santilli Date: Wed, 5 Jan 2005 22:48:29 +0000 (+0000) Subject: Had translate compute bbox cache translating input one if present. X-Git-Tag: pgis_1_0_0RC1~80 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfb0414e844a1771543267c154e3640af5aa45f0;p=postgis Had translate compute bbox cache translating input one if present. Cleanups. git-svn-id: http://svn.osgeo.org/postgis/trunk@1224 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/BBOXCACHE_BEHAVIOURS b/lwgeom/BBOXCACHE_BEHAVIOURS index eed4d6d38..5ea3ca502 100644 --- a/lwgeom/BBOXCACHE_BEHAVIOURS +++ b/lwgeom/BBOXCACHE_BEHAVIOURS @@ -78,10 +78,8 @@ section also use it. simplify(geometry, float8) *LWG* #### could use WHEN_SIMPLE - #### translating and transforming an eventually present - #### bbox cache in input - translate(geometry,float8,float8,[float8]) *SRL* - transform(geometry,integer) *SRL* + #### transforming an eventually present bbox cache in input + transform(geometry,integer) **SRL** [ WHEN_SIMPLE (use input bbox if present) ] noop(geometry) *LWG* @@ -101,10 +99,11 @@ section also use it. collect(geometry, geometry) *LWG* collect_garray (geometry[]) *LWG* - ## apply grid to eventually present box in input - apply_grid(geometry, float8, float8, float8, float8); + ## transform eventually present box in input + apply_grid(geometry, float8, float8, float8, float8); *LWG* + translate(geometry,float8,float8,[float8]) **SRL** - ## These use LWGEOM as a mean to access and modigy SERIALIZED form + ## These use LWGEOM as a mean to access and modify SERIALIZED form reverse(geometry) *LWG* **SRL** ForceRHR(geometry) *LWG* **SRL** diff --git a/lwgeom/lwgeom_functions_basic.c b/lwgeom/lwgeom_functions_basic.c index d83c7ad90..8f7676bba 100644 --- a/lwgeom/lwgeom_functions_basic.c +++ b/lwgeom/lwgeom_functions_basic.c @@ -1479,8 +1479,8 @@ PG_FUNCTION_INFO_V1(LWGEOM_translate); Datum LWGEOM_translate(PG_FUNCTION_ARGS) { PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)); - PG_LWGEOM *oldgeom; char *srl = SERIALIZED_FORM(geom); + BOX2DFLOAT4 *box; double xoff = PG_GETARG_FLOAT8(1); double yoff = PG_GETARG_FLOAT8(2); @@ -1488,14 +1488,13 @@ Datum LWGEOM_translate(PG_FUNCTION_ARGS) lwgeom_translate_recursive(srl, xoff, yoff, zoff); - if ( TYPE_HASBBOX(geom->type) ) + /* COMPUTE_BBOX WHEN_SIMPLE */ + if ( (box = getbox2d_internal(srl)) ) { - if ( ! compute_serialized_bbox_p(srl, getbox2d_internal(srl)) ) - { - oldgeom = geom; - geom = PG_LWGEOM_construct(srl, pglwgeom_getSRID(geom), 0); - lwfree(oldgeom); - } + box->xmin += xoff; + box->xmax += xoff; + box->ymin += yoff; + box->ymax += yoff; } PG_RETURN_POINTER(geom); diff --git a/lwgeom/lwgeom_transform.c b/lwgeom/lwgeom_transform.c index 3dfec6af0..650ca35db 100644 --- a/lwgeom/lwgeom_transform.c +++ b/lwgeom/lwgeom_transform.c @@ -301,17 +301,16 @@ Datum transform_geom(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - //great, now we have a geometry, and input/output PJ* structs. - //Excellent. + /* now we have a geometry, and input/output PJ structs. */ lwgeom_transform_recursive(SERIALIZED_FORM(result), input_pj, output_pj); - // clean up + /* clean up */ pj_free(input_pj); pj_free(output_pj); pfree(input_proj4); pfree(output_proj4); - // Compute bbox if input had one + /* Compute bbox if input had one */ if ( TYPE_HASBBOX(result->type) ) { srl = SERIALIZED_FORM(result);