Changes between Version 3 and Version 4 of DevWikiPostGISCoding
- Timestamp:
- 12/09/10 08:54:03 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevWikiPostGISCoding
v3 v4 55 55 { 56 56 PG_LWGEOM *result; 57 LWGEOM *theline; 58 57 59 /* Detoast the actual PgSQL varlena structures, in our case PG_LWGEOM (soon to be GSERIALIZED) */ 58 60 PG_LWGEOM *geom1 = (PG_LWGEOM*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); 59 61 PG_LWGEOM *geom2 = (PG_LWGEOM*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); 62 60 63 /* Build LWGEOM from the varlena (soon to be with lwgeom_from_gserialized) */ 61 64 LWGEOM *lwgeom1 = pglwgeom_deserialize(geom1); 62 65 LWGEOM *lwgeom2 = pglwgeom_deserialize(geom2); 63 LWGEOM *theline;64 66 65 67 /* SRID consistency test */ 66 68 if (lwgeom1->srid != lwgeom2->srid) 67 69 { … … 70 72 } 71 73 74 /* Calculate the shortest line, returned as an LWGEOM */ 72 75 theline = lw_dist2d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); 73 76 if (lwgeom_is_empty(theline)) … … 76 79 /* Serialize the result back down from LWGEOM, but don't return right away */ 77 80 result = pglwgeom_serialize(theline); 81 78 82 /* First free the LWGEOMs you used */ 79 83 lwgeom_free(lwgeom1);