[postgis-devel] Distance2D Review

Paul Ramsey pramsey at cleverelephant.ca
Wed Nov 11 17:05:11 PST 2009


Hi Niklas, thanks for looking over things:

On Wed, Nov 11, 2009 at 4:27 PM, Nicklas Avén
<nicklas.aven at jordogskog.no> wrote:

> is there a function for creating bbox after
> deserializing or what is the best way of doing that?

LWGEOM *lwg = lwgeom_deserialize(SERIALIZED_FORM(pglwg));
if( ! lwg->bbox )
  lwg->bbox = lwgeom_compute_box2d(lwg);

Actually, I think only POINT objects should show up without boxes, but
the above is comprehensive.

> next question is about
> the number of subgeometries. As it works now the number om subgeometries is
> presented in lwgeom_inspected, but I see no function inspecting a LWGEOM or
> something corresponding.

int lwcollection_ngeoms(const LWCOLLECTION *col)

> I just committed a change from void functions to integer as Paul suggested.
> I think a now have it "carrying" any false-value all the way up and out. My
> question is what to to do with the double-functions that are supposed to
> return the distance. If they got a false answer from the underlying
> functions I now just throw an error that something is wrong. Then the
> compiler varned that I didn't return values in all situations from a
> function that should return values so I put a "return 0.0;" after the error.

Yeah, I have a similar yucky solution in geography, but I return a
negative number (invalid value) so that can be caught higher if
necessary. It depends a lot on the number of error conditions and how
high we want to propogate them, unfortunately we don't have a hard and
set pattern to follow (I've seen some lovely consistent code that is
all return codes on the return and return values in pointer
arguments). Consistency is its own reward and it's own curse: do what
makes the most sense for your use case.

> If this gets more and more confusing it's because I should
> have gone sleeping some hours ago.

Sleep well!

P.



More information about the postgis-devel mailing list