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

Definition at line 694 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(), lwerror(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_locate_between_m(), MULTIPOLYGONTYPE, and POLYGONTYPE.

695 {
696  GSERIALIZED *gin = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
697  GSERIALIZED *gout;
698  double start_measure = PG_GETARG_FLOAT8(1);
699  double end_measure = PG_GETARG_FLOAT8(2);
700  LWGEOM *lwin, *lwout;
701  int hasz = gserialized_has_z(gin);
702  int hasm = gserialized_has_m(gin);
703  int type;
704 
705  elog(NOTICE,"ST_Locate_Between_Measures and ST_Locate_Along_Measure are deprecated. Use ST_LocateAlong and ST_LocateBetween.");
706 
707  if ( end_measure < start_measure )
708  {
709  lwerror("locate_between_m: 2nd arg must be bigger then 1st arg");
710  PG_RETURN_NULL();
711  }
712 
713  /*
714  * Return error if input doesn't have a measure
715  */
716  if ( ! hasm )
717  {
718  lwerror("Geometry argument does not have an 'M' ordinate");
719  PG_RETURN_NULL();
720  }
721 
722  /*
723  * Raise an error if input is a polygon, a multipolygon
724  * or a collection
725  */
726  type = gserialized_get_type(gin);
727 
728  if ( type == POLYGONTYPE || type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE )
729  {
730  lwerror("Areal or Collection types are not supported");
731  PG_RETURN_NULL();
732  }
733 
734  lwin = lwgeom_from_gserialized(gin);
735 
736  lwout = lwgeom_locate_between_m(lwin,
737  start_measure, end_measure);
738 
739  lwgeom_free(lwin);
740 
741  if ( lwout == NULL )
742  {
744  gserialized_get_srid(gin), hasz, hasm);
745  }
746 
747  gout = geometry_serialize(lwout);
748  lwgeom_free(lwout);
749 
750  PG_RETURN_POINTER(gout);
751 }
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:56
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:30
#define POLYGONTYPE
Definition: liblwgeom.h:62
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:25
static LWGEOM * lwgeom_locate_between_m(LWGEOM *lwin, double m0, double m1)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
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:70
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function: