PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_longestline3d ( PG_FUNCTION_ARGS  )

Definition at line 871 of file lwgeom_functions_basic.c.

References DIST_MAX, geometry_serialize(), lw_dist3d_distanceline(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), result, and LWGEOM::srid.

872 {
874  GSERIALIZED *geom1 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
875  GSERIALIZED *geom2 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
876  LWGEOM *theline;
877  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
878  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
879 
880  if (lwgeom1->srid != lwgeom2->srid)
881  {
882  elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
883  PG_RETURN_NULL();
884  }
885 
886  theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MAX);
887 
888  if (lwgeom_is_empty(theline))
889  PG_RETURN_NULL();
890 
891  result = geometry_serialize(theline);
892 
893  lwgeom_free(theline);
894  lwgeom_free(lwgeom1);
895  lwgeom_free(lwgeom2);
896 
897  PG_FREE_IF_COPY(geom1, 0);
898  PG_FREE_IF_COPY(geom2, 1);
899  PG_RETURN_POINTER(result);
900 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define DIST_MAX
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
int32_t srid
Definition: liblwgeom.h:355
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWGEOM * lw_dist3d_distanceline(LWGEOM *lw1, LWGEOM *lw2, int srid, int mode)
Function initializing 3dshortestline and 3dlongestline calculations.
Definition: measures3d.c:30
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229

Here is the call graph for this function: