PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwpoly_construct()

LWPOLY* lwpoly_construct ( int  srid,
GBOX bbox,
uint32_t  nrings,
POINTARRAY **  points 
)

Definition at line 43 of file lwpoly.c.

44 {
45  LWPOLY *result;
46  int hasz, hasm;
47 #ifdef CHECK_POLY_RINGS_ZM
48  char zm;
49  uint32_t i;
50 #endif
51 
52  if ( nrings < 1 ) lwerror("lwpoly_construct: need at least 1 ring");
53 
54  hasz = FLAGS_GET_Z(points[0]->flags);
55  hasm = FLAGS_GET_M(points[0]->flags);
56 
57 #ifdef CHECK_POLY_RINGS_ZM
58  zm = FLAGS_GET_ZM(points[0]->flags);
59  for (i=1; i<nrings; i++)
60  {
61  if ( zm != FLAGS_GET_ZM(points[i]->flags) )
62  lwerror("lwpoly_construct: mixed dimensioned rings");
63  }
64 #endif
65 
66  result = (LWPOLY*) lwalloc(sizeof(LWPOLY));
67  result->type = POLYGONTYPE;
68  result->flags = gflags(hasz, hasm, 0);
69  FLAGS_SET_BBOX(result->flags, bbox?1:0);
70  result->srid = srid;
71  result->nrings = nrings;
72  result->maxrings = nrings;
73  result->rings = points;
74  result->bbox = bbox;
75 
76  return result;
77 }
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:145
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:148
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
void * lwalloc(size_t size)
Definition: lwutil.c:229
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint8_t type
Definition: liblwgeom.h:454
uint32_t maxrings
Definition: liblwgeom.h:459
uint32_t nrings
Definition: liblwgeom.h:458
uint8_t flags
Definition: liblwgeom.h:455
GBOX * bbox
Definition: liblwgeom.h:456
int32_t srid
Definition: liblwgeom.h:457
unsigned int uint32_t
Definition: uthash.h:78

References LWPOLY::bbox, LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_GET_ZM, FLAGS_SET_BBOX, gflags(), lwalloc(), lwerror(), LWPOLY::maxrings, LWPOLY::nrings, POLYGONTYPE, LWPOLY::rings, LWPOLY::srid, and LWPOLY::type.

Referenced by _lwt_MakeRingShell(), GEOS2LWGEOM(), lwcurvepoly_linearize(), LWGEOM_dump_rings(), LWGEOM_envelope(), lwmsurface_linearize(), lwpoly_force_dims(), lwpoly_from_lwlines(), lwpoly_segmentize2d(), parse_geojson_polygon(), parse_gml_linearring(), parse_gml_patch(), parse_gml_polygon(), parse_kml_polygon(), polygon_to_geometry(), rt_raster_get_convex_hull(), rt_raster_get_envelope_geom(), rt_raster_get_perimeter(), rt_raster_pixel_as_polygon(), rt_util_envelope_to_lwpoly(), and SFCGAL2LWGEOM().

Here is the call graph for this function:
Here is the caller graph for this function: