[postgis-devel] lwgeom->bbox

Paul Ramsey pramsey at opengeo.org
Sun Oct 30 22:26:06 PDT 2011


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;
}
LWGEOM;

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.

So it would really be better if lwgeom was like this

typedef struct
{
	uint8_t type;
	uint8_t flags;
	GBOX bbox;
	int32_t srid;
	void *data;
}
LWGEOM;

And the lwgeom_from_gserialized function filled it in, in all cases,
and the serialization function optionally skipped writing down the box
for some subset of cases (points, two-vertex lines) where space
savings were available.

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.

P.



More information about the postgis-devel mailing list