PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_longestline2d()

Datum LWGEOM_longestline2d ( PG_FUNCTION_ARGS  )

Definition at line 653 of file lwgeom_functions_basic.c.

References error_if_srid_mismatch(), geometry_serialize(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_furthest_line(), lwgeom_is_empty(), LWGEOM_mindistance2d(), PG_FUNCTION_INFO_V1(), and LWGEOM::srid.

Referenced by LWGEOM_shortestline2d().

654 {
655  GSERIALIZED *result;
656  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
657  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
658  LWGEOM *theline;
659  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
660  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
661 
662  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
663 
664  theline = lwgeom_furthest_line(lwgeom1, lwgeom2);
665 
666  if (lwgeom_is_empty(theline))
667  PG_RETURN_NULL();
668 
669  result = geometry_serialize(theline);
670  lwgeom_free(theline);
671  lwgeom_free(lwgeom1);
672  lwgeom_free(lwgeom2);
673 
674  PG_FREE_IF_COPY(geom1, 0);
675  PG_FREE_IF_COPY(geom2, 1);
676  PG_RETURN_POINTER(result);
677 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
int32_t srid
Definition: liblwgeom.h:383
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:34
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
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:1297
Here is the call graph for this function:
Here is the caller graph for this function: