LWLINE *line = NULL;
POINTARRAY *pts;
LWPOINT *point;
- char *serializedpoint;
PG_LWGEOM *result;
int i;
}
pfree_inspected(inspected);
- if ( point == NULL ) {
+ if ( line == NULL ) {
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_NULL();
}
// Construct an LWPOINT
point = lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts);
- // Serialized the point
- serializedpoint = lwpoint_serialize(point);
-
- // And we construct the line (copy again)
- result = PG_LWGEOM_construct(serializedpoint, pglwgeom_getSRID(geom),
- 0);
+ // Construct a PG_LWGEOM
+ result = pglwgeom_serialize((LWGEOM *)point);
- pfree(point);
- pfree(serializedpoint);
- PG_FREE_IF_COPY(geom, 0);
lwgeom_release((LWGEOM *)line);
+ lwgeom_release((LWGEOM *)point);
+ PG_FREE_IF_COPY(geom, 0);
PG_RETURN_POINTER(result);
}
LWGEOM_INSPECTED *inspected;
LWLINE *line = NULL;
POINTARRAY *pts;
- LWPOINT *point;
- char *serializedpoint;
+ LWGEOM *point;
PG_LWGEOM *result;
int i;
}
pfree_inspected(inspected);
- if ( point == NULL ) {
+ if ( line == NULL ) {
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_NULL();
}
TYPE_HASM(line->type), 1);
// Construct an LWPOINT
- point = lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts);
-
- // Serialized the point
- serializedpoint = lwpoint_serialize(point);
+ point = (LWGEOM *)lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts);
- // And we construct the line (copy again)
- result = PG_LWGEOM_construct(serializedpoint, pglwgeom_getSRID(geom),
- 0);
+ // Serialize an PG_LWGEOM
+ result = pglwgeom_serialize(point);
- pfree(point);
- pfree(serializedpoint);
- PG_FREE_IF_COPY(geom, 0);
+ lwgeom_release(point);
lwgeom_release((LWGEOM *)line);
+ PG_FREE_IF_COPY(geom, 0);
PG_RETURN_POINTER(result);
}
{
text *wkttext = PG_GETARG_TEXT_P(0);
char *wkt, fc;
- int32 SRID;
size_t size;
PG_LWGEOM *geom;
PG_LWGEOM *result = NULL;