PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_locate_between_m()

Datum LWGEOM_locate_between_m ( PG_FUNCTION_ARGS  )

Definition at line 702 of file lwgeom_functions_lrs.c.

References COLLECTIONTYPE, geometry_serialize(), gserialized_get_srid(), gserialized_get_type(), gserialized_has_m(), gserialized_has_z(), lwcollection_construct_empty(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_locate_between_m(), MULTIPOLYGONTYPE, POLYGONTYPE, and ovdump::type.

Referenced by lwgeom_locate_between_m().

703 {
704  GSERIALIZED *gin = PG_GETARG_GSERIALIZED_P(0);
705  GSERIALIZED *gout;
706  double start_measure = PG_GETARG_FLOAT8(1);
707  double end_measure = PG_GETARG_FLOAT8(2);
708  LWGEOM *lwin, *lwout;
709  int hasz = gserialized_has_z(gin);
710  int hasm = gserialized_has_m(gin);
711  int type;
712 
713  elog(WARNING,"ST_Locate_Between_Measures and ST_Locate_Along_Measure were deprecated in 2.2.0. Please use ST_LocateAlong and ST_LocateBetween");
714 
715  if ( end_measure < start_measure )
716  {
717  lwpgerror("locate_between_m: 2nd arg must be bigger then 1st arg");
718  PG_RETURN_NULL();
719  }
720 
721  /*
722  * Return error if input doesn't have a measure
723  */
724  if ( ! hasm )
725  {
726  lwpgerror("Geometry argument does not have an 'M' ordinate");
727  PG_RETURN_NULL();
728  }
729 
730  /*
731  * Raise an error if input is a polygon, a multipolygon
732  * or a collection
733  */
734  type = gserialized_get_type(gin);
735 
736  if ( type == POLYGONTYPE || type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE )
737  {
738  lwpgerror("Areal or Collection types are not supported");
739  PG_RETURN_NULL();
740  }
741 
742  lwin = lwgeom_from_gserialized(gin);
743 
744  lwout = lwgeom_locate_between_m(lwin,
745  start_measure, end_measure);
746 
747  lwgeom_free(lwin);
748 
749  if ( lwout == NULL )
750  {
752  gserialized_get_srid(gin), hasz, hasm);
753  }
754 
755  gout = geometry_serialize(lwout);
756  lwgeom_free(lwout);
757 
758  PG_RETURN_POINTER(gout);
759 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:86
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:50
#define POLYGONTYPE
Definition: liblwgeom.h:87
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
static LWGEOM * lwgeom_locate_between_m(LWGEOM *lwin, double m0, double m1)
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
type
Definition: ovdump.py:41
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:100
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: