PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_locate_between_m()

Datum LWGEOM_locate_between_m ( PG_FUNCTION_ARGS  )

Definition at line 702 of file lwgeom_functions_lrs.c.

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 */
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}
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition gserialized.c:89
#define COLLECTIONTYPE
Definition liblwgeom.h:122
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:121
#define POLYGONTYPE
Definition liblwgeom.h:118
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
static LWGEOM * lwgeom_locate_between_m(LWGEOM *lwin, double m0, double m1)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

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, and POLYGONTYPE.

Here is the call graph for this function: