PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ geography_line_interpolate_point()

Datum geography_line_interpolate_point ( PG_FUNCTION_ARGS  )

Definition at line 1289 of file geography_measurement.c.

1290 {
1291  GSERIALIZED *gs = PG_GETARG_GSERIALIZED_P(0);
1292  double distance_fraction = PG_GETARG_FLOAT8(1);
1293  /* Read calculation type */
1294  bool use_spheroid = PG_GETARG_BOOL(2);
1295  /* Read repeat mode */
1296  bool repeat = (PG_NARGS() > 3) && PG_GETARG_BOOL(3);
1297  LWLINE* lwline;
1298  LWGEOM* lwresult;
1299  SPHEROID s;
1301 
1302  /* Return NULL on empty argument. */
1303  if ( gserialized_is_empty(gs) )
1304  {
1305  PG_FREE_IF_COPY(gs, 0);
1306  PG_RETURN_NULL();
1307  }
1308 
1309  if ( distance_fraction < 0 || distance_fraction > 1 )
1310  {
1311  elog(ERROR,"%s: second arg is not within [0,1]", __func__);
1312  PG_FREE_IF_COPY(gs, 0);
1313  PG_RETURN_NULL();
1314  }
1315 
1317  if ( !lwline )
1318  {
1319  elog(ERROR,"%s: first arg is not a line", __func__);
1320  PG_FREE_IF_COPY(gs, 0);
1321  PG_RETURN_NULL();
1322  }
1323 
1324  /* Initialize spheroid */
1325  spheroid_init_from_srid(gserialized_get_srid(gs), &s);
1326 
1327  /* Set to sphere if requested */
1328  if ( ! use_spheroid )
1329  s.a = s.b = s.radius;
1330 
1331  lwresult = geography_interpolate_points(lwline, distance_fraction, &s, repeat);
1332 
1333  lwgeom_free(lwline_as_lwgeom(lwline));
1334  PG_FREE_IF_COPY(gs, 0);
1335 
1336  lwgeom_set_geodetic(lwresult, true);
1337  result = geography_serialize(lwresult);
1338  lwgeom_free(lwresult);
1339 
1340  PG_RETURN_POINTER(result);
1341 }
char * s
Definition: cu_in_wkt.c:23
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: gserialized.c:126
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized.c:152
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:179
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:964
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:339
LWGEOM * geography_interpolate_points(const LWLINE *line, double length_fraction, const SPHEROID *s, char repeat)
Interpolate a point along a geographic line.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155

References geography_interpolate_points(), gserialized_get_srid(), gserialized_is_empty(), lwgeom_as_lwline(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_set_geodetic(), lwline_as_lwgeom(), result, and s.

Here is the call graph for this function: