PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geography_line_interpolate_point()

Datum geography_line_interpolate_point ( PG_FUNCTION_ARGS  )

Definition at line 1286 of file geography_measurement.c.

1287 {
1288  GSERIALIZED *gs = PG_GETARG_GSERIALIZED_P(0);
1289  double distance_fraction = PG_GETARG_FLOAT8(1);
1290  /* Read calculation type */
1291  bool use_spheroid = PG_GETARG_BOOL(2);
1292  /* Read repeat mode */
1293  bool repeat = (PG_NARGS() > 3) && PG_GETARG_BOOL(3);
1294  LWLINE* lwline;
1295  LWGEOM* lwresult;
1296  SPHEROID s;
1298 
1299  /* Return NULL on empty argument. */
1300  if ( gserialized_is_empty(gs) )
1301  {
1302  PG_FREE_IF_COPY(gs, 0);
1303  PG_RETURN_NULL();
1304  }
1305 
1306  if ( distance_fraction < 0 || distance_fraction > 1 )
1307  {
1308  elog(ERROR,"%s: second arg is not within [0,1]", __func__);
1309  PG_FREE_IF_COPY(gs, 0);
1310  PG_RETURN_NULL();
1311  }
1312 
1314  if ( !lwline )
1315  {
1316  elog(ERROR,"%s: first arg is not a line", __func__);
1317  PG_FREE_IF_COPY(gs, 0);
1318  PG_RETURN_NULL();
1319  }
1320 
1321  /* Initialize spheroid */
1322  spheroid_init_from_srid(gserialized_get_srid(gs), &s);
1323 
1324  /* Set to sphere if requested */
1325  if ( ! use_spheroid )
1326  s.a = s.b = s.radius;
1327 
1328  lwresult = geography_interpolate_points(lwline, distance_fraction, &s, repeat);
1329 
1330  lwgeom_free(lwline_as_lwgeom(lwline));
1331  PG_FREE_IF_COPY(gs, 0);
1332 
1333  lwgeom_set_geodetic(lwresult, true);
1334  result = geography_serialize(lwresult);
1335  lwgeom_free(lwresult);
1336 
1337  PG_RETURN_POINTER(result);
1338 }
char * s
Definition: cu_in_wkt.c:23
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
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:155
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized.c:181
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:1218

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: