PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_locate_between_m()

Datum LWGEOM_locate_between_m ( PG_FUNCTION_ARGS  )

Definition at line 689 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().

690 {
691  GSERIALIZED *gin = PG_GETARG_GSERIALIZED_P(0);
692  GSERIALIZED *gout;
693  double start_measure = PG_GETARG_FLOAT8(1);
694  double end_measure = PG_GETARG_FLOAT8(2);
695  LWGEOM *lwin, *lwout;
696  int hasz = gserialized_has_z(gin);
697  int hasm = gserialized_has_m(gin);
698  int type;
699 
700  elog(WARNING,"ST_Locate_Between_Measures and ST_Locate_Along_Measure were deprecated in 2.2.0. Please use ST_LocateAlong and ST_LocateBetween");
701 
702  if ( end_measure < start_measure )
703  {
704  lwpgerror("locate_between_m: 2nd arg must be bigger then 1st arg");
705  PG_RETURN_NULL();
706  }
707 
708  /*
709  * Return error if input doesn't have a measure
710  */
711  if ( ! hasm )
712  {
713  lwpgerror("Geometry argument does not have an 'M' ordinate");
714  PG_RETURN_NULL();
715  }
716 
717  /*
718  * Raise an error if input is a polygon, a multipolygon
719  * or a collection
720  */
721  type = gserialized_get_type(gin);
722 
723  if ( type == POLYGONTYPE || type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE )
724  {
725  lwpgerror("Areal or Collection types are not supported");
726  PG_RETURN_NULL();
727  }
728 
729  lwin = lwgeom_from_gserialized(gin);
730 
731  lwout = lwgeom_locate_between_m(lwin,
732  start_measure, end_measure);
733 
734  lwgeom_free(lwin);
735 
736  if ( lwout == NULL )
737  {
739  gserialized_get_srid(gin), hasz, hasm);
740  }
741 
742  gout = geometry_serialize(lwout);
743  lwgeom_free(lwout);
744 
745  PG_RETURN_POINTER(gout);
746 }
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:55
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:29
#define POLYGONTYPE
Definition: liblwgeom.h:72
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
static LWGEOM * lwgeom_locate_between_m(LWGEOM *lwin, double m0, double m1)
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
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: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:69
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
Here is the call graph for this function:
Here is the caller graph for this function: