Changes between Version 14 and Version 15 of DevWikiPostGISCoding


Ignore:
Timestamp:
03/14/12 15:01:26 (13 years ago)
Author:
pramsey
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • DevWikiPostGISCoding

    v14 v15  
    108108Datum shortestline2d(PG_FUNCTION_ARGS)
    109109{
    110        PG_LWGEOM *result;
     110       GSERIALIZED *result;
    111111       LWGEOM *theline;
    112112
    113        /* Detoast the actual PgSQL varlena structures, in our case PG_LWGEOM (soon to be GSERIALIZED) */
    114        PG_LWGEOM *geom1 = (PG_LWGEOM*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
    115        PG_LWGEOM *geom2 = (PG_LWGEOM*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
     113       /* Detoast the actual PgSQL varlena structures, in our case GSERIALIZED */
     114       GSERIALIZED *geom1 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
     115       GSERIALIZED *geom2 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
    116116
    117117       /* Build LWGEOM from the varlena (soon to be with lwgeom_from_gserialized) */
    118        LWGEOM *lwgeom1 = pglwgeom_deserialize(geom1);
    119        LWGEOM *lwgeom2 = pglwgeom_deserialize(geom2);
     118       LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
     119       LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
    120120
    121121       /* SRID consistency test */
     
    131131               PG_RETURN_NULL();
    132132
    133        /* Serialize the result back down from LWGEOM, but don't return right away */
    134        result = pglwgeom_serialize(theline);
    135 
    136        /* First free the LWGEOMs you used */
    137        lwgeom_free(theline);
     133       /* Finished with the input LWGEOMs */
    138134       lwgeom_free(lwgeom1);
    139135       lwgeom_free(lwgeom2);
     136
     137       /* Serialize the result back down from LWGEOM, but don't return right away */
     138       result = geometry_serialize(theline);
     139
     140       /* Finished with the derived LWGEOM */
     141       lwgeom_free(theline);
    140142
    141143       /* Then call free_if_copy on the *varlena* structures you originally get as arguments */