PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwpoly_construct()

LWPOLY* lwpoly_construct ( int32_t  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 = lwflags(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 }
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:188
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
#define POLYGONTYPE
Definition: liblwgeom.h:118
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:180
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:194
void * lwalloc(size_t size)
Definition: lwutil.c:227
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY ** rings
Definition: liblwgeom.h:505
uint8_t type
Definition: liblwgeom.h:508
uint32_t maxrings
Definition: liblwgeom.h:511
uint32_t nrings
Definition: liblwgeom.h:510
GBOX * bbox
Definition: liblwgeom.h:504
lwflags_t flags
Definition: liblwgeom.h:507
int32_t srid
Definition: liblwgeom.h:506

References LWPOLY::bbox, LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_GET_ZM, FLAGS_SET_BBOX, lwalloc(), lwerror(), lwflags(), 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_poly_rings(), 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: