PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_FilterByM()

Datum LWGEOM_FilterByM ( PG_FUNCTION_ARGS  )

Definition at line 3095 of file lwgeom_functions_basic.c.

3096 {
3097  GSERIALIZED *geom_in;
3098  GSERIALIZED *geom_out;
3099  LWGEOM *lwgeom_in;
3100  LWGEOM *lwgeom_out;
3101  double min, max;
3102  int returnm;
3103  int hasm;
3104 
3105  if ( PG_NARGS() > 0 && ! PG_ARGISNULL(0))
3106  {
3107  geom_in = PG_GETARG_GSERIALIZED_P(0);
3108  }
3109  else
3110  {
3111  PG_RETURN_NULL();
3112  }
3113 
3114  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1))
3115  min = PG_GETARG_FLOAT8(1);
3116  else
3117  {
3118  min = DBL_MIN;
3119  }
3120  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2))
3121  max = PG_GETARG_FLOAT8(2);
3122  else
3123  {
3124  max = DBL_MAX;
3125  }
3126  if ( PG_NARGS() > 3 && ! PG_ARGISNULL(3) && PG_GETARG_BOOL(3))
3127  returnm = 1;
3128  else
3129  {
3130  returnm=0;
3131  }
3132 
3133  if(min>max)
3134  {
3135  elog(ERROR,"Min-value cannot be larger than Max value\n");
3136  PG_RETURN_NULL();
3137  }
3138 
3139  lwgeom_in = lwgeom_from_gserialized(geom_in);
3140 
3141  hasm = FLAGS_GET_M(lwgeom_in->flags);
3142 
3143  if(!hasm)
3144  {
3145  elog(NOTICE,"No M-value, No vertex removed\n");
3146  PG_RETURN_POINTER(geom_in);
3147  }
3148 
3149  lwgeom_out = lwgeom_filter_m(lwgeom_in, min, max,returnm);
3150 
3151  geom_out = geometry_serialize(lwgeom_out);
3152  lwgeom_free(lwgeom_out);
3153  PG_RETURN_POINTER(geom_out);
3154 
3155 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_filter_m(LWGEOM *geom, double min, double max, int returnm)
Definition: lwmval.c:221
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
uint8_t flags
Definition: liblwgeom.h:400

References LWGEOM::flags, FLAGS_GET_M, geometry_serialize(), lwgeom_filter_m(), lwgeom_free(), and lwgeom_from_gserialized().

Here is the call graph for this function: