Skip to content
Permalink
Browse files

Optimize temporalseq_minus_timestampset

  • Loading branch information
Esteban Zimanyi
Esteban Zimanyi committed Mar 25, 2020
1 parent 5ab7432 commit 6d043deb2dd023294065e383eba9741dd6566c19
Showing with 16 additions and 21 deletions.
  1. +16 −21 point/src/tpoint_spatialfuncs.c
@@ -409,27 +409,6 @@ geompoint_trajectory_lwline(Datum value1, Datum value2)

/* Compute a trajectory from a set of points. The result is either a line or a
* multipoint depending on whether the interpolation is step or linear */
static Datum
pointarr_make_trajectory(Datum *points, int count, bool linear)
{
LWGEOM **lwpoints = palloc(sizeof(LWGEOM *) * count);
for (int i = 0; i < count; i++)
{
GSERIALIZED *gs = (GSERIALIZED *) DatumGetPointer(points[i]);
lwpoints[i] = lwgeom_from_gserialized(gs);
}
LWGEOM *geom;
if (linear)
geom = (LWGEOM *) lwline_from_lwgeom_array(lwpoints[0]->srid, (uint32_t) count, lwpoints);
else
geom = (LWGEOM *) lwcollection_construct(MULTIPOINTTYPE, lwpoints[0]->srid,
NULL, (uint32_t) count, lwpoints);
Datum result = PointerGetDatum(geometry_serialize(geom));
for (int i = 0; i < count; i++)
lwgeom_free(lwpoints[i]);
pfree(lwpoints); pfree(geom);
return result;
}

static Datum
lwpointarr_make_trajectory(LWGEOM **lwpoints, int count, bool linear)
@@ -444,6 +423,22 @@ lwpointarr_make_trajectory(LWGEOM **lwpoints, int count, bool linear)
return result;
}

static Datum
pointarr_make_trajectory(Datum *points, int count, bool linear)
{
LWGEOM **lwpoints = palloc(sizeof(LWGEOM *) * count);
for (int i = 0; i < count; i++)
{
GSERIALIZED *gs = (GSERIALIZED *) DatumGetPointer(points[i]);
lwpoints[i] = lwgeom_from_gserialized(gs);
}
Datum result = lwpointarr_make_trajectory(lwpoints, count, linear);
for (int i = 0; i < count; i++)
lwgeom_free(lwpoints[i]);
pfree(lwpoints);
return result;
}

/* Compute the trajectory of an array of instants.
* This function is called by the constructor of a temporal sequence and
* returns a single Datum which is a geometry */

0 comments on commit 6d043de

Please sign in to comment.
You can’t perform that action at this time.