[postgis-devel] lwgeom->bbox

Sandro Santilli strk at keybit.net
Sun Oct 30 23:43:59 PDT 2011

On Sun, Oct 30, 2011 at 10:26:06PM -0700, Paul Ramsey wrote:
> Right now the bbox on the lwgeom is allocated on the heap
> typedef struct
> {
> 	uint8_t type;
> 	uint8_t flags;
> 	GBOX *bbox;
> 	int32_t srid;
> 	void *data;
> }
> But it's a fixed-size object, and the only reason for it to be a
> pointer is it's "optional". But it's only not available for points,
> right now, and the "optionality" is tied really to the serialization,
> not to the memory structure. That is, we *want* optionality in the
> serialization because it saves us space for simple objects like points
> to not serialize the information twice. But for memory structures like
> lwgeom, it would actually be more convenient if we guaranteed it was
> always there.

Then we'd have to always compute it, whatever we're going to do 
with it, even for subcomponents (each edge of a multiline).

> As an intermediate idea, perhaps I can just change the contract of
> lwgeom, so that when you deserialize, you *always* get a bbox
> allocated, not sometimes. Hopefully this will help some code that is
> having to check for box presence and manually forcing boxes onto
> geometries.

I'd rather add an interface to fetch box which would either get you
the cached one or create one on demand, and another to know if it's
already cached, in case you want to only deal with it in that case.

Wasn't there such interface already ?


  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html

More information about the postgis-devel mailing list