[postgis-devel] Adding size to LWGEOM
Mark Cave-Ayland
mark.cave-ayland at siriusit.co.uk
Fri Dec 26 02:13:10 PST 2008
Paul Ramsey wrote:
> As I fart around with building multi-geometries, I am getting
> increasingly annoyed that I can't just efficiently add new geometries
> to an existing object. If LWGEOM had a size_t indicating how big the
> allocated dynamic segment was, I could build a bunch of simple
> accessors that filled out the allocated area, and doubled it when it
> get too small. Basically like the dynptarray idea, but in the main
> objects. Since the LWGEOMs aren't serialized directly, there's no real
> size penalty to doing this, i don't think (time to read the
> serialize/deserialize code). and the on-disk format wouldn't change,
> so it would be backward compatible.
>
> This is an idle thought, it's certainly possible to code around this
> (that's what I'm doing) but it just seems like I'm writing lots of
> code that isn't strictly necessary.
>
> p.
I'm not sure I quite follow what you mean here - the LWGEOM structure
for a multi/collection type contains a pointer to the sub-geometry and
not the geometry data itself so this shouldn't be relevant?
If you want to add a sub-geometry in a certain position within a
multi/collection type then look at the *_add functions in lwm*.c within
the liblwgeom directory.
NOTE TO SELF: These functions look as if they are slow and leak memory
as they deep-copy each individual geometry into a new array. In fact,
all you need to do is shuffle the pointer array to include the new entry.
ATB,
Mark.
--
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063
More information about the postgis-devel
mailing list