Changes between Version 14 and Version 15 of DevWikiPostGISCoding
- Timestamp:
- 03/14/12 15:01:26 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevWikiPostGISCoding
v14 v15 108 108 Datum shortestline2d(PG_FUNCTION_ARGS) 109 109 { 110 PG_LWGEOM*result;110 GSERIALIZED *result; 111 111 LWGEOM *theline; 112 112 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)); 116 116 117 117 /* 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); 120 120 121 121 /* SRID consistency test */ … … 131 131 PG_RETURN_NULL(); 132 132 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 */ 138 134 lwgeom_free(lwgeom1); 139 135 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); 140 142 141 143 /* Then call free_if_copy on the *varlena* structures you originally get as arguments */