[postgis-devel] PostGIS 3 and MobilityDB

Esteban Zimanyi esteban.zimanyi at ulb.be
Thu Jul 1 01:51:49 PDT 2021


> Hello Esteban,

> Is there a complete list of PostGIS functions you are using?

The PostGIS functions that we use are
* those in liblwgeom.h
* those stated in the postgis.h file
https://github.com/MobilityDB/MobilityDB/blob/develop/point/include/postgis.h

However, the issue is that we call the functions defined in liblwgeom.h
directly in order to increase performance. Indeed, a first version of
MobilityDB called PostGIS functions through SQL but the performance was
unacceptable and therefore we access directly the GSERIALIZED, LWPOINT,
POINT2D, etc. structures defined by PostGIS.

For example, we need to compute the temporal azimuth for a trip which
typically has 10K points. We have to do this for thousands of trips. The
function for doing this (somehow simplified) is as follows

/**
 * Returns the azimuth of the two geometry points
 */
static Datum
geom_azimuth(Datum geom1, Datum geom2)
{
  const POINT2D *p1 = datum_get_point2d_p(geom1);
  const POINT2D *p2 = datum_get_point2d_p(geom2);
  double result;
  azimuth_pt_pt(p1, p2, &result); <---- function defined in liblwgeom.h
  return Float8GetDatum(result);
}

static int
tpointseq_azimuth1(TSequence **result, const TSequence *seq)
{
  [...]

  const TInstant *inst1 = tsequence_inst_n(seq, 0);
  Datum value1 = tinstant_value(inst1);
  int k = 0;
  for (int i = 1; i < seq->count; i++)
  {
    const TInstant *inst2 = tsequence_inst_n(seq, i);
    Datum value2 = tinstant_value(inst2);
    if (datum_ne(value1, value2, seq->basetypid))
    {
      Datum azimuth = geom_azimuth(value1, value2);
      instants[k++] = tinstant_make(azimuth, inst1->t, FLOAT8OID);
    }
    else
    {
      [...]
    }
    inst1 = inst2;
    value1 = value2;
  }
  [...]
}

Many thanks for your help !

Esteban
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20210701/961b2b63/attachment.html>


More information about the postgis-devel mailing list