[postgis-devel] Re-sizeable Collections

Paul Ramsey pramsey at opengeo.org
Mon Mar 15 20:26:15 PDT 2010


Hi all,

As you know, I've been working on pushing down serializable form so we
can transition into an all-LWGEOM future for PostGIS 2.0. This has
meant working, most recently, on a new WKB reader (and soon a new WKT
reader), which has meant dealing with constructing LWGEOM on the fly.
And that has meant finally making collections expandable without
re-copying their contents.

So, I recently pushed a big commit in (apologies, it got away from me
and stopped being a small atomic change and turned into a hairball).
It adds lwcollection_add_lwgeom(), which leans on the fact that all
collections now have a maxgeoms attribute, which provides the size of
the allocated geoms** buffer. It also adds utility stuff like
lwmpoint_add_lwpoint() etc. It changes lwgeom_typename() into
lwtype_name(), since the previous function didn't actually take an
lwgeom as an argument. In general I am going to be trying to
rationalize the API as I go through this exercise. lwgeom_typename()
might come back, but with an lwgeom* argument.

It also dropped al the *_add() functions, which required a slight
re-work of the homogenize function (and then the kml/gml builders),
but nothing else, oddly enough.

As you can imagine, the next frontier will be resizeable pointarrays
and the retirement of the dynptarray special type. (and
lwgeom_inspected)

Before I do anything else though, I'm going to go back into the
utility functions (clone, construct, release, free) and document their
memory management behavior in one place, because right now we have a
mix of by-reference and by-value behavior. I think in general we want
more reference behavior for performance reasons, but the API needs to
be clean about what it's providing and where. For example, the
behavior of free/release with respect to the underlying pointarray
serializations is not particularly well documented.

Anyhow, I wanted to explain a little bit why I'm dropping big hunks of
commit in like this, it's all preparatory for the 2.0 serialization
change, which really can't go ahead until we've isolated the
serialized form under the LWGEOM struct, which in turn requires that
LWGEOM get modernized and cleaned up a little. You should start to see
functions with uchar* arguments and returns disappearing from
liblwgeom.h over time. Here's hoping I can get some more focussed time
to work on this over the next few months.

Best,

Paul



More information about the postgis-devel mailing list